linux nettlink套接字
来源:互联网 发布:目标优化矩阵 编辑:程序博客网 时间:2024/06/11 05:17
用于处理用户空间和内核空间的通信机制
套接字地址结构函数:
struct sockaddr_nl
{
_kernel_sa_family_t nl_family; /af_netlink/
unsigned short nl_pad ;
_u32 nl_pid;
_u32 nl_groups; /组播组掩码/
};
nl_family:始终为af_netlink
pad为0
pid值内核为0,在用户栈根据情况自动设置。
netlink消息报头。由结构nlmsghdr定义,长16字节。
nlmsg_len:
nlmsg_type:其中有四种基本netlik消息类型,noop,error,done,overrun。
nlmsg_flags;
nlmsg_seq;
nlmsg_pid;
属性头由nlattr定义
struct nlattr{
_u16 nla_len;
_u16 nla_type;};
nla_len;
nla_type:
通用netlink内核套接字由方法net_kernel_creat *net()创建,结构
static int_net_init genl_pernet_init(struct net *net){
struct netlink_kernel_cfg cfg = {
input =genl_rcv,
cb_mutex =&genl_mutex,
flags =nl_cfg_f_nonroot_recv,
};
net->genl_sock =netlink_kernel_creatr(net,netlink_generic,&cfg);
}
创建通用netlink内核套接字自后,需要注册控制器簇(genl_ctrl)
static struct genl_family genl_ctrl={
id =genl_id_ctrl,
name="nlctrl"
cersion =0x2,
maxattr = ctrl_attr_max,
netnsok = true,}
创建和发送通用netlink消息,消息报头
struct genlmsghdr{
——u8 cmd;
——u8 version;
——u16 reserved;}
套接字监视接口
netlink_sock_diag
结构函数如下
索引协议号
sock_diag_handler
struct sock_diag_handler{
}
- linux nettlink套接字
- linux套接字编程
- Linux--原始套接字
- Linux套接字
- linux 套接字接口
- Linux - 套接字编程
- Linux套接字
- linux套接字编程
- Linux网络套接字
- linux 套接字编程
- linux套接字
- Linux 套接字
- Linux 套接字
- linux套接字地址
- linux 套接字结构
- Linux--编程--套接字
- Linux编程---套接字
- linux套接字编程
- 机器学习入门秘笈
- 使用delphi对amr文件解码
- 窗口
- “放弃Jni”愉快的奔向JNA
- 在卷积神经网络中,卷积核到底是几层的?| 社区问答
- linux nettlink套接字
- 【1029】字符判断与转换
- bzoj3531: [Sdoi2014]旅行
- Hadoop集群搭建
- JAVA的不可变类(immutable)机制与String的不可变性
- Ubuntu14.04 安装pip
- Lintcode172 Remove Element solution 题解
- hibernate的三种查询方式
- c++note1 简单的学生信息处理程序实现