From 39c280cd3382860923e8593b128dac64b1ba3669 Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@nico-notebook.schottelius.org>
Date: Sat, 23 Mar 2019 14:30:20 +0100
Subject: [PATCH] Correct state parser to match on icmp6.type

---
 p4src/parsers.p4                              |  27 +++++++++---------
 p4src/static-mapping.p4                       |   1 -
 ...p => switch-ping6-2019-03-23-1321-h1.pcap} | Bin
 3 files changed, 14 insertions(+), 14 deletions(-)
 rename pcap/{ndp-switch-2019-03-23-1321-h1.pcap => switch-ping6-2019-03-23-1321-h1.pcap} (100%)

diff --git a/p4src/parsers.p4 b/p4src/parsers.p4
index 121b981..43b42a4 100644
--- a/p4src/parsers.p4
+++ b/p4src/parsers.p4
@@ -8,15 +8,16 @@
 #include "headers.p4"
 
 parser MyParser(packet_in packet,
-                out       headers hdr,
-                inout     metadata meta,
-                inout     standard_metadata_t standard_metadata) {
+    out       headers hdr,
+    inout     metadata meta,
+    inout     standard_metadata_t standard_metadata) {
 
     state start {
         packet.extract(hdr.ethernet);
         transition select(hdr.ethernet.ethertype){
             TYPE_IPV4: ipv4;
             TYPE_IPV6: ipv6;
+
             default: accept;
         }
     }
@@ -48,7 +49,7 @@ parser MyParser(packet_in packet,
 
     state icmp6 {
         packet.extract(hdr.icmp6);
-        transition select(hdr.ipv6.next_header){
+        transition select(hdr.icmp6.type) {
             ICMP6_NS: icmp6_neighbor_solicitation;
             default: accept;
         }
@@ -66,23 +67,23 @@ parser MyParser(packet_in packet,
 
     /* Leaf */
     state tcp {
-       packet.extract(hdr.tcp);
-       transition accept;
+        packet.extract(hdr.tcp);
+        transition accept;
     }
 
     state udp {
-       packet.extract(hdr.udp);
-       transition accept;
+        packet.extract(hdr.udp);
+        transition accept;
     }
 
     // state icmp6 {
-    //     packet.extract(hdr.icmp6);
-    //     transition accept;
-    // }
+        //     packet.extract(hdr.icmp6);
+        //     transition accept;
+        // }
 
     state icmp {
-       packet.extract(hdr.icmp);
-       transition accept;
+        packet.extract(hdr.icmp);
+        transition accept;
     }
 
 }
diff --git a/p4src/static-mapping.p4 b/p4src/static-mapping.p4
index 993353f..1205745 100644
--- a/p4src/static-mapping.p4
+++ b/p4src/static-mapping.p4
@@ -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.mac_addr = mac_addr;
 
-
         /* version1: rebuilding packet */
         /*
         truncate((bit<32>)(112 + 320 + 32)/8);
diff --git a/pcap/ndp-switch-2019-03-23-1321-h1.pcap b/pcap/switch-ping6-2019-03-23-1321-h1.pcap
similarity index 100%
rename from pcap/ndp-switch-2019-03-23-1321-h1.pcap
rename to pcap/switch-ping6-2019-03-23-1321-h1.pcap