add of_str64_t string type
We need a 64-byte string for the debug_counter extension. Since adding a new
string type is so much work, the new type is named generically so that any
extension can use it.
diff --git a/c_gen/c_code_gen.py b/c_gen/c_code_gen.py
index 10668b7..81f5a1a 100644
--- a/c_gen/c_code_gen.py
+++ b/c_gen/c_code_gen.py
@@ -700,6 +700,7 @@
typedef char of_table_name_t[OF_MAX_TABLE_NAME_LEN];
typedef char of_desc_str_t[OF_DESC_STR_LEN];
typedef char of_serial_num_t[OF_SERIAL_NUM_LEN];
+typedef char of_str64_t[64];
typedef struct of_bitmap_128_s {
uint64_t hi;
diff --git a/c_gen/c_test_gen.py b/c_gen/c_test_gen.py
index 316a2b3..01f1c5d 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -92,6 +92,7 @@
of_table_name_t="table_name",
of_desc_str_t="desc_str",
of_serial_num_t="ser_num",
+ of_str64_t="str64",
of_mac_addr_t="mac_addr",
of_ipv6_t="ipv6",
# Non-scalars; more TBD
@@ -115,7 +116,8 @@
"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", "of_bitmap_128_t", "of_checksum_128_t"]
+ "of_ipv6_t", "of_bitmap_128_t", "of_checksum_128_t",
+ "of_str64_t"]
scalar_types = integer_types[:]
scalar_types.extend(string_types)
diff --git a/c_gen/of_g_legacy.py b/c_gen/of_g_legacy.py
index 1fadba0..3311282 100644
--- a/c_gen/of_g_legacy.py
+++ b/c_gen/of_g_legacy.py
@@ -192,6 +192,7 @@
short_name="desc_str"),
of_serial_num_t = dict(bytes=ofp_constants["OF_SERIAL_NUM_LEN"],
short_name="ser_num"),
+ of_str64_t = dict(bytes=64, short_name="str64"),
of_match_v1_t = dict(bytes=40, to_w="match_v1_hton",
from_w="match_v1_ntoh",
short_name="match_v1"),
@@ -213,7 +214,8 @@
"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_ipv4_t", "of_bitmap_128_t", "of_checksum_128_t"]
+ "of_ipv6_t", "of_ipv4_t", "of_bitmap_128_t", "of_checksum_128_t",
+ "of_str64_t"]
##
# LOXI identifiers
diff --git a/c_gen/templates/loci_dump.h b/c_gen/templates/loci_dump.h
index 9cc719c..1344565 100644
--- a/c_gen/templates/loci_dump.h
+++ b/c_gen/templates/loci_dump.h
@@ -90,6 +90,7 @@
#define LOCI_DUMP_tab_name(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
#define LOCI_DUMP_desc_str(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
#define LOCI_DUMP_ser_num(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
+#define LOCI_DUMP_str64(writer, cookie, val) LOCI_DUMP_string(writer, cookie, val)
int loci_dump_match(loci_writer_f writer, void* cookie, of_match_t *match);
#define LOCI_DUMP_match(writer, cookie, val) loci_dump_match(writer, cookie, &val)
diff --git a/c_gen/templates/loci_show.h b/c_gen/templates/loci_show.h
index 5384837..4389f4c 100644
--- a/c_gen/templates/loci_show.h
+++ b/c_gen/templates/loci_show.h
@@ -158,6 +158,7 @@
#define LOCI_SHOW_tab_name(writer, cookie, val) LOCI_SHOW_string(writer, cookie, val)
#define LOCI_SHOW_desc_str(writer, cookie, val) LOCI_SHOW_string(writer, cookie, val)
#define LOCI_SHOW_ser_num(writer, cookie, val) LOCI_SHOW_string(writer, cookie, val)
+#define LOCI_SHOW_str64(writer, cookie, val) LOCI_SHOW_string(writer, cookie, val)
int loci_show_match(loci_writer_f writer, void *cookie, of_match_t *match);
#define LOCI_SHOW_match(writer, cookie, val) loci_show_match(writer, cookie, &val)
diff --git a/c_gen/templates/of_wire_buf.h b/c_gen/templates/of_wire_buf.h
index 4736ac0..0723454 100644
--- a/c_gen/templates/of_wire_buf.h
+++ b/c_gen/templates/of_wire_buf.h
@@ -853,6 +853,30 @@
_wbuf_octets_set(buf, offset, (uint8_t *)sernum, OF_SERIAL_NUM_LEN)
/**
+ * Get a str64 string from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param s The string
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_str64_get(buf, offset, s) \
+ _wbuf_octets_get(buf, offset, (uint8_t *)s, 64)
+
+/**
+ * Set a str64 string in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param s Where to store the str64
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_str64_set(buf, offset, s) \
+ _wbuf_octets_set(buf, offset, (uint8_t *)s, 64)
+
+/**
* Get an ipv6 address from a wire buffer
* @param wbuf The pointer to the wire buffer structure
* @param offset Offset in the wire buffer