LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-13-2006, 07:31 PM   #1
mousars
LQ Newbie
 
Registered: Feb 2006
Posts: 6

Rep: Reputation: 0
Post Linux struct net_device


Hi,

I am Linux newbie and I need urgent help PLEASEEEEEE!!!

Regarding net_device structures (I am programming in the Linux 2.6 kernel series).

Suppose I have a pointer to a net_device structure, for example

const struct net_device *dev,

How can I find out if this device corresponds to a wireless interface?

I thought about checking dev->wireless_handlers to see if it exists (as I am assuming it will only exist for wireless devices), i.e.

if (dev->wireless_handlers){
// device corresponds to a wireless interface
}

Is that correct, or am I way off?

PS. I am a real newbie :-)

Cheers,

Ramirez
 
Old 02-14-2006, 03:00 AM   #2
mehuljv
Member
 
Registered: Nov 2004
Posts: 72

Rep: Reputation: 15
I dnt know how will u get net_device structure.. bt if u can get it then u can get pointer to pdev structure frm it (net_device->pdev), and get the Vendor ID / Device ID of the device from its config space and compare it with the wireless device which u want to find out.

-- r u writing a driver for wireless device or wt ???

--Mehul.
 
Old 02-14-2006, 08:26 AM   #3
mousars
LQ Newbie
 
Registered: Feb 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Thank you for your reply!

No I am not writing a device driver. I am writing a kernel module that monitors the packets that arrive on the host. So, I registered my module with the IP_FORWARD kernel hook and now I have a callback function with the pointer to the packet, the network device it arrived on, and the network device it is leaving on. And the callback function gets called for every packet that traverses the host. So I have pointers to all these structures.

What I want to do is check the device the packet is leaving on to see if it is a wireless device or not. And I thought about checking

dev->wireless_handlers,

to see if it exists or not as I think it will only exist if the device is a wireless device. Is that correct???

I dont think I need to check the Vendor ID/Device ID as I am only checking to see if it is wireless or not.

Thanks so much for your help!

Ramirez
 
Old 02-14-2006, 09:46 AM   #4
mehuljv
Member
 
Registered: Nov 2004
Posts: 72

Rep: Reputation: 15
hi,
You can use wireless_handlers, bt the problem is this field is not mandatory for wireless drivers, e.g. ray_cs.c is a wireless lan driver but it doesnt initialize wireless_handlers. You can check for "get_wireless_stats", but that is also not mandatory...... But i suggest you to read Vendor ID/ Device ID, whnever you find any new net_dev address you can go and read config space, if its Dev/Vendor ID matches thn store a flag for this net_dev struct. I couldnt find any other way.

--Mehul.
 
Old 02-14-2006, 10:12 AM   #5
mousars
LQ Newbie
 
Registered: Feb 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks Mehul for your reply. You have been a lot of help for me.

On another issue, isn't "get_wireless_stats" depracated or phased out. I read on the net that it is being phased out and will no longer be supported in Linux 2.6 kernel. Is that true??

Thanks
 
Old 02-15-2006, 12:41 AM   #6
mehuljv
Member
 
Registered: Nov 2004
Posts: 72

Rep: Reputation: 15
hi,
i really dnt know if it is phased out, bt it is still there in the 2.6 kernel. As i told you tht u can read the config space, but again if the device is not pci than u are in big trouble .... I couldnt find any flag in dev structure which will tell whether the device is wireless or not ...

Regards,
Mehul.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
About struct size Nerox Programming 3 02-07-2005 04:49 PM
g++ and wrong struct member addresses / struct size misreporting sonajiso Linux - General 5 05-22-2004 10:16 PM
switch statement converting struct char to struct int oceaneyes2 Programming 2 12-10-2003 04:30 PM
using struct type X as pointer in struct X. worldmagic Programming 1 10-28-2003 02:06 PM
Accessing a struct inside struct cxel91a Programming 1 09-17-2003 04:24 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration