From owner-freebsd-net Mon Feb 7 21:53:13 2000 Delivered-To: freebsd-net@freebsd.org Received: from mc-qout4.whowhere.com (mc-qout4.whowhere.com [209.185.123.18]) by builder.freebsd.org (Postfix) with SMTP id 1F2E53D4D for ; Mon, 7 Feb 2000 21:53:09 -0800 (PST) Received: from Unknown/Local ([?.?.?.?]) by my-deja.com; Mon Feb 7 21:29:55 2000 To: "Garrett Wollman" Date: Mon, 07 Feb 2000 21:29:55 -0800 From: "gbnaidu " Message-ID: Mime-Version: 1.0 Cc: freebsd-net@FreeBSD.ORG X-Sent-Mail: off X-Mailer: MailCity Service Subject: Re: How to get outgoing interface... X-Sender-Ip: 164.164.56.2 Organization: My Deja Email (http://www.my-deja.com:80) Content-Type: text/plain; charset=us-ascii Content-Language: en Content-Length: 1874 Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org -- On Mon, 7 Feb 2000 11:42:26 Garrett Wollman wrote: >< said: > >[Paragraph reformatted for legibility. In the future, please press >return at the end of each 72-character line.] > >> I am trying to dump the routing table using the sysctl system >> call. I am able to get the destination address, gateway, mask all >> these entries. But How do I get the outgoing interface for a >> particular entry in the routing table? > >Keep on looking in the routing message. A typical response will look >like this: > >sockaddrs: > default anacreon default fxp0:0.a0.c9.3c.76.5c khavrinen > >You have found the first three sockaddrs in the message; the RTA_IFP >sockaddr will tell you which interface is being used, and the RTA_IFA >one will tell you the IP address configured on that interface. > >-GAWollman I tried looking in to those structures(RTA_IFP)also. But the structure is NULL. This is how I defined: mib[0] = CTL_NET; mib[1] = AF_ROUTE; mib[2] = 0; mib[3] = family; /* AF_INET */ mib[4] = NET_RT_DUMP; mib[5] = 0; /* Here do I need to set any flags? */ After calling sysctl, I am trying to read the structures by checking them whether they are null: rti_info contains all the returned sockaddr structrues by sysctl: if ( (sa = rti_info[RTAX_DST]) != NULL) { process the destination address; if ( (sa = rti_info[RTAX_GATEWAY]) != NULL) Similarly I amtrying to get the name of the interface: if ( (sa = rti_info[RTAX_IFP]) != NULL): here this condition fails. Do I need to give any other information like flags(RTA_IFP) to mib[5]? thank you gb --== Sent via Deja.com http://www.deja.com/ ==-- Share what you know. Learn what you don't. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message