gpt4 book ai didi

linux - 为什么即使包含 "RTMGRP_LINK undeclared"也会收到 "rtnetlink.h"错误?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:57:12 26 4
gpt4 key购买 nike

我已经编写了一个内核模块,我想在其中向用户空间程序发送接口(interface)启动/关闭通知。我已将消息组分配为 RTMGRP_LINK 并且还包括 linux/rtnetlink.h 头文件。但是当我编译模块时仍然收到以下错误:

abc.c: In function âevent_handlerâ:
abc.c:63: error: âRTMGRP_LINKâ undeclared (first use in this function)
abc.c:63: error: (Each undeclared identifier is reported only once
abc.c:63: error: for each function it appears in.)

有人可以提出原因吗?

最佳答案

通过 linux/rtnetlink.h header 后。我观察到 RTMGRP_LINK 是在 #ifndef __KERNEL__ 下定义的,这意味着它只能由用户空间程序使用。对于内核模块,RTNLGRP_LINK 应该用于使用 NETLINK_ROUTE 系列的 Netlink 套接字进行通信。

关于linux - 为什么即使包含 "RTMGRP_LINK undeclared"也会收到 "rtnetlink.h"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24732947/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com