This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
RE: ECOS:Incorrect default gateway entry - Free BSD
Andrew,
The function do_bootp() in bootp_support.c file sets up routing with
gateway as "255.255.255.255". I'm using that piece of code only for my
DHCP client. Please have a look at the code below. I'm using ecos v2 and
the compiler is mipsisa32-elf-gcc.
**********************
// Set up routing
/* the broadcast address is 255.255.255.255 */
memset(&addrp->sin_addr, 255, sizeof(addrp->sin_addr));
memset(&route, 0, sizeof(route));
memcpy(&route.rt_gateway, addrp, sizeof(*addrp));
addrp->sin_family = AF_INET;
addrp->sin_port = 0;
addrp->sin_addr.s_addr = INADDR_ANY;
memcpy(&route.rt_dst, addrp, sizeof(*addrp));
memcpy(&route.rt_genmask, addrp, sizeof(*addrp));
route.rt_dev = ifr.ifr_name;
route.rt_flags = RTF_UP|RTF_GATEWAY;
route.rt_metric = 0;
if (ioctl(s, SIOCADDRT, &route)) {
if (errno != EEXIST) {
perror("SIOCADDRT 3");
goto out;
}
}
********************************
regards,
Alok
-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Andrew Lunn
Sent: Tuesday, July 24, 2007 12:10 PM
To: Alok Singh
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] ECOS:Incorrect default gateway entry - Free BSD
On Tue, Jul 24, 2007 at 03:50:35AM +0530, Alok Singh wrote:
> 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 -
This is not a valid host IP address. It is a broadcast address.
Try giving your gateway the IP address 192.168.0.1 and your target
192.168.0.2. Give both a netmask for 255.255.255.0.
Andrew
> ***************
> Destination Gateway Mask Flags Interface
>
> 0.0.0.0 0.0.0.0 -1.0.0.0 U eth0
^^
Im supprised you are getting -1 here. Obviously it should be
255. However, i would expect it to be printed correctly. What eCos
sources and gcc are you using?
> 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
^^^^^^^^^^^^^^^^^^^^^^^
This looks very strange. Why so many bytes?
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss