LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 12-28-2010, 05:23 AM   #1
cshong
LQ Newbie
 
Registered: Nov 2006
Posts: 24

Rep: Reputation: 0
Detect which module/driver a network interface use.


Hello,

In C++ or C, is there anyway to detect the name of the module or driver currently used by a network interface card (either wired or wireless, INCLUDING USB DEVICES)?

My application must have this feature. I just want to detect whether the module / driver is ndiswrapper or not.
 
Old 12-29-2010, 04:45 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
You could look at the ethtool source for ideas.

EDIT: or you could use something like (my C is rusty) system( "ethtool" "<interface name>" ) and parse the output.

Last edited by catkin; 12-29-2010 at 06:22 AM.
 
Old 12-29-2010, 06:16 AM   #3
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
You may scan the output of
Code:
lspci -v
the last line of any devicesection shows the actually used module.
Or explore the sources of lspci respectively.

Markus

Last edited by markush; 12-29-2010 at 06:17 AM.
 
Old 12-29-2010, 08:16 AM   #4
cshong
LQ Newbie
 
Registered: Nov 2006
Posts: 24

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
You could look at the ethtool source for ideas.

EDIT: or you could use something like (my C is rusty) system( "ethtool" "<interface name>" ) and parse the output.
Command "ethtool -i <interface name>" really helpful. Thank you! Will look into ethtool's source codes later.

Quote:
Originally Posted by markush View Post
You may scan the output of
Code:
lspci -v
the last line of any devicesection shows the actually used module.
Or explore the sources of lspci respectively.

Markus
lspci only list the PCI based devices, USB devices will not be listed. That means if my program want to know the name of the driver used by my USB Network Interface Card, using lspci is impossible. However, I still appreciate for your reply.

Anyway, I still hope for more ideas. Anyone with any other ideas, or if anyone can suggest a library or give me sample codes, please feel free to reply here. Any replies, whether helpful or not, will be appreciated.
 
Old 12-29-2010, 11:02 PM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
lsusb lists the USB hardware but not the associated drivers. For more info (but still not but not the associated drivers) use its -v option. Given information from lsusb, the kernel messages in /var/log/messages (system dependent?) should (TM) reveal which driver is loaded for each USB device but this is non-trivial and not the best way of doing it programmatically.
 
  


Reply



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
Detect Centos NIC driver module andersb Linux - Kernel 2 12-28-2010 06:21 AM
udev and network interface module Panci Slackware 3 01-16-2009 08:18 AM
network driver module problem? LinuxLover Linux - Enterprise 1 04-14-2008 12:58 PM
How to modify existing network boot cd, cannot detect new network card driver. hocheetiong Linux - Newbie 0 12-05-2007 07:06 AM
how to install a new network interface car driver? hongxing SUSE / openSUSE 6 12-01-2005 05:58 PM

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

All times are GMT -5. The time now is 10:34 AM.

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
Open Source Consulting | Domain Registration