Microchip® Advanced Software Framework

ip64-addrmap.c File Reference
#include "ip64-addrmap.h"
#include "lib/memb.h"
#include "lib/list.h"
#include "ip64-conf.h"
#include <string.h>

Macros

#define FIRST_MAPPED_PORT   10000
 
#define LAST_MAPPED_PORT   20000
 
#define NUM_ENTRIES   32
 
#define printf(...)
 

Functions

static void check_age (void)
 
static void increase_mapped_port (void)
 
struct ip64_addrmap_entryip64_addrmap_create (const uip_ip6addr_t *ip6addr, uint16_t ip6port, const uip_ip4addr_t *ip4addr, uint16_t ip4port, uint8_t protocol)
 Create a new address mapping from an IPv6 address/port, an IPv4 address/port, and a protocol number. More...
 
void ip64_addrmap_init (void)
 Initialize the ip64_addrmap module. More...
 
struct ip64_addrmap_entryip64_addrmap_list (void)
 Obtain the list of all address mappings. More...
 
struct ip64_addrmap_entryip64_addrmap_lookup (const uip_ip6addr_t *ip6addr, uint16_t ip6port, const uip_ip4addr_t *ip4addr, uint16_t ip4port, uint8_t protocol)
 Look up an address mapping from inside the IPv6 network, given the IPv6 address/port, the IPv4 address/port, and the protocol. More...
 
struct ip64_addrmap_entryip64_addrmap_lookup_port (uint16_t mapped_port, uint8_t protocol)
 Look up an address mapping from the outside IPv4 network, given the mapped port number and protocol. More...
 
void ip64_addrmap_set_lifetime (struct ip64_addrmap_entry *e, clock_time_t time)
 Set the lifetime of an address mapping. More...
 
void ip64_addrmap_set_recycleble (struct ip64_addrmap_entry *e)
 Mark an address mapping to be recyclable. More...
 
 LIST (entrylist)
 
 MEMB (entrymemb, struct ip64_addrmap_entry, NUM_ENTRIES)
 
static int recycle (void)
 

Variables

static uint16_t mapped_port = FIRST_MAPPED_PORT
 

#define FIRST_MAPPED_PORT   10000
#define LAST_MAPPED_PORT   20000

Referenced by increase_mapped_port().

#define NUM_ENTRIES   32
#define printf (   ...)

static void increase_mapped_port ( void  )
static
struct ip64_addrmap_entry* ip64_addrmap_create ( const uip_ip6addr_t ip6addr,
uint16_t  ip6port,
const uip_ip4addr_t ip4addr,
uint16_t  ip4port,
uint8_t  protocol 
)
void ip64_addrmap_init ( void  )

Initialize the ip64_addrmap module.

References FIRST_MAPPED_PORT, list_init(), mapped_port, and memb_init().

struct ip64_addrmap_entry* ip64_addrmap_list ( void  )

Obtain the list of all address mappings.

References list_head().

struct ip64_addrmap_entry* ip64_addrmap_lookup ( const uip_ip6addr_t ip6addr,
uint16_t  ip6port,
const uip_ip4addr_t ip4addr,
uint16_t  ip4port,
uint8_t  protocol 
)

Look up an address mapping from inside the IPv6 network, given the IPv6 address/port, the IPv4 address/port, and the protocol.

References check_age(), ip64_addrmap_entry::ip4addr, ip64_addrmap_entry::ip4port, ip64_addrmap_entry::ip6addr, ip64_addrmap_entry::ip6port, list_head(), list_item_next(), NULL, printf, ip64_addrmap_entry::protocol, uip_htons(), uip_ip4addr_cmp, and uip_ip6addr_cmp.

Referenced by ip64_6to4().

struct ip64_addrmap_entry* ip64_addrmap_lookup_port ( uint16_t  mapped_port,
uint8_t  protocol 
)

Look up an address mapping from the outside IPv4 network, given the mapped port number and protocol.

References check_age(), list_head(), list_item_next(), ip64_addrmap_entry::mapped_port, NULL, printf, and ip64_addrmap_entry::protocol.

Referenced by ip64_4to6().

void ip64_addrmap_set_lifetime ( struct ip64_addrmap_entry e,
clock_time_t  time 
)

Set the lifetime of an address mapping.

References NULL, ip64_addrmap_entry::timer, and timer_set().

Referenced by ip64_6to4().

void ip64_addrmap_set_recycleble ( struct ip64_addrmap_entry e)

Mark an address mapping to be recyclable.

References ip64_addrmap_entry::flags, FLAGS_RECYCLABLE, and NULL.

Referenced by ip64_6to4().

LIST ( entrylist  )
MEMB ( entrymemb  ,
struct ip64_addrmap_entry  ,
NUM_ENTRIES   
)

uint16_t mapped_port = FIRST_MAPPED_PORT
static