LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-27-2004, 02:05 AM   #1
Jamesminh
LQ Newbie
 
Registered: May 2002
Location: Vietnam
Posts: 13

Rep: Reputation: 0
Question Get Network Card name by C


Dear all,

I am current working at network programming. And I get some trouble on the Network card info.

I don't know what api that I can used to get network card info (card name, vender id, vender name). I think this can't do by socket right? If not or have another way, please let me know you opinion.

Thank you so much for your help.
James.
 
Old 09-27-2004, 02:47 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
One easy way to tell the manufacturer is look at the first part of the MAC address, it's specific to manufacturer (you can see this if you do an ethereal sniff that shows the ethernet packets, for instance -- note MAC addresses can be reset, so this may not be reliable). Otherwise, it's kind of tough. You might want to look at the sources for ifconfig and mii-tool and see how they gather info (a strace suggests that many disgusting ioctls are involved). You may well have to be executing within the kernel to get full info.

Question for you: Why on earth do you actually want to do this? If you're not writing a network card driver, the low level nitty gritties of the ethernet card affect your programming nil. I suppose if you're writing an app that sends lots of data over a LAN, you might care about the speed the NIC has negotiated, but why let the flow control properties of TCP take care of this for you, in that case?

Of course, if you're just doing it to see if it can be done, more power to you!
 
Old 09-27-2004, 06:00 AM   #3
maroonbaboon
Senior Member
 
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495

Rep: Reputation: 48
The 'lspci' command gives you this information (probably /sbin/lspci). You could have a look at the source code. I guess it is must depend on the kernel's pci driver e.g.

kernel-source-2.6.7/drivers/pci/pci.c
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware 10 network configuration. Problem with 8139 network card drivers ! Padmakiran Linux - Networking 8 03-27-2007 06:48 AM
linux shuts down built in network card then windows tells me network card is unplugge lesmoxhaybaker SUSE / openSUSE 8 08-29-2006 05:10 PM
3c905C network card in docking station. Cannot activate network device eth0. pathelms Linux - Networking 4 04-12-2006 02:55 PM
how to set up SMC EZ Card 10/100 ethernet PCI network card mymojo Linux - Networking 2 12-16-2003 02:35 AM
network installation of RH7.3 on laptop with pcmcia network card. Smerk Linux - Distributions 1 10-31-2002 11:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:50 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
Open Source Consulting | Domain Registration