Make it more stupid - forget about tables
This commit is contained in:
parent
e13d0b974d
commit
53ce47a54e
6 changed files with 298 additions and 36 deletions
|
|
@ -128,8 +128,8 @@ action nat46_icmp_generic()
|
|||
hdr.icmp.setInvalid();
|
||||
}
|
||||
|
||||
/* NAT46: protocol unspecific changes */
|
||||
action nat46_generic(ipv6_addr_t src, ipv6_addr_t dst) {
|
||||
/* NAT46: protocol unspecific changes */
|
||||
action nat46_generic(ipv6_addr_t src, ipv6_addr_t dst) {
|
||||
hdr.ipv6.setValid();
|
||||
hdr.ipv4.setInvalid();
|
||||
|
||||
|
|
@ -171,7 +171,6 @@ action nat46_icmp_generic()
|
|||
NoAction;
|
||||
}
|
||||
size = NAT64_TABLE_SIZE;
|
||||
// default_action = controller_debug_table_id(TABLE_NAT64);
|
||||
default_action = NoAction;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,20 +58,17 @@ control RealMain(
|
|||
#include "actions_egress.p4"
|
||||
#include "actions_delta_checksum.p4"
|
||||
|
||||
|
||||
#include "netpfga_dummy.p4"
|
||||
|
||||
apply {
|
||||
bit<17> tmp17 = 0;
|
||||
bool apply_v4networks = true;
|
||||
bool apply_v6networks = true;
|
||||
|
||||
// #include "netpfga_nat64.p4"
|
||||
/* does not compile without a table - give it a table */
|
||||
dummy_table_for_netpfga.apply();
|
||||
|
||||
// if(apply_v4networks == true) {
|
||||
v4_networks.apply();
|
||||
// }
|
||||
|
||||
// if(apply_v6networks == true) {
|
||||
// v6_networks.apply();
|
||||
// }
|
||||
/* continue without tables */
|
||||
#include "netpfga_nat64_stupid_hardcoded.p4"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,6 @@
|
|||
#ifndef DUMMY_NETPFGA
|
||||
#define DUMMY_NETPFGA
|
||||
|
||||
action do_nothing() {
|
||||
;
|
||||
}
|
||||
|
||||
action send_to_port(port_t port) {
|
||||
sume_metadata.dst_port = port;
|
||||
}
|
||||
|
||||
action send_to_port1() {
|
||||
sume_metadata.dst_port = 1;
|
||||
}
|
||||
|
|
@ -19,12 +11,9 @@ table dummy_table_for_netpfga {
|
|||
}
|
||||
|
||||
actions = {
|
||||
do_nothing;
|
||||
send_to_port1;
|
||||
send_to_port;
|
||||
}
|
||||
size = TEST_TABLE_SIZE;
|
||||
// default_action = do_nothing;
|
||||
size = 64;
|
||||
default_action = send_to_port1;
|
||||
}
|
||||
|
||||
|
|
|
|||
46
p4src/netpfga_nat64_stupid_hardcoded.p4
Normal file
46
p4src/netpfga_nat64_stupid_hardcoded.p4
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
port_t v6_out = 64;
|
||||
port_t v4_out = 16;
|
||||
|
||||
/* nat64 */
|
||||
/*
|
||||
>>> int(ipaddress.IPv4Address("10.0.0.0"))
|
||||
167772160
|
||||
>>> int(ipaddress.IPv6Address("2001:db8:42::"))
|
||||
42540766411362381960998550477184434176
|
||||
*/
|
||||
|
||||
ipv6_addr_t v6_src = 42540766411362381960998550477184434176; /* 2001:db8:42:: -> v6 source range*/
|
||||
ipv6_addr_t v6_dst = 42540766411362381960998550477184434176; /* 2001:db8:42:: -> v6 source range*/
|
||||
ipv6_addr_t nat64_prefix = 42540766411362381960998550477184434176; /* 2001:db8:42:: -> v6 destination range */
|
||||
ipv4_addr_t v4_dst = 167772160; /* 10.0.0.0 -> v4 destination range */
|
||||
|
||||
|
||||
/* if it is ipv6, we always translate to IPv4 and output on v4_out */
|
||||
if(hdr.ipv6.isValid()) {
|
||||
nat64_static(v6_src, v4_dst, nat64_prefix);
|
||||
|
||||
if(hdr.udp.isValid()) {
|
||||
delta_udp_from_v6_to_v4
|
||||
}
|
||||
|
||||
if(hdr.tcp.isValid()) {
|
||||
delta_tcp_from_v6_to_v4
|
||||
}
|
||||
|
||||
set_egress_port(v4_out);
|
||||
|
||||
} else if(hdr.ipv4.isValid()) {
|
||||
nat46_static(v6_dst, v4_dst, nat64_prefix);
|
||||
|
||||
if(hdr.udp.isValid()) {
|
||||
delta_udp_from_v4_to_v6
|
||||
}
|
||||
|
||||
if(hdr.tcp.isValid()) {
|
||||
delta_tcp_from_v4_to_v6
|
||||
}
|
||||
|
||||
set_egress_port(v6_out);
|
||||
} else {
|
||||
set_egress_port(1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue