Skip to content

Commit

Permalink
Explicit address mapping.
Browse files Browse the repository at this point in the history
This is the implementation of the draft http://tools.ietf.org/html/draft-anderson-v6ops-siit-eam-00, attending the issue #116.
The new files aren't incorporated to the jool application yet. We could say that this is an approach, we need to see how Jool will behave as a Stateles NAT64, and then connect this files.
I did a unit test to see if this new feature behave as expected.

TODO: I need to program how to delete an EAM entry from the database when requested. This will be ready when this feature are connected to Jool.
  • Loading branch information
Daniel A. Hdz Felix committed Dec 4, 2014
1 parent c59ac21 commit 65c048e
Show file tree
Hide file tree
Showing 5 changed files with 588 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/nat64/comm/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ struct ipv6_transport_addr {
__u16 l4;
};

/**
* TODO:(dhernandez) check if this description is correct.
* A member of the IPv4 pool; the network component of a IPv4 address.
*/
struct ipv4_prefix {
/** IPv4 prefix. */
struct in_addr address;
/** Number of bits from "address" which represent the network. */
__u8 len;
};

/**
* A member of the IPv6 pool; the network component of a IPv6 address.
*/
Expand Down
56 changes: 56 additions & 0 deletions include/nat64/mod/address_mapping.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#ifndef _JOOL_MOD_ADDRESS_MAPPING_H
#define _JOOL_MOD_ADDRESS_MAPPING_H

/*
* address_mapping.h
*
* Created on: Nov 25, 2014
* @author: Daniel Hdz Felix
*/

#include "nat64/comm/types.h"

/**
* Explicit Address Mapping definition.
* Intended to be a row in the Explicit Address Mapping Table, bind an IPv4 Prefix to an IPv6 Prefix
* and vice versa.
*/
struct eam_entry {
/** The prefix address for the IPv4 network. */
struct ipv4_prefix pref4;
/** The prefix address for the IPv6 network. */
struct ipv6_prefix pref6;
/** Appends this entry to the database's IPv6 index. */
struct rb_node tree6_hook;
/** Appends this entry to the database's IPv4 index. */
struct rb_node tree4_hook;
};

/**
* Insert IPv6 Prefix "ip6_pref" and IPv4 Prefix "ip4_pref" to the database, return zero if the
* insert was successful.
*
* If the "ipX_pref" contains or is part of a prefix indexed in the databases, then returns error.
*/
int address_mapping_insert_entry(struct ipv6_prefix *ip6_pref, struct ipv4_prefix *ip4_pref);

/**
* Look in the IPv4 address mapping table, if the IPv4 address "addr" is part of a prefix indexed
* in the table, if "addr" exists, append the mapped IPv6 prefix to "result" and also append the
* suffix from "addr" to "result".
*
* otherwise return error.
*/
int address_mapping_get_ipv6_by_ipv4(struct in_addr *addr, struct in6_addr *result);

/**
* Look in the IPv6 address mapping table, if the IPv6 address "addr6" is part of a prefix indexed
* in the table, if "addr6" exists, append the mapped IPv4 prefix to "result" and also append the
* suffix from "addr6" to "result".
*
* otherwise return error.
*/
int address_mapping_get_ipv4_by_ipv6(struct in6_addr *addr6, struct in_addr *result);


#endif /* _JOOL_MOD_ADDRESS_MAPPING_H */
Loading

0 comments on commit 65c048e

Please sign in to comment.