diff options
Diffstat (limited to 'ospfd/ospf_vty.c')
| -rw-r--r-- | ospfd/ospf_vty.c | 137 |
1 files changed, 108 insertions, 29 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 780521bfe4..d4245bde7f 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -3432,7 +3432,7 @@ DEFUN (show_ip_ospf, if (uj) vty_json(vty, json); else if (!ospf_output) - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, "%% OSPF is not enabled\n"); return ret; } ospf = ospf_lookup_by_inst_name(inst, vrf_name); @@ -3440,7 +3440,9 @@ DEFUN (show_ip_ospf, if (uj) vty_json(vty, json); else - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf %s\n", + vrf_name); return CMD_SUCCESS; } @@ -3451,7 +3453,8 @@ DEFUN (show_ip_ospf, if (uj) vty_json(vty, json); else - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf default\n"); return CMD_SUCCESS; } @@ -4164,7 +4167,7 @@ DEFUN (show_ip_ospf_interface, if (uj) vty_json(vty, json); else if (!ospf) - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, "%% OSPF is not enabled\n"); return ret; } @@ -4173,7 +4176,9 @@ DEFUN (show_ip_ospf_interface, if (uj) vty_json(vty, json); else - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf %s\n", + vrf_name); return CMD_SUCCESS; } @@ -4187,7 +4192,8 @@ DEFUN (show_ip_ospf_interface, if (uj) vty_json(vty, json); else - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf default\n"); return CMD_SUCCESS; } @@ -4572,7 +4578,7 @@ DEFUN (show_ip_ospf_neighbor, if (uj) vty_json(vty, json); else if (!ospf) - vty_out(vty, "OSPF instance not found\n"); + vty_out(vty, "OSPF is not enabled\n"); return ret; } @@ -4582,7 +4588,9 @@ DEFUN (show_ip_ospf_neighbor, if (uj) vty_json(vty, json); else - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf %s\n", + vrf_name); return CMD_SUCCESS; } @@ -4593,7 +4601,8 @@ DEFUN (show_ip_ospf_neighbor, if (uj) vty_json(vty, json); else - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf default\n"); return CMD_SUCCESS; } @@ -7123,11 +7132,13 @@ DEFUN (show_ip_ospf_database_max, } if (!ospf_output) - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, "%% OSPF is not enabled\n"); } else { ospf = ospf_lookup_by_inst_name(inst, vrf_name); if (ospf == NULL || !ospf->oi_running) { - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf %s\n", + vrf_name); return CMD_SUCCESS; } ret = (show_ip_ospf_database_common( @@ -7138,7 +7149,7 @@ DEFUN (show_ip_ospf_database_max, /* Display default ospf (instance 0) info */ ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); if (ospf == NULL || !ospf->oi_running) { - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, "%% OSPF is not enabled in vrf default\n"); return CMD_SUCCESS; } @@ -7349,11 +7360,13 @@ DEFUN (show_ip_ospf_database_type_adv_router, uj); } if (!ospf_output) - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, "%% OSPF is not enabled\n"); } else { ospf = ospf_lookup_by_inst_name(inst, vrf_name); if ((ospf == NULL) || !ospf->oi_running) { - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf %s\n", + vrf_name); return CMD_SUCCESS; } @@ -7364,7 +7377,7 @@ DEFUN (show_ip_ospf_database_type_adv_router, /* Display default ospf (instance 0) info */ ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); if (ospf == NULL || !ospf->oi_running) { - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, "%% OSPF is not enabled on vrf default\n"); return CMD_SUCCESS; } @@ -10185,10 +10198,17 @@ static int ospf_show_gr_helper_details(struct vty *vty, struct ospf *ospf, json_object_int_add(json_vrf, "supportedGracePeriod", ospf->supported_grace_time); - if (ospf->last_exit_reason != OSPF_GR_HELPER_EXIT_NONE) +#if CONFDATE > 20230131 +CPP_NOTICE("Remove JSON object commands with keys starting with capital") +#endif + if (ospf->last_exit_reason != OSPF_GR_HELPER_EXIT_NONE) { json_object_string_add( json_vrf, "LastExitReason", ospf_exit_reason2str(ospf->last_exit_reason)); + json_object_string_add( + json_vrf, "lastExitReason", + ospf_exit_reason2str(ospf->last_exit_reason)); + } if (ospf->active_restarter_cnt) json_object_int_add(json_vrf, "activeRestarterCnt", @@ -10211,12 +10231,17 @@ static int ospf_show_gr_helper_details(struct vty *vty, struct ospf *ospf, if (uj) { json_object_object_get_ex(json_vrf, "Neighbors", &json_neighbors); + json_object_object_get_ex(json_vrf, "neighbors", + &json_neighbors); if (!json_neighbors) { json_neighbors = json_object_new_object(); json_object_object_add(json_vrf, "Neighbors", json_neighbors); + json_object_object_add(json_vrf, + "neighbors", + json_neighbors); } } @@ -10448,7 +10473,9 @@ DEFPY (show_ip_ospf_gr_helper, if (uj) vty_json(vty, json); else - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf %s\n", + vrf_name); return CMD_SUCCESS; } @@ -10462,7 +10489,8 @@ DEFPY (show_ip_ospf_gr_helper, if (uj) vty_json(vty, json); else - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf default\n"); return CMD_SUCCESS; } @@ -10514,6 +10542,9 @@ static void config_write_stub_router(struct vty *vty, struct ospf *ospf) return; } +#if CONFDATE > 20230131 +CPP_NOTICE("Remove JSON object commands with keys containing whitespaces") +#endif static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, struct route_table *rt, json_object *json) @@ -10621,6 +10652,12 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, ifindex2ifname( path->ifindex, ospf->vrf_id)); + json_object_string_add( + json_nexthop, + "directlyAttachedTo", + ifindex2ifname( + path->ifindex, + ospf->vrf_id)); } else { vty_out(vty, "%24s directly attached to %s\n", @@ -10706,9 +10743,12 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf, json_object_string_addf(json_route, "area", "%pI4", &or->u.std.area_id); - if (or->path_type == OSPF_PATH_INTER_AREA) + if (or->path_type == OSPF_PATH_INTER_AREA) { json_object_boolean_true_add(json_route, "IA"); + json_object_boolean_true_add(json_route, + "ia"); + } if (or->u.std.flags & ROUTER_LSA_BORDER) json_object_string_add(json_route, "routerType", @@ -10760,6 +10800,12 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf, ifindex2ifname( path->ifindex, ospf->vrf_id)); + json_object_string_add( + json_nexthop, + "directlyAttachedTo", + ifindex2ifname( + path->ifindex, + ospf->vrf_id)); } else { vty_out(vty, "%24s directly attached to %s\n", @@ -10886,6 +10932,12 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, ifindex2ifname( path->ifindex, ospf->vrf_id)); + json_object_string_add( + json_nexthop, + "directlyAttachedTo", + ifindex2ifname( + path->ifindex, + ospf->vrf_id)); } else { vty_out(vty, "%24s directly attached to %s\n", @@ -10983,11 +11035,13 @@ DEFUN (show_ip_ospf_border_routers, } if (!ospf_output) - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, "%% OSPF is not enabled\n"); } else { ospf = ospf_lookup_by_inst_name(inst, vrf_name); if (ospf == NULL || !ospf->oi_running) { - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf %s\n", + vrf_name); return CMD_SUCCESS; } @@ -10998,7 +11052,7 @@ DEFUN (show_ip_ospf_border_routers, /* Display default ospf (instance 0) info */ ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); if (ospf == NULL || !ospf->oi_running) { - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, "%% OSPF is not enabled in vrf default\n"); return CMD_SUCCESS; } @@ -11125,7 +11179,7 @@ DEFUN (show_ip_ospf_route, /* Keep Non-pretty format */ vty_json(vty, json); } else if (!ospf_output) - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, "%% OSPF is not enabled\n"); return ret; } @@ -11134,7 +11188,9 @@ DEFUN (show_ip_ospf_route, if (uj) vty_json(vty, json); else - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf %s\n", + vrf_name); return CMD_SUCCESS; } @@ -11145,7 +11201,8 @@ DEFUN (show_ip_ospf_route, if (uj) vty_json(vty, json); else - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf default\n"); return CMD_SUCCESS; } @@ -11408,12 +11465,15 @@ static int ospf_show_summary_address(struct vty *vty, struct ospf *ospf, ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf); - if (!uj) + if (!uj) { vty_out(vty, "aggregation delay interval :%u(in seconds)\n\n", ospf->aggr_delay_interval); - else + } else { json_object_int_add(json_vrf, "aggregation delay interval", ospf->aggr_delay_interval); + json_object_int_add(json_vrf, "aggregationDelayInterval", + ospf->aggr_delay_interval); + } for (rn = route_top(ospf->rt_aggr_tbl); rn; rn = route_next(rn)) if (rn->info) { @@ -11432,21 +11492,37 @@ static int ospf_show_summary_address(struct vty *vty, struct ospf *ospf, json_object_string_add(json_aggr, "Summary address", buf); + json_object_string_add(json_aggr, + "summaryAddress", buf); json_object_string_add( json_aggr, "Metric-type", (mtype == EXTERNAL_METRIC_TYPE_1) ? "E1" : "E2"); + json_object_string_add( + json_aggr, "metricType", + (mtype == EXTERNAL_METRIC_TYPE_1) + ? "E1" + : "E2"); +#if CONFDATE > 20230131 +CPP_NOTICE("Remove JSON object commands with keys starting with capital") +#endif json_object_int_add(json_aggr, "Metric", mval); + json_object_int_add(json_aggr, "metric", mval); json_object_int_add(json_aggr, "Tag", aggr->tag); + json_object_int_add(json_aggr, "tag", + aggr->tag); json_object_int_add( json_aggr, "External route count", OSPF_EXTERNAL_RT_COUNT(aggr)); + json_object_int_add( + json_aggr, "externalRouteCount", + OSPF_EXTERNAL_RT_COUNT(aggr)); if (OSPF_EXTERNAL_RT_COUNT(aggr) && detail) { hash_walk( @@ -11547,7 +11623,9 @@ DEFUN (show_ip_ospf_external_aggregator, if (uj) vty_json(vty, json); else - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf %s\n", + vrf_name); return CMD_SUCCESS; } @@ -11560,7 +11638,8 @@ DEFUN (show_ip_ospf_external_aggregator, if (uj) vty_json(vty, json); else - vty_out(vty, "%% OSPF instance not found\n"); + vty_out(vty, + "%% OSPF is not enabled in vrf default\n"); return CMD_SUCCESS; } |
