Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

netstat -nr's sysctl call returning weird data



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:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.