summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--zebra/connected.c47
-rw-r--r--zebra/connected.h5
-rw-r--r--zebra/rt_netlink.c1
3 files changed, 53 insertions, 0 deletions
diff --git a/zebra/connected.c b/zebra/connected.c
index bf5715e4..25186a80 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -36,6 +36,53 @@
#include "zebra/interface.h"
#include "zebra/connected.h"
extern struct zebra_t zebrad;
+
+#ifdef HAVE_NETLINK
+static const struct message rtscope_str[] = {
+ {RT_SCOPE_UNIVERSE, "global"},
+ {RT_SCOPE_SITE, "site"},
+ {RT_SCOPE_LINK, "link"},
+ {RT_SCOPE_HOST, "host"},
+ {RT_SCOPE_NOWHERE, "nowhere"},
+ {0, NULL}
+};
+
+/* for use in show interface */
+const char *
+connected_scope_name(unsigned value)
+{
+ const char *str;
+ static char buf[16];
+
+ str = lookup (rtscope_str, value);
+ if (!str || !*str) {
+ snprintf (buf, sizeof(buf), "%d", value);
+ str = buf;
+ }
+ return str;
+}
+
+int
+connected_scope_number(const char *name)
+{
+ const struct message *m;
+ char *errptr;
+ unsigned value;
+
+ if (!name || !*name)
+ return -1;
+
+ for (m = rtscope_str; m->str; m++)
+ if (!strcmp (m->str, name))
+ return m->key;
+
+ value = strtoul (name, &errptr, 0);
+ if (*errptr || value > 255)
+ return -1;
+
+ return value;
+}
+#endif /* HAVE_NETLINK */
/* withdraw a connected address */
static void
diff --git a/zebra/connected.h b/zebra/connected.h
index 0f7c586b..d7934055 100644
--- a/zebra/connected.h
+++ b/zebra/connected.h
@@ -54,4 +54,9 @@ extern void connected_down_ipv6 (struct interface *ifp, struct connected *);
#endif /* HAVE_IPV6 */
+#ifdef HAVE_NETLINK
+extern const char *connected_scope_name (unsigned value);
+extern int connected_scope_number (const char *name);
+#endif /* HAVE_NETLINK */
+
#endif /*_ZEBRA_CONNECTED_H */
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index dfe88002..da255e0f 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -549,6 +549,7 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h)
char buf[BUFSIZ];
zlog_debug ("netlink_interface_addr %s %s:",
lookup (nlmsg_str, h->nlmsg_type), ifp->name);
+ zlog_debug (" ifa_scope %s", connected_scope_name (ifa->ifa_scope));
if (tb[IFA_LOCAL])
zlog_debug (" IFA_LOCAL %s/%d",
inet_ntop (ifa->ifa_family, RTA_DATA (tb[IFA_LOCAL]),