網絡子系統79_inet協議族

//	inet協議族默認支持的協議類型
//		在inet_init中,通過inet_register_protosw註冊到inetsw鄰接表
1.1 static struct inet_protosw inetsw_array[] =
{

	//流類型
	{
		.type =       SOCK_STREAM,
		.protocol =   IPPROTO_TCP,
		.prot =       &tcp_prot,
		.ops =        &inet_stream_ops,
		.no_check =   0,
		.flags =      INET_PROTOSW_PERMANENT |
			      INET_PROTOSW_ICSK,
	},

	//數據報類型,UDP, ICMP
	{
		.type =       SOCK_DGRAM,
		.protocol =   IPPROTO_UDP,
		.prot =       &udp_prot,
		.ops =        &inet_dgram_ops,
		.no_check =   UDP_CSUM_DEFAULT,
		.flags =      INET_PROTOSW_PERMANENT,
    },

    {
		.type =       SOCK_DGRAM,
		.protocol =   IPPROTO_ICMP,
		.prot =       &ping_prot,
		.ops =        &inet_dgram_ops,
		.no_check =   UDP_CSUM_DEFAULT,
		.flags =      INET_PROTOSW_REUSE,
    },

    //raw類型
    {
       .type =       SOCK_RAW,
       .protocol =   IPPROTO_IP,	/* wild card */
       .prot =       &raw_prot,
       .ops =        &inet_sockraw_ops,
       .no_check =   UDP_CSUM_DEFAULT,
       .flags =      INET_PROTOSW_REUSE,
    }
};


//	注:
//		struct socket - general BSD socket
//		struct sock - network layer representation of sockets
//		struct inet_sock - representation of INET sockets
1.2 struct socket, struct sock, struct inet_sock

struct socket {

	..
	//(file->private_data指向socket)
	struct file	*file; 
	struct sock *sk;
	..

}

struct inet_sock {
	struct sock	sk;
	...
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章