ospf6d: add LSA payload to show summary output
Unlike OSPFv2, the LSID of an LSA isn't sufficient to know what the contents
of the LSA are. Its useful for debugging and basic eyeball tests to see the
contents of the LSA in the simple tabular format of "show ipv6 ospf6 database".
This patch adds that output to the command. It replaces the existing fields of
"duration, Chksum and Length" with a single field called Payload which is
dependent on the LSA type. For Inter-Area Prefix, Intra-Area Prefix and
AS-External LSAs, this will be the advertised prefix/prefix length, for Router
LSAs, it is RtrID/IfID etc.
Signed-off-by: Dinesh G Dutt <ddutt at cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat at cumulusnetworks.com>
Reviewed-by: Scott Feldman <sfeldma at cumulusnetworks.com>
[DL: rebase fix, line disappeared in ospf6_abr_originate_summary_to_area]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c
index 3277e7d..379a62e 100644
--- a/ospf6d/ospf6_abr.c
+++ b/ospf6d/ospf6_abr.c
@@ -764,12 +764,34 @@
/* Display functions */
+static char *
+ospf6_inter_area_prefix_lsa_get_prefix_str (struct ospf6_lsa *lsa, char *buf,
+ int buflen, int pos)
+{
+ struct ospf6_inter_prefix_lsa *prefix_lsa;
+ struct in6_addr in6;
+
+ if (lsa != NULL)
+ {
+ prefix_lsa = (struct ospf6_inter_prefix_lsa *)
+ OSPF6_LSA_HEADER_END (lsa->header);
+
+ ospf6_prefix_in6_addr (&in6, &prefix_lsa->prefix);
+ if (buf)
+ {
+ inet_ntop (AF_INET6, &in6, buf, buflen);
+ sprintf (&buf[strlen(buf)], "/%d", prefix_lsa->prefix.prefix_length);
+ }
+ }
+
+ return (buf);
+}
+
static int
ospf6_inter_area_prefix_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
{
struct ospf6_inter_prefix_lsa *prefix_lsa;
- struct in6_addr in6;
- char buf[64];
+ char buf[INET6_ADDRSTRLEN];
prefix_lsa = (struct ospf6_inter_prefix_lsa *)
OSPF6_LSA_HEADER_END (lsa->header);
@@ -781,14 +803,32 @@
buf, sizeof (buf));
vty_out (vty, " Prefix Options: %s%s", buf, VNL);
- ospf6_prefix_in6_addr (&in6, &prefix_lsa->prefix);
- inet_ntop (AF_INET6, &in6, buf, sizeof (buf));
- vty_out (vty, " Prefix: %s/%d%s", buf,
- prefix_lsa->prefix.prefix_length, VNL);
+ vty_out (vty, " Prefix: %s%s",
+ ospf6_inter_area_prefix_lsa_get_prefix_str (lsa, buf, sizeof(buf),
+ 0), VNL);
return 0;
}
+static char *
+ospf6_inter_area_router_lsa_get_prefix_str (struct ospf6_lsa *lsa, char *buf,
+ int buflen, int pos)
+{
+ struct ospf6_inter_router_lsa *router_lsa;
+
+ if (lsa != NULL)
+ {
+ router_lsa = (struct ospf6_inter_router_lsa *)
+ OSPF6_LSA_HEADER_END (lsa->header);
+
+
+ if (buf)
+ inet_ntop (AF_INET, &router_lsa->router_id, buf, buflen);
+ }
+
+ return (buf);
+}
+
static int
ospf6_inter_area_router_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
{
@@ -802,6 +842,7 @@
vty_out (vty, " Options: %s%s", buf, VNL);
vty_out (vty, " Metric: %lu%s",
(u_long) OSPF6_ABR_SUMMARY_METRIC (router_lsa), VNL);
+
inet_ntop (AF_INET, &router_lsa->router_id, buf, sizeof (buf));
vty_out (vty, " Destination Router ID: %s%s", buf, VNL);
@@ -855,14 +896,18 @@
{
OSPF6_LSTYPE_INTER_PREFIX,
"Inter-Prefix",
- ospf6_inter_area_prefix_lsa_show
+ "IAP",
+ ospf6_inter_area_prefix_lsa_show,
+ ospf6_inter_area_prefix_lsa_get_prefix_str,
};
struct ospf6_lsa_handler inter_router_handler =
{
OSPF6_LSTYPE_INTER_ROUTER,
"Inter-Router",
- ospf6_inter_area_router_lsa_show
+ "IAR",
+ ospf6_inter_area_router_lsa_show,
+ ospf6_inter_area_router_lsa_get_prefix_str,
};
void