我需要从iw_statistics结构中读取某些统计信息,这里是代码:
struct net_device *dev;
struct iw_statistics *wi_stats;
dev = first_net_device(&init_net);
while (dev)
{
if (strncmp(dev->name , "wlan",4)==0 )
{
if (dev->wireless_handlers->get_wireless_stats(dev) !=NULL ) // <--- here's where the code crashes.
{
wi_stats = dev-wireless_handlers->get_wireless_stats(dev);
printk(KERN_INFO "wi_stats = dev-wireless_handlers->get_wireless_stats(dev); worked!!! :D\n");
}
}
}
我正在研究linux内核2.6.35,我正在编写一个内核模块。我在这里做错了什么?
答案 0 :(得分:3)
看起来wireless_handlers
struct是Null
...只是因为网络设备已填充name
字段并不意味着它已配置。
这是设置wireless_handlers
的地方:
#ifdef CONFIG_WIRELESS_EXT
/* List of functions to handle Wireless Extensions (instead of ioctl).
* See <net/iw_handler.h> for details. Jean II */
const struct iw_handler_def * wireless_handlers;
/* Instance data managed by the core of Wireless Extensions. */
struct iw_public_data * wireless_data;
#endif
你应该检查名为CONFIG_WIRELESS_EXT
的值,如果它没有设置,wireless_handler
结构没有设置,那么你将指向Null
,你的模块将被卡住
答案 1 :(得分:0)
您应该检查dev-&gt; wireless_handlers是否为空。你能粘贴实际的代码片段吗?你得到的错误是什么?