- 论坛徽章:
- 0
|
偶在2.4.21上,注册netlink socket,最简单的代码了:
- static int __init init(void)
- {
- printk("Init netlink modules.\n");
- mynlfd = netlink_kernel_create(23,my_rev_handler);
-
- if(!mynlfd)
- {
- printk("Can't create netlink!\n");
- return -1;
- }
- /*多加了这句判断*/
- if(!mynlfd->socket)
- {
- printk("Error:socket is null!\n");
- return -1;
- }
-
- return 0;
- }
复制代码
PS:其中unit=23,我是随便写的,我试过从17-31的所有值,全是这样。
我发现,注册完成后,所有的成员指针都是空的,郁闷了……
# insmod /mnt/nltest.o
Using /mnt/nltest.o
Init netlink modules.
Error:socket is null!
insmod: init_module: nltest: Operation not permitted
还请有经验的朋友帮帮我,谢谢! |
|