Data Structure
Every xsock
has parent sock as its first filed.
sock_common
1
2
3157 struct sock_common {
...
}sock
1
2
3
4
5
6
7288 struct sock {
289 /*
290 * Now struct inet_timewait_sock also uses sock_common, so please just
291 * don't add nothing before this first member (__sk_common) --acme
292 */
293 struct sock_common __sk_common;
...inet_sock
1
2
3
437 struct inet_sock {
138 /* sk and pinet6 has to be the first two members of inet_sock */
139 struct sock sk;
...inet_connection_sock
1
2
3
487 struct inet_connection_sock {
88 /* inet_sock has to be the first member! */
89 struct inet_sock icsk_inet;
...tcp_sock
1
2
3
4133 struct tcp_sock {
134 /* inet_connection_sock has to be the first member of tcp_sock */
135 struct inet_connection_sock inet_conn;
...
转换函数:
sk to inet_sock
1 | 213 static inline struct inet_sock *inet_sk(const struct sock *sk) |
sk to inet_connection_sock
1 | 145 static inline struct inet_connection_sock *inet_csk(const struct sock *sk) |
sk to tcp_sk
1 | 351 static inline struct tcp_sock *tcp_sk(const struct sock *sk) |