diff --git a/CHANGELOG b/CHANGELOG index eb2e09a9..389e0916 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,10 @@ HISTORY ++ New features: + 2015-02-13: Simon Goldschmidt + * opt.h, pbuf.h/.c, etharp.c: Added the option PBUF_LINK_ENCAPSULATION_HLEN to + allocate additional header space for TX on netifs requiring additional headers + 2015-02-12: chrysn * timers.h/.c: introduce sys_timeouts_sleeptime (returns the time left before the next timeout is due, for NO_SYS==1) diff --git a/src/core/pbuf.c b/src/core/pbuf.c index d7508312..9a51e1c0 100644 --- a/src/core/pbuf.c +++ b/src/core/pbuf.c @@ -214,17 +214,22 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type) switch (layer) { case PBUF_TRANSPORT: /* add room for transport (often TCP) layer header */ - offset = PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN; + offset = PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN; break; case PBUF_IP: /* add room for IP layer header */ - offset = PBUF_LINK_HLEN + PBUF_IP_HLEN; + offset = PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN; break; case PBUF_LINK: /* add room for link layer header */ - offset = PBUF_LINK_HLEN; + offset = PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN; + break; + case PBUF_RAW_TX: + /* add room for encapsulating link layer headers (e.g. 802.11) */ + offset = PBUF_LINK_ENCAPSULATION_HLEN; break; case PBUF_RAW: + /* no offset (e.g. RX buffers or chain successors) */ offset = 0; break; default: diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h index 112fa2bc..362a2176 100644 --- a/src/include/lwip/opt.h +++ b/src/include/lwip/opt.h @@ -1189,6 +1189,14 @@ #endif /* LWIP_HOOK_VLAN_SET */ #endif +/** + * PBUF_LINK_ENCAPSULATION_HLEN: the number of bytes that should be allocated + * for an additional encapsulation header before ethernet headers (e.g. 802.11) + */ +#ifndef PBUF_LINK_ENCAPSULATION_HLEN +#define PBUF_LINK_ENCAPSULATION_HLEN 0 +#endif + /** * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is * designed to accommodate single full size TCP frame in one pbuf, including diff --git a/src/include/lwip/pbuf.h b/src/include/lwip/pbuf.h index 6bd6b308..bc6eceb3 100644 --- a/src/include/lwip/pbuf.h +++ b/src/include/lwip/pbuf.h @@ -60,6 +60,7 @@ typedef enum { PBUF_TRANSPORT, PBUF_IP, PBUF_LINK, + PBUF_RAW_TX, PBUF_RAW } pbuf_layer; diff --git a/src/netif/etharp.c b/src/netif/etharp.c index b1401f9f..037cc683 100644 --- a/src/netif/etharp.c +++ b/src/netif/etharp.c @@ -1128,7 +1128,7 @@ etharp_query(struct netif *netif, ip_addr_t *ipaddr, struct pbuf *q) } if(copy_needed) { /* copy the whole packet into new pbufs */ - p = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); + p = pbuf_alloc(PBUF_RAW_TX, p->tot_len, PBUF_RAM); if(p != NULL) { if (pbuf_copy(p, q) != ERR_OK) { pbuf_free(p); @@ -1240,7 +1240,7 @@ etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, LWIP_ASSERT("netif != NULL", netif != NULL); /* allocate a pbuf for the outgoing ARP request packet */ - p = pbuf_alloc(PBUF_RAW, SIZEOF_ETHARP_PACKET_TX, PBUF_RAM); + p = pbuf_alloc(PBUF_RAW_TX, SIZEOF_ETHARP_PACKET_TX, PBUF_RAM); /* could allocate a pbuf for an ARP request? */ if (p == NULL) { LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS,