}
static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue,
- uint8_t *root_sysid)
+ uint8_t *root_sysid, struct json_object **json)
{
struct listnode *node;
struct isis_vertex *vertex;
vertex_typestr, vertex_metricstr, vertex_nexthop,
vertex_interface, vertex_parent);
}
- table = ttable_dump(tt, "\n");
- vty_out(vty, "%s\n", table);
- XFREE(MTYPE_TMP, table);
+ if (json == NULL) {
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ } else
+ *json = ttable_json(tt, "ssdsss");
ttable_del(tt);
}
-void isis_print_spftree(struct vty *vty, struct isis_spftree *spftree)
+void isis_print_spftree(struct vty *vty, struct isis_spftree *spftree,
+ struct json_object **json)
{
const char *tree_id_text = NULL;
return;
}
- vty_out(vty, "IS-IS paths to level-%d routers %s\n", spftree->level,
- tree_id_text);
- isis_print_paths(vty, &spftree->paths, spftree->sysid);
- vty_out(vty, "\n");
+ if (!json)
+ vty_out(vty, "IS-IS paths to level-%d routers %s\n",
+ spftree->level, tree_id_text);
+
+ isis_print_paths(vty, &spftree->paths, spftree->sysid, json);
+ if (!json)
+ vty_out(vty, "\n");
}
static void show_isis_topology_common(struct vty *vty, int levels,
spftree = area->spftree[SPFTREE_IPV4]
[level - 1];
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree, NULL);
}
if (area->ipv6_circuits > 0) {
#ifndef FABRICD
#endif /* ifndef FABRICD */
spftree = area->spftree[SPFTREE_IPV6]
[level - 1];
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree, NULL);
}
if (isis_area_ipv6_dstsrc_enabled(area)) {
#ifndef FABRICD
#endif /* ifndef FABRICD */
spftree = area->spftree[SPFTREE_DSTSRC]
[level - 1];
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree, NULL);
}
}
if (fabricd_spftree(area)) {
vty_out(vty,
"IS-IS paths to level-2 routers with hop-by-hop metric\n");
- isis_print_paths(vty, &fabricd_spftree(area)->paths, isis->sysid);
+ isis_print_paths(vty, &fabricd_spftree(area)->paths,
+ isis->sysid, NULL);
vty_out(vty, "\n");
}
spftree = area->spftree[SPFTREE_IPV4]
[level - 1];
- if (!json)
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree,
+ json ? &json_val : NULL);
+ if (json && json_val) {
+ json_object_object_add(json_level,
+ "ipv4-paths",
+ json_val);
+ json_val = NULL;
+ }
isis_print_routes(vty, spftree,
json ? &json_val : NULL,
spftree = area->spftree[SPFTREE_IPV6]
[level - 1];
- if (!json)
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree,
+ json ? &json_val : NULL);
+ if (json && json_val) {
+ json_object_object_add(json_level,
+ "ipv6-paths",
+ json_val);
+ json_val = NULL;
+ }
isis_print_routes(vty, spftree,
json ? &json_val : NULL,
spftree = area->spftree[SPFTREE_DSTSRC]
[level - 1];
- if (!json)
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree,
+ json ? &json_val : NULL);
+ if (json && json_val) {
+ json_object_object_add(json_level,
+ "ipv6-dstsrc-paths",
+ json_val);
+ json_val = NULL;
+ }
isis_print_routes(vty, spftree,
json ? &json_val : NULL,
prefix_sid, backup);
isis_run_spf(spftree);
/* Print the SPT and the corresponding routing table. */
- isis_print_spftree(vty, spftree);
+ isis_print_spftree(vty, spftree, NULL);
isis_print_routes(vty, spftree, NULL, false, false);
/* Cleanup SPF tree. */
isis_lfa_compute(area, NULL, spftree_self, protected_resource);
/* Print the SPT and the corresponding main/backup routing tables. */
- isis_print_spftree(vty, spftree_self);
+ isis_print_spftree(vty, spftree_self, NULL);
vty_out(vty, "Main:\n");
isis_print_routes(vty, spftree_self, NULL, false, false);
vty_out(vty, "Backup:\n");
vty_out(vty, "\n");
/* Print the post-convergence SPT. */
- isis_print_spftree(vty, spftree_pc);
+ isis_print_spftree(vty, spftree_pc, NULL);
/*
* Activate the computed RLFAs (if any) using artificial LDP labels for
}
/* Print the SPT and the corresponding main/backup routing tables. */
- isis_print_spftree(vty, spftree_self);
+ isis_print_spftree(vty, spftree_self, NULL);
vty_out(vty, "Main:\n");
isis_print_routes(vty, spftree_self, NULL, false, false);
vty_out(vty, "Backup:\n");
/*
* Print the post-convergence SPT and the corresponding routing table.
*/
- isis_print_spftree(vty, spftree_pc);
+ isis_print_spftree(vty, spftree_pc, NULL);
isis_print_routes(vty, spftree_self, NULL, false, true);
/* Cleanup everything. */