aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if_llatbl.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/net/if_llatbl.c')
-rw-r--r--sys/net/if_llatbl.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/sys/net/if_llatbl.c b/sys/net/if_llatbl.c
index 10d555b1bd86..c61a19f39de2 100644
--- a/sys/net/if_llatbl.c
+++ b/sys/net/if_llatbl.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_var.h>
#include <net/route.h>
#include <net/route/route_ctl.h>
+#include <net/route/route_debug.h>
#include <net/vnet.h>
#include <netinet/if_ether.h>
#include <netinet6/in6_var.h>
@@ -419,6 +420,67 @@ llentry_lookup_family(struct llentry *lle, int family)
}
/*
+ * Retrieves upper protocol family for the llentry.
+ * By default, all "normal" (e.g. upper_family == transport_family)
+ * llentries have r_family set to 0.
+ * Thus, use @default_family in that regard, otherwise use r_family.
+ *
+ * Returns upper protocol family
+ */
+int
+llentry_get_upper_family(const struct llentry *lle, int default_family)
+{
+ return (lle->r_family == 0 ? default_family : lle->r_family);
+}
+
+/*
+ * Prints llentry @lle data into provided buffer.
+ * Example: lle/inet/valid/em0/1.2.3.4
+ *
+ * Returns @buf.
+ */
+char *
+llentry_print_buf(const struct llentry *lle, struct ifnet *ifp, int family,
+ char *buf, size_t bufsize)
+{
+ char abuf[INET6_ADDRSTRLEN];
+
+ const char *valid = (lle->r_flags & RLLE_VALID) ? "valid" : "no_l2";
+ const char *upper_str = rib_print_family(llentry_get_upper_family(lle, family));
+
+ switch (family) {
+#ifdef INET
+ case AF_INET:
+ inet_ntop(AF_INET, &lle->r_l3addr.addr4, abuf, sizeof(abuf));
+ snprintf(buf, bufsize, "lle/%s/%s/%s/%s", upper_str,
+ valid, if_name(ifp), abuf);
+ break;
+#endif
+#ifdef INET6
+ case AF_INET6:
+ inet_ntop(AF_INET6, &lle->r_l3addr.addr6, abuf, sizeof(abuf));
+ snprintf(buf, bufsize, "lle/%s/%s/%s/%s", upper_str,
+ valid, if_name(ifp), abuf);
+ break;
+#endif
+ default:
+ snprintf(buf, bufsize, "lle/%s/%s/%s/????", upper_str,
+ valid, if_name(ifp));
+ break;
+ }
+
+ return (buf);
+}
+
+char *
+llentry_print_buf_lltable(const struct llentry *lle, char *buf, size_t bufsize)
+{
+ struct lltable *tbl = lle->lle_tbl;
+
+ return (llentry_print_buf(lle, lltable_get_ifp(tbl), lltable_get_af(tbl), buf, bufsize));
+}
+
+/*
* Requests feedback from the datapath.
* First packet using @lle should result in
* setting r_skip_req back to 0 and updating