summaryrefslogtreecommitdiffstats
path: root/lib/prefix.h
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-08-03 14:42:29 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-08-04 15:06:14 +0200
commit7628d862cac325e47cfd89717299347dee627d14 (patch)
tree9cbd95db1d4472acf7a5024dca6f0a3d31faca0e /lib/prefix.h
parentzebra: Fix crash when OOM happens. (diff)
downloadfrr-7628d862cac325e47cfd89717299347dee627d14.tar.xz
frr-7628d862cac325e47cfd89717299347dee627d14.zip
lib: Add ETH_ALEN to prefix.h and deprecate ETHER_ADDR_LEN
From discussion we decided that we should use ETH_ALEN instead of ETHER_ADDR_LEN. Add ETH_ALEN to prefix.h and make ETHER_ADDR_LEN generate a warning when used( but still work ). Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to '')
-rw-r--r--lib/prefix.h30
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/prefix.h b/lib/prefix.h
index 4f1f0b22d..5f2b57ccc 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -34,21 +34,39 @@
#include "sockunion.h"
#include "ipaddr.h"
-#ifndef ETHER_ADDR_LEN
-#ifdef ETHERADDRL
-#define ETHER_ADDR_LEN ETHERADDRL
+#ifndef ETH_ALEN
+#define ETH_ALEN 6
+#endif
+
+/* for compatibility */
+#if defined(__ICC)
+#define CPP_WARN_STR(X) #X
+#define CPP_WARN(text) _Pragma(CPP_WARN_STR(message __FILE__ ": " text))
+
+#elif (defined(__GNUC__) \
+ && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) \
+ || (defined(__clang__) \
+ && (__clang_major__ >= 4 \
+ || (__clang_major__ == 3 && __clang_minor__ >= 5)))
+#define CPP_WARN_STR(X) #X
+#define CPP_WARN(text) _Pragma(CPP_WARN_STR(GCC warning text))
+
#else
-#define ETHER_ADDR_LEN 6
+#define CPP_WARN(text)
#endif
+
+#ifdef ETHER_ADDR_LEN
+#undef ETHER_ADDR_LEN
#endif
+#define ETHER_ADDR_LEN 6 CPP_WARN("ETHER_ADDR_LEN is being replaced by ETH_ALEN.\\n")
-#define ETHER_ADDR_STRLEN (3*ETHER_ADDR_LEN)
+#define ETHER_ADDR_STRLEN (3*ETH_ALEN)
/*
* there isn't a portable ethernet address type. We define our
* own to simplify internal handling
*/
struct ethaddr {
- u_char octet[ETHER_ADDR_LEN];
+ u_char octet[ETH_ALEN];
} __attribute__((packed));