This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
ECOS:Incorrect default gateway entry - Free BSD
- From: "Alok Singh" <aloks at broadcom dot com>
- To: <ecos-discuss at ecos dot sourceware dot org>
- Date: Tue, 24 Jul 2007 03:50:35 +0530
- Subject: [ECOS] ECOS:Incorrect default gateway entry - Free BSD
Hi,
I'm trying to add the default gateway entry. I'm not able to
ping(access) the box from a different subnet. The dump of
"show_network_tables" is showing junk mask value. This may be the reason
why I'm not able to ping the
Box from a different subnet.
Interestingly, when I'm configuring the default gateway entry to
255.255.255.255, to enable DHCP client to send packets out, I'm not
getting any error. I'm able to get the address.
Dump when gateway is 255.255.255.255 -
***************
Destination Gateway Mask Flags Interface
0.0.0.0 0.0.0.0 -1.0.0.0 U eth0
0.0.0.0 255.255.255.255 0.0.0.0 UG eth0
Interface statistics
eth0 IP: 0.0.0.0, Broadcast: 255.255.255.255, Netmask: -1.0.0.0
UP BROADCAST RUNNING MULTICAST MTU: 1500, Metric: 0
Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0
lo0 IP: 127.0.0.1, Broadcast: 127.0.0.1, Netmask: -1.0.0.0
UP LOOPBACK RUNNING MULTICAST MTU: 16384, Metric: 0
Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0
*************************************
After getting the DHCP address, I do a cyg_route_reinit(), and then
configure the stack again.
After route_reinit(), dump is -
***************
Destination Gateway Mask Flags Interface
Interface statistics
eth0 IP: 0.0.0.0, Broadcast: 255.255.255.255, Netmask: -1.0.0.0
UP BROADCAST RUNNING MULTICAST MTU: 1500, Metric: 0
Rx - Packets: 6, Bytes: 1800, Tx - Packets: 4, Bytes: 1144
lo0 IP: 127.0.0.1, Broadcast: 127.0.0.1, Netmask: -1.0.0.0
UP LOOPBACK RUNNING MULTICAST MTU: 16384, Metric: 0
Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0
*****************
After configuring the gateway,
*************************
Destination Gateway Mask Flags Interface
0.0.0.0 10.240.3.1 0.0.0.0.0.0.0.3.0.0.0.1 UG eth0
10.240.3.0 10.240.3.0 -1.-1.-1.0 U eth0
Interface statistics
Eth0 IP: 10.240.3.123, Broadcast: 10.240.3.255, Netmask: -1.-1.-1.0
UP BROADCAST RUNNING MULTICAST MTU: 1500, Metric: 0
Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0
lo0 IP: 127.0.0.1, Broadcast: 127
********************
Code is:
*************
struct ecos_rtentry route;
struct ifreq ifr;
struct sockaddr_in *addrp;
addrp = (struct sockaddr_in *) &ifr.ifr_addr;
if((sock = socket(AF_INET, SOCK_RAW, 0)) < 0) {
printf("Failed to Open Socket\n");
return L7_FAILURE;
}
memset(&route, 0x00, sizeof (route));
addrp->sin_family = AF_INET;
addrp->sin_port = 0;
addrp->sin_len = sizeof(*addrp);
addrp->sin_addr.s_addr = INADDR_ANY;
memcpy(&route.rt_dst, addrp, sizeof(*addrp));
addrp->sin_addr.s_addr = INADDR_ANY;
memcpy(&route.rt_genmask, addrp, sizeof(*addrp));
addrp->sin_addr.s_addr = osapiHtonl(gateway);
memcpy(&route.rt_gateway, addrp, sizeof(*addrp));
route.rt_dev = "eth0";
route.rt_flags = RTF_UP|RTF_GATEWAY;
route.rt_metric = 0;
if ((ioctl(sock, SIOCADDRT, &route) < 0) && (errno != EEXIST)) {
printf("l3intfAddRoute: Failed to Add Route\n");
close(sock);
********************************
regards,
Alok
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss