Rtos API example

Embed: (wiki syntax)

« Back to documentation index

lwip_ip4_frag.c File Reference

lwip_ip4_frag.c File Reference

This is the IPv4 packet segmentation and reassembly implementation. More...

Go to the source code of this file.

Functions

static void ip_reass_dequeue_datagram (struct ip_reassdata *ipr, struct ip_reassdata *prev)
 Dequeues a datagram from the datagram queue.
static int ip_reass_free_complete_datagram (struct ip_reassdata *ipr, struct ip_reassdata *prev)
 Free a datagram (struct ip_reassdata) and all its pbufs.
void ip_reass_tmr (void)
 Reassembly timer base function for both NO_SYS == 0 and 1 (!).
static int ip_reass_remove_oldest_datagram (struct ip_hdr *fraghdr, int pbufs_needed)
 Free the oldest datagram to make room for enqueueing new fragments.
static struct ip_reassdataip_reass_enqueue_new_datagram (struct ip_hdr *fraghdr, int clen)
 Enqueues a new fragment into the fragment queue.
static int ip_reass_chain_frag_into_datagram_and_validate (struct ip_reassdata *ipr, struct pbuf *new_p)
 Chain a new pbuf into the pbuf list that composes the datagram.
struct pbufip4_reass (struct pbuf *p)
 Reassembles incoming IP fragments into an IP datagram.
static struct pbuf_custom_refip_frag_alloc_pbuf_custom_ref (void)
 Allocate a new struct pbuf_custom_ref.
static void ip_frag_free_pbuf_custom_ref (struct pbuf_custom_ref *p)
 Free a struct pbuf_custom_ref.
static void ipfrag_free_pbuf_custom (struct pbuf *p)
 Free-callback function to free a 'struct pbuf_custom_ref', called by pbuf_free.
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.

Detailed Description

This is the IPv4 packet segmentation and reassembly implementation.

Definition in file lwip_ip4_frag.c.


Function Documentation

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:
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

Definition at line 685 of file lwip_ip4_frag.c.

struct pbuf* ip4_reass ( struct pbuf p ) [read]

Reassembles incoming IP fragments into an IP datagram.

Parameters:
ppoints to a pbuf chain of the fragment
Returns:
NULL if reassembly is incomplete, ? otherwise

Definition at line 484 of file lwip_ip4_frag.c.

static struct pbuf_custom_ref* ip_frag_alloc_pbuf_custom_ref ( void   ) [static, read]

Allocate a new struct pbuf_custom_ref.

Definition at line 644 of file lwip_ip4_frag.c.

static void ip_frag_free_pbuf_custom_ref ( struct pbuf_custom_ref p ) [static]

Free a struct pbuf_custom_ref.

Definition at line 651 of file lwip_ip4_frag.c.

static int ip_reass_chain_frag_into_datagram_and_validate ( struct ip_reassdata ipr,
struct pbuf new_p 
) [static]

Chain a new pbuf into the pbuf list that composes the datagram.

The pbuf list will grow over time as new pbufs are rx. Also checks that the datagram passes basic continuity checks (if the last fragment was received at least once).

Parameters:
iprpoints to the reassembly state
new_ppoints to the pbuf for the current fragment
Returns:
0 if invalid, >0 otherwise

Definition at line 339 of file lwip_ip4_frag.c.

static void ip_reass_dequeue_datagram ( struct ip_reassdata ipr,
struct ip_reassdata prev 
) [static]

Dequeues a datagram from the datagram queue.

Doesn't deallocate the pbufs.

Parameters:
iprpoints to the queue entry to dequeue

Definition at line 313 of file lwip_ip4_frag.c.

static struct ip_reassdata* ip_reass_enqueue_new_datagram ( struct ip_hdr *  fraghdr,
int  clen 
) [static, read]

Enqueues a new fragment into the fragment queue.

Parameters:
fraghdrpoints to the new fragments IP hdr
clennumber of pbufs needed to enqueue (used for freeing other datagrams if not enough space)
Returns:
A pointer to the queue location into which the fragment was enqueued

Definition at line 274 of file lwip_ip4_frag.c.

static int ip_reass_free_complete_datagram ( struct ip_reassdata ipr,
struct ip_reassdata prev 
) [static]

Free a datagram (struct ip_reassdata) and all its pbufs.

Updates the total count of enqueued pbufs (ip_reass_pbufcount), SNMP counters and sends an ICMP time exceeded packet.

Parameters:
iprdatagram to free
prevthe previous datagram in the linked list
Returns:
the number of pbufs freed

Definition at line 160 of file lwip_ip4_frag.c.

static int ip_reass_remove_oldest_datagram ( struct ip_hdr *  fraghdr,
int  pbufs_needed 
) [static]

Free the oldest datagram to make room for enqueueing new fragments.

The datagram 'fraghdr' belongs to is not freed!

Parameters:
fraghdrIP header of the current fragment
pbufs_needednumber of pbufs needed to enqueue (used for freeing other datagrams if not enough space)
Returns:
the number of pbufs freed

Definition at line 223 of file lwip_ip4_frag.c.

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).

Definition at line 124 of file lwip_ip4_frag.c.

static void ipfrag_free_pbuf_custom ( struct pbuf p ) [static]

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

Definition at line 660 of file lwip_ip4_frag.c.