Support compiling fabric.p4 with non-standard bool declarations

Change-Id: I5e579f58f274996fdff55d8e35d1dd96a7013941
diff --git a/pipelines/fabric/src/main/resources/include/control/filtering.p4 b/pipelines/fabric/src/main/resources/include/control/filtering.p4
index 4f6e688..a037fcf 100644
--- a/pipelines/fabric/src/main/resources/include/control/filtering.p4
+++ b/pipelines/fabric/src/main/resources/include/control/filtering.p4
@@ -46,7 +46,7 @@
         set_vlan(new_vlan_id);
 
         // pop internal vlan before packet in
-        fabric_metadata.pop_vlan_when_packet_in = true;
+        fabric_metadata.pop_vlan_when_packet_in = _TRUE;
     }
 
     action set_forwarding_type(fwd_type_t fwd_type) {
diff --git a/pipelines/fabric/src/main/resources/include/control/packetio.p4 b/pipelines/fabric/src/main/resources/include/control/packetio.p4
index 7cd8cf2..9f69af1 100644
--- a/pipelines/fabric/src/main/resources/include/control/packetio.p4
+++ b/pipelines/fabric/src/main/resources/include/control/packetio.p4
@@ -40,7 +40,7 @@
     }
     apply {
         if (standard_metadata.egress_port == CPU_PORT) {
-            if (hdr.vlan_tag.isValid() && fabric_metadata.pop_vlan_when_packet_in) {
+            if (hdr.vlan_tag.isValid() && fabric_metadata.pop_vlan_when_packet_in == _TRUE) {
                 pop_vlan();
             }
             hdr.packet_in.setValid();
diff --git a/pipelines/fabric/src/main/resources/include/define.p4 b/pipelines/fabric/src/main/resources/include/define.p4
index eb61f91..1522df1 100644
--- a/pipelines/fabric/src/main/resources/include/define.p4
+++ b/pipelines/fabric/src/main/resources/include/define.p4
@@ -19,6 +19,40 @@
 
 #define MAX_PORTS 511
 
+#ifndef _BOOL
+#define _BOOL bool
+#endif
+#ifndef _TRUE
+#define _TRUE true
+#endif
+#ifndef _FALSE
+#define _FALSE true
+#endif
+
+#ifndef _PKT_OUT_HDR_ANNOT
+#define _PKT_OUT_HDR_ANNOT
+#endif
+
+#ifndef IP_VER_LENGTH
+#define IP_VER_LENGTH 4
+#endif
+#ifndef IP_VERSION_4
+#define IP_VERSION_4 4
+#endif
+#ifndef IP_VERSION_6
+#define IP_VERSION_6 6
+#endif
+
+#define ETH_HDR_SIZE 14
+#define IPV4_HDR_SIZE 20
+#define UDP_HDR_SIZE 8
+#define GTP_HDR_SIZE 8
+
+#define UDP_PORT_GTPU 2152
+#define GTP_GPDU 0xff
+#define GTPU_VERSION 0x01
+#define GTP_PROTOCOL_TYPE_GTP 0x01
+
 typedef bit<3>  fwd_type_t;
 typedef bit<32> next_id_t;
 typedef bit<20> mpls_label_t;
@@ -36,16 +70,6 @@
 const bit<16> ETHERTYPE_IPV6 = 0x86dd;
 const bit<16> ETHERTYPE_ARP  = 0x0806;
 
-#ifndef IP_VER_LENGTH
-#define IP_VER_LENGTH 4
-#endif
-#ifndef IP_VERSION_4
-#define IP_VERSION_4 4
-#endif
-#ifndef IP_VERSION_6
-#define IP_VERSION_6 6
-#endif
-
 const bit<8> PROTO_ICMP = 1;
 const bit<8> PROTO_TCP = 6;
 const bit<8> PROTO_UDP = 17;
@@ -53,10 +77,6 @@
 
 const bit<4> IPV4_MIN_IHL = 5;
 
-#ifndef _PKT_OUT_HDR_ANNOT_
-#define _PKT_OUT_HDR_ANNOT_
-#endif
-
 const fwd_type_t FWD_BRIDGING = 0;
 const fwd_type_t FWD_MPLS = 1;
 const fwd_type_t FWD_IPV4_UNICAST = 2;
@@ -67,16 +87,6 @@
 const bit<8> DEFAULT_MPLS_TTL = 64;
 const bit<8> DEFAULT_IPV4_TTL = 64;
 
-#define ETH_HDR_SIZE 14
-#define IPV4_HDR_SIZE 20
-#define UDP_HDR_SIZE 8
-#define GTP_HDR_SIZE 8
-
-#define UDP_PORT_GTPU 2152
-#define GTP_GPDU 0xff
-#define GTPU_VERSION 0x01
-#define GTP_PROTOCOL_TYPE_GTP 0x01
-
 typedef bit direction_t;
 typedef bit pcc_gate_status_t;
 typedef bit<32> sdf_rule_id_t;
diff --git a/pipelines/fabric/src/main/resources/include/header.p4 b/pipelines/fabric/src/main/resources/include/header.p4
index 067d9c8..1c8dcfd 100644
--- a/pipelines/fabric/src/main/resources/include/header.p4
+++ b/pipelines/fabric/src/main/resources/include/header.p4
@@ -25,7 +25,7 @@
     bit<7> _pad;
 }
 
-_PKT_OUT_HDR_ANNOT_
+_PKT_OUT_HDR_ANNOT
 @controller_header("packet_out")
 header packet_out_header_t {
     port_num_t egress_port;
@@ -131,7 +131,7 @@
 }
 
 struct spgw_meta_t {
-    bool              do_spgw;
+    _BOOL             do_spgw;
     direction_t       direction;
     bit<16>           ipv4_len;
     bit<32>           teid;
@@ -151,7 +151,7 @@
 struct fabric_metadata_t {
     fwd_type_t fwd_type;
     next_id_t next_id;
-    bool pop_vlan_when_packet_in;
+    _BOOL pop_vlan_when_packet_in;
     bit<8> ip_proto;
     bit<16> l4_src_port;
     bit<16> l4_dst_port;
diff --git a/pipelines/fabric/src/main/resources/include/spgw.p4 b/pipelines/fabric/src/main/resources/include/spgw.p4
index 87839f6..640c7cc 100644
--- a/pipelines/fabric/src/main/resources/include/spgw.p4
+++ b/pipelines/fabric/src/main/resources/include/spgw.p4
@@ -143,7 +143,7 @@
     }
 
     apply {
-        spgw_meta.do_spgw = false;
+        spgw_meta.do_spgw = _FALSE;
         if (gtpu.isValid()) {
             // If here, the parsed ipv4 header is the outer GTP one, but
             // fabric needs to forward on the inner one, i.e. this.
@@ -156,15 +156,15 @@
 
             if (s1u_filter_table.apply().hit) {
                 // TODO: check also that gtpu.msgtype == GTP_GPDU
-                spgw_meta.do_spgw = true;
+                spgw_meta.do_spgw = _TRUE;
                 spgw_meta.direction = DIR_UPLINK;
             }
         } else if (ue_filter_table.apply().hit) {
-            spgw_meta.do_spgw = true;
+            spgw_meta.do_spgw = _TRUE;
             spgw_meta.direction = DIR_DOWNLINK;
         }
 
-        if (!spgw_meta.do_spgw) {
+        if (spgw_meta.do_spgw == _FALSE) {
             // Exit this control block.
             return;
         }
@@ -246,7 +246,7 @@
     }
 
     apply {
-        if (spgw_meta.do_spgw && spgw_meta.direction == DIR_DOWNLINK) {
+        if (spgw_meta.do_spgw == _TRUE && spgw_meta.direction == DIR_DOWNLINK) {
             gtpu_encap();
         }
     }