This will see its first real user in the following commit.

Signed-off-by: Ben Pfaff <b...@ovn.org>
---
 build-aux/check-structs     |  1 +
 include/openvswitch/types.h | 10 +++++++++-
 lib/packets.h               | 34 +++++++++++++++++++++++++++++++++-
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/build-aux/check-structs b/build-aux/check-structs
index 8de9defe2b36..a55480b1dbc7 100755
--- a/build-aux/check-structs
+++ b/build-aux/check-structs
@@ -16,6 +16,7 @@ types['ovs_be32'] = {"size": 4, "alignment": 4}
 types['ovs_be64'] = {"size": 8, "alignment": 8}
 types['ovs_32aligned_be64'] = {"size": 8, "alignment": 4}
 types['struct eth_addr'] = {"size": 6, "alignment": 2}
+types['struct eth_addr64'] = {"size": 8, "alignment": 2}
 
 token = None
 line = ""
diff --git a/include/openvswitch/types.h b/include/openvswitch/types.h
index 2f5fcca2876c..5ae0972dac99 100644
--- a/include/openvswitch/types.h
+++ b/include/openvswitch/types.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 2013, 2014, 2016 Nicira, Inc.
+ * Copyright (c) 2010, 2011, 2013, 2014, 2016, 2017 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -152,4 +152,12 @@ struct eth_addr {
     };
 };
 
+/* Similar to struct eth_addr, for EUI-64 addresses. */
+struct eth_addr64 {
+    union {
+        uint8_t ea64[8];
+        ovs_be16 be16[4];
+    };
+};
+
 #endif /* openvswitch/types.h */
diff --git a/lib/packets.h b/lib/packets.h
index a4de7a5963b6..755f08d6d06d 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, 
Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 
Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -156,6 +156,8 @@ static const struct eth_addr eth_addr_exact OVS_UNUSED
 
 static const struct eth_addr eth_addr_zero OVS_UNUSED
     = { { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } };
+static const struct eth_addr64 eth_addr64_zero OVS_UNUSED
+    = { { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } };
 
 static const struct eth_addr eth_addr_stp OVS_UNUSED
     = { { { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x00 } } };
@@ -188,6 +190,10 @@ static inline bool eth_addr_is_zero(const struct eth_addr 
a)
 {
     return !(a.be16[0] | a.be16[1] | a.be16[2]);
 }
+static inline bool eth_addr64_is_zero(const struct eth_addr64 a)
+{
+    return !(a.be16[0] | a.be16[1] | a.be16[2] | a.be16[3]);
+}
 
 static inline int eth_mask_is_exact(const struct eth_addr a)
 {
@@ -199,12 +205,22 @@ static inline int eth_addr_compare_3way(const struct 
eth_addr a,
 {
     return memcmp(&a, &b, sizeof a);
 }
+static inline int eth_addr64_compare_3way(const struct eth_addr64 a,
+                                          const struct eth_addr64 b)
+{
+    return memcmp(&a, &b, sizeof a);
+}
 
 static inline bool eth_addr_equals(const struct eth_addr a,
                                    const struct eth_addr b)
 {
     return !eth_addr_compare_3way(a, b);
 }
+static inline bool eth_addr64_equals(const struct eth_addr64 a,
+                                     const struct eth_addr64 b)
+{
+    return !eth_addr64_compare_3way(a, b);
+}
 
 static inline bool eth_addr_equal_except(const struct eth_addr a,
                                          const struct eth_addr b,
@@ -315,6 +331,22 @@ ovs_be32 set_mpls_lse_values(uint8_t ttl, uint8_t tc, 
uint8_t bos,
 
 /* Example:
  *
+ * struct eth_addr64 eui64;
+ *    [...]
+ * printf("The EUI-64 address is "ETH_ADDR64_FMT"\n", ETH_ADDR64_ARGS(mac));
+ *
+ */
+#define ETH_ADDR64_FMT \
+    "%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":" \
+    "%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8
+#define ETH_ADDR64_ARGS(EA) ETH_ADDR64_BYTES_ARGS((EA).ea64)
+#define ETH_ADDR64_BYTES_ARGS(EAB) \
+         (EAB)[0], (EAB)[1], (EAB)[2], (EAB)[3], \
+         (EAB)[4], (EAB)[5], (EAB)[6], (EAB)[7]
+#define ETH_ADDR64_STRLEN 23
+
+/* Example:
+ *
  * char *string = "1 00:11:22:33:44:55 2";
  * struct eth_addr mac;
  * int a, b;
-- 
2.10.2

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to