Changed IP_REASSEMBLY to enqueue the received pbufs so that multiple packets can be reassembled simultaneously and no static reassembly buffer is needed.

This commit is contained in:
goldsimon
2007-10-06 15:24:43 +00:00
parent cb71d6d393
commit b7ef6077df
7 changed files with 381 additions and 183 deletions

View File

@@ -38,6 +38,7 @@
#include "lwip/pbuf.h"
#include "lwip/netif.h"
#include "lwip/ip_addr.h"
#include "lwip/ip.h"
#ifdef __cplusplus
extern "C" {
@@ -47,6 +48,18 @@ extern "C" {
/* The IP reassembly timer interval in milliseconds. */
#define IP_TMR_INTERVAL 1000
/* IP reassembly helper struct.
* This is exported because memp needs to know the size.
*/
struct ip_reassdata {
struct ip_reassdata *next;
struct pbuf *p;
struct ip_hdr iphdr;
u16_t packet_len;
u8_t flags;
u8_t timer;
};
void ip_reass_init(void);
void ip_reass_tmr(void);
struct pbuf * ip_reass(struct pbuf *p);

View File

@@ -43,6 +43,10 @@ LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN, sizeof(struct tcp_pcb_lis
LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG")
#endif /* LWIP_TCP */
#if IP_REASSEMBLY
LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA")
#endif
#if LWIP_NETCONN
LWIP_MEMPOOL(NETBUF, MEMP_NUM_NETBUF, sizeof(struct netbuf), "NETBUF")
LWIP_MEMPOOL(NETCONN, MEMP_NUM_NETCONN, sizeof(struct netconn), "NETCONN")

View File

@@ -162,9 +162,9 @@
------------------------------------------------
*/
/**
* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
* sends a lot of data out of ROM (or other static memory), this
* should be set high.
* MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF).
* If the application sends a lot of data out of ROM (or other static memory),
* this should be set high.
*/
#ifndef MEMP_NUM_PBUF
#define MEMP_NUM_PBUF 16
@@ -361,17 +361,22 @@
#endif
/**
* IP_REASS_MAXAGE: IP reassemly default age in seconds.
* IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally)
* a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived
* in this time, the whole packet is discarded.
*/
#ifndef IP_REASS_MAXAGE
#define IP_REASS_MAXAGE 3
#endif
/**
* IP_REASS_BUFSIZE: IP reassembly buffer size (minus IP header).
* IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled.
* Since the received pbufs are enqueued, be sure to configure
* PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive
* packets even if the maximum amount of fragments is enqueued for reassembly!
*/
#ifndef IP_REASS_BUFSIZE
#define IP_REASS_BUFSIZE 5760
#ifndef IP_REASS_MAX_PBUFS
#define IP_REASS_MAX_PBUFS 10
#endif
/**