免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1388 | 回复: 0
打印 上一主题 下一主题

请教linux上的netlink的小问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-09-27 08:55 |只看该作者 |倒序浏览
偶在2.4.21上,注册netlink socket,最简单的代码了:

  1. static int __init init(void)
  2. {
  3.         printk("Init netlink modules.\n");

  4.         mynlfd = netlink_kernel_create(23,my_rev_handler);
  5.         
  6.         if(!mynlfd)
  7.         {
  8.                 printk("Can't create netlink!\n");
  9.                 return -1;
  10.         }

  11.                 /*多加了这句判断*/
  12.         if(!mynlfd->socket)
  13.         {
  14.                 printk("Error:socket is null!\n");
  15.                 return -1;
  16.         }
  17.         
  18.         return 0;
  19. }
复制代码


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

还请有经验的朋友帮帮我,谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP