[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Re: [lwip] UDP questions
From: |
Adam Dunkels |
Subject: |
[lwip-users] Re: [lwip] UDP questions |
Date: |
Thu, 09 Jan 2003 01:06:24 -0000 |
Horst,
On Thursday 13 December 2001 12.50, you wrote:
> netbuf_ref() sets buf->p->payload to a ROM address, but your
> udp_send() calls pbuf_header(), which assumes that payload
> is a address behind buf->p (it tries to decrement payload
> by UDP_HLEN to insert a udp header);
>
> I'm wrong? Is it impossible sendung UDP datagrams from
> ROM without copy?
You are right, the code is wrong :-) What UDP really should do when
pbuf_header() fails is to allocate an extra pbuf and chain it in front of the
pbuf containing the data.
The code for doing this looks like this:
struct pbuf *q;
if(pbuf_header(p, UDP_HLEN)) {
q = pbuf_alloc(PBUF_IP, UDP_HLEN, PBUF_RAM);
if(q == NULL) {
return ERR_MEM;
}
pbuf_chain(q, p);
p = q;
}
(This is in the beginning of the udp_send() function.)
Thanks for pointing this out!
> Another question:
>
> Is it possible to send broadcast UDP datagrams to 255.255.255.255?
> As understand your code, udp_send() calls ip_route(), which allows
> subnet-broadcasts only?
ip_route() returns the default interface when it cannot find a matching
interface, so sending to 255.255.255.255 works. The packet comes out on the
default interface.
/adam
--
Adam Dunkels <address@hidden>
http://www.sics.se/~adam
[This message was sent through the lwip discussion list.]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-users] Re: [lwip] UDP questions,
Adam Dunkels <=