lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] lwipopts question


From: Simon Goldschmidt
Subject: Re: [lwip-users] lwipopts question
Date: Wed, 21 Dec 2011 09:39:54 +0100

Martin Velek <address@hidden> wrote:
> I am a little bit confused with PBUF_LINK_HLEN. In opt.h there is
> computed as (14 + ETH_PAD_SIZE).
> My netif driver is filled copy of src/netif/ethernetif.c
> with"pbuf_header(p, -ETH_PAD_SIZE)".
> Should I set PBUF_LINK_HLEN to 16?

Yes, just leave it as opt.h defines it. Your driver is correct in masking out 
the padding size. The reason PBUF_LINK_HLEN needs to be 16 is that the pbuf 
actually needs the room for the padding (which is created using that define). 
The actual layout of an IPv4 packet on ethernet (without VLAN) will be:

- 2 bytes padding
- 14 bytes ethernet header
- 20 bytes IPv4 header
- UDP/TCP header
- data

So when sending or receiving, your netif driver has to handle this correctly.

> As I told, the heap is almost unlimited. I have these settings
> #define MEM_LIBC_MALLOC                1
> #define MEMP_MEM_MALLOC             1
> #define MEM_USE_POOLS                   0
> 
> Is it correct to have all pbufs allocated by malloc and do not use any
> static or code memory to hold anything about pool structure?

Yes. As long as you only modifed the above defines and haven't modified the 
code itself, pbufs area allocated correctly (the main concern here is that for 
PBUF_RAM and PBUF_POOL, the struct pbuf and the payload must be in a contiguous 
memory area).

Simon
-- 
NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!               
Jetzt informieren: http://www.gmx.net/de/go/freephone



reply via email to

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