Microchip® Advanced Software Framework

ip_frag.c File Reference

This is the IPv4 packet segmentation and reassembly implementation.

#include "lwip/opt.h"
#include "lwip/ip_frag.h"
#include "lwip/def.h"
#include "lwip/inet_chksum.h"
#include "lwip/netif.h"
#include "lwip/snmp.h"
#include "lwip/stats.h"
#include "lwip/icmp.h"
#include <string.h>

Functions

err_t ip_frag (struct pbuf *p, struct netif *netif, ip_addr_t *dest)
 Fragment an IP datagram if too large for the netif. More...
 
static struct pbuf_custom_refip_frag_alloc_pbuf_custom_ref (void)
 Allocate a new struct pbuf_custom_ref. More...
 
static void ip_frag_free_pbuf_custom_ref (struct pbuf_custom_ref *p)
 Free a struct pbuf_custom_ref. More...
 
static void ipfrag_free_pbuf_custom (struct pbuf *p)
 Free-callback function to free a 'struct pbuf_custom_ref', called by pbuf_free. More...
 

err_t ip_frag ( struct pbuf p,
struct netif netif,
ip_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 using a fixed size static memory buffer (PBUF_REF) or point PBUF_REFs into p (depending on IP_FRAG_USES_STATIC_BUF).

Parameters
pip packet to send
netifthe netif on which to send
destdestination ip address to which to send
Returns
ERR_OK if sent successfully, err_t otherwise

References pbuf_custom::custom_free_function, ERR_MEM, ERR_OK, htons, if(), inet_chksum(), ip_frag(), ip_frag_alloc_pbuf_custom_ref(), ip_frag_free_pbuf_custom_ref(), IP_HLEN, IP_MF, IP_OFFMASK, IP_REASS_DEBUG, ipfrag_free_pbuf_custom(), IPFRAG_STATS_INC, IPH_CHKSUM_SET, IPH_LEN_SET, IPH_OFFSET, IPH_OFFSET_SET, iphdr, pbuf::len, LWIP_ASSERT, LWIP_DEBUGF, LWIP_MEM_ALIGN, netif::mtu, pbuf::next, ntohs, NULL, pbuf_custom_ref::original, netif::output, pbuf::payload, pbuf_alloc(), pbuf_alloced_custom(), pbuf_cat(), pbuf_chain(), pbuf_copy_partial(), pbuf_free(), pbuf_header(), PBUF_IP, PBUF_LINK, PBUF_RAM, PBUF_RAW, pbuf_realloc(), PBUF_REF, pbuf_ref(), pbuf_custom_ref::pc, SMEMCPY, snmp_inc_ipfragcreates, snmp_inc_ipfragoks, and pbuf::tot_len.

Referenced by ip_frag().

static struct pbuf_custom_ref* ip_frag_alloc_pbuf_custom_ref ( void  )
static

Allocate a new struct pbuf_custom_ref.

References memp_malloc().

Referenced by ip_frag().

static void ip_frag_free_pbuf_custom_ref ( struct pbuf_custom_ref p)
static

Free a struct pbuf_custom_ref.

References LWIP_ASSERT, memp_free(), and NULL.

Referenced by ip_frag(), and ipfrag_free_pbuf_custom().

static void ipfrag_free_pbuf_custom ( struct pbuf p)
static

Free-callback function to free a 'struct pbuf_custom_ref', called by pbuf_free.

References ip_frag_free_pbuf_custom_ref(), LWIP_ASSERT, NULL, pbuf_custom_ref::original, and pbuf_free().

Referenced by ip_frag().