Hi,
I am developing an application require the use of the Ethernet and PPP interfaces. The latter for a GPRS modem.
Keil's PPP seems to have several limitations, the main ones being limited runtime configuration and the control of whether Ethernet or PPP is used for routing of IP data.
My application requires Ethernet for some services and PPP for others but this seems impossible because Middleware 7.2.0 has a PPP_DEFAULT_GW config value which can only be changed at compile-time and even if it could be changed at runtime, it it global, not per IP service.
My understanding is that when it is ON the library will send packets via PPP, if the destination address is within the subnet of the PPP interface. It is the same for any other interface. If the destination address does not fit in any subnet, it will be send to the default gateway.
So for example, if my Ethernet and PPP(GPRS) interface are using DHCP and ...
Ethernet IP Address: 192.168.1.226 Ethernet Subnet: 255.255.255.0
PPP IP Address: 31.111.217.203 PPP Subnet: 255.255.255.255 (this doesn't seem to be configurable in "Net_Config_PPP.h" but is shown in localm[NETIF_PPP].NetMask)
PPP_DEFAULT_GW is ON: Destination 192.168.1.218 uses Ethernet as within Ethernet subnet Destination 212.227.17.174 is outside of both subnets so PPP is used as PPP_DEFAULT_GW is ON
PPP_DEFAULT_GW is OFF: Destination 192.168.1.218 uses Ethernet as within Ethernet subnet Destination 212.227.17.174 is outside of both subnets so Ethernet is used as PPP_DEFAULT_GW is OFF
The problem with all of this is that one of my IP services is a DDNS client and is using the PPP interface but I want it to use the Ethernet interface as this is the IP address I want to give to the DDNS provider (for remote Web Server connections etc). I can't do this without changing the PPP config, which then affects my other IP services.
Has anyone else had any experience of this? Is my understanding correct? Are there any workarounds/tricks to solve this issue?
Thanks.
Have you checked if you are allowed to bind a socket to the IP of the eth interface, to force the source IP to use when connecting to the DDNS proider?
You mean create a socket and "link" it to an interface and then use that socket for the DDNS client? I don't think you can bind a socket to a specific interface, only to an address and port. This is the main problem - Keil control which interface is used and when and there doesn't appear to be a way round this. This also means I have to always do a ppp_connect() (small financial cost), just in case the Middleware decides to use PPP instead of Ethernet.
Per, I guess you meant using the SO_BINDTODEVICE option with setsockopt() - no, it is not listed as a supported option.
Keil if already told me that it is not possible to control which interface is used on a per socket basis. I was hoping that someone may have an idea or workaround that I haven't thought of.
No, I wasn't thinking about the SO_BINDTODEVICE option, because the Keil documentation only mentions SO_KEEPALIVE and SO_RCVTIMEO.
What I was thinking about was to bind the source socket to the specific source IP address of a specific interface, as described in this link: stackoverflow.com/.../tcp-ip-connection-on-a-specific-interface
I didn't see any note in the documentation if Keil supports this or not, to select which source interface to send out the packets on.
Tried that and it made no difference. Even if it did work, whilst it would be better, it wouldn't help when Keil's DNS client or SNTP client are being used as they do the socket/connect internally so I wouldn't be able to bind to the socket.
Thanks for the suggestion though.