Merge into master from pull request #37:
Add type ipv4_t (https://github.com/floodlight/loxigen/pull/37)
diff --git a/Makefile b/Makefile
index 36f73ef..c0cc473 100644
--- a/Makefile
+++ b/Makefile
@@ -90,6 +90,7 @@
 	./utest/test_parser.py
 	./utest/test_frontend.py
 	./utest/test_test_data.py
+	./utest/test_generic_utils.py
 
 check-py: python
 	PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi:. python py_gen/tests/generic_util.py
diff --git a/c_gen/c_test_gen.py b/c_gen/c_test_gen.py
index 54d18b7..96614e5 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -79,6 +79,7 @@
         uint16_t="val16",
         uint32_t="val32",
         uint64_t="val64",
+        of_ipv4_t="ipv4",
         of_port_no_t="port_no",
         of_fm_cmd_t="fm_cmd",
         of_wc_bmap_t="wc_bmap",
@@ -105,7 +106,7 @@
 
 integer_types = ["uint8_t", "uint16_t", "uint32_t", "uint64_t",
                  "of_port_no_t", "of_fm_cmd_t", "of_wc_bmap_t",
-                 "of_match_bmap_t"]
+                 "of_match_bmap_t", "of_ipv4_t"]
 string_types = [ "of_port_name_t", "of_table_name_t",
                 "of_desc_str_t", "of_serial_num_t", "of_mac_addr_t",
                 "of_ipv6_t"]
diff --git a/c_gen/templates/loci_show.h b/c_gen/templates/loci_show.h
index acb06b8..b28b807 100644
--- a/c_gen/templates/loci_show.h
+++ b/c_gen/templates/loci_show.h
@@ -74,7 +74,7 @@
  */
 #define LOCI_SHOW_u32_ipv6_flabel(writer, cookie, val)     LOCI_SHOW_u32(writer, cookie, val)
 #define LOCI_SHOW_u8_vlan_pcp(writer, cookie, val)         LOCI_SHOW_u8(writer, cookie, val)
-#define LOCI_SHOW_u32_ipv4_src(writer, cookie, val)        LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_ipv4_ipv4_src(writer, cookie, val)        LOCI_SHOW_ipv4(writer, cookie, val)
 #define LOCI_SHOW_ipv6_ipv6_dst(writer, cookie, val)       LOCI_SHOW_ipv6(writer, cookie, val)
 #define LOCI_SHOW_u32_arp_tpa(writer, cookie, val)         LOCI_SHOW_ipv4(writer, cookie, val)
 #define LOCI_SHOW_u8_icmpv6_type(writer, cookie, val)      LOCI_SHOW_u8(writer, cookie, val)
@@ -99,7 +99,7 @@
 #define LOCI_SHOW_u8_ip_ecn(writer, cookie, val)           LOCI_SHOW_u8(writer, cookie, val)
 #define LOCI_SHOW_u16_udp_dst(writer, cookie, val)         LOCI_SHOW_u16(writer, cookie, val)
 #define LOCI_SHOW_port_no_in_phy_port(writer, cookie, val) LOCI_SHOW_port_no(writer, cookie, val)
-#define LOCI_SHOW_u32_ipv4_dst(writer, cookie, val)        LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_ipv4_ipv4_dst(writer, cookie, val)        LOCI_SHOW_ipv4(writer, cookie, val)
 #define LOCI_SHOW_mac_eth_src(writer, cookie, val)         LOCI_SHOW_mac(writer, cookie, val)
 #define LOCI_SHOW_u16_udp_src(writer, cookie, val)         LOCI_SHOW_u16(writer, cookie, val)
 #define LOCI_SHOW_mac_ipv6_nd_tll(writer, cookie, val)     LOCI_SHOW_mac(writer, cookie, val)
@@ -266,8 +266,8 @@
 #define LOCI_SHOW_u64_metadata_mask(writer, cookie, val) LOCI_SHOW_x64(writer, cookie, val)
 #define LOCI_SHOW_mac_eth_src_mask(writer, cookie, val) LOCI_SHOW_mac(writer, cookie, val)
 #define LOCI_SHOW_mac_eth_dst_mask(writer, cookie, val) LOCI_SHOW_mac(writer, cookie, val)
-#define LOCI_SHOW_u32_ipv4_src_mask(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
-#define LOCI_SHOW_u32_ipv4_dst_mask(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_ipv4_ipv4_src_mask(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_ipv4_ipv4_dst_mask(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
 #define LOCI_SHOW_u32_curr_speed(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
 #define LOCI_SHOW_u32_max_speed(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
 #define LOCI_SHOW_match_bmap_match(writer, cookie, val) LOCI_SHOW_match_bmap(writer, cookie, val)
@@ -328,11 +328,12 @@
 #define LOCI_SHOW_u32_service(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
 #define LOCI_SHOW_u32_status(writer, cookie, val) LOCI_SHOW_u32(writer, cookie, val)
 #define LOCI_SHOW_u16_subtype(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
-#define LOCI_SHOW_u32_ipv4_addr(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
-#define LOCI_SHOW_u32_ipv4_netmask(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_ipv4_ipv4_addr(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_ipv4_ipv4_netmask(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
 #define LOCI_SHOW_u8_l2_table_enable(writer, cookie, val) LOCI_SHOW_u8(writer, cookie, val)
 #define LOCI_SHOW_u16_l2_table_priority(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
-
+#define LOCI_SHOW_ipv4_value(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
+#define LOCI_SHOW_ipv4_value_mask(writer, cookie, val) LOCI_SHOW_ipv4(writer, cookie, val)
 
 
 #endif /* _LOCI_SHOW_H_ */
diff --git a/c_gen/templates/of_wire_buf.h b/c_gen/templates/of_wire_buf.h
index 9e91b9b..8750565 100644
--- a/c_gen/templates/of_wire_buf.h
+++ b/c_gen/templates/of_wire_buf.h
@@ -348,6 +348,38 @@
     buf_u32_set(OF_WIRE_BUFFER_INDEX(wbuf, offset), value);
 }
 
+
+/**
+ * Get a uint32_t scalar from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value Pointer to where to put value
+ *
+ * The underlying buffer accessor funtions handle endian and alignment.
+ */
+
+static inline void
+of_wire_buffer_ipv4_get(of_wire_buffer_t *wbuf, int offset, of_ipv4_t *value)
+{
+    of_wire_buffer_u32_get(wbuf, offset, value);
+}
+
+/**
+ * Set a ipv4 (uint32_t) scalar in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param value The value to store
+ *
+ * The underlying buffer accessor funtions handle endian and alignment.
+ */
+
+static inline void
+of_wire_buffer_ipv4_set(of_wire_buffer_t *wbuf, int offset, of_ipv4_t value)
+{
+    of_wire_buffer_u32_set(wbuf, offset, value);
+}
+
+
 /**
  * Get a uint64_t scalar from a wire buffer
  * @param wbuf The pointer to the wire buffer structure
diff --git a/loxi_front_end/match.py b/loxi_front_end/match.py
index 42c0a9e..20d5030 100644
--- a/loxi_front_end/match.py
+++ b/loxi_front_end/match.py
@@ -147,7 +147,7 @@
         ),
     ipv4_src = dict(
         name="ipv4_src",
-        m_type="uint32_t",
+        m_type="of_ipv4_t",
         v1_wc_shift=8,
         print_type="PRIx32",
         conditions="is_ipv4(match)",
@@ -156,7 +156,7 @@
         ),
     ipv4_dst = dict(
         name="ipv4_dst",
-        m_type="uint32_t",
+        m_type="of_ipv4_t",
         v1_wc_shift=14,
         print_type="PRIx32",
         conditions="is_ipv4(match)",
diff --git a/of_g.py b/of_g.py
index 2e8b5ba..651ee64 100644
--- a/of_g.py
+++ b/of_g.py
@@ -280,6 +280,7 @@
 #    of_counter_t = dict(bytes=8, to_w="u64_hton", from_w="u64_ntoh", use_as_rv=1,
 #                    short_name="counter"),
     of_mac_addr_t = dict(bytes=6, short_name="mac"),
+    of_ipv4_t = dict(bytes=4, short_name="ipv4"),
     of_ipv6_t = dict(bytes=16, short_name="ipv6"),
     of_port_name_t = dict(bytes=ofp_constants["OF_MAX_PORT_NAME_LEN"],
                           short_name="port_name"),
@@ -308,7 +309,7 @@
                    "of_port_no_t", "of_fm_cmd_t", "of_wc_bmap_t",
                    "of_match_bmap_t", "of_port_name_t", "of_table_name_t",
                    "of_desc_str_t", "of_serial_num_t", "of_mac_addr_t",
-                   "of_ipv6_t"]
+                   "of_ipv6_t", "of_ipv4_t"]
 
 base_object_members = """\
     /* The control block for the underlying data buffer */
diff --git a/openflow_input/bsn_get_interfaces b/openflow_input/bsn_get_interfaces
index ba1508c..01902bc 100644
--- a/openflow_input/bsn_get_interfaces
+++ b/openflow_input/bsn_get_interfaces
@@ -40,8 +40,8 @@
     of_mac_addr_t hw_addr;
     pad(2);
     of_port_name_t name;
-    uint32_t ipv4_addr;
-    uint32_t ipv4_netmask;
+    of_ipv4_t ipv4_addr;
+    of_ipv4_t ipv4_netmask;
 };
 
 struct of_bsn_get_interfaces_reply {
diff --git a/openflow_input/oxm-1.2 b/openflow_input/oxm-1.2
index b18c6fb..01af6c6 100644
--- a/openflow_input/oxm-1.2
+++ b/openflow_input/oxm-1.2
@@ -227,24 +227,24 @@
 
 struct of_oxm_ipv4_dst {
     uint32_t type_len == 0x80001804;
-    uint32_t value;
+    of_ipv4_t value;
 };
 
 struct of_oxm_ipv4_dst_masked {
     uint32_t type_len == 0x80001908;
-    uint32_t value;
-    uint32_t value_mask;
+    of_ipv4_t value;
+    of_ipv4_t value_mask;
 };
 
 struct of_oxm_ipv4_src {
     uint32_t type_len == 0x80001604;
-    uint32_t value;
+    of_ipv4_t value;
 };
 
 struct of_oxm_ipv4_src_masked {
     uint32_t type_len == 0x80001708;
-    uint32_t value;
-    uint32_t value_mask;
+    of_ipv4_t value;
+    of_ipv4_t value_mask;
 };
 
 struct of_oxm_ipv6_dst {
diff --git a/openflow_input/standard-1.0 b/openflow_input/standard-1.0
index 5d4405c..e9cb6f0 100644
--- a/openflow_input/standard-1.0
+++ b/openflow_input/standard-1.0
@@ -563,8 +563,8 @@
     uint8_t ip_dscp;
     uint8_t ip_proto;
     pad(2);
-    uint32_t ipv4_src;
-    uint32_t ipv4_dst;
+    of_ipv4_t ipv4_src;
+    of_ipv4_t ipv4_dst;
     uint16_t tcp_src;
     uint16_t tcp_dst;
 };
diff --git a/openflow_input/standard-1.1 b/openflow_input/standard-1.1
index a477d55..553e665 100644
--- a/openflow_input/standard-1.1
+++ b/openflow_input/standard-1.1
@@ -779,10 +779,10 @@
     uint16_t eth_type;
     uint8_t ip_dscp;
     uint8_t ip_proto;
-    uint32_t ipv4_src;
-    uint32_t ipv4_src_mask;
-    uint32_t ipv4_dst;
-    uint32_t ipv4_dst_mask;
+    of_ipv4_t ipv4_src;
+    of_ipv4_t ipv4_src_mask;
+    of_ipv4_t ipv4_dst;
+    of_ipv4_t ipv4_dst_mask;
     uint16_t tcp_src;
     uint16_t tcp_dst;
     uint32_t mpls_label;
diff --git a/py_gen/oftype.py b/py_gen/oftype.py
index 67af1e7..2399266 100644
--- a/py_gen/oftype.py
+++ b/py_gen/oftype.py
@@ -78,6 +78,11 @@
         pack='util.pack_match_bmap(%s)',
         unpack='util.unpack_match_bmap(%s)'),
 
+    'of_ipv4_t': OFTypeData(
+        init='0',
+        pack='struct.pack("!L", %s)',
+        unpack='%s.read("!L")[0]'),
+
     'of_ipv6_t': OFTypeData(
         init="'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'",
         pack='struct.pack("!16s", %s)',
diff --git a/py_gen/templates/_pretty_print.py b/py_gen/templates/_pretty_print.py
index 7be7a14..ed9d5cc 100644
--- a/py_gen/templates/_pretty_print.py
+++ b/py_gen/templates/_pretty_print.py
@@ -46,7 +46,7 @@
                     q.text('None')
 :: elif m.oftype == 'of_mac_addr_t':
                 q.text(util.pretty_mac(self.${m.name}))
-:: elif m.oftype == 'uint32_t' and m.name.startswith("ipv4"):
+:: elif m.oftype == 'of_ipv4_t':
                 q.text(util.pretty_ipv4(self.${m.name}))
 :: elif m.oftype == 'of_wc_bmap_t' and version in [1,2]:
                 q.text(util.pretty_wildcards(self.${m.name}))