From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 30 04:52:37 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B244716A4CE for ; Mon, 30 Aug 2004 04:52:37 +0000 (GMT) Received: from out004.verizon.net (out004pub.verizon.net [206.46.170.142]) by mx1.FreeBSD.org (Postfix) with ESMTP id 371D343D41 for ; Mon, 30 Aug 2004 04:52:37 +0000 (GMT) (envelope-from skip.ford@verizon.net) Received: from pool-70-17-33-17.pskn.east.verizon.net ([70.17.33.17]) by out004.verizon.netESMTP <20040830045236.SMBY28868.out004.verizon.net@pool-70-17-33-17.pskn.east.verizon.net>; Sun, 29 Aug 2004 23:52:36 -0500 Date: Mon, 30 Aug 2004 00:52:35 -0400 From: Skip Ford To: Dennis George Message-ID: <20040830045235.GA587@lucy.pool-70-17-33-17.pskn.east.verizon.net> Mail-Followup-To: Dennis George , freebsd-hackers@freebsd.org References: <20040830025527.88596.qmail@web53908.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040830025527.88596.qmail@web53908.mail.yahoo.com> User-Agent: Mutt/1.4.2.1i X-Authentication-Info: Submitted using SMTP AUTH at out004.verizon.net from [70.17.33.17] at Sun, 29 Aug 2004 23:52:36 -0500 cc: freebsd-hackers@freebsd.org Subject: Re: Finding MTU X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Aug 2004 04:52:37 -0000 Dennis George wrote: > Can anybody tell me how to find the MTU (Maximum Transmitting > Unit) in freeBSD programatically... The full source for ifconfig(8) is available. No need to ask anyone... http://www.freebsd.org/cgi/cvsweb.cgi/src/sbin/ifconfig/ifconfig.c?rev=1.106&content-type=text/x-cvsweb-markup However, here's a small program, probably taken from the sources above at some point, that prints the MTU for ed0. #include #include #include #include #include #include #include #include int main(void) { int s, af = AF_INET; char *name = "ed0"; struct ifreq ifr; if ((s = socket(af, SOCK_DGRAM, 0)) < 0) err(1, "socket"); ifr.ifr_addr.sa_family = AF_INET; strcpy(ifr.ifr_name, name); if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) < 0) warn("ioctl (get mtu)"); fprintf(stdout, "MTU of %s is %d.\n", name, ifr.ifr_mtu); close(s); return(0); } -- Skip