From owner-freebsd-net@FreeBSD.ORG Thu Mar 17 17:07:47 2005 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CE18B16A4CE for ; Thu, 17 Mar 2005 17:07:47 +0000 (GMT) Received: from odin.ac.hmc.edu (Odin.AC.HMC.Edu [134.173.32.75]) by mx1.FreeBSD.org (Postfix) with ESMTP id 85D9543D49 for ; Thu, 17 Mar 2005 17:07:47 +0000 (GMT) (envelope-from brdavis@odin.ac.hmc.edu) Received: from odin.ac.hmc.edu (localhost.localdomain [127.0.0.1]) by odin.ac.hmc.edu (8.13.0/8.13.0) with ESMTP id j2HH7i6M031570; Thu, 17 Mar 2005 09:07:44 -0800 Received: (from brdavis@localhost) by odin.ac.hmc.edu (8.13.0/8.13.0/Submit) id j2HH7ix3031569; Thu, 17 Mar 2005 09:07:44 -0800 Date: Thu, 17 Mar 2005 09:07:44 -0800 From: Brooks Davis To: Patrik Arlos Message-ID: <20050317170743.GA25383@odin.ac.hmc.edu> References: <00c701c52af3$6528cf40$73942fc2@Trantor> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="x+6KMIRAuhnl3hBn" Content-Disposition: inline In-Reply-To: <00c701c52af3$6528cf40$73942fc2@Trantor> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new X-Spam-Status: No, hits=0.0 required=8.0 tests=none autolearn=no version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on odin.ac.hmc.edu cc: freebsd-net@freebsd.org Subject: Re: Accessing ifunit/ifaddr_byindex X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Mar 2005 17:07:47 -0000 --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--