当前位置: 技术问答>linux和unix
看udp实现源代码,看不懂结构protosw
来源: 互联网 发布时间:2015-04-15
本文导语: 看udp实现时,看到udp的一个结构protosw,书上说是udp协议交换入口,我就是不明白,这个结构到底是什么意思啊,有什么作用啊?望高手解释一下,万分感激! | /* This is used to register socket i...
看udp实现时,看到udp的一个结构protosw,书上说是udp协议交换入口,我就是不明白,这个结构到底是什么意思啊,有什么作用啊?望高手解释一下,万分感激!
|
/* This is used to register socket interfaces for IP protocols. */
struct inet_protosw {
struct list_head list; /* These two fields form the lookup key. */
unsigned short type; /* This is the 2nd argument to socket(2). */
int protocol; /* This is the L4 protocol number. */
struct proto *prot;
struct proto_ops *ops;
int capability; /* Which (if any) capability do
* we need to use this socket
* interface? */
char no_check; /* checksum on rcv/xmit/none? */
unsigned char flags; /* See INET_PROTOSW_* below. */
};
struct inet_protosw {
struct list_head list; /* These two fields form the lookup key. */
unsigned short type; /* This is the 2nd argument to socket(2). */
int protocol; /* This is the L4 protocol number. */
struct proto *prot;
struct proto_ops *ops;
int capability; /* Which (if any) capability do
* we need to use this socket
* interface? */
char no_check; /* checksum on rcv/xmit/none? */
unsigned char flags; /* See INET_PROTOSW_* below. */
};
|
我感觉sw是switch的意思,每个protosw存放了一个协议栈相关的东东,象inet_protosw就是ipv4的协议栈,其中会有一个链表,链表上的每一项对应一个具体协议,和相关协议的操作函数集,当接受报文时,这就是索引具体处理函数的所在
|
没找到,只找到了一个struct inet_protosw