Embedded WebSockets Experiment

Dependencies:   mbed MD5

Embed: (wiki syntax)

« Back to documentation index

ip_frag.c File Reference

ip_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_reassdata * ip_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 pbuf * ip_reass (struct pbuf *p)
 Reassembles incoming IP fragments into an IP datagram.
err_t ip_frag (struct pbuf *p, struct netif *netif, struct ip_addr *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 ip_frag.c.


Function Documentation

err_t ip_frag ( struct pbuf *  p,
struct netif netif,
struct ip_addr *  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

Definition at line 636 of file ip_frag.c.

struct pbuf* ip_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 477 of file ip_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:
root_ppoints to the 'root' pbuf for the current datagram being assembled.
new_ppoints to the pbuf for the current fragment
Returns:
0 if invalid, >0 otherwise

Definition at line 332 of file ip_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 305 of file ip_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 270 of file ip_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 164 of file ip_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 222 of file ip_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 128 of file ip_frag.c.