diff options
author | harios_niral <hari@niralnetworks.com> | 2021-05-05 22:19:01 +0200 |
---|---|---|
committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-05-06 09:54:31 +0200 |
commit | d48ef099db433a5d0be9d1584af346e015e84991 (patch) | |
tree | 327ed47e64e01eab8db0bd17b86ed6da7fbefcb7 /ospf6d/ospf6_neighbor.c | |
parent | ospf6d: add internal support for multiple vrfs (diff) | |
download | frr-d48ef099db433a5d0be9d1584af346e015e84991.tar.xz frr-d48ef099db433a5d0be9d1584af346e015e84991.zip |
ospf6d: add vty support for multiple vrfs
Co-authored-by: Kaushik Nath <kaushiknath.null@gmail.com>
Signed-off-by: harios_niral <hari@niralnetworks.com>
Diffstat (limited to 'ospf6d/ospf6_neighbor.c')
-rw-r--r-- | ospf6d/ospf6_neighbor.c | 108 |
1 files changed, 78 insertions, 30 deletions
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index b35d8bf97..9323da8be 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -969,35 +969,24 @@ static void ospf6_neighbor_show_detail(struct vty *vty, } } -DEFUN (show_ipv6_ospf6_neighbor, - show_ipv6_ospf6_neighbor_cmd, - "show ipv6 ospf6 neighbor [<detail|drchoice>] [json]", - SHOW_STR - IP6_STR - OSPF6_STR - "Neighbor list\n" - "Display details\n" - "Display DR choices\n" - JSON_STR) +static void ospf6_neighbor_show_detail_common(struct vty *vty, int argc, + struct cmd_token **argv, + struct ospf6 *ospf6, int idx_type, + int detail_idx, int json_idx) { - int idx_type = 4; struct ospf6_neighbor *on; struct ospf6_interface *oi; struct ospf6_area *oa; struct listnode *i, *j, *k; - 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 ((uj && argc == 6) || (!uj && argc == 5)) { + if ((uj && argc == detail_idx) || (!uj && argc == json_idx)) { if (!strncmp(argv[idx_type]->arg, "de", 2)) showfunc = ospf6_neighbor_show_detail; else if (!strncmp(argv[idx_type]->arg, "dr", 2)) @@ -1037,21 +1026,50 @@ DEFUN (show_ipv6_ospf6_neighbor, json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } - return CMD_SUCCESS; } +DEFUN(show_ipv6_ospf6_neighbor, show_ipv6_ospf6_neighbor_cmd, + "show ipv6 ospf6 [vrf <NAME|all>] neighbor [<detail|drchoice>] [json]", + SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR + "All VRFs\n" + "Neighbor list\n" + "Display details\n" + "Display DR choices\n" JSON_STR) +{ + int idx_type = 4; + int detail_idx = 5; + int json_idx = 6; + struct ospf6 *ospf6; + struct listnode *node; + const char *vrf_name = NULL; + bool all_vrf = false; + int idx_vrf = 0; + + OSPF6_CMD_CHECK_RUNNING(); + OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); + if (idx_vrf > 0) { + idx_type += 2; + detail_idx += 2; + json_idx += 2; + } + + for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) { + if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) { + ospf6_neighbor_show_detail_common(vty, argc, argv, + ospf6, idx_type, + detail_idx, json_idx); + if (!all_vrf) + break; + } + } -DEFUN (show_ipv6_ospf6_neighbor_one, - show_ipv6_ospf6_neighbor_one_cmd, - "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) + return CMD_SUCCESS; +} + +static int ospf6_neighbor_show_common(struct vty *vty, int argc, + struct cmd_token **argv, + struct ospf6 *ospf6, int idx_ipv4) { - int idx_ipv4 = 4; struct ospf6_neighbor *on; struct ospf6_interface *oi; struct ospf6_area *oa; @@ -1059,12 +1077,9 @@ DEFUN (show_ipv6_ospf6_neighbor_one, 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(); @@ -1088,6 +1103,39 @@ DEFUN (show_ipv6_ospf6_neighbor_one, 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 [vrf <NAME|all>] neighbor A.B.C.D [json]", + SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR + "All VRFs\n" + "Neighbor list\n" + "Specify Router-ID as IPv4 address notation\n" JSON_STR) +{ + int idx_ipv4 = 4; + struct ospf6 *ospf6; + struct listnode *node; + const char *vrf_name = NULL; + bool all_vrf = false; + int idx_vrf = 0; + + OSPF6_CMD_CHECK_RUNNING(); + OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); + if (idx_vrf > 0) + idx_ipv4 += 2; + + for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) { + if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) { + ospf6_neighbor_show_common(vty, argc, argv, ospf6, + idx_ipv4); + + if (!all_vrf) + break; + } + } + return CMD_SUCCESS; } |