[ECOS] issue with raw bsd sockets

Jay Foster jay@systech.com
Fri Aug 7 16:19:00 GMT 2009


DHCP uses INADDR_BROADCAST (255.255.255.255) as the broadcast address. 
You probably need to set the interface broadcast address to match.  You 
may also need to add a route to allow broadcasts.  Look at the 
DHCP/BOOTP eCos code.  It does some of this too.

Jay

Mandeep Sandhu wrote:
> On Fri, Aug 7, 2009 at 6:21 PM, Sergei
> Gavrikov<sergei.gavrikov@gmail.com> wrote:
>> Mandeep Sandhu wrote:
>>> I'm using the FreeBSD stack on my Linux Synthetic target to implement
>>> a tiny DHCP server. I can receive DHCP REQUEST packets coming over the
>>> tap interface, but am unable to send back the broadcast resp packet
>>> (DHCP Offer).
>> [snip]
>>
>>> Any hint's appreciated.
>> Hi Mandeep,
>>
>> I call that recently Jay Foster share on the list a solution
>> http://sourceware.org/ml/ecos-discuss/2009-06/msg00075.html
>> Follow this thread. HIH.
> 
> Thanks Sergei. This is _exactly_ my problem too.
> 
> Though this patch didn't help much. Now my IP broadcast addr is not
> converted to the subnet bcast addr of the interface...but my ip_output
> function fails when trying to get an interface for 255.255.255.255
> 
> Here's where it fails:
> 
> packages/net/bsd_tcpip/v3_0/src/sys/netinet/ip_output.c
> 
> <snip>
> ...
>     if (flags & IP_ROUTETOIF) {
>         if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst)))) == 0 &&
>             (ia = ifatoia(ifa_ifwithnet(sintosa(dst)))) == 0) { <<---- PROBLEM!
>             ipstat.ips_noroute++;
>             error = ENETUNREACH; <<-- shows up as 'Network is unreachable'
>             goto bad;
>         }
>         ifp = ia->ia_ifp;
>         ip->ip_ttl = 1;
>         isbroadcast = in_broadcast(dst->sin_addr, ifp);
>     }
> ...
> </snip>
> 
> Any other clue? Or should I switch stack to LWIP? Any idea if this works in
> LWIP?
> 
> Looking at the same function in lwip stack...I see it picks up the
> default interface
> if the route lookup does not find a suitable match.
> 
> Thanks,
> -mandeep
> 
>> Sergei
>>
> 

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list