Network Interface for a Given Destination Address
Network Interface for a Given Destination Address
- Subject: Network Interface for a Given Destination Address
- From: Jones Curtis <email@hidden>
- Date: Fri, 9 Mar 2007 03:32:31 -0500
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?
Thanks.
--
Curtis Jones
email@hidden
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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