几个重要数据结构的关系

这几个数据结构关联在一起:

tcp_sock --> inet_connection_sock --> inet_sock --> sock --> sock_common


struct tcp_sock {
	/* inet_connection_sock has to be the first member of tcp_sock */
	struct inet_connection_sock	inet_conn;
	u16	tcp_header_len;	/* Bytes of tcp header to send		*/
	u16	gso_segs;	/* Max number of segs per GSO packet	*/
}
struct inet_connection_sock {
	/* inet_sock has to be the first member! */
	struct inet_sock	  icsk_inet;

 	struct timer_list	  icsk_retransmit_timer; // timer
 	struct timer_list	  icsk_delack_timer;
}

struct inet_sock {
	/* sk and pinet6 has to be the first two members of inet_sock */
	struct sock		sk;

	__be32			inet_saddr;      // IP地址   
	__s16			uc_ttl;
	__u16			cmsg_flags;
	__be16			inet_sport;      // 端口号
	__u16			inet_id;         
}
struct sock {
	/*
	 * Now struct inet_timewait_sock also uses sock_common, so please just
	 * don't add nothing before this first member (__sk_common) --acme
	 */
	struct sock_common	__sk_common;

	struct sk_buff_head	sk_receive_queue;
    
	struct {
		atomic_t	rmem_alloc;
		int		len;
		struct sk_buff	*head;
		struct sk_buff	*tail;
	} sk_backlog;

	struct sk_buff_head	sk_write_queue;
}
struct sock_common {
	/* skc_daddr and skc_rcv_saddr must be grouped on a 8 bytes aligned
	 * address on 64bit arches : cf INET_MATCH()
	 */
	union {
		__addrpair	skc_addrpair;
		struct {
			__be32	skc_daddr;
			__be32	skc_rcv_saddr;
		};
	};
	union  {
		unsigned int	skc_hash;
		__u16		skc_u16hashes[2];
	};
	/* skc_dport && skc_num must be grouped as well */
	union {
		__portpair	skc_portpair;
		struct {
			__be16	skc_dport;
			__u16	skc_num;
		};
	};

}

猜你喜欢

转载自blog.csdn.net/yinming4u/article/details/84312871
今日推荐