Re: sol_socket so_bindtodevice alternative
Re: sol_socket so_bindtodevice alternative
- Subject: Re: sol_socket so_bindtodevice alternative
- From: Vincent Lubet <email@hidden>
- Date: Mon, 06 Jan 2014 10:43:41 -0800
On Jan 6, 2014, at 5:53 AM, Hado Hein <email@hidden> wrote:
>
> On 05.01.2014, at 05:30, Ross Bencina <email@hidden> wrote:
>
>> On 5/01/2014 7:43 AM, Hado Hein wrote:
>>> I’m trying to find a solution to send udp broadcasts over a specific network interface.
>>> Binding to an address is not an option.
>>
>> Probably I am missing something, but why is binding to an address not an option?
>>
>> 1. Determine the address of the local adapter you want to send from (there are APIs to enumerate adapters and get their addresses).
>>
>> 2. Use the local adapter address in sin_addr.s_addr to bind().
>>
>> Ross.
>
> Hi Ross,
>
> binding to an adress does not influence routing (afaik).
> Binding to an address is about receiving only. If i send on a bound socket the ip stack still routes the packet on through the interface that has the gateway.
Ross is correct in principle.
With recent version of the xnu networking stack binding to an IP address does affect the routing decision. The route lookup will be restricted to route entries with the interface of the bound IP address.
> The situation is:
> pdp0 10.x.x.x with gateway
> eth0 192.x.x.x without gateway, but with physical/layer 2 reachability for the devices which have 2.x.x.x
>
> Even if i bind to the eth0 ip packets will go out on pdp0 since this one has the gateway. SO_dontroute wasn’t a success also.
This may be a bug or a corner case. Does this happen only on iOS?
Vincent
_______________________________________________
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