lwIP 2.2.0 Lightweight IP stack

Data Structures | Macros | Functions
ip4_frag.c File Reference
`#include "lwip/opt.h"`
`#include "lwip/ip4_frag.h"`
`#include "lwip/def.h"`
`#include "lwip/inet_chksum.h"`
`#include "lwip/netif.h"`
`#include "lwip/stats.h"`
`#include "lwip/icmp.h"`
`#include <string.h>`
`#include "arch/bpstruct.h"`
`#include "arch/epstruct.h"`

## Data Structures
struct | ip_reass_helper

## Macros
#define | IP_REASS_CHECK_OVERLAP 1
#define | IP_REASS_FREE_OLDEST 1

## Functions
void | ip_reass_tmr (void)
struct pbuf * | ip4_reass (struct pbuf *p)
err_t | ip4_frag (struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)

## Detailed Description

This is the IPv4 packet segmentation and reassembly implementation.

## Macro Definition Documentation

## ◆ IP_REASS_CHECK_OVERLAP

#define IP_REASS_CHECK_OVERLAP 1

The IP reassembly code currently has the following limitations:

- IP header options are not supported
- fragments must not overlap (e.g. due to different routes), currently, overlapping or duplicate fragments are thrown away if IP_REASS_CHECK_OVERLAP=1 (the default)!

Setting this to 0, you can turn off checking the fragments for overlapping regions. The code gets a little smaller. Only use this if you know that overlapping won't occur on your network!

## ◆ IP_REASS_FREE_OLDEST

#define IP_REASS_FREE_OLDEST 1

Set to 0 to prevent freeing the oldest datagram when the reassembly buffer is full (IP_REASS_MAX_PBUFS pbufs are enqueued). The code gets a little smaller. Datagrams will be freed by timeout only. Especially useful when MEMP_NUM_REASSDATA is set to 1, so one datagram can be reassembled at a time, only.

## Function Documentation

## ◆ ip4_frag()

err_t ip4_frag | ( | struct pbuf * | p,
|  | struct netif * | netif,
|  | const ip4_addr_t * | dest
| ) |  |

Fragment an IP datagram if too large for the netif.

Chop the datagram in MTU sized chunks and send them in order by pointing PBUF_REFs into p.

Parameters

  p | ip packet to send
  netif | the netif on which to send
  dest | destination ip address to which to send

Returns
  ERR_OK if sent successfully, err_t otherwise

## ◆ ip4_reass()

struct pbuf* ip4_reass | ( | struct pbuf * | p | ) |

Reassembles incoming IP fragments into an IP datagram.

Parameters

  p | points to a pbuf chain of the fragment

Returns
  NULL if reassembly is incomplete, ? otherwise

## ◆ ip_reass_tmr()

void ip_reass_tmr | ( | void |  | ) |

Reassembly timer base function for both NO_SYS == 0 and 1 (!).

Should be called every 1000 msec (defined by IP_TMR_INTERVAL).