lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Setting source port number for UDP send


From: address@hidden
Subject: Re: [lwip-users] Setting source port number for UDP send
Date: Fri, 11 Dec 2009 08:24:38 +0100
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0

Marco Jakobs wrote:
Thanks for your thoughts, David!

I figured it out how to set a defined source port (in my case 69): Just insert this line to change the local port in the pcb:

        netconn_connect(tftptxcon,&modsrv_addr,ip_data_out.port);    // Open connection
        tftptxcon->pcb.udp->local_port=69;   // Set local (source) port
BIG FAT WARNING!
This is *totally* unsupported! Doing this, you risk:
a) threading issues: the raw API structs and functions may only be used from tcpip_thread, while you are changing a raw API struct from your application thread (the udp pcb).
b) The members of both struct netconn as well as struct udp_pcb are *not* part of the public API, meaning they are bound to change without you noticing (and without us announcing it). You can access them, I know, but that doesn't mean you should use them like that.

Once you leave lwIP and work with another stack (although that will never be the case, I hope *g*), you face the same problem again. Therefore, you can just do it right now and use bind() (whether it be lwip_bind() for sockets, netconn_bind() for netconns or udp_bind() for raw API udp pcbs). David suggested the correct functions, so no need to mess around in lwIP internal structs.


Simon

reply via email to

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