lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Re: Re: [lwip] Need a udp sample using raw interface


From: Rajeev Nair
Subject: [lwip-users] Re: Re: [lwip] Need a udp sample using raw interface
Date: Wed, 08 Jan 2003 23:29:12 -0000

Thanks John, that was indeed useful.
Rajeev
On Sat, 07 Sep 2002 John C. Toman wrote :
>Rajeev,
>
>Your code to send a packet should look something like the 
>following pseudocode (this works with lwIP 0.5.3 and I believe 
>it's fine for later versions):
>
>struct ip_addr *destination;
>struct udp_pcb *pcb;
>struct pbuf *p;
>u16_t packet_size; // You need to determine how big your packet 
>needs to be
>
>p = pbuf_alloc(PBUF_TRANSPORT, packet_size, PBUF_RAM);
>
>// Code omitted here would fill in your packet (for example, get 
>p->payload and cast it to a structure)
>
>// Open the port and send the data
>pcb = udp_new();
>udp_connect(pcb, destination, 
>SERVER_PORT_YOU_ARE_CONNECTING_TO);
>udp_send(pcb, p);
>
>// Close the port
>udp_remove(pdb);
>
>Binding to receive data with the raw API is a little different, 
>you've got to have a callback function (and don't close the 
>pcb):
>
>void
>udp_callback_function(void *passed_data, struct udp_pcb *pcb, 
>struct pbuf *p, struct ip_addr *addr, u16_t port)
>{
>    // Do something with the packet that was just received
>}
>
>// The rest here is pseudocode
>
>void *passed_data = NULL;
>
>udp_recv(pcb, udp_callback_function, passed_data);
>udp_bind(pcb, IP_ADDR_ANY, PORT_I_WANT_TO_RECEIVE_DATA_ON);
>
>Hope this helps,
>
>John
>
>Rajeev Nair wrote:
>
>>Hi,
>>I am partly getting success in porting lwip on WinCE. So far I 
>>have ported the raw interface only. I would like to get hold of 
>>a udp sample that sends udp datagrams using raw interface. Any 
>>inputs/references/links will be of great help.
>>thanks,
>>regards
>>rajeev
>>[This message was sent through the lwip discussion list.]
>
>
>
>
>
>[This message was sent through the lwip discussion list.]

[This message was sent through the lwip discussion list.]




reply via email to

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