|[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]|
My system has a wireless interface and an ethernet interface. The ethernet interface is the primary interface, so the default route goes through the ethernet interface. I have an 802.1x supplicant that replaces the native (Airport) supplicant. After authenticating via a wireless access point, I get a new IP address from some DHCP server on the network that the access point is on.
At this point my code creates a socket and binds it to the wireless interface. When the code uses connect() to open a connection to a server, the traffic is routed through the ethernet interface because it follows the default route. The server rejects the connection because it is expecting traffic from the interface that I bound to (the wireless interface), and my default route is over the ethernet.
When I do the same thing on Windows the operating system dynamically adds a route to the server over the wireless interface and my communication with the server proceeds over that interface. Likewise if I manually add a route on Mac OS X that routes traffic to the server over the wireless interface, everything works fine. Is there some way to configure the network stack to do this dynamic routing? I also tried setting the SO_DONTROUTE socket option but that doesn’t seem to work.
At this point, I see two options:
1. Once I have a valid IP address on the wireless interface, temporarily make the wireless interface the default using the SystemConfiguration API.
2. Programatically add a specific route to the server, with the wireless interface as the gateway. Of course, my code then has to make sure to clean up this route when it is finished, etc.
Are there any other approaches that are better?
Windows Live™: Keep your life in sync. Check it out.
_______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
Visit the Apple Store online or at retail locations.
Copyright © 2011 Apple Inc. All rights reserved.