Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Mar 2005 09:07:44 -0800
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        Patrik Arlos <Patrik.Arlos@bth.se>
Cc:        freebsd-net@freebsd.org
Subject:   Re: Accessing ifunit/ifaddr_byindex
Message-ID:  <20050317170743.GA25383@odin.ac.hmc.edu>
In-Reply-To: <00c701c52af3$6528cf40$73942fc2@Trantor>
References:  <00c701c52af3$6528cf40$73942fc2@Trantor>

next in thread | previous in thread | raw e-mail | index | archive | help

--x+6KMIRAuhnl3hBn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Mar 17, 2005 at 02:15:31PM +0100, Patrik Arlos wrote:
> Hi,
>=20
> 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 t=
he
> 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 (?).=20
>=20
> 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

--=20
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

--x+6KMIRAuhnl3hBn
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFCOblfXY6L6fI4GtQRAioeAJ9hUqY/8r7kimEdV4Pnecp/cGSerwCgr4t1
sKqmLQF+Y6OXeXKVgM/mkGI=
=aYHT
-----END PGP SIGNATURE-----

--x+6KMIRAuhnl3hBn--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050317170743.GA25383>