summaryrefslogtreecommitdiff
path: root/ospf6d
diff options
context:
space:
mode:
Diffstat (limited to 'ospf6d')
-rw-r--r--ospf6d/ospf6_abr.c13
-rw-r--r--ospf6d/ospf6_asbr.c46
-rw-r--r--ospf6d/ospf6_bfd.c5
-rw-r--r--ospf6d/ospf6_bfd.h6
-rw-r--r--ospf6d/ospf6_interface.c2
-rw-r--r--ospf6d/ospf6_neighbor.c442
-rw-r--r--ospf6d/ospf6_neighbor.h2
7 files changed, 364 insertions, 152 deletions
diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c
index f087289df6..c71b30a2d4 100644
--- a/ospf6d/ospf6_abr.c
+++ b/ospf6d/ospf6_abr.c
@@ -196,7 +196,7 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (ADV_ROUTER_IN_PREFIX(&route->prefix)
== area->ospf6->router_id) {
zlog_debug(
- "%s: Skipping ASBR announcement for ABR (%pFX)",
+ "%s: Skipping ASBR announcement for ABR (%pI4)",
__func__,
&ADV_ROUTER_IN_PREFIX(&route->prefix));
return 0;
@@ -208,7 +208,7 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
|| IS_OSPF6_DEBUG_ORIGINATE(INTER_ROUTER)) {
is_debug++;
zlog_debug(
- "Originating summary in area %s for ASBR %pFX",
+ "Originating summary in area %s for ASBR %pI4",
area->name,
&ADV_ROUTER_IN_PREFIX(&route->prefix));
}
@@ -225,9 +225,7 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (is_debug)
zlog_debug(
"%s: route %pFX with cost %u is not best, ignore.",
- __func__,
- &ADV_ROUTER_IN_PREFIX(
- &route->prefix),
+ __func__, &route->prefix,
route->path.cost);
return 0;
}
@@ -405,8 +403,7 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (is_debug)
zlog_debug(
"prefix %pFX was denied by export list",
- &ADV_ROUTER_IN_PREFIX(
- &route->prefix));
+ &route->prefix);
return 0;
}
}
@@ -418,7 +415,7 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
if (is_debug)
zlog_debug(
"prefix %pFX was denied by filter-list out",
- &ADV_ROUTER_IN_PREFIX(&route->prefix));
+ &route->prefix);
return 0;
}
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c
index c053716f26..1d222d5568 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -1095,8 +1095,7 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
tinfo.ifindex = ifindex;
tinfo.tag = tag;
- ret = route_map_apply(ospf6->rmap[type].map, prefix, RMAP_OSPF6,
- &troute);
+ ret = route_map_apply(ospf6->rmap[type].map, prefix, &troute);
if (ret == RMAP_DENYMATCH) {
if (IS_OSPF6_DEBUG_ASBR)
zlog_debug("Denied by route-map \"%s\"",
@@ -1400,14 +1399,11 @@ static void ospf6_redistribute_show_config(struct vty *vty, struct ospf6 *ospf6)
static enum route_map_cmd_result_t
ospf6_routemap_rule_match_address_prefixlist(void *rule,
const struct prefix *prefix,
- route_map_object_t type,
+
void *object)
{
struct prefix_list *plist;
- if (type != RMAP_OSPF6)
- return RMAP_NOMATCH;
-
plist = prefix_list_lookup(AFI_IP6, (char *)rule);
if (plist == NULL)
return RMAP_NOMATCH;
@@ -1440,18 +1436,16 @@ static const struct route_map_rule_cmd
zero. */
static enum route_map_cmd_result_t
ospf6_routemap_rule_match_interface(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
struct interface *ifp;
struct ospf6_external_info *ei;
- if (type == RMAP_OSPF6) {
- ei = ((struct ospf6_route *)object)->route_option;
- ifp = if_lookup_by_name_all_vrf((char *)rule);
+ ei = ((struct ospf6_route *)object)->route_option;
+ ifp = if_lookup_by_name_all_vrf((char *)rule);
- if (ifp != NULL && ei->ifindex == ifp->ifindex)
- return RMAP_MATCH;
- }
+ if (ifp != NULL && ei->ifindex == ifp->ifindex)
+ return RMAP_MATCH;
return RMAP_NOMATCH;
}
@@ -1480,14 +1474,13 @@ static const struct route_map_rule_cmd
/* Match function for matching route tags */
static enum route_map_cmd_result_t
-ospf6_routemap_rule_match_tag(void *rule, const struct prefix *p,
- route_map_object_t type, void *object)
+ospf6_routemap_rule_match_tag(void *rule, const struct prefix *p, void *object)
{
route_tag_t *tag = rule;
struct ospf6_route *route = object;
struct ospf6_external_info *info = route->route_option;
- if (type == RMAP_OSPF6 && info->tag == *tag)
+ if (info->tag == *tag)
return RMAP_MATCH;
return RMAP_NOMATCH;
@@ -1503,14 +1496,11 @@ static const struct route_map_rule_cmd
static enum route_map_cmd_result_t
ospf6_routemap_rule_set_metric_type(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
char *metric_type = rule;
struct ospf6_route *route = object;
- if (type != RMAP_OSPF6)
- return RMAP_OKAY;
-
if (strcmp(metric_type, "type-2") == 0)
route->path.metric_type = 2;
else
@@ -1541,14 +1531,11 @@ static const struct route_map_rule_cmd
static enum route_map_cmd_result_t
ospf6_routemap_rule_set_metric(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
char *metric = rule;
struct ospf6_route *route = object;
- if (type != RMAP_OSPF6)
- return RMAP_OKAY;
-
route->path.cost = atoi(metric);
return RMAP_OKAY;
}
@@ -1578,15 +1565,12 @@ static const struct route_map_rule_cmd
static enum route_map_cmd_result_t
ospf6_routemap_rule_set_forwarding(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
char *forwarding = rule;
struct ospf6_route *route = object;
struct ospf6_external_info *info = route->route_option;
- if (type != RMAP_OSPF6)
- return RMAP_OKAY;
-
if (inet_pton(AF_INET6, forwarding, &info->forwarding) != 1) {
memset(&info->forwarding, 0, sizeof(struct in6_addr));
return RMAP_ERROR;
@@ -1617,16 +1601,12 @@ static const struct route_map_rule_cmd
};
static enum route_map_cmd_result_t
-ospf6_routemap_rule_set_tag(void *rule, const struct prefix *p,
- route_map_object_t type, void *object)
+ospf6_routemap_rule_set_tag(void *rule, const struct prefix *p, void *object)
{
route_tag_t *tag = rule;
struct ospf6_route *route = object;
struct ospf6_external_info *info = route->route_option;
- if (type != RMAP_OSPF6)
- return RMAP_OKAY;
-
info->tag = *tag;
return RMAP_OKAY;
}
diff --git a/ospf6d/ospf6_bfd.c b/ospf6d/ospf6_bfd.c
index 4e50ab5244..523ed7f181 100644
--- a/ospf6d/ospf6_bfd.c
+++ b/ospf6d/ospf6_bfd.c
@@ -55,12 +55,13 @@ void ospf6_bfd_info_free(void **bfd_info)
/*
* ospf6_bfd_show_info - Show BFD info structure
*/
-void ospf6_bfd_show_info(struct vty *vty, void *bfd_info, int param_only)
+void ospf6_bfd_show_info(struct vty *vty, void *bfd_info, int param_only,
+ json_object *json_obj, bool use_json)
{
if (param_only)
bfd_show_param(vty, bfd_info, 1, 0, 0, NULL);
else
- bfd_show_info(vty, bfd_info, 0, 1, 0, NULL);
+ bfd_show_info(vty, bfd_info, 0, 1, use_json, json_obj);
}
/*
diff --git a/ospf6d/ospf6_bfd.h b/ospf6d/ospf6_bfd.h
index 19dff1ff7c..b4e798e911 100644
--- a/ospf6d/ospf6_bfd.h
+++ b/ospf6d/ospf6_bfd.h
@@ -19,7 +19,7 @@
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
+#include "lib/json.h"
#ifndef OSPF6_BFD_H
#define OSPF6_BFD_H
@@ -35,8 +35,8 @@ extern void ospf6_bfd_info_nbr_create(struct ospf6_interface *oi,
extern void ospf6_bfd_info_free(void **bfd_info);
-extern void ospf6_bfd_show_info(struct vty *vty, void *bfd_info,
- int param_only);
+extern void ospf6_bfd_show_info(struct vty *vty, void *bfd_info, int param_only,
+ json_object *json_obj, bool use_json);
extern void ospf6_bfd_reg_dereg_nbr(struct ospf6_neighbor *on, int command);
#endif /* OSPF6_BFD_H */
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 75917b9d85..2d1b5e7b5a 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -996,7 +996,7 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp)
(oi->thread_send_lsack ? "on" : "off"));
for (ALL_LSDB(oi->lsack_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);
- ospf6_bfd_show_info(vty, oi->bfd_info, 1);
+ ospf6_bfd_show_info(vty, oi->bfd_info, 1, NULL, false);
return 0;
}
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c
index 9f13ecffa1..c1905e8c1e 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -44,6 +44,7 @@
#include "ospf6_lsa.h"
#include "ospf6_spf.h"
#include "ospf6_zebra.h"
+#include "lib/json.h"
DEFINE_HOOK(ospf6_neighbor_change,
(struct ospf6_neighbor * on, int state, int next_state),
@@ -595,7 +596,8 @@ int inactivity_timer(struct thread *thread)
/* vty functions */
/* show neighbor structure */
-static void ospf6_neighbor_show(struct vty *vty, struct ospf6_neighbor *on)
+static void ospf6_neighbor_show(struct vty *vty, struct ospf6_neighbor *on,
+ json_object *json_array, bool use_json)
{
char router_id[16];
char duration[64];
@@ -603,6 +605,7 @@ static void ospf6_neighbor_show(struct vty *vty, struct ospf6_neighbor *on)
char nstate[16];
char deadtime[64];
long h, m, s;
+ json_object *json_route;
/* Router-ID (Name) */
inet_ntop(AF_INET, &on->router_id, router_id, sizeof(router_id));
@@ -641,23 +644,43 @@ static void ospf6_neighbor_show(struct vty *vty, struct ospf6_neighbor *on)
/*
vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]\n",
- "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration",
- "I/F", "State");
+ "Neighbor ID", "Pri", "DeadTime", "State", "IfState",
+ "Duration", "I/F", "State");
*/
-
- vty_out(vty, "%-15s %3d %11s %8s/%-12s %11s %s[%s]\n", router_id,
- on->priority, deadtime, ospf6_neighbor_state_str[on->state],
- nstate, duration, on->ospf6_if->interface->name,
- ospf6_interface_state_str[on->ospf6_if->state]);
+ if (use_json) {
+ json_route = json_object_new_object();
+
+ json_object_string_add(json_route, "neighborId", router_id);
+ json_object_int_add(json_route, "priority", on->priority);
+ json_object_string_add(json_route, "deadTime", deadtime);
+ json_object_string_add(json_route, "state",
+ ospf6_neighbor_state_str[on->state]);
+ json_object_string_add(json_route, "ifState", nstate);
+ json_object_string_add(json_route, "duration", duration);
+ json_object_string_add(json_route, "interfaceName",
+ on->ospf6_if->interface->name);
+ json_object_string_add(
+ json_route, "interfaceState",
+ ospf6_interface_state_str[on->ospf6_if->state]);
+
+ json_object_array_add(json_array, json_route);
+ } else
+ vty_out(vty, "%-15s %3d %11s %8s/%-12s %11s %s[%s]\n",
+ router_id, on->priority, deadtime,
+ ospf6_neighbor_state_str[on->state], nstate, duration,
+ on->ospf6_if->interface->name,
+ ospf6_interface_state_str[on->ospf6_if->state]);
}
static void ospf6_neighbor_show_drchoice(struct vty *vty,
- struct ospf6_neighbor *on)
+ struct ospf6_neighbor *on,
+ json_object *json_array, bool use_json)
{
char router_id[16];
char drouter[16], bdrouter[16];
char duration[64];
struct timeval now, res;
+ json_object *json_route;
/*
vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]\n",
@@ -673,19 +696,39 @@ static void ospf6_neighbor_show_drchoice(struct vty *vty,
timersub(&now, &on->last_changed, &res);
timerstring(&res, duration, sizeof(duration));
- vty_out(vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", router_id,
- ospf6_neighbor_state_str[on->state], duration, drouter,
- bdrouter, on->ospf6_if->interface->name,
- ospf6_interface_state_str[on->ospf6_if->state]);
+ if (use_json) {
+ json_route = json_object_new_object();
+ json_object_string_add(json_route, "routerId", router_id);
+ json_object_string_add(json_route, "state",
+ ospf6_neighbor_state_str[on->state]);
+ json_object_string_add(json_route, "duration", duration);
+ json_object_string_add(json_route, "dRouter", drouter);
+ json_object_string_add(json_route, "bdRouter", bdrouter);
+ json_object_string_add(json_route, "interfaceName",
+ on->ospf6_if->interface->name);
+ json_object_string_add(
+ json_route, "interfaceState",
+ ospf6_interface_state_str[on->ospf6_if->state]);
+
+ json_object_array_add(json_array, json_route);
+ } else
+ vty_out(vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", router_id,
+ ospf6_neighbor_state_str[on->state], duration, drouter,
+ bdrouter, on->ospf6_if->interface->name,
+ ospf6_interface_state_str[on->ospf6_if->state]);
}
static void ospf6_neighbor_show_detail(struct vty *vty,
- struct ospf6_neighbor *on)
+ struct ospf6_neighbor *on,
+ json_object *json, bool use_json)
{
char drouter[16], bdrouter[16];
char linklocal_addr[64], duration[32];
struct timeval now, res;
struct ospf6_lsa *lsa, *lsanext;
+ json_object *json_neighbor;
+ json_object *json_array;
+ char db_desc_str[20];
inet_ntop(AF_INET6, &on->linklocal_addr, linklocal_addr,
sizeof(linklocal_addr));
@@ -696,149 +739,333 @@ static void ospf6_neighbor_show_detail(struct vty *vty,
timersub(&now, &on->last_changed, &res);
timerstring(&res, duration, sizeof(duration));
- vty_out(vty, " Neighbor %s\n", on->name);
- vty_out(vty, " Area %s via interface %s (ifindex %d)\n",
- on->ospf6_if->area->name, on->ospf6_if->interface->name,
- on->ospf6_if->interface->ifindex);
- vty_out(vty, " His IfIndex: %d Link-local address: %s\n",
- on->ifindex, linklocal_addr);
- vty_out(vty, " State %s for a duration of %s\n",
- ospf6_neighbor_state_str[on->state], duration);
- vty_out(vty, " His choice of DR/BDR %s/%s, Priority %d\n", drouter,
- bdrouter, on->priority);
- vty_out(vty, " DbDesc status: %s%s%s SeqNum: %#lx\n",
- (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial "
- : ""),
- (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""),
- (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ? "Master"
- : "Slave"),
- (unsigned long)ntohl(on->dbdesc_seqnum));
-
- vty_out(vty, " Summary-List: %d LSAs\n", on->summary_list->count);
- for (ALL_LSDB(on->summary_list, lsa, lsanext))
- vty_out(vty, " %s\n", lsa->name);
-
- vty_out(vty, " Request-List: %d LSAs\n", on->request_list->count);
- for (ALL_LSDB(on->request_list, lsa, lsanext))
- vty_out(vty, " %s\n", lsa->name);
-
- vty_out(vty, " Retrans-List: %d LSAs\n", on->retrans_list->count);
- for (ALL_LSDB(on->retrans_list, lsa, lsanext))
- vty_out(vty, " %s\n", lsa->name);
-
- timerclear(&res);
- if (on->thread_send_dbdesc)
- timersub(&on->thread_send_dbdesc->u.sands, &now, &res);
- timerstring(&res, duration, sizeof(duration));
- vty_out(vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]\n",
- on->dbdesc_list->count, duration,
- (on->thread_send_dbdesc ? "on" : "off"));
- for (ALL_LSDB(on->dbdesc_list, lsa, lsanext))
- vty_out(vty, " %s\n", lsa->name);
-
- timerclear(&res);
- if (on->thread_send_lsreq)
- timersub(&on->thread_send_lsreq->u.sands, &now, &res);
- timerstring(&res, duration, sizeof(duration));
- vty_out(vty, " %d Pending LSAs for LSReq in Time %s [thread %s]\n",
- on->request_list->count, duration,
- (on->thread_send_lsreq ? "on" : "off"));
- for (ALL_LSDB(on->request_list, lsa, lsanext))
- vty_out(vty, " %s\n", lsa->name);
-
- timerclear(&res);
- if (on->thread_send_lsupdate)
- timersub(&on->thread_send_lsupdate->u.sands, &now, &res);
- timerstring(&res, duration, sizeof(duration));
- vty_out(vty,
- " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
- on->lsupdate_list->count, duration,
- (on->thread_send_lsupdate ? "on" : "off"));
- for (ALL_LSDB(on->lsupdate_list, lsa, lsanext))
- vty_out(vty, " %s\n", lsa->name);
-
- timerclear(&res);
- if (on->thread_send_lsack)
- timersub(&on->thread_send_lsack->u.sands, &now, &res);
- timerstring(&res, duration, sizeof(duration));
- vty_out(vty, " %d Pending LSAs for LSAck in Time %s [thread %s]\n",
- on->lsack_list->count, duration,
- (on->thread_send_lsack ? "on" : "off"));
- for (ALL_LSDB(on->lsack_list, lsa, lsanext))
- vty_out(vty, " %s\n", lsa->name);
-
- ospf6_bfd_show_info(vty, on->bfd_info, 0);
+ if (use_json) {
+ json_neighbor = json_object_new_object();
+ json_object_string_add(json_neighbor, "area",
+ on->ospf6_if->area->name);
+ json_object_string_add(json_neighbor, "interface",
+ on->ospf6_if->interface->name);
+ json_object_int_add(json_neighbor, "interfaceIndex",
+ on->ospf6_if->interface->ifindex);
+ json_object_int_add(json_neighbor, "neighborInterfaceIndex",
+ on->ifindex);
+ json_object_string_add(json_neighbor, "linkLocalAddress",
+ linklocal_addr);
+ json_object_string_add(json_neighbor, "neighborState",
+ ospf6_neighbor_state_str[on->state]);
+ json_object_string_add(json_neighbor, "neighborStateDuration",
+ duration);
+ json_object_string_add(json_neighbor, "neighborDRouter",
+ drouter);
+ json_object_string_add(json_neighbor, "neighborBdRouter",
+ bdrouter);
+ snprintf(db_desc_str, sizeof(db_desc_str), "%s%s%s",
+ (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT)
+ ? "Initial "
+ : ""),
+ (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT)
+ ? "More"
+ : ""),
+ (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT)
+ ? "Master"
+ : "Slave"));
+ json_object_string_add(json_neighbor, "dbDescStatus",
+ db_desc_str);
+
+ json_object_int_add(json_neighbor, "dbDescSeqNumber",
+ (unsigned long)ntohl(on->dbdesc_seqnum));
+
+ json_array = json_object_new_array();
+ json_object_int_add(json_neighbor, "summaryListCount",
+ on->summary_list->count);
+ for (ALL_LSDB(on->summary_list, lsa, lsanext))
+ json_object_array_add(
+ json_array, json_object_new_string(lsa->name));
+ json_object_object_add(json_neighbor, "summaryListLsa",
+ json_array);
+
+ json_array = json_object_new_array();
+ json_object_int_add(json_neighbor, "requestListCount",
+ on->request_list->count);
+ for (ALL_LSDB(on->request_list, lsa, lsanext))
+ json_object_array_add(
+ json_array, json_object_new_string(lsa->name));
+ json_object_object_add(json_neighbor, "requestListLsa",
+ json_array);
+
+ json_array = json_object_new_array();
+ json_object_int_add(json_neighbor, "reTransListCount",
+ on->retrans_list->count);
+ for (ALL_LSDB(on->retrans_list, lsa, lsanext))
+ json_object_array_add(
+ json_array, json_object_new_string(lsa->name));
+ json_object_object_add(json_neighbor, "reTransListLsa",
+ json_array);
+
+
+ timerclear(&res);
+ if (on->thread_send_dbdesc)
+ timersub(&on->thread_send_dbdesc->u.sands, &now, &res);
+ timerstring(&res, duration, sizeof(duration));
+ json_object_int_add(json_neighbor, "pendingLsaDbDescCount",
+ on->dbdesc_list->count);
+ json_object_string_add(json_neighbor, "pendingLsaDbDescTime",
+ duration);
+ json_object_string_add(json_neighbor, "dbDescSendThread",
+ (on->thread_send_dbdesc ? "on" : "off"));
+ json_array = json_object_new_array();
+ for (ALL_LSDB(on->dbdesc_list, lsa, lsanext))
+ json_object_array_add(
+ json_array, json_object_new_string(lsa->name));
+ json_object_object_add(json_neighbor, "pendingLsaDbDesc",
+ json_array);
+
+ timerclear(&res);
+ if (on->thread_send_lsreq)
+ timersub(&on->thread_send_lsreq->u.sands, &now, &res);
+ timerstring(&res, duration, sizeof(duration));
+ json_object_int_add(json_neighbor, "pendingLsaLsReqCount",
+ on->request_list->count);
+ json_object_string_add(json_neighbor, "pendingLsaLsReqTime",
+ duration);
+ json_object_string_add(json_neighbor, "lsReqSendThread",
+ (on->thread_send_lsreq ? "on" : "off"));
+ json_array = json_object_new_array();
+ for (ALL_LSDB(on->request_list, lsa, lsanext))
+ json_object_array_add(
+ json_array, json_object_new_string(lsa->name));
+ json_object_object_add(json_neighbor, "pendingLsaLsReq",
+ json_array);
+
+
+ timerclear(&res);
+ if (on->thread_send_lsupdate)
+ timersub(&on->thread_send_lsupdate->u.sands, &now,
+ &res);
+ timerstring(&res, duration, sizeof(duration));
+ json_object_int_add(json_neighbor, "pendingLsaLsUpdateCount",
+ on->lsupdate_list->count);
+ json_object_string_add(json_neighbor, "pendingLsaLsUpdateTime",
+ duration);
+ json_object_string_add(
+ json_neighbor, "lsUpdateSendThread",
+ (on->thread_send_lsupdate ? "on" : "off"));
+ json_array = json_object_new_array();
+ for (ALL_LSDB(on->lsupdate_list, lsa, lsanext))
+ json_object_array_add(
+ json_array, json_object_new_string(lsa->name));
+ json_object_object_add(json_neighbor, "pendingLsaLsUpdate",
+ json_array);
+
+ timerclear(&res);
+ if (on->thread_send_lsack)
+ timersub(&on->thread_send_lsack->u.sands, &now, &res);
+ timerstring(&res, duration, sizeof(duration));
+ json_object_int_add(json_neighbor, "pendingLsaLsAckCount",
+ on->lsack_list->count);
+ json_object_string_add(json_neighbor, "pendingLsaLsAckTime",
+ duration);
+ json_object_string_add(json_neighbor, "lsAckSendThread",
+ (on->thread_send_lsack ? "on" : "off"));
+ json_array = json_object_new_array();
+ for (ALL_LSDB(on->lsack_list, lsa, lsanext))
+ json_object_array_add(
+ json_array, json_object_new_string(lsa->name));
+ json_object_object_add(json_neighbor, "pendingLsaLsAck",
+ json_array);
+
+ ospf6_bfd_show_info(vty, on->bfd_info, 0, json_neighbor,
+ use_json);
+
+ json_object_object_add(json, on->name, json_neighbor);
+
+
+ } else {
+ vty_out(vty, " Neighbor %s\n", on->name);
+ vty_out(vty, " Area %s via interface %s (ifindex %d)\n",
+ on->ospf6_if->area->name, on->ospf6_if->interface->name,
+ on->ospf6_if->interface->ifindex);
+ vty_out(vty, " His IfIndex: %d Link-local address: %s\n",
+ on->ifindex, linklocal_addr);
+ vty_out(vty, " State %s for a duration of %s\n",
+ ospf6_neighbor_state_str[on->state], duration);
+ vty_out(vty, " His choice of DR/BDR %s/%s, Priority %d\n",
+ drouter, bdrouter, on->priority);
+ vty_out(vty, " DbDesc status: %s%s%s SeqNum: %#lx\n",
+ (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT)
+ ? "Initial "
+ : ""),
+ (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT)
+ ? "More "
+ : ""),
+ (CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT)
+ ? "Master"
+ : "Slave"),
+ (unsigned long)ntohl(on->dbdesc_seqnum));
+
+ vty_out(vty, " Summary-List: %d LSAs\n",
+ on->summary_list->count);
+ for (ALL_LSDB(on->summary_list, lsa, lsanext))
+ vty_out(vty, " %s\n", lsa->name);
+
+ vty_out(vty, " Request-List: %d LSAs\n",
+ on->request_list->count);
+ for (ALL_LSDB(on->request_list, lsa, lsanext))
+ vty_out(vty, " %s\n", lsa->name);
+
+ vty_out(vty, " Retrans-List: %d LSAs\n",
+ on->retrans_list->count);
+ for (ALL_LSDB(on->retrans_list, lsa, lsanext))
+ vty_out(vty, " %s\n", lsa->name);
+
+ timerclear(&res);
+ if (on->thread_send_dbdesc)
+ timersub(&on->thread_send_dbdesc->u.sands, &now, &res);
+ timerstring(&res, duration, sizeof(duration));
+ vty_out(vty,
+ " %d Pending LSAs for DbDesc in Time %s [thread %s]\n",
+ on->dbdesc_list->count, duration,
+ (on->thread_send_dbdesc ? "on" : "off"));
+ for (ALL_LSDB(on->dbdesc_list, lsa, lsanext))
+ vty_out(vty, " %s\n", lsa->name);
+
+ timerclear(&res);
+ if (on->thread_send_lsreq)
+ timersub(&on->thread_send_lsreq->u.sands, &now, &res);
+ timerstring(&res, duration, sizeof(duration));
+ vty_out(vty,
+ " %d Pending LSAs for LSReq in Time %s [thread %s]\n",
+ on->request_list->count, duration,
+ (on->thread_send_lsreq ? "on" : "off"));
+ for (ALL_LSDB(on->request_list, lsa, lsanext))
+ vty_out(vty, " %s\n", lsa->name);
+
+ timerclear(&res);
+ if (on->thread_send_lsupdate)
+ timersub(&on->thread_send_lsupdate->u.sands, &now,
+ &res);
+ timerstring(&res, duration, sizeof(duration));
+ vty_out(vty,
+ " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
+ on->lsupdate_list->count, duration,
+ (on->thread_send_lsupdate ? "on" : "off"));
+ for (ALL_LSDB(on->lsupdate_list, lsa, lsanext))
+ vty_out(vty, " %s\n", lsa->name);
+
+ timerclear(&res);
+ if (on->thread_send_lsack)
+ timersub(&on->thread_send_lsack->u.sands, &now, &res);
+ timerstring(&res, duration, sizeof(duration));
+ vty_out(vty,
+ " %d Pending LSAs for LSAck in Time %s [thread %s]\n",
+ on->lsack_list->count, duration,
+ (on->thread_send_lsack ? "on" : "off"));
+ for (ALL_LSDB(on->lsack_list, lsa, lsanext))
+ vty_out(vty, " %s\n", lsa->name);
+
+ ospf6_bfd_show_info(vty, on->bfd_info, 0, NULL, use_json);
+ }
}
DEFUN (show_ipv6_ospf6_neighbor,
show_ipv6_ospf6_neighbor_cmd,
- "show ipv6 ospf6 neighbor [<detail|drchoice>]",
+ "show ipv6 ospf6 neighbor [<detail|drchoice>] [json]",
SHOW_STR
IP6_STR
OSPF6_STR
"Neighbor list\n"
"Display details\n"
- "Display DR choices\n")
+ "Display DR choices\n"
+ JSON_STR)
{
int idx_type = 4;
struct ospf6_neighbor *on;
struct ospf6_interface *oi;
struct ospf6_area *oa;
struct listnode *i, *j, *k;
- void (*showfunc)(struct vty *, struct ospf6_neighbor *);
struct ospf6 *ospf6;
+ json_object *json = NULL;
+ json_object *json_array = NULL;
+ bool uj = use_json(argc, argv);
+ void (*showfunc)(struct vty *, struct ospf6_neighbor *,
+ json_object *json, bool use_json);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
showfunc = ospf6_neighbor_show;
- if (argc == 5) {
+ if ((uj && argc == 6) || (!uj && argc == 5)) {
if (!strncmp(argv[idx_type]->arg, "de", 2))
showfunc = ospf6_neighbor_show_detail;
else if (!strncmp(argv[idx_type]->arg, "dr", 2))
showfunc = ospf6_neighbor_show_drchoice;
}
- if (showfunc == ospf6_neighbor_show)
- vty_out(vty, "%-15s %3s %11s %8s/%-12s %11s %s[%s]\n",
- "Neighbor ID", "Pri", "DeadTime", "State", "IfState",
- "Duration", "I/F", "State");
- else if (showfunc == ospf6_neighbor_show_drchoice)
- vty_out(vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n", "RouterID",
- "State", "Duration", "DR", "BDR", "I/F", "State");
+ if (uj) {
+ json = json_object_new_object();
+ json_array = json_object_new_array();
+ } else {
+ if (showfunc == ospf6_neighbor_show)
+ vty_out(vty, "%-15s %3s %11s %8s/%-12s %11s %s[%s]\n",
+ "Neighbor ID", "Pri", "DeadTime", "State",
+ "IfState", "Duration", "I/F", "State");
+ else if (showfunc == ospf6_neighbor_show_drchoice)
+ vty_out(vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]\n",
+ "RouterID", "State", "Duration", "DR", "BDR",
+ "I/F", "State");
+ }
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa))
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi))
- for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on))
- (*showfunc)(vty, on);
-
+ for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on)) {
+ if (showfunc == ospf6_neighbor_show_detail)
+ (*showfunc)(vty, on, json, uj);
+ else
+ (*showfunc)(vty, on, json_array, uj);
+ }
+
+ if (uj) {
+ if (showfunc != ospf6_neighbor_show_detail)
+ json_object_object_add(json, "neighbors", json_array);
+ else
+ json_object_free(json_array);
+ vty_out(vty, "%s\n",
+ json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
+ json_object_free(json);
+ }
return CMD_SUCCESS;
}
DEFUN (show_ipv6_ospf6_neighbor_one,
show_ipv6_ospf6_neighbor_one_cmd,
- "show ipv6 ospf6 neighbor A.B.C.D",
+ "show ipv6 ospf6 neighbor A.B.C.D [json]",
SHOW_STR
IP6_STR
OSPF6_STR
"Neighbor list\n"
"Specify Router-ID as IPv4 address notation\n"
- )
+ JSON_STR)
{
int idx_ipv4 = 4;
struct ospf6_neighbor *on;
struct ospf6_interface *oi;
struct ospf6_area *oa;
struct listnode *i, *j, *k;
- void (*showfunc)(struct vty *, struct ospf6_neighbor *);
+ void (*showfunc)(struct vty *, struct ospf6_neighbor *,
+ json_object *json, bool use_json);
uint32_t router_id;
struct ospf6 *ospf6;
+ json_object *json = NULL;
+ bool uj = use_json(argc, argv);
ospf6 = ospf6_lookup_by_vrf_name(VRF_DEFAULT_NAME);
OSPF6_CMD_CHECK_RUNNING(ospf6);
showfunc = ospf6_neighbor_show_detail;
+ if (uj)
+ json = json_object_new_object();
if ((inet_pton(AF_INET, argv[idx_ipv4]->arg, &router_id)) != 1) {
vty_out(vty, "Router-ID is not parsable: %s\n",
@@ -849,8 +1076,15 @@ DEFUN (show_ipv6_ospf6_neighbor_one,
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, i, oa))
for (ALL_LIST_ELEMENTS_RO(oa->if_list, j, oi))
for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, k, on))
- (*showfunc)(vty, on);
+ (*showfunc)(vty, on, json, uj);
+
+ if (uj) {
+ vty_out(vty, "%s\n",
+ json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
+ json_object_free(json);
+ }
return CMD_SUCCESS;
}
diff --git a/ospf6d/ospf6_neighbor.h b/ospf6d/ospf6_neighbor.h
index 1a45a1966a..94300ff2ba 100644
--- a/ospf6d/ospf6_neighbor.h
+++ b/ospf6d/ospf6_neighbor.h
@@ -64,7 +64,7 @@ struct ospf6_neighbor {
/* Options field (Capability) */
char options[3];
- /* IPaddr of I/F on our side link */
+ /* IPaddr of I/F on neighbour's link */
struct in6_addr linklocal_addr;
/* For Database Exchange */