lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Problem trying to recieve an UDP packet


From: Iwan Budi Kusnanto
Subject: Re: [lwip-users] Problem trying to recieve an UDP packet
Date: Mon, 28 Nov 2011 16:20:29 +0700

[Sorry for top posting]

Hi Victor, please read RAW API doc first, at doc/rawapi.txt
You can take a look at my code
https://gist.github.com/1399729
Tested with lwip 1.4.0-rc2

2011/11/25 Víctor Mateo <address@hidden>:
> Hi all
>
>
>
> I´m stuck trying to recieve an UDP packet from a host (192.168.10.10) to a
> LWIP on 192.168.10.11 and send it back to the host as a simple echo.
>
> I'm sending the UDP packet (a simple character or string) trough port 31
> from a C# Console I've programmed and checked that it actually sends right.
>
>
>
> This are the functions I'm using in the NIOS II IDE enviroment:
>
>
>
> -------------------------------------------------------------------------------------
>
> -------------------------------------------------------------------------------------
>
>
>
> void udp_echo_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct
> ip_addr *addr, u16_t port)
> {
>  struct ip_addr adr;
>  IP4_ADDR(&adr, 192, 168, 10, 11);
>  udp_connect(pcb, &adr,  31);
>  //udp_send(pcb, p);
>
>
>    if (p != NULL) {
>     /* FIXME: possibly use udp_connect() and udp_disconnect()
>                   instead of manipulating the pcb directly */
>         pcb->remote_ip = *addr;
>         pcb->remote_port = port;
>         udp_send(pcb, p);
>         /* FIXME: udp_disconnect() ? */
>     }
>     /* free the pbuf */
>     pbuf_free(p);
>     printf("udp_echo OK!\n");
> }
>
> void udp_echo_init(void)
> {
>       struct ip_addr adr;
> //    IP4_ADDR(&adr, 192, 168, 10, 10);
> //    udp_connect(pcb, &adr,  31);
> //    udp_send(pcb, p);
>     udp_remove(pcb); //Elimino el pcb anterior (el de transmision)
>     err_t retval;
>     struct udp_pcb * pcb;
>
>     pcb = udp_new();
>     if (pcb == NULL) printf("udp_new failed!\n");
>
>     retval = udp_bind(pcb, IP_ADDR_ANY, 31);
>     //retval = udp_bind(pcb, IP_ADDR_ANY, 31);
>     if (retval != ERR_OK) printf("udp_bind failed!\n");
>     IP4_ADDR(&adr, 192, 168, 10, 11);
>     udp_connect(pcb, &adr,  31);
>     //udp_bind(pcb, IP_ADDR_ANY, 31);
>
>
>     udp_recv(pcb, udp_echo_recv, NULL );
>
>     printf("udp_rcv OK!\n");
>     //udp_disconnect(pcb);
> }
>
> -------------------------------------------------------------------------------------
>
> -------------------------------------------------------------------------------------
>
>
>
> and I call udd_echo_init() from the main.c as an infinite listen circle:
>
>
>
> -------------------------------
>
> while(1)
>
> {
>
> udp_echo_init();
>
> }
>
> -------------------------------
>
>
>
> NIOS II compiles and runs the program fine, the message "udp_recv OK" is
> shown but "udp_echo OK" doesn't. I don't know but it seems that
> udp_echo_recv() is not working.
>
> Can anybody help me with this?
>
>
>
> Thank you
>
> --
>
> Víctor Mateo Gómez
>
>
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>



reply via email to

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