Re: Accessing ifunit/ifaddr_byindex

From: Brooks Davis (brooks_at_one-eyed-alien.net)
Date: 03/17/05

  • Next message: Eli Dart: "polling and twa coexistence problems under 5.4-PRE"
    Date: Thu, 17 Mar 2005 09:07:44 -0800
    To: Patrik Arlos <Patrik.Arlos@bth.se>
    
    
    

    On Thu, Mar 17, 2005 at 02:15:31PM +0100, Patrik Arlos wrote:
    > Hi,
    >
    > I'm writing a small program that tries to read out some parameters from a
    > ifnet structure. The code used ifunit() to obtain the ifnet structure for
    > the interface in question and later on it used ifaddr_byindex. The code
    > compiles nicely, but fails miserably to link, with undefined references to
    > the two mentioned functions. I've googled quite a lot (but obviously at the
    > wrong places), but can't find what library to include. I've included the
    > code below, the compile command used is the following; 'gcc -o ifList.bsd
    > -lpcap ifList.c'. The system is a FreeBSD-5.3-Release (?).
    >
    > If there are any other ways of finding the hw address and MTU for an
    > Interface please let me know.

    ifunit() and ifaddr_byindex() are both kernel functions and may not
    be used in userland. In fact, no program should access struct ifnet
    directly from userland (though a few badly behaved ones do). To get the
    MTU, check the code if ifconfig that does it. It's not all that hard,
    though ifconfig obfuscates the process a fair bit.

    -- Brooks

    -- 
    Any statement of the form "X is the one, true Y" is FALSE.
    PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4
    
    



  • Next message: Eli Dart: "polling and twa coexistence problems under 5.4-PRE"