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_lsa.c b/ospf6d/ospf6_lsa.c
index 592aad9..4aa2b12 100644
--- a/ospf6d/ospf6_lsa.c
+++ b/ospf6d/ospf6_lsa.c
@@ -74,8 +74,10 @@
struct ospf6_lsa_handler unknown_handler =
{
OSPF6_LSTYPE_UNKNOWN,
- "unknown",
+ "Unknown",
+ "Unk",
ospf6_unknown_lsa_show,
+ NULL,
OSPF6_LSA_DEBUG,
};
@@ -118,6 +120,20 @@
return buf;
}
+const char *
+ospf6_lstype_short_name (u_int16_t type)
+{
+ static char buf[8];
+ struct ospf6_lsa_handler *handler;
+
+ handler = ospf6_get_lsa_handler (type);
+ if (handler && handler != &unknown_handler)
+ return handler->short_name;
+
+ snprintf (buf, sizeof (buf), "0x%04hx", ntohs (type));
+ return buf;
+}
+
u_char
ospf6_lstype_debug (u_int16_t type)
{
@@ -371,17 +387,19 @@
void
ospf6_lsa_show_summary_header (struct vty *vty)
{
- vty_out (vty, "%-12s %-15s %-15s %4s %8s %4s %4s %-8s%s",
+ vty_out (vty, "%-4s %-15s%-15s%4s %8s %30s%s",
"Type", "LSId", "AdvRouter", "Age", "SeqNum",
- "Cksm", "Len", "Duration", VNL);
+ "Payload", VNL);
}
void
ospf6_lsa_show_summary (struct vty *vty, struct ospf6_lsa *lsa)
{
char adv_router[16], id[16];
- struct timeval now, res;
- char duration[16];
+ int type;
+ struct ospf6_lsa_handler *handler;
+ char buf[64], tmpbuf[80];
+ int cnt = 0;
assert (lsa);
assert (lsa->header);
@@ -390,16 +408,38 @@
inet_ntop (AF_INET, &lsa->header->adv_router, adv_router,
sizeof (adv_router));
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
- timersub (&now, &lsa->installed, &res);
- timerstring (&res, duration, sizeof (duration));
+ type = ntohs(lsa->header->type);
+ handler = ospf6_get_lsa_handler (lsa->header->type);
+ if ((type == OSPF6_LSTYPE_INTER_PREFIX) ||
+ (type == OSPF6_LSTYPE_INTER_ROUTER) ||
+ (type == OSPF6_LSTYPE_AS_EXTERNAL))
+ {
+ vty_out (vty, "%-4s %-15s%-15s%4hu %8lx %30s%s",
+ ospf6_lstype_short_name (lsa->header->type),
+ id, adv_router, ospf6_lsa_age_current (lsa),
+ (u_long) ntohl (lsa->header->seqnum),
+ handler->get_prefix_str(lsa, buf, sizeof(buf), 0), VNL);
+ }
+ else if (type != OSPF6_LSTYPE_UNKNOWN)
+ {
+ sprintf (tmpbuf, "%-4s %-15s%-15s%4hu %8lx",
+ ospf6_lstype_short_name (lsa->header->type),
+ id, adv_router, ospf6_lsa_age_current (lsa),
+ (u_long) ntohl (lsa->header->seqnum));
- vty_out (vty, "%-12s %-15s %-15s %4hu %8lx %04hx %4hu %8s%s",
- ospf6_lstype_name (lsa->header->type),
- id, adv_router, ospf6_lsa_age_current (lsa),
- (u_long) ntohl (lsa->header->seqnum),
- ntohs (lsa->header->checksum), ntohs (lsa->header->length),
- duration, VNL);
+ while (handler->get_prefix_str(lsa, buf, sizeof(buf), cnt) != NULL)
+ {
+ vty_out (vty, "%s %30s%s", tmpbuf, buf, VNL);
+ cnt++;
+ }
+ }
+ else
+ {
+ vty_out (vty, "%-4s %-15s%-15s%4hu %8lx%s",
+ ospf6_lstype_short_name (lsa->header->type),
+ id, adv_router, ospf6_lsa_age_current (lsa),
+ (u_long) ntohl (lsa->header->seqnum), VNL);
+ }
}
void
@@ -464,6 +504,8 @@
{
char adv_router[64], id[64];
struct ospf6_lsa_handler *handler;
+ struct timeval now, res;
+ char duration[16];
assert (lsa && lsa->header);
@@ -471,6 +513,10 @@
inet_ntop (AF_INET, &lsa->header->adv_router,
adv_router, sizeof (adv_router));
+ quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ timersub (&now, &lsa->installed, &res);
+ timerstring (&res, duration, sizeof (duration));
+
vty_out (vty, "Age: %4hu Type: %s%s", ospf6_lsa_age_current (lsa),
ospf6_lstype_name (lsa->header->type), VNL);
vty_out (vty, "Link State ID: %s%s", id, VNL);
@@ -480,6 +526,7 @@
vty_out (vty, "CheckSum: %#06hx Length: %hu%s",
ntohs (lsa->header->checksum),
ntohs (lsa->header->length), VNL);
+ vty_out (vty, "Duration: %s%s", duration, VNL);
handler = ospf6_get_lsa_handler (lsa->header->type);
if (handler->show == NULL)