struct netlink_skb_parms

来源:互联网 发布:淘宝后台管理系统 编辑:程序博客网 时间:2024/06/14 06:39

struct netlink_skb_parms {
 struct scm_creds creds;  /* Skb credentials */
 __u32   portid;
 __u32   dst_group;
 __u32   flags;
 struct sock  *sk;
 bool   nsid_is_set;
 int   nsid;
};

#define NETLINK_CB(skb)  (*(struct netlink_skb_parms*)&((skb)->cb))
#define NETLINK_CREDS(skb) (&NETLINK_CB((skb)).creds)

##############################################################

NETLINK_CB(skb).creds.pid

##############################################################

struct netlink_kernel_cfg cfg = {
        .input = sample_input,
};
static int init_netlink(void)
{
    //nl_sk = netlink_kernel_create(&init_net, NETLINK_SAMPLE, 0, sample_input, NULL, THIS_MODULE);
    nl_sk = netlink_kernel_create(&init_net, NETLINK_SAMPLE, &cfg);
    if (!nl_sk)
    {  
        printk("net_link: Cannot create netlink socket.\n");
        return -EIO;
    }  
    printk("net_link: create socket ok.\n");
    return 0;
}

原创粉丝点击