lwip-users
[Top][All Lists]
Advanced

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

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


From: Víctor Mateo
Subject: [lwip-users] Problem trying to recieve an UDP packet
Date: Fri, 25 Nov 2011 10:08:52 +0100
User-agent: Mozilla/5.0

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


 


reply via email to

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