Web server based weather station using Sparkfun Weather Meters.

Dependencies:   FatFileSystem mbed WeatherMeters SDFileSystem

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.
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 ip_frag (struct pbuf *p, struct netif *netif, ip_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 ip_frag.c.


Function Documentation

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

Definition at line 667 of file ip_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 624 of file ip_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 631 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 476 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 331 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 304 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 269 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 158 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 221 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 122 of file ip_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 640 of file ip_frag.c.