网络子系统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;
	...
}

上一篇:日本陆上自卫队网络系统被黑 或有信息外泄


下一篇:Code Forces68B