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
        tftpsrvbuf=netbuf_new();        // Create netbuf
          .....



David Empson schrieb:
With the raw API, the trick is to use udp_bind() to bind the PCB to a specified local IP address and port.
 
It looks like netconn_bind() will achieve the same thing for the netconn API, and lwip_bind() for the sockets API.
 
In each case, the bind is done after creating the PCB with the appropriate "new" call, before doing the first send/sendto/sendto_if.
 
Judging from a comment in api_lib.c, it isn't clear whether you can safely re-bind an existing PCB, so you might need to destroy the PCB and recreate it if you need to change your source port.
 

_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to