Skip to content

Commit

Permalink
isisd: Command 'show isis interface IFNAME json' displays the circuit…
Browse files Browse the repository at this point in the history
… ID of all interfaces

Signed-off-by: baozhen-H3C <[email protected]>
  • Loading branch information
baozhen-H3C committed Oct 18, 2024
1 parent 5fecb1f commit 0af4c91
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
2 changes: 2 additions & 0 deletions isisd/isis_circuit.c
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,8 @@ void isis_circuit_print_json(struct isis_circuit *circuit,
char buf_prx[INET6_BUFSIZ];
char buf[255];

json_object_int_add(json, "circuit", circuit->circuit_id);

snprintfrr(buf, sizeof(buf), "0x%x", circuit->circuit_id);
if (detail == ISIS_UI_LEVEL_BRIEF) {
iface_json = json_object_new_object();
Expand Down
35 changes: 12 additions & 23 deletions isisd/isisd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,20 +1043,15 @@ int show_isis_interface_common_json(struct json_object *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)
if (!ifname ||
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(circuits_json, circuit_json);
if (ifname)
break;
}
}
json_object_array_add(areas_json, area_json);
}
Expand All @@ -1076,22 +1071,16 @@ int show_isis_interface_common_json(struct json_object *json,
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)) {
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)
if (!ifname || strcmp(circuit->interface->name, ifname) == 0) {
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(circuits_json, circuit_json);
if (ifname)
break;
}
}
json_object_array_add(areas_json, area_json);
}
Expand Down

0 comments on commit 0af4c91

Please sign in to comment.