Linux netfilter源码分析(5)
五、 ipt_do_table()函数,数据包的过滤
5.1 ipt_entry 相关结构 ip_tables.h
ipt_entry结构前面有过了,再看一遍
struct ipt_entry
{
struct ipt_ip ip;
/* 所要匹配的报文的IP头信息 */
unsigned int nfcache;
/* 位向量,标示本规则关心报文的什么部分,暂未使用 */
u_int16_t target_offset;
/* target区的偏移,通常target区位于match区之后,而match区则在ipt_entry的末尾;
初始化为sizeof(struct ipt_entry),即假定没有match */
u_int16_t next_offset;
/* 下一条规则相对于本规则的偏移,也即本规则所用空间的总和,
初始化为sizeof(struct ipt_entry)+sizeof(struct ipt_target),即没有match */
unsigned int comefrom;
/* 位向量,标记调用本规则的HOOK号,可用于检查规则的有效性 */
struct ipt_counters counters;
/* 记录该规则处理过的报文数和报文总字节数 */
unsigned char elems[0];
/*target或者是match的起始位置 */
}
ipt_ip结构 ip_tables.h
struct ipt_ip {
struct in_addr src, dst; /* 来源/目的地址 */
struct in_addr smsk, dmsk; /* 来源/目的地址的掩码 */
char iniface[IFNAMSIZ], outiface[IFNAMSIZ]; /*输入输出网络接口*/
unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
u_int16_t proto; /* 协议, 0 = ANY */
u_int8_t flags; /* 标志字段 */
u_int8_t invflags; /* 取反标志 */
};
5.2 ipt_do_table函数 ip_tables.c
unsigned int
ipt_do_table(struct sk_buff **pskb,
unsigned int hook,
const struct net_device *in,
&
相关文档:
一:前言
最近在研究android的sensor driver,主要是E-compass,其中用到了Linux input子系统.在网上也看了很多这方面的资料,感觉还是这篇分析的比较细致透彻,因此转载一下以便自己学习,同时和大家分享!
(这篇博客主要是以键盘驱动为例的,不过讲解的是Linux Input Subsystem,可以仔细的研究一下!)
键盘驱动将检 ......
转贴自http://alexanderlaw.blog.hexun.com/8968771_d.html
二、ipt_table数据结构和表的初始化
2.1 include/linux/netfilter_ipv4/ip_tables.h struct ipt_table 表结构
struct ipt_table
{
struct list_head list;
/* 表链 */
char name[IPT_TABLE_MAXNAMELEN];
/* 表名,如"fil ......
上篇文章说到linux需要itoa函数,下面我就提供一份跨平台的itoa函数。
//return the length of result string. support only 10 radix for easy use and better performance
int my_itoa(int val, char* buf)
{
const int radix = 10;
char* p;
int a;&nbs ......
linux查找文件命令find
每一种操作系统都是由成千上万个不同种类的文件所组成的。其中有系统本身自带的文件,用户自己的文件,还有共享文件等等。我们有时候经常忘记某
份文件放在硬盘中的哪个地方。在微软的WINDOWS操作系统中要查找一份文件是相当简单的事情,只要在桌面上点击&ldq ......
1.磁盘命令
mount 挂上文件系统
umount 卸下已挂上的文件系统
df   ......