1

I need to read certain statistics from iw_statistics structure, here's the code:

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"); 
         }
       }

    }

I'm working on linux kernel 2.6.35 and I'm writing a kernel module. What am I doing wrong here?

4

2 回答 2

3

Looks like wireless_handlers struct is Null ... Just because a net device has it's name field filled doesn't mean it's configured.

This is where wireless_handlers gets set:

#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

You should check the value called CONFIG_WIRELESS_EXT if it's not set , the wireless_handler struct is not set and thus you''ll be pointing to a Null and your module will get stuck

于 2012-06-16T09:20:38.117 回答
0

You should check that dev->wireless_handlers is not null. Can you paste the actual code snippet? What is the error you get?

于 2012-06-15T15:09:51.517 回答