mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-21 17:51:17 +00:00
Merge pull request #7668 from ranjanyash54/dev_6
ospf6d: Json support added for command "show ipv6 ospf6 database [json]"
This commit is contained in:
commit
52624d7945
@ -170,10 +170,34 @@ Showing OSPF6 information
|
|||||||
instance ID, simply type "show ipv6 ospf6 <cr>". JSON output can be
|
instance ID, simply type "show ipv6 ospf6 <cr>". JSON output can be
|
||||||
obtained by appending 'json' to the end of command.
|
obtained by appending 'json' to the end of command.
|
||||||
|
|
||||||
.. index:: show ipv6 ospf6 database
|
.. index:: show ipv6 ospf6 database [<detail|dump|internal>] [json]
|
||||||
.. clicmd:: show ipv6 ospf6 database
|
.. clicmd:: show ipv6 ospf6 database [<detail|dump|internal>] [json]
|
||||||
|
|
||||||
This command shows LSA database summary. You can specify the type of LSA.
|
This command shows LSAs present in the LSDB. There are three view options.
|
||||||
|
These options helps in viewing all the parameters of the LSAs. JSON output
|
||||||
|
can be obtained by appending 'json' to the end of command. JSON option is
|
||||||
|
not applicable with 'dump' option.
|
||||||
|
|
||||||
|
.. index:: show ipv6 ospf6 database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> [json]
|
||||||
|
.. clicmd:: show ipv6 ospf6 database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> [json]
|
||||||
|
|
||||||
|
These options filters out the LSA based on its type. The three views options
|
||||||
|
works here as well. JSON output can be obtained by appending 'json' to the
|
||||||
|
end of command.
|
||||||
|
|
||||||
|
.. index:: show ipv6 ospf6 database adv-router A.B.C.D linkstate-id A.B.C.D [json]
|
||||||
|
.. clicmd:: show ipv6 ospf6 database adv-router A.B.C.D linkstate-id A.B.C.D [json]
|
||||||
|
|
||||||
|
The LSAs additinally can also be filtered with the linkstate-id and
|
||||||
|
advertising-router fields. We can use the LSA type filter and views with
|
||||||
|
this command as well and visa-versa. JSON output can be obtained by
|
||||||
|
appending 'json' to the end of command.
|
||||||
|
|
||||||
|
.. index:: show ipv6 ospf6 database self-originated [json]
|
||||||
|
.. clicmd:: show ipv6 ospf6 database self-originated [json]
|
||||||
|
|
||||||
|
This command is used to filter the LSAs which are originated by the present
|
||||||
|
router. All the other filters are applicable here as well.
|
||||||
|
|
||||||
.. index:: show ipv6 ospf6 interface [json]
|
.. index:: show ipv6 ospf6 interface [json]
|
||||||
.. clicmd:: show ipv6 ospf6 interface [json]
|
.. clicmd:: show ipv6 ospf6 interface [json]
|
||||||
|
@ -1296,7 +1296,9 @@ static char *ospf6_inter_area_prefix_lsa_get_prefix_str(struct ospf6_lsa *lsa,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int ospf6_inter_area_prefix_lsa_show(struct vty *vty,
|
static int ospf6_inter_area_prefix_lsa_show(struct vty *vty,
|
||||||
struct ospf6_lsa *lsa)
|
struct ospf6_lsa *lsa,
|
||||||
|
json_object *json_obj,
|
||||||
|
bool use_json)
|
||||||
{
|
{
|
||||||
struct ospf6_inter_prefix_lsa *prefix_lsa;
|
struct ospf6_inter_prefix_lsa *prefix_lsa;
|
||||||
char buf[INET6_ADDRSTRLEN];
|
char buf[INET6_ADDRSTRLEN];
|
||||||
@ -1304,16 +1306,29 @@ static int ospf6_inter_area_prefix_lsa_show(struct vty *vty,
|
|||||||
prefix_lsa = (struct ospf6_inter_prefix_lsa *)OSPF6_LSA_HEADER_END(
|
prefix_lsa = (struct ospf6_inter_prefix_lsa *)OSPF6_LSA_HEADER_END(
|
||||||
lsa->header);
|
lsa->header);
|
||||||
|
|
||||||
vty_out(vty, " Metric: %lu\n",
|
if (use_json) {
|
||||||
(unsigned long)OSPF6_ABR_SUMMARY_METRIC(prefix_lsa));
|
json_object_int_add(
|
||||||
|
json_obj, "metric",
|
||||||
|
(unsigned long)OSPF6_ABR_SUMMARY_METRIC(prefix_lsa));
|
||||||
|
ospf6_prefix_options_printbuf(prefix_lsa->prefix.prefix_options,
|
||||||
|
buf, sizeof(buf));
|
||||||
|
json_object_string_add(json_obj, "prefixOptions", buf);
|
||||||
|
json_object_string_add(
|
||||||
|
json_obj, "prefix",
|
||||||
|
ospf6_inter_area_prefix_lsa_get_prefix_str(
|
||||||
|
lsa, buf, sizeof(buf), 0));
|
||||||
|
} else {
|
||||||
|
vty_out(vty, " Metric: %lu\n",
|
||||||
|
(unsigned long)OSPF6_ABR_SUMMARY_METRIC(prefix_lsa));
|
||||||
|
|
||||||
ospf6_prefix_options_printbuf(prefix_lsa->prefix.prefix_options, buf,
|
ospf6_prefix_options_printbuf(prefix_lsa->prefix.prefix_options,
|
||||||
sizeof(buf));
|
buf, sizeof(buf));
|
||||||
vty_out(vty, " Prefix Options: %s\n", buf);
|
vty_out(vty, " Prefix Options: %s\n", buf);
|
||||||
|
|
||||||
vty_out(vty, " Prefix: %s\n",
|
vty_out(vty, " Prefix: %s\n",
|
||||||
ospf6_inter_area_prefix_lsa_get_prefix_str(lsa, buf,
|
ospf6_inter_area_prefix_lsa_get_prefix_str(
|
||||||
sizeof(buf), 0));
|
lsa, buf, sizeof(buf), 0));
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1338,7 +1353,9 @@ static char *ospf6_inter_area_router_lsa_get_prefix_str(struct ospf6_lsa *lsa,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int ospf6_inter_area_router_lsa_show(struct vty *vty,
|
static int ospf6_inter_area_router_lsa_show(struct vty *vty,
|
||||||
struct ospf6_lsa *lsa)
|
struct ospf6_lsa *lsa,
|
||||||
|
json_object *json_obj,
|
||||||
|
bool use_json)
|
||||||
{
|
{
|
||||||
struct ospf6_inter_router_lsa *router_lsa;
|
struct ospf6_inter_router_lsa *router_lsa;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
@ -1347,12 +1364,22 @@ static int ospf6_inter_area_router_lsa_show(struct vty *vty,
|
|||||||
lsa->header);
|
lsa->header);
|
||||||
|
|
||||||
ospf6_options_printbuf(router_lsa->options, buf, sizeof(buf));
|
ospf6_options_printbuf(router_lsa->options, buf, sizeof(buf));
|
||||||
vty_out(vty, " Options: %s\n", buf);
|
if (use_json) {
|
||||||
vty_out(vty, " Metric: %lu\n",
|
json_object_string_add(json_obj, "options", buf);
|
||||||
(unsigned long)OSPF6_ABR_SUMMARY_METRIC(router_lsa));
|
json_object_int_add(
|
||||||
|
json_obj, "metric",
|
||||||
|
(unsigned long)OSPF6_ABR_SUMMARY_METRIC(router_lsa));
|
||||||
|
} else {
|
||||||
|
vty_out(vty, " Options: %s\n", buf);
|
||||||
|
vty_out(vty, " Metric: %lu\n",
|
||||||
|
(unsigned long)OSPF6_ABR_SUMMARY_METRIC(router_lsa));
|
||||||
|
}
|
||||||
|
|
||||||
inet_ntop(AF_INET, &router_lsa->router_id, buf, sizeof(buf));
|
inet_ntop(AF_INET, &router_lsa->router_id, buf, sizeof(buf));
|
||||||
vty_out(vty, " Destination Router ID: %s\n", buf);
|
if (use_json)
|
||||||
|
json_object_string_add(json_obj, "destinationRouterId", buf);
|
||||||
|
else
|
||||||
|
vty_out(vty, " Destination Router ID: %s\n", buf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1890,7 +1890,8 @@ static char *ospf6_as_external_lsa_get_prefix_str(struct ospf6_lsa *lsa,
|
|||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ospf6_as_external_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
static int ospf6_as_external_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
|
json_object *json_obj, bool use_json)
|
||||||
{
|
{
|
||||||
struct ospf6_as_external_lsa *external;
|
struct ospf6_as_external_lsa *external;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
@ -1908,31 +1909,65 @@ static int ospf6_as_external_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
(CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T) ? 'T'
|
(CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T) ? 'T'
|
||||||
: '-'));
|
: '-'));
|
||||||
|
|
||||||
vty_out(vty, " Bits: %s\n", buf);
|
if (use_json) {
|
||||||
vty_out(vty, " Metric: %5lu\n",
|
json_object_string_add(json_obj, "bits", buf);
|
||||||
(unsigned long)OSPF6_ASBR_METRIC(external));
|
json_object_int_add(json_obj, "metric",
|
||||||
|
(unsigned long)OSPF6_ASBR_METRIC(external));
|
||||||
|
ospf6_prefix_options_printbuf(external->prefix.prefix_options,
|
||||||
|
buf, sizeof(buf));
|
||||||
|
json_object_string_add(json_obj, "prefixOptions", buf);
|
||||||
|
json_object_int_add(
|
||||||
|
json_obj, "referenceLsType",
|
||||||
|
ntohs(external->prefix.prefix_refer_lstype));
|
||||||
|
json_object_string_add(json_obj, "prefix",
|
||||||
|
ospf6_as_external_lsa_get_prefix_str(
|
||||||
|
lsa, buf, sizeof(buf), 0));
|
||||||
|
|
||||||
ospf6_prefix_options_printbuf(external->prefix.prefix_options, buf,
|
/* Forwarding-Address */
|
||||||
sizeof(buf));
|
json_object_boolean_add(
|
||||||
vty_out(vty, " Prefix Options: %s\n", buf);
|
json_obj, "forwardingAddressPresent",
|
||||||
|
CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F));
|
||||||
|
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F))
|
||||||
|
json_object_string_add(
|
||||||
|
json_obj, "forwardingAddress",
|
||||||
|
ospf6_as_external_lsa_get_prefix_str(
|
||||||
|
lsa, buf, sizeof(buf), 1));
|
||||||
|
|
||||||
vty_out(vty, " Referenced LSType: %d\n",
|
/* Tag */
|
||||||
ntohs(external->prefix.prefix_refer_lstype));
|
json_object_boolean_add(
|
||||||
|
json_obj, "tagPresent",
|
||||||
|
CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T));
|
||||||
|
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T))
|
||||||
|
json_object_int_add(json_obj, "tag",
|
||||||
|
ospf6_as_external_lsa_get_tag(lsa));
|
||||||
|
} else {
|
||||||
|
vty_out(vty, " Bits: %s\n", buf);
|
||||||
|
vty_out(vty, " Metric: %5lu\n",
|
||||||
|
(unsigned long)OSPF6_ASBR_METRIC(external));
|
||||||
|
|
||||||
vty_out(vty, " Prefix: %s\n",
|
ospf6_prefix_options_printbuf(external->prefix.prefix_options,
|
||||||
ospf6_as_external_lsa_get_prefix_str(lsa, buf, sizeof(buf), 0));
|
buf, sizeof(buf));
|
||||||
|
vty_out(vty, " Prefix Options: %s\n", buf);
|
||||||
|
|
||||||
/* Forwarding-Address */
|
vty_out(vty, " Referenced LSType: %d\n",
|
||||||
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F)) {
|
ntohs(external->prefix.prefix_refer_lstype));
|
||||||
vty_out(vty, " Forwarding-Address: %s\n",
|
|
||||||
|
vty_out(vty, " Prefix: %s\n",
|
||||||
ospf6_as_external_lsa_get_prefix_str(lsa, buf,
|
ospf6_as_external_lsa_get_prefix_str(lsa, buf,
|
||||||
sizeof(buf), 1));
|
sizeof(buf), 0));
|
||||||
}
|
|
||||||
|
|
||||||
/* Tag */
|
/* Forwarding-Address */
|
||||||
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T)) {
|
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F)) {
|
||||||
vty_out(vty, " Tag: %" ROUTE_TAG_PRI "\n",
|
vty_out(vty, " Forwarding-Address: %s\n",
|
||||||
ospf6_as_external_lsa_get_tag(lsa));
|
ospf6_as_external_lsa_get_prefix_str(
|
||||||
|
lsa, buf, sizeof(buf), 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tag */
|
||||||
|
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T)) {
|
||||||
|
vty_out(vty, " Tag: %" ROUTE_TAG_PRI "\n",
|
||||||
|
ospf6_as_external_lsa_get_tag(lsa));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -92,12 +92,15 @@ static char *ospf6_router_lsa_get_nbr_id(struct ospf6_lsa *lsa, char *buf,
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ospf6_router_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
static int ospf6_router_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
|
json_object *json_obj, bool use_json)
|
||||||
{
|
{
|
||||||
char *start, *end, *current;
|
char *start, *end, *current;
|
||||||
char buf[32], name[32], bits[16], options[32];
|
char buf[32], name[32], bits[16], options[32];
|
||||||
struct ospf6_router_lsa *router_lsa;
|
struct ospf6_router_lsa *router_lsa;
|
||||||
struct ospf6_router_lsdesc *lsdesc;
|
struct ospf6_router_lsdesc *lsdesc;
|
||||||
|
json_object *json_arr;
|
||||||
|
json_object *json_loop;
|
||||||
|
|
||||||
router_lsa =
|
router_lsa =
|
||||||
(struct ospf6_router_lsa *)((char *)lsa->header
|
(struct ospf6_router_lsa *)((char *)lsa->header
|
||||||
@ -105,7 +108,12 @@ static int ospf6_router_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
|
|
||||||
ospf6_capability_printbuf(router_lsa->bits, bits, sizeof(bits));
|
ospf6_capability_printbuf(router_lsa->bits, bits, sizeof(bits));
|
||||||
ospf6_options_printbuf(router_lsa->options, options, sizeof(options));
|
ospf6_options_printbuf(router_lsa->options, options, sizeof(options));
|
||||||
vty_out(vty, " Bits: %s Options: %s\n", bits, options);
|
if (use_json) {
|
||||||
|
json_object_string_add(json_obj, "bits", bits);
|
||||||
|
json_object_string_add(json_obj, "options", options);
|
||||||
|
json_arr = json_object_new_array();
|
||||||
|
} else
|
||||||
|
vty_out(vty, " Bits: %s Options: %s\n", bits, options);
|
||||||
|
|
||||||
start = (char *)router_lsa + sizeof(struct ospf6_router_lsa);
|
start = (char *)router_lsa + sizeof(struct ospf6_router_lsa);
|
||||||
end = (char *)lsa->header + ntohs(lsa->header->length);
|
end = (char *)lsa->header + ntohs(lsa->header->length);
|
||||||
@ -126,18 +134,43 @@ static int ospf6_router_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
snprintf(name, sizeof(name), "Unknown (%#x)",
|
snprintf(name, sizeof(name), "Unknown (%#x)",
|
||||||
lsdesc->type);
|
lsdesc->type);
|
||||||
|
|
||||||
vty_out(vty, " Type: %s Metric: %d\n", name,
|
if (use_json) {
|
||||||
ntohs(lsdesc->metric));
|
json_loop = json_object_new_object();
|
||||||
vty_out(vty, " Interface ID: %s\n",
|
json_object_string_add(json_loop, "type", name);
|
||||||
inet_ntop(AF_INET, &lsdesc->interface_id, buf,
|
json_object_int_add(json_loop, "metric",
|
||||||
sizeof(buf)));
|
ntohs(lsdesc->metric));
|
||||||
vty_out(vty, " Neighbor Interface ID: %s\n",
|
json_object_string_add(json_loop, "interfaceId",
|
||||||
inet_ntop(AF_INET, &lsdesc->neighbor_interface_id, buf,
|
inet_ntop(AF_INET,
|
||||||
sizeof(buf)));
|
&lsdesc->interface_id,
|
||||||
vty_out(vty, " Neighbor Router ID: %s\n",
|
buf, sizeof(buf)));
|
||||||
inet_ntop(AF_INET, &lsdesc->neighbor_router_id, buf,
|
json_object_string_add(
|
||||||
sizeof(buf)));
|
json_loop, "neighborInterfaceId",
|
||||||
|
inet_ntop(AF_INET,
|
||||||
|
&lsdesc->neighbor_interface_id, buf,
|
||||||
|
sizeof(buf)));
|
||||||
|
json_object_string_add(
|
||||||
|
json_loop, "neighborRouterId",
|
||||||
|
inet_ntop(AF_INET, &lsdesc->neighbor_router_id,
|
||||||
|
buf, sizeof(buf)));
|
||||||
|
json_object_array_add(json_arr, json_loop);
|
||||||
|
} else {
|
||||||
|
vty_out(vty, " Type: %s Metric: %d\n", name,
|
||||||
|
ntohs(lsdesc->metric));
|
||||||
|
vty_out(vty, " Interface ID: %s\n",
|
||||||
|
inet_ntop(AF_INET, &lsdesc->interface_id, buf,
|
||||||
|
sizeof(buf)));
|
||||||
|
vty_out(vty, " Neighbor Interface ID: %s\n",
|
||||||
|
inet_ntop(AF_INET,
|
||||||
|
&lsdesc->neighbor_interface_id, buf,
|
||||||
|
sizeof(buf)));
|
||||||
|
vty_out(vty, " Neighbor Router ID: %s\n",
|
||||||
|
inet_ntop(AF_INET, &lsdesc->neighbor_router_id,
|
||||||
|
buf, sizeof(buf)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (use_json)
|
||||||
|
json_object_object_add(json_obj, "lsaDescription", json_arr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,29 +454,44 @@ static char *ospf6_network_lsa_get_ar_id(struct ospf6_lsa *lsa, char *buf,
|
|||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ospf6_network_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
static int ospf6_network_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
|
json_object *json_obj, bool use_json)
|
||||||
{
|
{
|
||||||
char *start, *end, *current;
|
char *start, *end, *current;
|
||||||
struct ospf6_network_lsa *network_lsa;
|
struct ospf6_network_lsa *network_lsa;
|
||||||
struct ospf6_network_lsdesc *lsdesc;
|
struct ospf6_network_lsdesc *lsdesc;
|
||||||
char buf[128], options[32];
|
char buf[128], options[32];
|
||||||
|
json_object *json_arr;
|
||||||
|
|
||||||
network_lsa =
|
network_lsa =
|
||||||
(struct ospf6_network_lsa *)((caddr_t)lsa->header
|
(struct ospf6_network_lsa *)((caddr_t)lsa->header
|
||||||
+ sizeof(struct ospf6_lsa_header));
|
+ sizeof(struct ospf6_lsa_header));
|
||||||
|
|
||||||
ospf6_options_printbuf(network_lsa->options, options, sizeof(options));
|
ospf6_options_printbuf(network_lsa->options, options, sizeof(options));
|
||||||
vty_out(vty, " Options: %s\n", options);
|
if (use_json)
|
||||||
|
json_object_string_add(json_obj, "options", options);
|
||||||
|
else
|
||||||
|
vty_out(vty, " Options: %s\n", options);
|
||||||
|
|
||||||
start = (char *)network_lsa + sizeof(struct ospf6_network_lsa);
|
start = (char *)network_lsa + sizeof(struct ospf6_network_lsa);
|
||||||
end = (char *)lsa->header + ntohs(lsa->header->length);
|
end = (char *)lsa->header + ntohs(lsa->header->length);
|
||||||
|
if (use_json)
|
||||||
|
json_arr = json_object_new_array();
|
||||||
|
|
||||||
for (current = start;
|
for (current = start;
|
||||||
current + sizeof(struct ospf6_network_lsdesc) <= end;
|
current + sizeof(struct ospf6_network_lsdesc) <= end;
|
||||||
current += sizeof(struct ospf6_network_lsdesc)) {
|
current += sizeof(struct ospf6_network_lsdesc)) {
|
||||||
lsdesc = (struct ospf6_network_lsdesc *)current;
|
lsdesc = (struct ospf6_network_lsdesc *)current;
|
||||||
inet_ntop(AF_INET, &lsdesc->router_id, buf, sizeof(buf));
|
inet_ntop(AF_INET, &lsdesc->router_id, buf, sizeof(buf));
|
||||||
vty_out(vty, " Attached Router: %s\n", buf);
|
if (use_json)
|
||||||
|
json_object_array_add(json_arr,
|
||||||
|
json_object_new_string(buf));
|
||||||
|
else
|
||||||
|
vty_out(vty, " Attached Router: %s\n", buf);
|
||||||
}
|
}
|
||||||
|
if (use_json)
|
||||||
|
json_object_object_add(json_obj, "attachedRouter", json_arr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,7 +673,8 @@ static char *ospf6_link_lsa_get_prefix_str(struct ospf6_lsa *lsa, char *buf,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ospf6_link_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
static int ospf6_link_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
|
json_object *json_obj, bool use_json)
|
||||||
{
|
{
|
||||||
char *start, *end, *current;
|
char *start, *end, *current;
|
||||||
struct ospf6_link_lsa *link_lsa;
|
struct ospf6_link_lsa *link_lsa;
|
||||||
@ -634,6 +683,10 @@ static int ospf6_link_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
struct ospf6_prefix *prefix;
|
struct ospf6_prefix *prefix;
|
||||||
const char *p, *mc, *la, *nu;
|
const char *p, *mc, *la, *nu;
|
||||||
struct in6_addr in6;
|
struct in6_addr in6;
|
||||||
|
json_object *json_loop;
|
||||||
|
json_object *json_arr = NULL;
|
||||||
|
char str[15];
|
||||||
|
char prefix_string[133];
|
||||||
|
|
||||||
link_lsa = (struct ospf6_link_lsa *)((caddr_t)lsa->header
|
link_lsa = (struct ospf6_link_lsa *)((caddr_t)lsa->header
|
||||||
+ sizeof(struct ospf6_lsa_header));
|
+ sizeof(struct ospf6_lsa_header));
|
||||||
@ -642,10 +695,18 @@ static int ospf6_link_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
inet_ntop(AF_INET6, &link_lsa->linklocal_addr, buf, sizeof(buf));
|
inet_ntop(AF_INET6, &link_lsa->linklocal_addr, buf, sizeof(buf));
|
||||||
prefixnum = ntohl(link_lsa->prefix_num);
|
prefixnum = ntohl(link_lsa->prefix_num);
|
||||||
|
|
||||||
vty_out(vty, " Priority: %d Options: %s\n", link_lsa->priority,
|
if (use_json) {
|
||||||
options);
|
json_arr = json_object_new_array();
|
||||||
vty_out(vty, " LinkLocal Address: %s\n", buf);
|
json_object_int_add(json_obj, "priority", link_lsa->priority);
|
||||||
vty_out(vty, " Number of Prefix: %d\n", prefixnum);
|
json_object_string_add(json_obj, "options", options);
|
||||||
|
json_object_string_add(json_obj, "linkLocalAddress", buf);
|
||||||
|
json_object_int_add(json_obj, "numberOfPrefix", prefixnum);
|
||||||
|
} else {
|
||||||
|
vty_out(vty, " Priority: %d Options: %s\n",
|
||||||
|
link_lsa->priority, options);
|
||||||
|
vty_out(vty, " LinkLocal Address: %s\n", buf);
|
||||||
|
vty_out(vty, " Number of Prefix: %d\n", prefixnum);
|
||||||
|
}
|
||||||
|
|
||||||
start = (char *)link_lsa + sizeof(struct ospf6_link_lsa);
|
start = (char *)link_lsa + sizeof(struct ospf6_link_lsa);
|
||||||
end = (char *)lsa->header + ntohs(lsa->header->length);
|
end = (char *)lsa->header + ntohs(lsa->header->length);
|
||||||
@ -668,16 +729,31 @@ static int ospf6_link_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
nu = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_NU)
|
nu = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_NU)
|
||||||
? "NU"
|
? "NU"
|
||||||
: "--");
|
: "--");
|
||||||
vty_out(vty, " Prefix Options: %s|%s|%s|%s\n", p, mc, la,
|
if (use_json) {
|
||||||
nu);
|
json_loop = json_object_new_object();
|
||||||
|
snprintf(str, sizeof(str), "%s|%s|%s|%s", p, mc, la,
|
||||||
|
nu);
|
||||||
|
json_object_string_add(json_loop, "prefixOption", str);
|
||||||
|
} else
|
||||||
|
vty_out(vty, " Prefix Options: %s|%s|%s|%s\n", p,
|
||||||
|
mc, la, nu);
|
||||||
|
|
||||||
memset(&in6, 0, sizeof(in6));
|
memset(&in6, 0, sizeof(in6));
|
||||||
memcpy(&in6, OSPF6_PREFIX_BODY(prefix),
|
memcpy(&in6, OSPF6_PREFIX_BODY(prefix),
|
||||||
OSPF6_PREFIX_SPACE(prefix->prefix_length));
|
OSPF6_PREFIX_SPACE(prefix->prefix_length));
|
||||||
inet_ntop(AF_INET6, &in6, buf, sizeof(buf));
|
inet_ntop(AF_INET6, &in6, buf, sizeof(buf));
|
||||||
vty_out(vty, " Prefix: %s/%d\n", buf,
|
if (use_json) {
|
||||||
prefix->prefix_length);
|
snprintf(prefix_string, sizeof(prefix_string), "%s/%d",
|
||||||
|
buf, prefix->prefix_length);
|
||||||
|
json_object_string_add(json_loop, "prefix",
|
||||||
|
prefix_string);
|
||||||
|
json_object_array_add(json_arr, json_loop);
|
||||||
|
} else
|
||||||
|
vty_out(vty, " Prefix: %s/%d\n", buf,
|
||||||
|
prefix->prefix_length);
|
||||||
}
|
}
|
||||||
|
if (use_json)
|
||||||
|
json_object_object_add(json_obj, "prefix", json_arr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -828,7 +904,8 @@ static char *ospf6_intra_prefix_lsa_get_prefix_str(struct ospf6_lsa *lsa,
|
|||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ospf6_intra_prefix_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
static int ospf6_intra_prefix_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
|
json_object *json_obj, bool use_json)
|
||||||
{
|
{
|
||||||
char *start, *end, *current;
|
char *start, *end, *current;
|
||||||
struct ospf6_intra_prefix_lsa *intra_prefix_lsa;
|
struct ospf6_intra_prefix_lsa *intra_prefix_lsa;
|
||||||
@ -838,6 +915,10 @@ static int ospf6_intra_prefix_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
char id[16], adv_router[16];
|
char id[16], adv_router[16];
|
||||||
const char *p, *mc, *la, *nu;
|
const char *p, *mc, *la, *nu;
|
||||||
struct in6_addr in6;
|
struct in6_addr in6;
|
||||||
|
json_object *json_loop;
|
||||||
|
json_object *json_arr = NULL;
|
||||||
|
char str[15];
|
||||||
|
char prefix_string[133];
|
||||||
|
|
||||||
intra_prefix_lsa = (struct ospf6_intra_prefix_lsa
|
intra_prefix_lsa = (struct ospf6_intra_prefix_lsa
|
||||||
*)((caddr_t)lsa->header
|
*)((caddr_t)lsa->header
|
||||||
@ -845,13 +926,25 @@ static int ospf6_intra_prefix_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
|
|
||||||
prefixnum = ntohs(intra_prefix_lsa->prefix_num);
|
prefixnum = ntohs(intra_prefix_lsa->prefix_num);
|
||||||
|
|
||||||
vty_out(vty, " Number of Prefix: %d\n", prefixnum);
|
if (use_json) {
|
||||||
|
json_arr = json_object_new_array();
|
||||||
|
json_object_int_add(json_obj, "numberOfPrefix", prefixnum);
|
||||||
|
} else
|
||||||
|
vty_out(vty, " Number of Prefix: %d\n", prefixnum);
|
||||||
|
|
||||||
inet_ntop(AF_INET, &intra_prefix_lsa->ref_id, id, sizeof(id));
|
inet_ntop(AF_INET, &intra_prefix_lsa->ref_id, id, sizeof(id));
|
||||||
inet_ntop(AF_INET, &intra_prefix_lsa->ref_adv_router, adv_router,
|
inet_ntop(AF_INET, &intra_prefix_lsa->ref_adv_router, adv_router,
|
||||||
sizeof(adv_router));
|
sizeof(adv_router));
|
||||||
vty_out(vty, " Reference: %s Id: %s Adv: %s\n",
|
if (use_json) {
|
||||||
ospf6_lstype_name(intra_prefix_lsa->ref_type), id, adv_router);
|
json_object_string_add(
|
||||||
|
json_obj, "reference",
|
||||||
|
ospf6_lstype_name(intra_prefix_lsa->ref_type));
|
||||||
|
json_object_string_add(json_obj, "referenceId", id);
|
||||||
|
json_object_string_add(json_obj, "referenceAdv", adv_router);
|
||||||
|
} else
|
||||||
|
vty_out(vty, " Reference: %s Id: %s Adv: %s\n",
|
||||||
|
ospf6_lstype_name(intra_prefix_lsa->ref_type), id,
|
||||||
|
adv_router);
|
||||||
|
|
||||||
start = (char *)intra_prefix_lsa
|
start = (char *)intra_prefix_lsa
|
||||||
+ sizeof(struct ospf6_intra_prefix_lsa);
|
+ sizeof(struct ospf6_intra_prefix_lsa);
|
||||||
@ -875,16 +968,31 @@ static int ospf6_intra_prefix_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
nu = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_NU)
|
nu = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_NU)
|
||||||
? "NU"
|
? "NU"
|
||||||
: "--");
|
: "--");
|
||||||
vty_out(vty, " Prefix Options: %s|%s|%s|%s\n", p, mc, la,
|
if (use_json) {
|
||||||
nu);
|
json_loop = json_object_new_object();
|
||||||
|
snprintf(str, sizeof(str), "%s|%s|%s|%s", p, mc, la,
|
||||||
|
nu);
|
||||||
|
json_object_string_add(json_loop, "prefixOption", str);
|
||||||
|
} else
|
||||||
|
vty_out(vty, " Prefix Options: %s|%s|%s|%s\n", p,
|
||||||
|
mc, la, nu);
|
||||||
|
|
||||||
memset(&in6, 0, sizeof(in6));
|
memset(&in6, 0, sizeof(in6));
|
||||||
memcpy(&in6, OSPF6_PREFIX_BODY(prefix),
|
memcpy(&in6, OSPF6_PREFIX_BODY(prefix),
|
||||||
OSPF6_PREFIX_SPACE(prefix->prefix_length));
|
OSPF6_PREFIX_SPACE(prefix->prefix_length));
|
||||||
inet_ntop(AF_INET6, &in6, buf, sizeof(buf));
|
inet_ntop(AF_INET6, &in6, buf, sizeof(buf));
|
||||||
vty_out(vty, " Prefix: %s/%d\n", buf,
|
if (use_json) {
|
||||||
prefix->prefix_length);
|
snprintf(prefix_string, sizeof(prefix_string), "%s/%d",
|
||||||
|
buf, prefix->prefix_length);
|
||||||
|
json_object_string_add(json_loop, "prefix",
|
||||||
|
prefix_string);
|
||||||
|
json_object_array_add(json_arr, json_loop);
|
||||||
|
} else
|
||||||
|
vty_out(vty, " Prefix: %s/%d\n", buf,
|
||||||
|
prefix->prefix_length);
|
||||||
}
|
}
|
||||||
|
if (use_json)
|
||||||
|
json_object_object_add(json_obj, "prefix", json_arr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,8 @@ struct ospf6 *ospf6_get_by_lsdb(struct ospf6_lsa *lsa)
|
|||||||
return ospf6;
|
return ospf6;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ospf6_unknown_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
static int ospf6_unknown_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
|
json_object *json_obj, bool use_json)
|
||||||
{
|
{
|
||||||
uint8_t *start, *end, *current;
|
uint8_t *start, *end, *current;
|
||||||
char byte[4];
|
char byte[4];
|
||||||
@ -74,18 +75,22 @@ static int ospf6_unknown_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
start = (uint8_t *)lsa->header + sizeof(struct ospf6_lsa_header);
|
start = (uint8_t *)lsa->header + sizeof(struct ospf6_lsa_header);
|
||||||
end = (uint8_t *)lsa->header + ntohs(lsa->header->length);
|
end = (uint8_t *)lsa->header + ntohs(lsa->header->length);
|
||||||
|
|
||||||
vty_out(vty, " Unknown contents:\n");
|
if (use_json)
|
||||||
for (current = start; current < end; current++) {
|
json_object_string_add(json_obj, "LsaType", "unknown");
|
||||||
if ((current - start) % 16 == 0)
|
else {
|
||||||
vty_out(vty, "\n ");
|
vty_out(vty, " Unknown contents:\n");
|
||||||
else if ((current - start) % 4 == 0)
|
for (current = start; current < end; current++) {
|
||||||
vty_out(vty, " ");
|
if ((current - start) % 16 == 0)
|
||||||
|
vty_out(vty, "\n ");
|
||||||
|
else if ((current - start) % 4 == 0)
|
||||||
|
vty_out(vty, " ");
|
||||||
|
|
||||||
snprintf(byte, sizeof(byte), "%02x", *current);
|
snprintf(byte, sizeof(byte), "%02x", *current);
|
||||||
vty_out(vty, "%s", byte);
|
vty_out(vty, "%s", byte);
|
||||||
|
}
|
||||||
|
|
||||||
|
vty_out(vty, "\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
vty_out(vty, "\n\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,13 +397,15 @@ void ospf6_lsa_show_summary_header(struct vty *vty)
|
|||||||
"AdvRouter", "Age", "SeqNum", "Payload");
|
"AdvRouter", "Age", "SeqNum", "Payload");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa)
|
void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
|
json_object *json_array, bool use_json)
|
||||||
{
|
{
|
||||||
char adv_router[16], id[16];
|
char adv_router[16], id[16];
|
||||||
int type;
|
int type;
|
||||||
const struct ospf6_lsa_handler *handler;
|
const struct ospf6_lsa_handler *handler;
|
||||||
char buf[64], tmpbuf[80];
|
char buf[64];
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
json_object *json_obj = NULL;
|
||||||
|
|
||||||
assert(lsa);
|
assert(lsa);
|
||||||
assert(lsa->header);
|
assert(lsa->header);
|
||||||
@ -409,34 +416,95 @@ void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
|
|
||||||
type = ntohs(lsa->header->type);
|
type = ntohs(lsa->header->type);
|
||||||
handler = ospf6_get_lsa_handler(lsa->header->type);
|
handler = ospf6_get_lsa_handler(lsa->header->type);
|
||||||
|
|
||||||
|
if (use_json)
|
||||||
|
json_obj = json_object_new_object();
|
||||||
|
|
||||||
if ((type == OSPF6_LSTYPE_INTER_PREFIX)
|
if ((type == OSPF6_LSTYPE_INTER_PREFIX)
|
||||||
|| (type == OSPF6_LSTYPE_INTER_ROUTER)
|
|| (type == OSPF6_LSTYPE_INTER_ROUTER)
|
||||||
|| (type == OSPF6_LSTYPE_AS_EXTERNAL)) {
|
|| (type == OSPF6_LSTYPE_AS_EXTERNAL)) {
|
||||||
vty_out(vty, "%-4s %-15s%-15s%4hu %8lx %30s\n",
|
if (use_json) {
|
||||||
ospf6_lstype_short_name(lsa->header->type), id,
|
json_object_string_add(
|
||||||
adv_router, ospf6_lsa_age_current(lsa),
|
json_obj, "type",
|
||||||
(unsigned long)ntohl(lsa->header->seqnum),
|
ospf6_lstype_short_name(lsa->header->type));
|
||||||
handler->lh_get_prefix_str(lsa, buf, sizeof(buf), 0));
|
json_object_string_add(json_obj, "lsId", id);
|
||||||
|
json_object_string_add(json_obj, "advRouter",
|
||||||
|
adv_router);
|
||||||
|
json_object_int_add(json_obj, "age",
|
||||||
|
ospf6_lsa_age_current(lsa));
|
||||||
|
json_object_int_add(
|
||||||
|
json_obj, "seqNum",
|
||||||
|
(unsigned long)ntohl(lsa->header->seqnum));
|
||||||
|
json_object_string_add(
|
||||||
|
json_obj, "payload",
|
||||||
|
handler->lh_get_prefix_str(lsa, buf,
|
||||||
|
sizeof(buf), 0));
|
||||||
|
json_object_array_add(json_array, json_obj);
|
||||||
|
} else
|
||||||
|
vty_out(vty, "%-4s %-15s%-15s%4hu %8lx %30s\n",
|
||||||
|
ospf6_lstype_short_name(lsa->header->type), id,
|
||||||
|
adv_router, ospf6_lsa_age_current(lsa),
|
||||||
|
(unsigned long)ntohl(lsa->header->seqnum),
|
||||||
|
handler->lh_get_prefix_str(lsa, buf,
|
||||||
|
sizeof(buf), 0));
|
||||||
} else if (type != OSPF6_LSTYPE_UNKNOWN) {
|
} else if (type != OSPF6_LSTYPE_UNKNOWN) {
|
||||||
snprintf(tmpbuf, sizeof(tmpbuf), "%-4s %-15s%-15s%4hu %8lx",
|
|
||||||
ospf6_lstype_short_name(lsa->header->type), id,
|
|
||||||
adv_router, ospf6_lsa_age_current(lsa),
|
|
||||||
(unsigned long)ntohl(lsa->header->seqnum));
|
|
||||||
|
|
||||||
while (handler->lh_get_prefix_str(lsa, buf, sizeof(buf), cnt)
|
while (handler->lh_get_prefix_str(lsa, buf, sizeof(buf), cnt)
|
||||||
!= NULL) {
|
!= NULL) {
|
||||||
vty_out(vty, "%s %30s\n", tmpbuf, buf);
|
if (use_json) {
|
||||||
|
json_object_string_add(
|
||||||
|
json_obj, "type",
|
||||||
|
ospf6_lstype_short_name(
|
||||||
|
lsa->header->type));
|
||||||
|
json_object_string_add(json_obj, "lsId", id);
|
||||||
|
json_object_string_add(json_obj, "advRouter",
|
||||||
|
adv_router);
|
||||||
|
json_object_int_add(json_obj, "age",
|
||||||
|
ospf6_lsa_age_current(lsa));
|
||||||
|
json_object_int_add(
|
||||||
|
json_obj, "seqNum",
|
||||||
|
(unsigned long)ntohl(
|
||||||
|
lsa->header->seqnum));
|
||||||
|
json_object_string_add(json_obj, "payload",
|
||||||
|
buf);
|
||||||
|
json_object_array_add(json_array, json_obj);
|
||||||
|
json_obj = json_object_new_object();
|
||||||
|
} else
|
||||||
|
vty_out(vty, "%-4s %-15s%-15s%4hu %8lx %30s\n",
|
||||||
|
ospf6_lstype_short_name(
|
||||||
|
lsa->header->type),
|
||||||
|
id, adv_router,
|
||||||
|
ospf6_lsa_age_current(lsa),
|
||||||
|
(unsigned long)ntohl(
|
||||||
|
lsa->header->seqnum),
|
||||||
|
buf);
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
|
if (use_json)
|
||||||
|
json_object_free(json_obj);
|
||||||
} else {
|
} else {
|
||||||
vty_out(vty, "%-4s %-15s%-15s%4hu %8lx\n",
|
if (use_json) {
|
||||||
ospf6_lstype_short_name(lsa->header->type), id,
|
json_object_string_add(
|
||||||
adv_router, ospf6_lsa_age_current(lsa),
|
json_obj, "type",
|
||||||
(unsigned long)ntohl(lsa->header->seqnum));
|
ospf6_lstype_short_name(lsa->header->type));
|
||||||
|
json_object_string_add(json_obj, "lsId", id);
|
||||||
|
json_object_string_add(json_obj, "advRouter",
|
||||||
|
adv_router);
|
||||||
|
json_object_int_add(json_obj, "age",
|
||||||
|
ospf6_lsa_age_current(lsa));
|
||||||
|
json_object_int_add(
|
||||||
|
json_obj, "seqNum",
|
||||||
|
(unsigned long)ntohl(lsa->header->seqnum));
|
||||||
|
json_object_array_add(json_array, json_obj);
|
||||||
|
} else
|
||||||
|
vty_out(vty, "%-4s %-15s%-15s%4hu %8lx\n",
|
||||||
|
ospf6_lstype_short_name(lsa->header->type), id,
|
||||||
|
adv_router, ospf6_lsa_age_current(lsa),
|
||||||
|
(unsigned long)ntohl(lsa->header->seqnum));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ospf6_lsa_show_dump(struct vty *vty, struct ospf6_lsa *lsa)
|
void ospf6_lsa_show_dump(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
|
json_object *json_array, bool use_json)
|
||||||
{
|
{
|
||||||
uint8_t *start, *end, *current;
|
uint8_t *start, *end, *current;
|
||||||
char byte[4];
|
char byte[4];
|
||||||
@ -444,6 +512,9 @@ void ospf6_lsa_show_dump(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
start = (uint8_t *)lsa->header;
|
start = (uint8_t *)lsa->header;
|
||||||
end = (uint8_t *)lsa->header + ntohs(lsa->header->length);
|
end = (uint8_t *)lsa->header + ntohs(lsa->header->length);
|
||||||
|
|
||||||
|
if (use_json)
|
||||||
|
return;
|
||||||
|
|
||||||
vty_out(vty, "\n");
|
vty_out(vty, "\n");
|
||||||
vty_out(vty, "%s:\n", lsa->name);
|
vty_out(vty, "%s:\n", lsa->name);
|
||||||
|
|
||||||
@ -458,12 +529,15 @@ void ospf6_lsa_show_dump(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
}
|
}
|
||||||
|
|
||||||
vty_out(vty, "\n\n");
|
vty_out(vty, "\n\n");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ospf6_lsa_show_internal(struct vty *vty, struct ospf6_lsa *lsa)
|
void ospf6_lsa_show_internal(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
|
json_object *json_array, bool use_json)
|
||||||
{
|
{
|
||||||
char adv_router[64], id[64];
|
char adv_router[64], id[64];
|
||||||
|
json_object *json_obj;
|
||||||
|
|
||||||
assert(lsa && lsa->header);
|
assert(lsa && lsa->header);
|
||||||
|
|
||||||
@ -471,30 +545,56 @@ void ospf6_lsa_show_internal(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
inet_ntop(AF_INET, &lsa->header->adv_router, adv_router,
|
inet_ntop(AF_INET, &lsa->header->adv_router, adv_router,
|
||||||
sizeof(adv_router));
|
sizeof(adv_router));
|
||||||
|
|
||||||
vty_out(vty, "\n");
|
if (use_json) {
|
||||||
vty_out(vty, "Age: %4hu Type: %s\n", ospf6_lsa_age_current(lsa),
|
json_obj = json_object_new_object();
|
||||||
ospf6_lstype_name(lsa->header->type));
|
json_object_int_add(json_obj, "age",
|
||||||
vty_out(vty, "Link State ID: %s\n", id);
|
ospf6_lsa_age_current(lsa));
|
||||||
vty_out(vty, "Advertising Router: %s\n", adv_router);
|
json_object_string_add(json_obj, "type",
|
||||||
vty_out(vty, "LS Sequence Number: %#010lx\n",
|
ospf6_lstype_name(lsa->header->type));
|
||||||
(unsigned long)ntohl(lsa->header->seqnum));
|
json_object_string_add(json_obj, "linkStateId", id);
|
||||||
vty_out(vty, "CheckSum: %#06hx Length: %hu\n",
|
json_object_string_add(json_obj, "advertisingRouter",
|
||||||
ntohs(lsa->header->checksum), ntohs(lsa->header->length));
|
adv_router);
|
||||||
vty_out(vty, "Flag: %x \n", lsa->flag);
|
json_object_int_add(json_obj, "lsSequenceNumber",
|
||||||
vty_out(vty, "Lock: %d \n", lsa->lock);
|
(unsigned long)ntohl(lsa->header->seqnum));
|
||||||
vty_out(vty, "ReTx Count: %d\n", lsa->retrans_count);
|
json_object_int_add(json_obj, "checksum",
|
||||||
vty_out(vty, "Threads: Expire: 0x%p, Refresh: 0x%p \n",
|
ntohs(lsa->header->checksum));
|
||||||
(void *)lsa->expire, (void *)lsa->refresh);
|
json_object_int_add(json_obj, "length",
|
||||||
vty_out(vty, "\n");
|
ntohs(lsa->header->length));
|
||||||
|
json_object_int_add(json_obj, "flag", lsa->flag);
|
||||||
|
json_object_int_add(json_obj, "lock", lsa->lock);
|
||||||
|
json_object_int_add(json_obj, "reTxCount", lsa->retrans_count);
|
||||||
|
|
||||||
|
/* Threads Data not added */
|
||||||
|
json_object_array_add(json_array, json_obj);
|
||||||
|
} else {
|
||||||
|
vty_out(vty, "\n");
|
||||||
|
vty_out(vty, "Age: %4hu Type: %s\n", ospf6_lsa_age_current(lsa),
|
||||||
|
ospf6_lstype_name(lsa->header->type));
|
||||||
|
vty_out(vty, "Link State ID: %s\n", id);
|
||||||
|
vty_out(vty, "Advertising Router: %s\n", adv_router);
|
||||||
|
vty_out(vty, "LS Sequence Number: %#010lx\n",
|
||||||
|
(unsigned long)ntohl(lsa->header->seqnum));
|
||||||
|
vty_out(vty, "CheckSum: %#06hx Length: %hu\n",
|
||||||
|
ntohs(lsa->header->checksum),
|
||||||
|
ntohs(lsa->header->length));
|
||||||
|
vty_out(vty, "Flag: %x \n", lsa->flag);
|
||||||
|
vty_out(vty, "Lock: %d \n", lsa->lock);
|
||||||
|
vty_out(vty, "ReTx Count: %d\n", lsa->retrans_count);
|
||||||
|
vty_out(vty, "Threads: Expire: 0x%p, Refresh: 0x%p \n",
|
||||||
|
(void *)lsa->expire, (void *)lsa->refresh);
|
||||||
|
vty_out(vty, "\n");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ospf6_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
void ospf6_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
|
json_object *json_array, bool use_json)
|
||||||
{
|
{
|
||||||
char adv_router[64], id[64];
|
char adv_router[64], id[64];
|
||||||
const struct ospf6_lsa_handler *handler;
|
const struct ospf6_lsa_handler *handler;
|
||||||
struct timeval now, res;
|
struct timeval now, res;
|
||||||
char duration[64];
|
char duration[64];
|
||||||
|
json_object *json_obj = NULL;
|
||||||
|
|
||||||
assert(lsa && lsa->header);
|
assert(lsa && lsa->header);
|
||||||
|
|
||||||
@ -505,27 +605,47 @@ void ospf6_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
|
|||||||
monotime(&now);
|
monotime(&now);
|
||||||
timersub(&now, &lsa->installed, &res);
|
timersub(&now, &lsa->installed, &res);
|
||||||
timerstring(&res, duration, sizeof(duration));
|
timerstring(&res, duration, sizeof(duration));
|
||||||
|
if (use_json) {
|
||||||
vty_out(vty, "Age: %4hu Type: %s\n", ospf6_lsa_age_current(lsa),
|
json_obj = json_object_new_object();
|
||||||
ospf6_lstype_name(lsa->header->type));
|
json_object_int_add(json_obj, "age",
|
||||||
vty_out(vty, "Link State ID: %s\n", id);
|
ospf6_lsa_age_current(lsa));
|
||||||
vty_out(vty, "Advertising Router: %s\n", adv_router);
|
json_object_string_add(json_obj, "type",
|
||||||
vty_out(vty, "LS Sequence Number: %#010lx\n",
|
ospf6_lstype_name(lsa->header->type));
|
||||||
(unsigned long)ntohl(lsa->header->seqnum));
|
json_object_string_add(json_obj, "advertisingRouter",
|
||||||
vty_out(vty, "CheckSum: %#06hx Length: %hu\n",
|
adv_router);
|
||||||
ntohs(lsa->header->checksum), ntohs(lsa->header->length));
|
json_object_int_add(json_obj, "lsSequenceNumber",
|
||||||
vty_out(vty, "Duration: %s\n", duration);
|
(unsigned long)ntohl(lsa->header->seqnum));
|
||||||
|
json_object_int_add(json_obj, "checkSum",
|
||||||
|
ntohs(lsa->header->checksum));
|
||||||
|
json_object_int_add(json_obj, "length",
|
||||||
|
ntohs(lsa->header->length));
|
||||||
|
json_object_string_add(json_obj, "duration", duration);
|
||||||
|
} else {
|
||||||
|
vty_out(vty, "Age: %4hu Type: %s\n", ospf6_lsa_age_current(lsa),
|
||||||
|
ospf6_lstype_name(lsa->header->type));
|
||||||
|
vty_out(vty, "Link State ID: %s\n", id);
|
||||||
|
vty_out(vty, "Advertising Router: %s\n", adv_router);
|
||||||
|
vty_out(vty, "LS Sequence Number: %#010lx\n",
|
||||||
|
(unsigned long)ntohl(lsa->header->seqnum));
|
||||||
|
vty_out(vty, "CheckSum: %#06hx Length: %hu\n",
|
||||||
|
ntohs(lsa->header->checksum),
|
||||||
|
ntohs(lsa->header->length));
|
||||||
|
vty_out(vty, "Duration: %s\n", duration);
|
||||||
|
}
|
||||||
|
|
||||||
handler = ospf6_get_lsa_handler(lsa->header->type);
|
handler = ospf6_get_lsa_handler(lsa->header->type);
|
||||||
|
|
||||||
if (handler->lh_show != NULL)
|
if (handler->lh_show != NULL)
|
||||||
handler->lh_show(vty, lsa);
|
handler->lh_show(vty, lsa, json_obj, use_json);
|
||||||
else {
|
else {
|
||||||
assert(unknown_handler.lh_show != NULL);
|
assert(unknown_handler.lh_show != NULL);
|
||||||
unknown_handler.lh_show(vty, lsa);
|
unknown_handler.lh_show(vty, lsa, json_obj, use_json);
|
||||||
}
|
}
|
||||||
|
|
||||||
vty_out(vty, "\n");
|
if (use_json)
|
||||||
|
json_object_array_add(json_array, json_obj);
|
||||||
|
else
|
||||||
|
vty_out(vty, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OSPFv3 LSA creation/deletion function */
|
/* OSPFv3 LSA creation/deletion function */
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#ifndef OSPF6_LSA_H
|
#ifndef OSPF6_LSA_H
|
||||||
#define OSPF6_LSA_H
|
#define OSPF6_LSA_H
|
||||||
#include "ospf6_top.h"
|
#include "ospf6_top.h"
|
||||||
|
#include "lib/json.h"
|
||||||
|
|
||||||
/* Debug option */
|
/* Debug option */
|
||||||
#define OSPF6_LSA_DEBUG 0x01
|
#define OSPF6_LSA_DEBUG 0x01
|
||||||
@ -141,9 +142,10 @@ struct ospf6_lsa_handler {
|
|||||||
uint16_t lh_type; /* host byte order */
|
uint16_t lh_type; /* host byte order */
|
||||||
const char *lh_name;
|
const char *lh_name;
|
||||||
const char *lh_short_name;
|
const char *lh_short_name;
|
||||||
int (*lh_show)(struct vty *, struct ospf6_lsa *);
|
int (*lh_show)(struct vty *, struct ospf6_lsa *, json_object *json_obj,
|
||||||
char *(*lh_get_prefix_str)(struct ospf6_lsa *, char *buf,
|
bool use_json);
|
||||||
int buflen, int pos);
|
char *(*lh_get_prefix_str)(struct ospf6_lsa *, char *buf, int buflen,
|
||||||
|
int pos);
|
||||||
|
|
||||||
uint8_t lh_debug;
|
uint8_t lh_debug;
|
||||||
};
|
};
|
||||||
@ -206,10 +208,14 @@ extern char *ospf6_lsa_printbuf(struct ospf6_lsa *lsa, char *buf, int size);
|
|||||||
extern void ospf6_lsa_header_print_raw(struct ospf6_lsa_header *header);
|
extern void ospf6_lsa_header_print_raw(struct ospf6_lsa_header *header);
|
||||||
extern void ospf6_lsa_header_print(struct ospf6_lsa *lsa);
|
extern void ospf6_lsa_header_print(struct ospf6_lsa *lsa);
|
||||||
extern void ospf6_lsa_show_summary_header(struct vty *vty);
|
extern void ospf6_lsa_show_summary_header(struct vty *vty);
|
||||||
extern void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa);
|
extern void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
extern void ospf6_lsa_show_dump(struct vty *vty, struct ospf6_lsa *lsa);
|
json_object *json, bool use_json);
|
||||||
extern void ospf6_lsa_show_internal(struct vty *vty, struct ospf6_lsa *lsa);
|
extern void ospf6_lsa_show_dump(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
extern void ospf6_lsa_show(struct vty *vty, struct ospf6_lsa *lsa);
|
json_object *json, bool use_json);
|
||||||
|
extern void ospf6_lsa_show_internal(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
|
json_object *json, bool use_json);
|
||||||
|
extern void ospf6_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||||
|
json_object *json, bool use_json);
|
||||||
|
|
||||||
extern struct ospf6_lsa *ospf6_lsa_create(struct ospf6_lsa_header *header);
|
extern struct ospf6_lsa *ospf6_lsa_create(struct ospf6_lsa_header *header);
|
||||||
extern struct ospf6_lsa *
|
extern struct ospf6_lsa *
|
||||||
|
@ -346,55 +346,6 @@ int ospf6_lsdb_maxage_remover(struct ospf6_lsdb *lsdb)
|
|||||||
return (reschedule);
|
return (reschedule);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ospf6_lsdb_show(struct vty *vty, enum ospf_lsdb_show_level level,
|
|
||||||
uint16_t *type, uint32_t *id, uint32_t *adv_router,
|
|
||||||
struct ospf6_lsdb *lsdb)
|
|
||||||
{
|
|
||||||
struct ospf6_lsa *lsa;
|
|
||||||
const struct route_node *end = NULL;
|
|
||||||
void (*showfunc)(struct vty *, struct ospf6_lsa *) = NULL;
|
|
||||||
|
|
||||||
switch (level) {
|
|
||||||
case OSPF6_LSDB_SHOW_LEVEL_DETAIL:
|
|
||||||
showfunc = ospf6_lsa_show;
|
|
||||||
break;
|
|
||||||
case OSPF6_LSDB_SHOW_LEVEL_INTERNAL:
|
|
||||||
showfunc = ospf6_lsa_show_internal;
|
|
||||||
break;
|
|
||||||
case OSPF6_LSDB_SHOW_LEVEL_DUMP:
|
|
||||||
showfunc = ospf6_lsa_show_dump;
|
|
||||||
break;
|
|
||||||
case OSPF6_LSDB_SHOW_LEVEL_NORMAL:
|
|
||||||
default:
|
|
||||||
showfunc = ospf6_lsa_show_summary;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type && id && adv_router) {
|
|
||||||
lsa = ospf6_lsdb_lookup(*type, *id, *adv_router, lsdb);
|
|
||||||
if (lsa) {
|
|
||||||
if (level == OSPF6_LSDB_SHOW_LEVEL_NORMAL)
|
|
||||||
ospf6_lsa_show(vty, lsa);
|
|
||||||
else
|
|
||||||
(*showfunc)(vty, lsa);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (level == OSPF6_LSDB_SHOW_LEVEL_NORMAL)
|
|
||||||
ospf6_lsa_show_summary_header(vty);
|
|
||||||
|
|
||||||
end = ospf6_lsdb_head(lsdb, !!type + !!(type && adv_router),
|
|
||||||
type ? *type : 0, adv_router ? *adv_router : 0,
|
|
||||||
&lsa);
|
|
||||||
while (lsa) {
|
|
||||||
if ((!adv_router || lsa->header->adv_router == *adv_router)
|
|
||||||
&& (!id || lsa->header->id == *id))
|
|
||||||
(*showfunc)(vty, lsa);
|
|
||||||
|
|
||||||
lsa = ospf6_lsdb_next(end, lsa);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t ospf6_new_ls_id(uint16_t type, uint32_t adv_router,
|
uint32_t ospf6_new_ls_id(uint16_t type, uint32_t adv_router,
|
||||||
struct ospf6_lsdb *lsdb)
|
struct ospf6_lsdb *lsdb)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +92,8 @@ enum ospf_lsdb_show_level {
|
|||||||
|
|
||||||
extern void ospf6_lsdb_show(struct vty *vty, enum ospf_lsdb_show_level level,
|
extern void ospf6_lsdb_show(struct vty *vty, enum ospf_lsdb_show_level level,
|
||||||
uint16_t *type, uint32_t *id, uint32_t *adv_router,
|
uint16_t *type, uint32_t *id, uint32_t *adv_router,
|
||||||
struct ospf6_lsdb *lsdb);
|
struct ospf6_lsdb *lsdb, json_object *json,
|
||||||
|
bool use_json);
|
||||||
|
|
||||||
extern uint32_t ospf6_new_ls_id(uint16_t type, uint32_t adv_router,
|
extern uint32_t ospf6_new_ls_id(uint16_t type, uint32_t adv_router,
|
||||||
struct ospf6_lsdb *lsdb);
|
struct ospf6_lsdb *lsdb);
|
||||||
|
766
ospf6d/ospf6d.c
766
ospf6d/ospf6d.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user