struct sock注释
针对 struct sock 的一些注释:
struct sock {
/* Socket demultiplex comparisons on incoming packets. */
__u32 daddr; /* 外部IP地址 */
__u32 rcv_saddr; /* 绑定的本地IP地址 */
__u16 dport; /* 目标端口 */
unsigned short num; /* 本地端口 */
int bound_dev_if; /* 绑定网卡接口的索引 不为0 */
/* 用于各种协议查找表的哈希链表 */
struct sock *next;
struct sock **pprev;
struct sock *bind_next;
struct sock **bind_pprev;
volatile unsigned char state, /* 连接状态 */
zapped; /* In ax25 & ipx means not linked */
__u16 sport; /* 源端口 */
unsigned short family; /* 地址簇 */
unsigned char reuse; /* SO_REUSEADDR设置,表示地址重用 */
unsigned char shutdown; /* 半关闭标志 SEND_SHUTDOWN和RCV_SHUTDOWN掩码 */
atomic_t refcnt; /* 引用计数 */
socket_lock_t lock; /* 同步锁. */
int rcvbuf; /* 接受缓冲区长度(单位:字节) */
wait_queue_head_t *sleep; /* 等待队列,通常指向socket的wait域 */
struct dst_entry *dst_cache; /* 目的地缓存,用于路由查找结果 */
rwlock_t dst_lock; /* 目的地缓存锁*/
atomic_t rmem_alloc; /* 已接收队列字节数 */
struct sk_buff_head receive_queue; /* 接收包队列 */
atomic_t wmem_alloc; /* 已发送字节数 */
struct sk_buff_head write_queue; /* 包发送队列 */
atomic_t omem_alloc; /* "o"是"option"(选项)或"other"(其它)的意思 */
int wmem_queued; /* 稳定的队列长度 */
int forward_alloc; /* 提前分配的空间 */
__u32 saddr; /* 发送源地址 */
unsigned int allocation; /* 分配模式 */
int sndbuf; /* 发送缓冲区长度(单位:字节) */
struct sock *prev;
/* Not all are volatile, but some are, so we might as well say they all are.
* XXX Make this a flag word -DaveM
*/
volatile char dead,
done,
urginline,
keepopen,
linger,
destroy,
no_check, /*SO_NO_CHECK标志,表示是否检查包*/
broadcast,
bsdism;
unsigned char debug;
unsigned char rcvtstamp;
unsigned char userlocks;/*SO_SNDBUF和SO_RCVBUF标志 */
int proc;
unsigned long lingertime;
int hashent;
struct sock *pair;
/* The backlog queue is special, it is always used with
* the per-socket spinlock held and requires low latency
* access. Therefore we special case it's implementation.
*/
struct {
struct sk_buff *head;
struct sk_buff *tail;
} backlog;
rwlock_t callback_lock;/*用于结构末尾的回调函数互斥*/
/* 错误队列,很少使用 */
struct sk_buff_head error_queue;
struct proto *prot;/*网络地址簇内部协议处理*/
#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
union {
struct ipv6_pinfo af_inet6;
} net_pinfo;
#endif
union {
struct tcp_opt af_tcp;
#if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE)
struct raw_opt tp_raw4;
#endif
#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
struct raw6_opt tp_raw;
#endif /* CONFIG_IPV6 */
#if defined(CONFIG_SPX) || defined (CONFIG_SPX_MODULE)
struct spx_opt af_spx;
#endif /* CONFIG_SPX */
} tp_pinfo;
int err, err_soft; /* Soft holds errors that don't
cause failure but are the cause
of a persistent failure not just
'timed out' */
unsigned short ack_backlog;
unsigned short max_ack_backlog;
__u32 priority;
unsigned short type; /*socket类型,如:SOCK_STREAM*/
unsigned char localroute; /* 仅用于本地路由 */
unsigned char protocol; /*socket 所属网络地址簇的协议*/
struct ucred peercred; /*对端sock信息 SO_PEERCRED标志设置*/
int rcvlowat; /*SO_RCVLOWAT标志位*/
long rcvtimeo; /*SO_RCVTIMEO标志位*/
long sndtimeo; /*SO_SNDTIMEO标志位*/
#ifdef CONFIG_FILTER
/* Socket过滤指令 */
struct sk_filter *filter;
#endif /* CONFIG_FILTER */
/* This is where all the private (optional) areas that don't
* overlap will eventually live.
*/
union {
void *destruct_hook;
struct unix_opt af_unix;
#if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE)
struct inet_opt af_inet;
#endif
#if defined(CONFIG_ATALK) || defined(CONFIG_ATALK_MODULE)
struct atalk_sock af_at;
#endif
#if defined(CONFIG_IPX) || defined(CONFIG_IPX_MODULE)
struct ipx_opt af_ipx;
#endif
#if defined (CONFIG_DECNET) || defined(CONFIG_DECNET_MODULE)
struct dn_scp dn;
#endif
#if defined (CONFIG_PACKET) || defined(CONFIG_PACKET_MODULE)
struct packet_opt *af_packet;
#endif
#if defined(CONFIG_X25) || defined(CONFIG_X25_MODULE)
x25_cb *x25;
#endif
#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
ax25_cb *ax25;
#endif
#if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE)
nr_cb *nr;
#endif
#if defined(CONFIG_ROSE) || defined(CONFIG_ROSE_MODULE)
rose_cb *rose;
#endif
#if defined(CONFIG_PPPOE) || defined(CONFIG_PPPOE_MODULE)
struct pppox_opt *pppox;
#endif
#ifdef CONFIG_NETLINK
struct netlink_opt *af_netlink;
#endif
#if defined(CONFIG_ECONET) || defined(CONFIG_ECONET_MODULE)
struct econet_opt *af_econet;
#endif
#if defined(CONFIG_ATM) || defined(CONFIG_ATM_MODULE)
struct atm_vcc *af_atm;
#endif
#if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
struct irda_sock *irda;
#endif
} protinfo; /*私有数据区,网络地址簇规范*/
/* This part is used for the timeout functions. */
struct timer_list timer; /* sock清除定时器. */
struct timeval stamp; /*最后到达的包的时间戳*/
/* Identd and reporting IO signals */
struct socket *socket; /*BSD socket层套接字*/
/* RPC层私有数据 */
void *user_data;
/* 回调函数 */
void (*state_change)(struct sock *sk);
void (*data_ready)(struct sock *sk,int bytes);
void (*write_space)(struct sock *sk);
void (*error_report)(struct sock *sk);
int (*backlog_rcv) (struct sock *sk,
struct sk_buff *skb);
void (*destruct)(struct sock *sk);
};
struct sock注释的更多相关文章
- struct socket 结构详解
Socket数据结构网络协议CC++ 用户使用socket系统调用编写应用程序时,通过一个数字来表示一个socket,所有的操作都在该数字上进行,这个数字称为套接字描述符.在系统调用 的实现函 ...
- Linux内核源代码解析之——sock's buffer参数
本文原创为freas_1990,转载请标明出处:http://blog.csdn.net/freas_1990/article/details/11539695 关于socket与sock的关系再简单 ...
- Linux skbuff注释笔记
SKB结构定义 /usr/src/linux/include/linux/skbuff.h sk_buff_head: struct sk_buff_head { //SKB的头结点 /* The ...
- 使用Crash工具查看一个TCP listen sock内存布局实例
利用crash工具,我们可以很方便的查看正在运行内核的一些全局变量的数据结构,如TCP的ehash.bhash哈希桶,全局变量的查看比较简单.Crash工具还允许我们查看调用堆栈内部的局部变量,下面示 ...
- 【Linux 内核网络协议栈源码剖析】网络栈主要结构介绍(socket、sock、sk_buff,etc)
原文:http://blog.csdn.net/wenqian1991/article/details/46700177 通过前面的分析,可以发现,网络协议栈中的数据处理,都是基于各类结构体,所有有关 ...
- struct socket结构体详解
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://weiguozhihui.blog.51cto.com/3060615/15852 ...
- Struct Socket详细分析(转)
原文地址:http://anders0913.iteye.com/blog/411986 用户使用socket系统调用编写应用程序时,通过一个数字来表示一个socket,所有的操作都在该数字上进行,这 ...
- ERROR 2002 (HY000): Can 't connect to local MySQL server through socket '/tmp/mysql.sock '(2) "
找不到mysql.sock这个文件 如果在你操作安装提示创建该文件,重启服务器还是提示这个错误可以试一下 mysql -uroot -h 127.0.0.1 -p 应该是可以直接进入 具体处理方法 重 ...
- sock skbuf 结构:
/** * struct sock - network layer representation of sockets * @__sk_common: shared layout with inet_ ...
随机推荐
- BZOJ4177Mike的农场——最小割
题目描述 Mike有一个农场,这个农场n个牲畜围栏,现在他想在每个牲畜围栏中养一只动物,每只动物可以是牛或羊,并且每个牲畜围栏中的饲养条件都不同,其中第i个牲畜围栏中的动物长大后,每只牛可以卖a[i] ...
- Redis 5种数据结构
转载:https://baijiahao.baidu.com/s?id=1593806211408070879&wfr=spider&for=pc Redis数据类型 Redis支持五 ...
- Elasticsearch 聚合统计与SQL聚合统计语法对比(一)
Es相比关系型数据库在数据检索方面有着极大的优势,在处理亿级数据时,可谓是毫秒级响应,我们在使用Es时不仅仅进行简单的查询,有时候会做一些数据统计与分析,如果你以前是使用的关系型数据库,那么Es的数据 ...
- 杨辉三角(java实现)
package lizi; import java.util.Scanner; public class Yanghui { private static Scanner input; public ...
- scrapy 登陆知乎
参考 https://github.com/zkqiang/Zhihu-Login # -*- coding: utf-8 -*- import scrapy import time import r ...
- Python中使用operator模块实现对象的多级排序
Python中使用operator模块实现对象的多级排序 今天碰到一个小的排序问题,需要按嵌套对象的多个属性来排序,于是发现了Python里的operator模块和sorted函数组合可以实现这个功能 ...
- python3 列表list
列表用中括号表示[]: list()创建一个列表: 是可变的: 可以被迭代,也可以被切片: +组合列表,*重复列表: 可以使用del删除元素,del L[index]; 方法: append(obj) ...
- Android 程序优化总结
第一部分 编程规范 1.1 基本要求: 程序结构清晰,简单易懂,单个函数的程序行数不得超过100行. 打算干什么,要简单,直接. 尽量使用标准库函数和公共函数 不要随意定义全局变量,尽量使用局部变量. ...
- 【BZOJ4543】Hotel加强版(长链剖分)
[BZOJ4543]Hotel加强版(长链剖分) 题面 BZOJ,没有题面 洛谷,只是普通版本 题解 原来我们的\(O(n^2)\)做法是设\(f[i][j]\)表示以\(i\)为根的子树中,距离\( ...
- 【CF526G】Spiders Evil Plan(贪心)
[CF526G]Spiders Evil Plan(贪心) 题面 洛谷 CodeForces 给定一棵树,要求选择\(y\)条链,满足被链覆盖的所有点在树上联通,且\(x\)必定在联通块中. 对于每次 ...