Find the answer to your Linux question:
Results 1 to 9 of 9
Hi, I am trying to get network adapter vendor name through c program in Linux. I tried using ioctl calls to fetch the name of the adapter but i ended ...
  1. #1
    Just Joined!
    Join Date
    Sep 2009
    Posts
    5

    Question Get Network adapter vendor name through C Program

    Hi,

    I am trying to get network adapter vendor name through c program in Linux.
    I tried using ioctl calls to fetch the name of the adapter but i ended up in fetching the logical name of the network interface.
    I used system cal ioctl(fd, SIOCGIFHWADDR, &ifreq). I got eth0 & lp.
    But i need the Vendor name of my network adapter through c program i dont want to use lspci and ethtool to do this.

    Can any one suggest me how i can fetch this through c program?
    Thanks for your help.

    Regards,
    Bharath P

  2. #2
    Linux Guru rokytnji's Avatar
    Join Date
    Jul 2008
    Location
    Pecos, Texas
    Posts
    2,943
    I don't know if you have this script included in your distro, but I get good results from
    inxi -F
    Linux Registered User # 475019
    Lead,Follow, or get the heck out of the way
    AntiX,Puppy,Ubuntu,Windows 7=(cuz of scooters)
    Open CourseWare for Linux Geeks

  3. #3
    Just Joined!
    Join Date
    Sep 2009
    Posts
    5

    Question access PCI structure in c program

    Can anyone tel how i can access pci_device_id structure in my c program and get al the vendor id's listed in it ?

    I think i can get my Vendor ID and name if i can access PCI structure mentioned above. So please guide how to access PCI structure if possible provide me some example.

    Regards,
    Bharath P

  4. #4
    Just Joined!
    Join Date
    Jul 2009
    Posts
    58

  5. #5
    Linux Newbie tetsujin's Avatar
    Join Date
    Oct 2008
    Posts
    115
    Quote Originally Posted by aram535 View Post
    I don't think that's what he was asking... He doesn't appear to want to write a driver, he just wants to get information on the PCI devices in the system, the way one might use lspci...

    And speaking of which - I guess my answer would be to read the lspci source code.

  6. #6
    Just Joined!
    Join Date
    Jul 2009
    Posts
    58
    It not a very long slide show, but half way in between it goes into card identification and how to setup and read the pci_device_id.

    I thought it would be easier to point there than pump out c code into a forum.

  7. #7
    Linux Newbie tetsujin's Avatar
    Join Date
    Oct 2008
    Posts
    115
    Quote Originally Posted by aram535 View Post
    It not a very long slide show, but half way in between it goes into card identification and how to setup and read the pci_device_id.

    I thought it would be easier to point there than pump out c code into a forum.
    So, this page, and the one following it?

    Slide shows aren't much good without the presenter talking over them, IMO. The information on them tends to be rather oversimplified and incomplete. In this case, the slide shows that there is this structure called pci_device_id, and how to populate it - but nothing, as far as I can tell, about how to read the device ID from a device, let alone how to do it from userspace.

    If I'm not mistaken, pci_device_id isn't even the structure you need to use to read a PCI device's info in userspace. Rather, it appears that PCI device drivers keep a table of pci_device_id which the kernel uses to match PCI devices in the system to relevant drivers... 'Course I could be wrong there...

  8. #8
    Just Joined!
    Join Date
    Jul 2009
    Posts
    58
    Oh I've never looked for what he is looking for I assume he knew what he was asking for. He wanted to know how to setup the structure.

    Now that I think about it "scanpci" should have the code he is looking for at least that'll confirm where the data is located. I'm 99.9% sure that it prints out the vendor name or at least the vendor code.

  9. #9
    Linux Newbie tetsujin's Avatar
    Join Date
    Oct 2008
    Posts
    115
    Quote Originally Posted by aram535 View Post
    Oh I've never looked for what he is looking for I assume he knew what he was asking for. He wanted to know how to setup the structure.
    Ah, I guess I misunderstood a bit... XD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...