lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] How do I receive UDP packets with unconfigred IP addres


From: Rogier Wolff
Subject: Re: [lwip-users] How do I receive UDP packets with unconfigred IP address.
Date: Thu, 21 Jan 2021 14:06:55 +0100

On Thu, Jan 21, 2021 at 01:32:22PM +0100, Indan Zupancic wrote:
> On 2021-01-21 11:58, Rogier Wolff wrote:
> > On Thu, Jan 21, 2021 at 10:37:52AM +0100, Indan Zupancic wrote:
> > > You probably also have to call ip_set_option(pcb, SOF_BROADCAST);
> > > and of course tell lwIP that the network interface is up.
> > 
> > The "upping" of the interface, I think that happens inside the call:
> 
> I meant a call to netif_set_link_up().
> 
> Looking at the code it seems you have to call netif_set_up() too,
> but with 0.0.0.0 IP address till you have a real one.
> 
> You also need to set the NETIF_FLAG_BROADCAST flag for your interface.

I use chibios as the micro-OS on my system. it has: 

    netifapi_netif_set_up(&thisif);

in the init function that I call. 


When I have the static IP already configured (over USB, that the
device won't have in the field), the transmit to the network broadcast
address has been tested to work. So I think the NETIF_FLAG_BROADCAST
is set.

I have followed the input path and ip4_input eventually calls 
ip4_addr_isbroadcast_u32 to see if it will accept the packet. 

And the way I read that function it will accept the packet if it is
the "all internet broadcast" address (255.255.255.255 or 0.0.0.0), or
matches the current IP address except for all ones in the NOT NETMASK
part of the destination address.. 

So it will NOT match 192.168.x.255 when I have 0.0.0.0 or 169.254.x.y
configured as "my IP address". 

So.... I will have to broadcast to 255.255.255.255 to reach the
"unconfigured" devices and trust that modern routers won't propagate
that.

Correct?

        Roger. 

-- 
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]