Everything seems to work great except when attempting to set the default router… here’s my relevant code
#define TCPCONFIG 6
// globals
longword defaultGateway;
char defaultGatewayStr[16];
void main(void)
{
sock_init();
ifconfig(IF_ETH0,
IFS_DOWN,
IFS_DHCP, 0,
IFS_DHCP_TIMEOUT, 30,
IFS_IPADDR, aton(“192.168.0.100”),
IFS_NETMASK, aton(“255.255.255.0”),
IFS_ROUTER_SET, aton(“192.168.0.1”),
IFS_END);
// get default gateway
ifconfig(IF_ETH0, IFG_ROUTER_DEFAULT, &defaultGateway, IFS_END);
inet_ntoa((char*)&defaultGatewayStr, defaultGateway);
printf("default gateway: %s
", defaultGatewayStr);
}
I have no problem printing out the ipaddr and netmask, but for some strange reason the router doesn’t take when I perform an IFS_ROUTER_SET via ipconfig()
Any help is appreciated
1 Like
Edit: So when I originally posted my issue, I was not actually connecting the eth0 interface to my network or attempting to bring it up… all testing was with the interface left down
When actually connecting to a network and bringing the interface up, the gateway will read back properly…
Is there a way to actually retrieve the default router configuration via ipconfig() without actually bringing up the interface?
I recommend separating the IFS_DOWN from the other settings, and possibly disabling DHCP in one call to ifconfig() and then setting the static parameters in a separate call.
And make sure that the router’s IP address isn’t local for any other interfaces on the device (e.g., Wi-Fi or PPP). If that’s the case, ifconfig() will set the router for THAT interface instead.
Tom,
I have done what you suggested and separated the ifconfig() calls when setting IFS_DOWN and DHCP
I’m running two interfaces, but only one is being brought up at any given time.
I am also using TCPCONFIG 6, which defines USE_ETHERNET 1 and USE_WIFI 1
Now here’s the scenarios from my testing:
Scenario 1 - With USE_ETHERNET 1 and USE_WIFI 1 defined:
I am only able to read the default gateway when bringing up the ETHERNET interface… I am unable to read the default gateway when bringing up the WiFi in this scenario.
Scenario 2 - With USE_ETHERNET 0 and USE_WIFI 1 defined:
I am able to successfully read the gateway after bringing up the WiFi in this scenario.
How can I manipulate two interfaces (with only one being active at any given time) so that I can individually bring either interface up and read it’s assigned gateway address?
Does the interface in which I pass into my ifconfig() call matter? for example:
ifconfig(IF_ETH0, IFG_ROUTER_DEFAULT, …);
vs.
ifconfig(IF_ANY, IFG_ROUTER_DEFAULT, …);
Also, when you say to make sure the router’s IP address (let’s say 192.168.10.1) shouldn’t be local to another interface on the device… does this mean the IP address assignments of the interface which I’m not using needs to be assigned to a different network from that of the router prior to me calling an ifconfig() on the interface I am intending to bring up?
Please explain if I’m off track with this…
Thanks for your assistance
Edit:
I seem to have it working now, the culprit was the interface parameter I was passing into ifconfig() when performing IFG_ROUTER_DEFAULT
ifconfig(IF_WIFI0, IFG_ROUTER_DEFAULT, …); <– This doesn’t work
vs.
ifconfig(IF_ANY, IFG_ROUTER_DEFAULT, …); <– this works
Let me know if you run into any other issues after applying the ARP patch I linked to in your other forum post.
Tom,
I wasn’t aware of it but I’m still having an issue pinging non-local peers via WiFi while the Ethernet interface is default… I’ve made a new post which further clarifies the problem and also gives some router debug printout information…
this post was sort of a conglomeration of problems, so I want to separate my latest issue from the ones I was having here.