fast-classifier: support ipv6
Change-Id: I91354be76cd71866ed0ad94c8c8a1cfde9bcd9a1
Signed-off-by: Xiaoping Fan <xfan@codeaurora.org>
diff --git a/shortcut-fe/sfe_cm.h b/shortcut-fe/sfe_cm.h
index ec676a3..12f2ffa 100644
--- a/shortcut-fe/sfe_cm.h
+++ b/shortcut-fe/sfe_cm.h
@@ -207,3 +207,38 @@
return;
}
#endif
+
+/*
+ * sfe_ipv6_addr_equal()
+ * compare ipv6 address
+ *
+ * return: 1, equal; 0, no equal
+ */
+static inline int sfe_ipv6_addr_equal(struct sfe_ipv6_addr *a,
+ struct sfe_ipv6_addr *b)
+{
+ return a->addr[0] == b->addr[0] &&
+ a->addr[1] == b->addr[1] &&
+ a->addr[2] == b->addr[2] &&
+ a->addr[3] == b->addr[3];
+}
+
+/*
+ * sfe_ipv4_addr_equal()
+ * compare ipv4 address
+ *
+ * return: 1, equal; 0, no equal
+ */
+#define sfe_ipv4_addr_equal(a, b) ((uint32_t)(a) == (uint32_t)(b))
+
+/*
+ * sfe_addr_equal()
+ * compare ipv4 or ipv6 address
+ *
+ * return: 1, equal; 0, no equal
+ */
+static inline int sfe_addr_equal(sfe_ip_addr_t *a,
+ sfe_ip_addr_t *b, int is_v4)
+{
+ return is_v4 ? sfe_ipv4_addr_equal(a->ip, b->ip) : sfe_ipv6_addr_equal(a->ip6, b->ip6);
+}