From owner-freebsd-current Tue Jun 30 06:27:08 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id GAA19515 for freebsd-current-outgoing; Tue, 30 Jun 1998 06:27:08 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from biggusdiskus.flyingfox.com (biggusdiskus.flyingfox.com [205.162.1.28]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id GAA19501 for ; Tue, 30 Jun 1998 06:27:03 -0700 (PDT) (envelope-from jas@flyingfox.com) Received: (from jas@localhost) by biggusdiskus.flyingfox.com (8.8.5/8.8.5) id GAA09844; Tue, 30 Jun 1998 06:27:57 -0700 (PDT) Date: Tue, 30 Jun 1998 06:27:57 -0700 (PDT) From: Jim Shankland Message-Id: <199806301327.GAA09844@biggusdiskus.flyingfox.com> To: abial@nask.pl, freebsd-current@FreeBSD.ORG Subject: Re: Retrieving routing table via sysctl Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Andrzej Bialecki writes: > There are sysctl's which are named appropriately, but what they return > is a series of struct rt_msghdr, which doesn't contain the struct > sockaddr of the route itself and of the gateway... (I'm speaking here > about: > > int mib[]={CTL_NET,PF_ROUTE,0,0,NET_RT_DUMP}; > ) > > I'd like to be able to do this _without_ resorting to kread and friends, > so that it works on a stripped kernel. The sockaddr's immediately follow the struct rt_msghdr; flags in the struct rt_msghdr tell you which sockaddr's are present. Beware: the sockaddr for a netmask is only 8 bytes long. When in doubt, check against the kernel source, and/or carefully eyeball several sets of sample output. This is not for the faint of heart, but it can be made to work. All the above is based on -stable; your -current mileage may vary. Jim Shankland Flying Fox Computer Systems, Inc. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message