小编use*_*787的帖子

Netlink 多播内核组

我想要实现的任务实际上非常简单(将字符串“TEST”多播到用户态守护程序),但内核模块无法编译。它因错误而停止:

\n\n
passing argument 4 of \xe2\x80\x98genlmsg_multicast_allns\xe2\x80\x99 makes integer from pointer without a cast [enabled by default]\n
Run Code Online (Sandbox Code Playgroud)\n\n

但不应该只是我定义的多播组吗?

\n\n

这是“澄清”的代码:

\n\n
#include <linux/module.h>\n#include <net/sock.h>\n#include <linux/netlink.h>\n#include <linux/skbuff.h>\n#include <linux/string.h>\n#include <net/netlink.h>\n#include <net/genetlink.h>\n\nstruct sock *nl_sk = NULL;\n\nstatic void daemon(void){\n        struct sk_buff *skb;\n        void* msg_head;\n        unsigned char *msg;\n\n        struct genl_family my_genl_family = {\n                .id = GENL_ID_GENERATE,\n                .hdrsize = 0,\n                .name = "family_name",\n                .version = 1,\n                .maxattr = 5\n        };\n\n        struct genl_multicast_group my_mc_group = {\n                .name = "mc_group",\n        };\n\n\n        msg = "TEST";\n        skb = genlmsg_new(NLMSG_GOODSIZE, …
Run Code Online (Sandbox Code Playgroud)

c multicast kernel-module linux-kernel netlink

5
推荐指数
2
解决办法
3858
查看次数

标签 统计

c ×1

kernel-module ×1

linux-kernel ×1

multicast ×1

netlink ×1