Re: Why can struct sock convert to struct tcp_sock?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

On 15:02 Mon 11 Jan     , Kapuddi wrote:
> In funciton:
> 
> static int tcp_v4_init_sock(struct sock *sk)
> {
> 	struct inet_connection_sock *icsk = inet_csk(sk);
> 	struct tcp_sock *tp = tcp_sk(sk);
> 
>         ...
> }
> 
> Why can struct sock convert to struct tcp_sock?

Because struct tcp_sock contains struct sock as the first member:

struct tcp_sock {
	struct inet_connection_sock     inet_conn;
	...
};

struct inet_connection_sock {
	struct inet_sock          icsk_inet;
	...
};

struct inet_sock {
	struct sock             sk;
	...
};

	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux