summaryrefslogtreecommitdiffstats
path: root/isisd/isisd.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--isisd/isisd.c320
1 files changed, 151 insertions, 169 deletions
diff --git a/isisd/isisd.c b/isisd/isisd.c
index 772eb97..982df08 100644
--- a/isisd/isisd.c
+++ b/isisd/isisd.c
@@ -988,63 +988,17 @@ int show_isis_interface_common_json(struct json_object *json,
"no");
return CMD_SUCCESS;
}
- if (vrf_name) {
- if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) {
- areas_json = json_object_new_array();
- json_object_object_add(json, "areas",
- areas_json);
- for (ALL_LIST_ELEMENTS_RO(isis->area_list,
- anode, area)) {
- area_json = json_object_new_object();
- json_object_string_add(
- area_json, "area",
- area->area_tag ? area->area_tag
- : "null");
- circuits_json = json_object_new_array();
- json_object_object_add(area_json,
- "circuits",
- circuits_json);
- for (ALL_LIST_ELEMENTS_RO(
- area->circuit_list, cnode,
- circuit)) {
- circuit_json =
- json_object_new_object();
- json_object_int_add(
- circuit_json, "circuit",
- circuit->circuit_id);
- if (!ifname)
- isis_circuit_print_json(
- circuit,
- circuit_json,
- detail);
- else if (strcmp(circuit->interface->name, ifname) == 0)
- isis_circuit_print_json(
- circuit,
- circuit_json,
- detail);
- json_object_array_add(
- circuits_json,
- circuit_json);
- }
- json_object_array_add(areas_json,
- area_json);
- }
- }
- return CMD_SUCCESS;
- }
- isis = isis_lookup_by_vrfname(vrf_name);
- if (isis != NULL) {
+
+ if (all_vrf) {
+ for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) {
areas_json = json_object_new_array();
json_object_object_add(json, "areas", areas_json);
- for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode,
- area)) {
+ for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
area_json = json_object_new_object();
json_object_string_add(area_json, "area",
area->area_tag
? area->area_tag
: "null");
-
circuits_json = json_object_new_array();
json_object_object_add(area_json, "circuits",
circuits_json);
@@ -1055,22 +1009,56 @@ int show_isis_interface_common_json(struct json_object *json,
circuit_json, "circuit",
circuit->circuit_id);
if (!ifname)
- isis_circuit_print_json(
- circuit, circuit_json,
- detail);
- else if (
- strcmp(circuit->interface->name,
- ifname) == 0)
- isis_circuit_print_json(
- circuit, circuit_json,
- detail);
+ isis_circuit_print_json(circuit,
+ circuit_json,
+ detail);
+ else if (strcmp(circuit->interface->name,
+ ifname) == 0)
+ isis_circuit_print_json(circuit,
+ circuit_json,
+ detail);
json_object_array_add(circuits_json,
circuit_json);
}
json_object_array_add(areas_json, area_json);
}
}
+ return CMD_SUCCESS;
+ }
+ isis = isis_lookup_by_vrfname(vrf_name);
+ if (isis != NULL) {
+ areas_json = json_object_new_array();
+ json_object_object_add(json, "areas", areas_json);
+ for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
+ area_json = json_object_new_object();
+ json_object_string_add(area_json, "area",
+ area->area_tag ? area->area_tag
+ : "null");
+
+ circuits_json = json_object_new_array();
+ json_object_object_add(area_json, "circuits",
+ circuits_json);
+ for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode,
+ circuit)) {
+ circuit_json = json_object_new_object();
+ json_object_int_add(circuit_json, "circuit",
+ circuit->circuit_id);
+ if (!ifname)
+ isis_circuit_print_json(circuit,
+ circuit_json,
+ detail);
+ else if (strcmp(circuit->interface->name,
+ ifname) == 0)
+ isis_circuit_print_json(circuit,
+ circuit_json,
+ detail);
+ json_object_array_add(circuits_json,
+ circuit_json);
+ }
+ json_object_array_add(areas_json, area_json);
+ }
}
+
return CMD_SUCCESS;
}
@@ -1087,37 +1075,10 @@ int show_isis_interface_common_vty(struct vty *vty, const char *ifname,
vty_out(vty, "IS-IS Routing Process not enabled\n");
return CMD_SUCCESS;
}
- if (vrf_name) {
- if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) {
- for (ALL_LIST_ELEMENTS_RO(isis->area_list,
- anode, area)) {
- vty_out(vty, "Area %s:\n",
- area->area_tag);
- if (detail == ISIS_UI_LEVEL_BRIEF)
- vty_out(vty,
- " Interface CircId State Type Level\n");
-
- for (ALL_LIST_ELEMENTS_RO(
- area->circuit_list, cnode,
- circuit))
- if (!ifname)
- isis_circuit_print_vty(
- circuit, vty,
- detail);
- else if (strcmp(circuit->interface->name, ifname) == 0)
- isis_circuit_print_vty(
- circuit, vty,
- detail);
- }
- }
- return CMD_SUCCESS;
- }
- isis = isis_lookup_by_vrfname(vrf_name);
- if (isis != NULL) {
- for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode,
- area)) {
+ if (all_vrf) {
+ for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) {
+ for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
vty_out(vty, "Area %s:\n", area->area_tag);
if (detail == ISIS_UI_LEVEL_BRIEF)
@@ -1127,15 +1088,37 @@ int show_isis_interface_common_vty(struct vty *vty, const char *ifname,
for (ALL_LIST_ELEMENTS_RO(area->circuit_list,
cnode, circuit))
if (!ifname)
- isis_circuit_print_vty(
- circuit, vty, detail);
- else if (
- strcmp(circuit->interface->name,
- ifname) == 0)
- isis_circuit_print_vty(
- circuit, vty, detail);
+ isis_circuit_print_vty(circuit,
+ vty,
+ detail);
+ else if (strcmp(circuit->interface->name,
+ ifname) == 0)
+ isis_circuit_print_vty(circuit,
+ vty,
+ detail);
}
}
+ return CMD_SUCCESS;
+ }
+ isis = isis_lookup_by_vrfname(vrf_name);
+ if (isis != NULL) {
+ for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) {
+ vty_out(vty, "Area %s:\n", area->area_tag);
+
+ if (detail == ISIS_UI_LEVEL_BRIEF)
+ vty_out(vty,
+ " Interface CircId State Type Level\n");
+
+ for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode,
+ circuit))
+ if (!ifname)
+ isis_circuit_print_vty(circuit, vty,
+ detail);
+ else if (strcmp(circuit->interface->name,
+ ifname) == 0)
+ isis_circuit_print_vty(circuit, vty,
+ detail);
+ }
}
return CMD_SUCCESS;
@@ -1318,7 +1301,7 @@ static void isis_neighbor_common_vty(struct vty *vty, const char *id,
if (detail == ISIS_UI_LEVEL_BRIEF)
vty_out(vty,
- " System Id Interface L State Holdtime SNPA\n");
+ " System Id Interface L State Holdtime SNPA\n");
for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) {
if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
@@ -1376,28 +1359,23 @@ int show_isis_neighbor_common(struct vty *vty, struct json_object *json,
return CMD_SUCCESS;
}
- if (vrf_name) {
- if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
- if (id_to_sysid(isis, id, sysid)) {
- vty_out(vty, "Invalid system id %s\n",
- id);
- return CMD_SUCCESS;
- }
- isis_neighbor_common(vty, json, id, detail,
- isis, sysid);
- }
- return CMD_SUCCESS;
- }
- isis = isis_lookup_by_vrfname(vrf_name);
- if (isis != NULL) {
+ if (all_vrf) {
+ for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
if (id_to_sysid(isis, id, sysid)) {
vty_out(vty, "Invalid system id %s\n", id);
return CMD_SUCCESS;
}
- isis_neighbor_common(vty, json, id, detail, isis,
- sysid);
+ isis_neighbor_common(vty, json, id, detail, isis, sysid);
+ }
+ return CMD_SUCCESS;
+ }
+ isis = isis_lookup_by_vrfname(vrf_name);
+ if (isis != NULL) {
+ if (id_to_sysid(isis, id, sysid)) {
+ vty_out(vty, "Invalid system id %s\n", id);
+ return CMD_SUCCESS;
}
+ isis_neighbor_common(vty, json, id, detail, isis, sysid);
}
return CMD_SUCCESS;
@@ -1461,27 +1439,23 @@ int clear_isis_neighbor_common(struct vty *vty, const char *id, const char *vrf_
return CMD_SUCCESS;
}
- if (vrf_name) {
- if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
- if (id_to_sysid(isis, id, sysid)) {
- vty_out(vty, "Invalid system id %s\n",
- id);
- return CMD_SUCCESS;
- }
- isis_neighbor_common_clear(vty, id, sysid,
- isis);
- }
- return CMD_SUCCESS;
- }
- isis = isis_lookup_by_vrfname(vrf_name);
- if (isis != NULL) {
+ if (all_vrf) {
+ for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
if (id_to_sysid(isis, id, sysid)) {
vty_out(vty, "Invalid system id %s\n", id);
return CMD_SUCCESS;
}
isis_neighbor_common_clear(vty, id, sysid, isis);
}
+ return CMD_SUCCESS;
+ }
+ isis = isis_lookup_by_vrfname(vrf_name);
+ if (isis != NULL) {
+ if (id_to_sysid(isis, id, sysid)) {
+ vty_out(vty, "Invalid system id %s\n", id);
+ return CMD_SUCCESS;
+ }
+ isis_neighbor_common_clear(vty, id, sysid, isis);
}
return CMD_SUCCESS;
@@ -2234,17 +2208,16 @@ DEFUN (show_hostname,
struct isis *isis;
ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
- if (vrf_name) {
- if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
- dynhn_print_all(vty, isis);
- return CMD_SUCCESS;
- }
- isis = isis_lookup_by_vrfname(vrf_name);
- if (isis != NULL)
+ if (all_vrf) {
+ for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
dynhn_print_all(vty, isis);
+
+ return CMD_SUCCESS;
}
+ isis = isis_lookup_by_vrfname(vrf_name);
+ if (isis != NULL)
+ dynhn_print_all(vty, isis);
return CMD_SUCCESS;
}
@@ -2307,17 +2280,15 @@ DEFUN(show_isis_spf_ietf, show_isis_spf_ietf_cmd,
return CMD_SUCCESS;
}
- if (vrf_name) {
- if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
- isis_spf_ietf_common(vty, isis);
-
- return CMD_SUCCESS;
- }
- isis = isis_lookup_by_vrfname(vrf_name);
- if (isis != NULL)
+ if (all_vrf) {
+ for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
isis_spf_ietf_common(vty, isis);
+
+ return CMD_SUCCESS;
}
+ isis = isis_lookup_by_vrfname(vrf_name);
+ if (isis != NULL)
+ isis_spf_ietf_common(vty, isis);
return CMD_SUCCESS;
}
@@ -2596,17 +2567,16 @@ DEFUN(show_isis_summary, show_isis_summary_cmd,
}
if (uj)
json = json_object_new_object();
- if (vrf_name) {
- if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
- common_isis_summary(vty, json, isis);
- return CMD_SUCCESS;
- }
- isis = isis_lookup_by_vrfname(vrf_name);
- if (isis != NULL)
+ if (all_vrf) {
+ for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
common_isis_summary(vty, json, isis);
+
+ return CMD_SUCCESS;
}
+ isis = isis_lookup_by_vrfname(vrf_name);
+ if (isis != NULL)
+ common_isis_summary(vty, json, isis);
if (uj)
vty_json(vty, json);
@@ -2679,8 +2649,10 @@ void show_isis_database_lspdb_json(struct json_object *json,
struct lspdb_head *lspdb,
const char *sysid_str, int ui_level)
{
+ struct json_object *array_json, *lsp_json;
struct isis_lsp *lsp;
int lsp_count;
+ struct json_object *lsp_arr_json;
if (lspdb_count(lspdb) > 0) {
lsp = lsp_for_sysid(lspdb, sysid_str, area->isis);
@@ -2690,16 +2662,27 @@ void show_isis_database_lspdb_json(struct json_object *json,
}
if (lsp) {
+ json_object_object_get_ex(json, "lsps", &array_json);
+ if (!array_json) {
+ array_json = json_object_new_array();
+ json_object_object_add(json, "lsps", array_json);
+ }
+ lsp_json = json_object_new_object();
+ json_object_array_add(array_json, lsp_json);
+
if (ui_level == ISIS_UI_LEVEL_DETAIL)
- lsp_print_detail(lsp, NULL, json,
+ lsp_print_detail(lsp, NULL, lsp_json,
area->dynhostname, area->isis);
else
- lsp_print_json(lsp, json, area->dynhostname,
+ lsp_print_json(lsp, lsp_json, area->dynhostname,
area->isis);
} else if (sysid_str == NULL) {
- lsp_count =
- lsp_print_all(NULL, json, lspdb, ui_level,
- area->dynhostname, area->isis);
+ lsp_arr_json = json_object_new_array();
+ json_object_object_add(json, "lsps", lsp_arr_json);
+
+ lsp_count = lsp_print_all(NULL, lsp_arr_json, lspdb,
+ ui_level, area->dynhostname,
+ area->isis);
json_object_int_add(json, "count", lsp_count);
}
@@ -2765,6 +2748,8 @@ static void show_isis_database_json(struct json_object *json, const char *sysid_
json_object_object_add(area_json,"area",tag_area_json);
json_object_object_add(area_json,"levels",arr_json);
for (level = 0; level < ISIS_LEVELS; level++) {
+ if (lspdb_count(&area->lspdb[level]) == 0)
+ continue;
lsp_json = json_object_new_object();
show_isis_database_lspdb_json(lsp_json, area, level,
&area->lspdb[level],
@@ -2828,19 +2813,16 @@ static int show_isis_database(struct vty *vty, struct json_object *json, const c
struct listnode *node;
struct isis *isis;
- if (vrf_name) {
- if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
- show_isis_database_common(vty, json, sysid_str,
- ui_level, isis);
-
- return CMD_SUCCESS;
- }
- isis = isis_lookup_by_vrfname(vrf_name);
- if (isis)
+ if (all_vrf) {
+ for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
show_isis_database_common(vty, json, sysid_str,
ui_level, isis);
+
+ return CMD_SUCCESS;
}
+ isis = isis_lookup_by_vrfname(vrf_name);
+ if (isis)
+ show_isis_database_common(vty, json, sysid_str, ui_level, isis);
return CMD_SUCCESS;
}