diff --git a/doc/plan.org b/doc/plan.org index 3f43230..0eba721 100644 --- a/doc/plan.org +++ b/doc/plan.org @@ -66,7 +66,8 @@ **** See time table above *** Additional features queue (to be discussed) **** TODO Offset based translation (v4->v6) -> same as range (?) -**** +**** TODO IP address learning (v6/v4) for real life switch? + ** Thesis documentation *** Motivation TBD diff --git a/p4src/headers.p4 b/p4src/headers.p4 index 7c4be86..ca65fd2 100644 --- a/p4src/headers.p4 +++ b/p4src/headers.p4 @@ -76,11 +76,35 @@ header tcp_t{ bit<16> urgentPtr; } +header udp_t { + bit<16> src_port; + bit<16> dst_port; + bit<16> payload_length; + bit<16> checksum; +} + +header icmp6_t { + bit<8> type; + bit<8> code; + bit<16> checksum; +} + +header icmp_t { + bit<8> type; + bit<8> code; + bit<16> checksum; + bit<32> rest; +} + + struct headers { ethernet_t ethernet; ipv4_t ipv4; ipv6_t ipv6; tcp_t tcp; + udp_t udp; + icmp6_t icmp6; + icmp_t icmp; } struct metadata { diff --git a/p4src/parsers.p4 b/p4src/parsers.p4 index e2b5d54..79448e8 100644 --- a/p4src/parsers.p4 +++ b/p4src/parsers.p4 @@ -26,7 +26,10 @@ parser MyParser(packet_in packet, meta.tcp_length = hdr.ipv4.totalLen - 16w20; transition select(hdr.ipv4.protocol){ - TYPE_TCP: tcp; + PROTO_TCP: tcp; + PROTO_UDP: udp; + PROTO_ICMP: icmp; + default: accept; } } @@ -36,16 +39,34 @@ parser MyParser(packet_in packet, meta.tcp_length = hdr.ipv6.payload_length; transition select(hdr.ipv6.next_header){ - TYPE_TCP: tcp; + PROTO_TCP: tcp; + PROTO_UDP: udp; + PROTO_ICMP6: icmp6; default: accept; } } + /* Leaf */ state tcp { packet.extract(hdr.tcp); transition accept; } + state udp { + packet.extract(hdr.udp); + transition accept; + } + + state icmp6 { + packet.extract(hdr.icmp6); + transition accept; + } + + state icmp { + packet.extract(hdr.icmp); + transition accept; + } + } /*************************************************************************