Correct state parser to match on icmp6.type

This commit is contained in:
Nico Schottelius 2019-03-23 14:30:20 +01:00
parent 68bb8e9edd
commit 39c280cd33
3 changed files with 14 additions and 14 deletions

View file

@ -8,15 +8,16 @@
#include "headers.p4" #include "headers.p4"
parser MyParser(packet_in packet, parser MyParser(packet_in packet,
out headers hdr, out headers hdr,
inout metadata meta, inout metadata meta,
inout standard_metadata_t standard_metadata) { inout standard_metadata_t standard_metadata) {
state start { state start {
packet.extract(hdr.ethernet); packet.extract(hdr.ethernet);
transition select(hdr.ethernet.ethertype){ transition select(hdr.ethernet.ethertype){
TYPE_IPV4: ipv4; TYPE_IPV4: ipv4;
TYPE_IPV6: ipv6; TYPE_IPV6: ipv6;
default: accept; default: accept;
} }
} }
@ -48,7 +49,7 @@ parser MyParser(packet_in packet,
state icmp6 { state icmp6 {
packet.extract(hdr.icmp6); packet.extract(hdr.icmp6);
transition select(hdr.ipv6.next_header){ transition select(hdr.icmp6.type) {
ICMP6_NS: icmp6_neighbor_solicitation; ICMP6_NS: icmp6_neighbor_solicitation;
default: accept; default: accept;
} }
@ -66,23 +67,23 @@ parser MyParser(packet_in packet,
/* Leaf */ /* Leaf */
state tcp { state tcp {
packet.extract(hdr.tcp); packet.extract(hdr.tcp);
transition accept; transition accept;
} }
state udp { state udp {
packet.extract(hdr.udp); packet.extract(hdr.udp);
transition accept; transition accept;
} }
// state icmp6 { // state icmp6 {
// packet.extract(hdr.icmp6); // packet.extract(hdr.icmp6);
// transition accept; // transition accept;
// } // }
state icmp { state icmp {
packet.extract(hdr.icmp); packet.extract(hdr.icmp);
transition accept; transition accept;
} }
} }

View file

@ -67,7 +67,6 @@ control MyIngress(inout headers hdr,
hdr.icmp6_option_link_layer_addr.ll_length = 1; /* 1* 64 bit */ hdr.icmp6_option_link_layer_addr.ll_length = 1; /* 1* 64 bit */
hdr.icmp6_option_link_layer_addr.mac_addr = mac_addr; hdr.icmp6_option_link_layer_addr.mac_addr = mac_addr;
/* version1: rebuilding packet */ /* version1: rebuilding packet */
/* /*
truncate((bit<32>)(112 + 320 + 32)/8); truncate((bit<32>)(112 + 320 + 32)/8);