netstat -nr's sysctl call returning weird data
netstat -nr's sysctl call returning weird data
- Subject: netstat -nr's sysctl call returning weird data
- From: Justin Delegard <email@hidden>
- Date: Sat, 8 Mar 2008 03:46:12 -0500
In my attempts to practice both programming in cocoa and low level system interaction, I created a small program to give basically the same info as netstat -nr does. Netstat makes a sysctl call which returns what amounts to an array of struct rt_msghdr2's (declared in net/route.h). Immediately following each struct rt_msghd2 is an array of struct sockaddrs, the length of which is determined by how many flags in the rt_msghdr2->rtm_addrs are set. Generally there are three sockaddrs returned: the destination, the netmask, and the gateway. Both the destination and the gateway are normal struct sockaddrs and when I mask them as struct sockaddr_ins they all behave as I would expect. The problem is with the netmask. For several routes it exists with a length of zero, and for others longer than you would expect an ipv4 netmask to be. Is there something going on with the implementation of routing tables that I am unaware of, or perhaps some netmask convention that I don't know? Why are these values so strange?
If you want to look at my project you can download it at http://j-dizzle.net/Routes.zip
Thanks, Justin |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden