summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2017-11-28 15:32:24 -0800
committerBen Pfaff <blp@ovn.org>2017-11-29 13:27:16 -0800
commit134fefa4deaf1f15d003a7c07893c9d7a602c8e3 (patch)
tree4e660b6e467102c9f1c57b3aeecd3808be85712b /include
parentee3ac719f204bd5827aaf7f9237c8f7c1cdb60c3 (diff)
downloadopenvswitch-134fefa4deaf1f15d003a7c07893c9d7a602c8e3.tar.gz
types: New macros ETH_ADDR_C and ETH_ADDR64_C.
These macros expand to constants of type struct eth_addr and struct eth_addr64, respectively, and make it more convenient to initialize or assign to an Ethernet address object. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mark Michelson <mmichels@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/openvswitch/types.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/openvswitch/types.h b/include/openvswitch/types.h
index f7e1c07dd..d5792c3b2 100644
--- a/include/openvswitch/types.h
+++ b/include/openvswitch/types.h
@@ -168,6 +168,11 @@ struct eth_addr {
};
};
+/* Ethernet address constant, e.g. ETH_ADDR_C(01,23,45,67,89,ab) is
+ * 01:23:45:67:89:ab. */
+#define ETH_ADDR_C(A,B,C,D,E,F) (struct eth_addr) \
+ { { .ea = { 0x##A, 0x##B, 0x##C, 0x##D, 0x##E, 0x##F } } }
+
/* Similar to struct eth_addr, for EUI-64 addresses. */
struct eth_addr64 {
union {
@@ -176,6 +181,12 @@ struct eth_addr64 {
};
};
+/* EUI-64 address constant, e.g. ETH_ADDR_C(01,23,45,67,89,ab,cd,ef) is
+ * 01:23:45:67:89:ab:cd:ef. */
+#define ETH_ADDR64_C(A,B,C,D,E,F,G,H) (struct eth_addr64) \
+ { { .ea64 = { 0x##A, 0x##B, 0x##C, 0x##D, \
+ 0x##E, 0x##F, 0x##G, 0x##H} } }
+
#ifdef __cplusplus
}
#endif