Re: Network Interface for a Given Destination Address
Re: Network Interface for a Given Destination Address
- Subject: Re: Network Interface for a Given Destination Address
- From: Michael Smith <email@hidden>
- Date: Fri, 9 Mar 2007 00:43:27 -0800
On Mar 9, 2007, at 12:32 AM, Jones Curtis wrote:
I'm trying to determine the ethernet interface (en0, en1, etc.)
that will be used for a given destination ip address. I've tried
using ifaddr_withdstaddr() and ifaddr_withnet() and I can get the
correct result for addresses that are local to the machine and for
those that are on the same subnet as one of the ethernet interfaces
for the machine. So, that's part of the solution, but not all of it.
I looked at ifaddr_findbestforaddr(), thinking that it might return
NULL if that the given interface wasn't useful for that address,
but if I'm reading the source code for ifaof_ifpforaddr()
correctly, it doesn't touch the routing tables and it simply
returns the first address entry if none of them match.
So, I'm guessing I need to specifically find the interface for the
default route if _withdstaddr() / _withnet() don't help. Is this
the correct approach? And how would I go about doing that?
It's my understanding that advisory forms of the kernel's routing
policy decisions are not exported to userspace.
There are good reasons for this; not the least of which being that
between obtaining such advice and actually committing to a decision
based on that advice, the validity of the advice may expire due to
changes in the system's topology.
I realise this doesn't help you much, but telling the future is a
tough business. 8(
= Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden