+ reorg +add simple nat64 w/o protocol specific translations
This commit is contained in:
parent
4972f550d8
commit
a408d7a803
3 changed files with 130 additions and 87 deletions
|
|
@ -52,7 +52,7 @@ control MyIngress(inout headers hdr,
|
|||
hdr.ipv4.diff_serv = (bit<6>)0; // no ToS
|
||||
hdr.ipv4.ecn = (bit<2>)0; // unsupported
|
||||
|
||||
hdr.ipv4.ihl = (bit<4>) 5; // internet header length -- needs to be dynamic!
|
||||
hdr.ipv4.ihl = (bit<4>) 5; // internet header length -- needs to be dynamic!?
|
||||
hdr.ipv4.totalLen = (bit<16>) hdr.ipv6.payload_length + 5; // should probably also dynamic
|
||||
|
||||
hdr.ipv4.identification = (bit<16>) 0; // no support for fragments
|
||||
|
|
@ -93,25 +93,58 @@ control MyIngress(inout headers hdr,
|
|||
|
||||
|
||||
/* nat64_prefix is the same as the matching key, but without the mask */
|
||||
action nat64_static(ipv6_addr_t v6_network, ipv4_addr_t v4_network, ipv6_addr_t nat64_prefix) {
|
||||
ipv6_addr_t src_offset = hdr.ipv6.src_addr - v6_network;
|
||||
ipv4_addr_t src = v4_network + (ipv4_addr_t) src_offset;
|
||||
action nat64_static(ipv6_addr_t v6_src, ipv4_addr_t v4_dst, ipv6_addr_t nat64_prefix) {
|
||||
ipv6_addr_t src_offset = hdr.ipv6.src_addr - v6_src;
|
||||
ipv4_addr_t src = v4_dst + (ipv4_addr_t) src_offset;
|
||||
|
||||
ipv4_addr_t dst = (ipv4_addr_t) (hdr.ipv6.dst_addr - nat64_prefix);
|
||||
|
||||
nat64_generic(src, dst);
|
||||
|
||||
/* fix the protocol specific translations */
|
||||
// switch() ...
|
||||
}
|
||||
|
||||
/* matching key: v4_network specified again */
|
||||
action nat46_static(ipv6_addr_t v6_network, ipv4_addr_t v4_network, ipv6_addr_t nat64_prefix ) {
|
||||
action nat46_static(ipv6_addr_t v6_src, ipv4_addr_t v4_dst, ipv6_addr_t nat64_prefix) {
|
||||
ipv6_addr_t src = nat64_prefix + (ipv6_addr_t) hdr.ipv4.src_addr;
|
||||
|
||||
ipv4_addr_t dst_offset = hdr.ipv4.dst_addr - v4_network;
|
||||
ipv6_addr_t dst = v6_network + (ipv6_addr_t) dst_offset;
|
||||
ipv4_addr_t dst_offset = hdr.ipv4.dst_addr - v4_dst;
|
||||
ipv6_addr_t dst = v6_src + (ipv6_addr_t) dst_offset;
|
||||
|
||||
nat46_generic(src, dst);
|
||||
|
||||
/* fix the protocol specific translations */
|
||||
// switch() ...
|
||||
}
|
||||
|
||||
table nat64 {
|
||||
key = {
|
||||
hdr.ipv6.src_addr: lpm;
|
||||
hdr.ipv6.dst_addr: lpm;
|
||||
}
|
||||
actions = {
|
||||
controller_debug;
|
||||
nat64_static;
|
||||
NoAction;
|
||||
}
|
||||
size = NAT64_TABLE_SIZE;
|
||||
default_action = controller_debug;
|
||||
}
|
||||
|
||||
table nat46 {
|
||||
key = {
|
||||
hdr.ipv4.src_addr: lpm;
|
||||
hdr.ipv4.dst_addr: lpm;
|
||||
}
|
||||
actions = {
|
||||
controller_debug;
|
||||
nat46_static;
|
||||
NoAction;
|
||||
}
|
||||
size = NAT64_TABLE_SIZE;
|
||||
default_action = controller_debug;
|
||||
}
|
||||
|
||||
|
||||
/********************** ICMP6 ***********************************/
|
||||
|
|
@ -272,8 +305,6 @@ control MyIngress(inout headers hdr,
|
|||
set_egress_port;
|
||||
controller_debug;
|
||||
controller_reply;
|
||||
nat64_static;
|
||||
icmp6_neighbor_solicitation;
|
||||
NoAction;
|
||||
}
|
||||
size = ROUTING_TABLE_SIZE;
|
||||
|
|
@ -287,7 +318,6 @@ control MyIngress(inout headers hdr,
|
|||
}
|
||||
actions = {
|
||||
set_egress_port;
|
||||
nat46_static;
|
||||
NoAction;
|
||||
}
|
||||
size = ROUTING_TABLE_SIZE;
|
||||
|
|
@ -297,12 +327,9 @@ control MyIngress(inout headers hdr,
|
|||
/********************** APPLYING TABLES ***********************************/
|
||||
apply {
|
||||
if(hdr.ipv6.isValid()) {
|
||||
/* FIXME: structure / use .hit to do logic */
|
||||
// ndp_answer.apply();
|
||||
//ndp.apply(); /* flood or if it is us - answer */
|
||||
|
||||
icmp6.apply();
|
||||
v6_networks.apply();
|
||||
icmp6.apply(); /* icmp6 echo, icmp6 ndp */
|
||||
v6_networks.apply(); /* routing, egress */
|
||||
}
|
||||
if(hdr.ipv4.isValid()) {
|
||||
v4_networks.apply();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue