Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
uIP packet forwarding

Data Structures

struct  fwcache_entry
 
struct  icmpip_hdr
 
struct  tcpip_hdr
 
struct  uip_fw_netif
 Representation of a uIP network interface. More...
 

Files

file  uip-fw.c
 uIP packet forwarding.
 
file  uip-fw.h
 uIP packet forwarding header file.
 

Macros

#define BUF   ((struct tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
 
#define FW_TIME   20
 
#define FWCACHE_SIZE   2
 
#define ICMP_ECHO   8
 
#define ICMP_TE   11
 
#define ICMPBUF   ((struct icmpip_hdr *)&uip_buf[UIP_LLH_LEN])
 
#define notdef   0
 
#define UIP_FW_DROPPED
 An error message that indicates that a packet that should be forwarded or output was dropped. More...
 
#define UIP_FW_FORWARDED
 A non-error message that indicates that a packet was forwarded. More...
 
#define UIP_FW_LOCAL
 A non-error message that indicates that a packet should be processed locally. More...
 
#define UIP_FW_NETIF(ip1, ip2, ip3, ip4, nm1, nm2, nm3, nm4, outputfunc)
 Instantiating macro for a uIP network interface. More...
 
#define UIP_FW_NOROUTE
 An error message that indicates that no suitable interface could be found for an outbound packet. More...
 
#define UIP_FW_OK
 A non-error message that indicates that something went OK. More...
 
#define uip_fw_setipaddr(netif, addr)
 Set the IP address of a network interface. More...
 
#define uip_fw_setnetmask(netif, addr)
 Set the netmask of a network interface. More...
 
#define UIP_FW_TOOLARGE
 An error message that indicates that a packet that was too large for the outbound network interface was detected. More...
 
#define UIP_FW_ZEROLEN
 A non-error message that indicates that a zero-length packet transmission was attempted, and that no packet was sent. More...
 

Functions

static struct uip_fw_netiffind_netif (void)
 
static void fwcache_register (void)
 
static unsigned char ipaddr_maskcmp (uip_ipaddr_t *ipaddr, uip_ipaddr_t *netipaddr, uip_ipaddr_t *netmask)
 
static void time_exceeded (void)
 
void uip_fw_default (struct uip_fw_netif *netif)
 Register a default network interface. More...
 
uint8_t uip_fw_forward (void)
 Forward an IP packet in the uip_buf buffer. More...
 
void uip_fw_init (void)
 Initialize the uIP packet forwarding module. More...
 
uint8_t uip_fw_output (void)
 Output an IP packet on the correct network interface. More...
 
void uip_fw_periodic (void)
 Perform periodic processing. More...
 
void uip_fw_register (struct uip_fw_netif *netif)
 Register a network interface with the forwarding module. More...
 

Variables

static struct uip_fw_netifdefaultnetif = NULL
 
static struct fwcache_entry fwcache [FWCACHE_SIZE]
 
static struct uip_fw_netifnetifs = NULL
 

#define FW_TIME   20

The time that a packet cache is active.

Referenced by fwcache_register().

#define FWCACHE_SIZE   2
#define ICMP_ECHO   8

Referenced by time_exceeded(), and uip_fw_forward().

#define ICMP_TE   11

Referenced by time_exceeded().

#define ICMPBUF   ((struct icmpip_hdr *)&uip_buf[UIP_LLH_LEN])

Referenced by time_exceeded(), and uip_fw_forward().

#define notdef   0

Referenced by uip_fw_forward().

#define UIP_FW_DROPPED

An error message that indicates that a packet that should be forwarded or output was dropped.

Referenced by uip_over_mesh_send().

#define UIP_FW_FORWARDED

A non-error message that indicates that a packet was forwarded.

Referenced by uip_fw_forward().

#define UIP_FW_LOCAL

A non-error message that indicates that a packet should be processed locally.

Referenced by packet_input(), and uip_fw_forward().

#define UIP_FW_NETIF (   ip1,
  ip2,
  ip3,
  ip4,
  nm1,
  nm2,
  nm3,
  nm4,
  outputfunc 
)

Instantiating macro for a uIP network interface.

Example:

struct uip_fw_netif slipnetif =
{UIP_FW_NETIF(192,168,76,1, 255,255,255,0, slip_output)};
Parameters
ip1,ip2,ip3,ip4The IP address of the network interface.
nm1,nm2,nm3,nm4The netmask of the network interface.
outputfuncA pointer to the output function of the network interface.
#define UIP_FW_NOROUTE

An error message that indicates that no suitable interface could be found for an outbound packet.

Referenced by uip_fw_output().

#define UIP_FW_OK

A non-error message that indicates that something went OK.

Referenced by slip_send(), uip_fw_output(), and uip_over_mesh_send().

#define uip_fw_setipaddr (   netif,
  addr 
)

Set the IP address of a network interface.

Parameters
netifA pointer to the uip_fw_netif structure for the network interface.
addrA pointer to an IP address.
#define uip_fw_setnetmask (   netif,
  addr 
)

Set the netmask of a network interface.

Parameters
netifA pointer to the uip_fw_netif structure for the network interface.
addrA pointer to an IP address representing the netmask.
#define UIP_FW_TOOLARGE

An error message that indicates that a packet that was too large for the outbound network interface was detected.

#define UIP_FW_ZEROLEN

A non-error message that indicates that a zero-length packet transmission was attempted, and that no packet was sent.

Referenced by uip_fw_output().

static struct uip_fw_netif* find_netif ( void  )
static

Find a network interface for the IP packet in uip_buf.

References BUF, defaultnetif, uip_fw_netif::ipaddr, ipaddr_maskcmp(), uip_fw_netif::netmask, uip_fw_netif::next, and NULL.

Referenced by uip_fw_output().

static void fwcache_register ( void  )
static

Register a packet in the forwarding cache so that it won't be forwarded again.

References BUF, fwcache_entry::destipaddr, FW_TIME, fwcache, FWCACHE_SIZE, i, fwcache_entry::ipid, NULL, fwcache_entry::proto, fwcache_entry::srcipaddr, fwcache_entry::timer, and uip_ipaddr_copy.

Referenced by uip_fw_output().

static unsigned char ipaddr_maskcmp ( uip_ipaddr_t ipaddr,
uip_ipaddr_t netipaddr,
uip_ipaddr_t netmask 
)
static

Check if an IP address is within the network defined by an IP address and a netmask.

Parameters
ipaddrThe IP address to be checked.
netipaddrThe IP address of the network.
netmaskThe netmask of the network.
Returns
Non-zero if IP address is in network, zero otherwise.

References uip_ip6addr_t::u16.

Referenced by find_netif().

static void time_exceeded ( void  )
static

Send out an ICMP TIME-EXCEEDED message.

This function replaces the packet in the uip_buf buffer with the ICMP packet.

References BUF, ICMP_ECHO, ICMP_TE, ICMPBUF, uip_chksum(), uip_hostaddr, uip_ipaddr_copy, uip_ipchksum(), UIP_IPH_LEN, uip_len, UIP_PROTO_ICMP, and UIP_TTL.

Referenced by uip_fw_forward().

void uip_fw_default ( struct uip_fw_netif netif)

Register a default network interface.

All packets that don't go out on any of the other interfaces will be routed to the default interface.

Parameters
netifA pointer to the network interface that is to be registered.
uint8_t uip_fw_forward ( void  )
void uip_fw_init ( void  )

Initialize the uIP packet forwarding module.

References netifs, uip_fw_netif::next, and NULL.

uint8_t uip_fw_output ( void  )

Output an IP packet on the correct network interface.

The IP packet should be present in the uip_buf buffer and its length in the global uip_len variable.

Return values
UIP_FW_ZEROLENIndicates that a zero-length packet transmission was attempted and that no packet was sent.
UIP_FW_NOROUTENo suitable network interface could be found for the outbound packet, and the packet was not sent.
Returns
The return value from the actual network interface output function is passed unmodified as a return value.

References BUF, uip_udpip_hdr::destipaddr, find_netif(), fwcache_register(), uip_fw_netif::next, NULL, uip_fw_netif::output, uip_broadcast_addr, UIP_FW_NOROUTE, UIP_FW_OK, UIP_FW_ZEROLEN, uip_ipaddr_cmp, and uip_len.

Referenced by uip_fw_forward().

void uip_fw_periodic ( void  )

Perform periodic processing.

References fwcache, FWCACHE_SIZE, and fwcache_entry::timer.

Referenced by eventhandler().

void uip_fw_register ( struct uip_fw_netif netif)

Register a network interface with the forwarding module.

Parameters
netifA pointer to the network interface that is to be registered.

References netifs, and uip_fw_netif::next.

struct uip_fw_netif* defaultnetif = NULL
static

Referenced by find_netif().

struct uip_fw_netif* netifs = NULL
static

Referenced by uip_fw_init(), and uip_fw_register().