From 0bb4a2b51a63fa29cbe0e9f7f3878c37358fd35e Mon Sep 17 00:00:00 2001 From: Helin Zhang Date: Thu, 5 Jun 2014 13:08:50 +0800 Subject: [PATCH] ethdev: function to compare ethernet addresses To support i40e, function is_same_ether_addr() has been added to compare two ethernet address. Signed-off-by: Helin Zhang Signed-off-by: Jing Chen Acked-by: Cunming Liang Acked-by: Jijiang Liu Acked-by: Jingjing Wu Acked-by: Heqing Zhu Tested-by: Waterman Cao --- lib/librte_ether/rte_ether.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/librte_ether/rte_ether.h b/lib/librte_ether/rte_ether.h index 08feb412de..a25ca109bf 100644 --- a/lib/librte_ether/rte_ether.h +++ b/lib/librte_ether/rte_ether.h @@ -85,6 +85,30 @@ struct ether_addr { #define ETHER_LOCAL_ADMIN_ADDR 0x02 /**< Locally assigned Eth. address. */ #define ETHER_GROUP_ADDR 0x01 /**< Multicast or broadcast Eth. address. */ +/** + * Check if two Ethernet addresses are the same. + * + * @param ea1 + * A pointer to the first ether_addr structure containing + * the ethernet address. + * @param ea2 + * A pointer to the second ether_addr structure containing + * the ethernet address. + * + * @return + * True (1) if the given two ethernet address are the same; + * False (0) otherwise. + */ +static inline int is_same_ether_addr(const struct ether_addr *ea1, + const struct ether_addr *ea2) +{ + int i; + for (i = 0; i < ETHER_ADDR_LEN; i++) + if (ea1->addr_bytes[i] != ea2->addr_bytes[i]) + return 0; + return 1; +} + /** * Check if an Ethernet address is filled with zeros. * -- 2.20.1