summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/command.h1
-rw-r--r--lib/command_graph.c4
-rw-r--r--lib/prefix.c2
-rw-r--r--lib/prefix.h30
-rw-r--r--lib/vty.h5
5 files changed, 34 insertions, 8 deletions
diff --git a/lib/command.h b/lib/command.h
index 533b4b3289..5184b53a9f 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -181,6 +181,7 @@ struct cmd_node {
#define CMD_ERR_NO_FILE 11
#define CMD_SUSPEND 12
#define CMD_WARNING_CONFIG_FAILED 13
+#define CMD_NOT_MY_INSTANCE 14
/* Argc max counts. */
#define CMD_ARGC_MAX 25
diff --git a/lib/command_graph.c b/lib/command_graph.c
index 3efa4d5cfc..dc7233c1fe 100644
--- a/lib/command_graph.c
+++ b/lib/command_graph.c
@@ -385,7 +385,6 @@ static void cmd_node_names(struct graph_node *gn, struct graph_node *join,
break;
case START_TKN:
- case END_TKN:
case JOIN_TKN:
/* "<foo|bar> WORD" -> word is not "bar" or "foo" */
prevname = NULL;
@@ -405,6 +404,9 @@ static void cmd_node_names(struct graph_node *gn, struct graph_node *join,
cmd_token_varname_set(tailtok, jointok->varname);
}
break;
+
+ case END_TKN:
+ return;
}
for (i = 0; i < vector_active(gn->to); i++) {
diff --git a/lib/prefix.c b/lib/prefix.c
index 47e16dbf8b..33b6ff1987 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -1062,7 +1062,7 @@ int prefix_blen(const struct prefix *p)
return IPV6_MAX_BYTELEN;
break;
case AF_ETHERNET:
- return ETHER_ADDR_LEN;
+ return ETH_ALEN;
}
return 0;
}
diff --git a/lib/prefix.h b/lib/prefix.h
index 4f1f0b22d7..5f2b57ccce 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));
diff --git a/lib/vty.h b/lib/vty.h
index 0839f7fb68..0980f73afa 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -166,6 +166,11 @@ static inline void vty_push_context(struct vty *vty, int node, uint64_t id)
#define VTY_DECLVAR_CONTEXT_SUB(structname, ptr) \
struct structname *ptr = VTY_GET_CONTEXT_SUB(structname); \
VTY_CHECK_CONTEXT(ptr);
+#define VTY_DECLVAR_INSTANCE_CONTEXT(structname, ptr) \
+ if (vty->qobj_index == 0) \
+ return CMD_NOT_MY_INSTANCE; \
+ struct structname *ptr = VTY_GET_CONTEXT(structname); \
+ VTY_CHECK_CONTEXT(ptr);
struct vty_arg {
const char *name;