Linux内核如何接收不同类型以太帧
1. 前言
以太头中除了6字节目的MAC地址、6字节源MAC地址外,还有两字节的以太帧类型值,如IPv4为0x0800,ARP为0x0806等,网卡驱动收到以太帧后通过接口函数netif_receive_skb()(netif_rx实际最后也是调用netif_receive_skb)交到上层,而这个接口函数就完成对以太帧类型的区分,交到不同的协议处理程序。如果想自己编写某一以太类型帧的处理程序,需要自己添加相应的
以下Linux内核代码为2.6.17.11。
2. 数据结构
每种协议都要定义一个packet_type结构,引导进入相关的协议数据处理函数,所有节点组成一个链表(HASH链表)。
/* include/linux/netdevice.h */
struct packet_type {
__be16 type; /* This is really htons(ether_type). */
struct net_device *dev; /* NULL is wildcarded here */
int (*func) (struct sk_buff *,
struct net_device *,
struct packet_type *,
struct net_device *);
void *af_packet_priv;
struct list_head list;
};
参数说明:
type:以太帧类型,16位
dev:所附着的网卡设备,如果为NULL则匹配全部网卡
func:协议入口接收处理函数
af_packet_priv:协议私有数据
list:链表扣
一般各协议的packet_type结构都是静态存在,初始化时只提供type和func两个参数就可以了,每个协议在初始化时都要将此结构加入到系统类型链表中。
3. 处理函数
3.1 添加节点
/* net/core/dev.c */
/**
* dev_add_pack - add packet handler
* @pt: packet type declaration
*
* Add a protocol handler to the networking stack. The passed &packet_type
* is linked into kernel lists and may not be freed until it has been
* removed from the kernel lists.
*
* This call does not sleep therefore it can not
* guarantee all CPU's that are in middle of receiving packets
* will see the new packet type (until the next received packet).
*/
void dev_add_pack(struct packet_type *pt)
{
int hash;
 
相关文档:
1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI) 就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......
2、APACHE的安装
1)当然还是下载源码包,如:httpd-2.0.55.tar.gz,地址自己找……
2)解压缩,>tar -zxvf httpd-2.0.55.tar.gz
3)进入解压后的httpd-2.0.55,>cd httpd-2.0.55
4)安装配置,>./configure --prefix=/opt/apache --enable-cgi
5)编译,>make
6)安装,>make install
......
1、下载phpMyAdmin至web服务器目录并重命名为:phpmyadmin。假设服务器目录为www,则存放位置为www/phpmyadmin,访问路径为http://localhost/phpmyadmin
2、复制"/phpmyadmin/libraries/"目录下的"config.default.php"文件至"/phpmyadmin/"目录下,并重命名为"config.inc.php"
3 ......
RPM有5种基本操作模式(不包括软件包建构):安装、删除、升级、查询和校验。
RPM包的名称格式,eg:caleng-1.0-1.i386.rpm。该文件名包括软件包名称“caleng”;软件版本号“1.0“,其中包括主版本号和次版本号;"i386"是软件所运行的硬件平台。
1、安装RPM包,eg: $>rpm -ivh test.rp ......
linux系统root用户可强制踢制其它登录用户,
首先以root登录以便查看全部的在线用户信息,可用w命令查看登录用户信息
强制踢人命令格式:pkill -kill -t tty
解释:
pkill -kill -t 踢人命令
tty 所踢用户的TTY
如上踢出liu用户的命令为: pkill -kill -t pts/1
......