diff options
Diffstat (limited to 'ospfd/ospf_vty.c')
| -rw-r--r-- | ospfd/ospf_vty.c | 166 |
1 files changed, 132 insertions, 34 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 91a29f7d65..c58073c521 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -3365,6 +3365,54 @@ DEFUN (show_ip_ospf_instance, return ret; } +static void ospf_interface_auth_show(struct vty *vty, struct ospf_interface *oi, + json_object *json, bool use_json) +{ + int auth_type; + + auth_type = OSPF_IF_PARAM(oi, auth_type); + + switch (auth_type) { + case OSPF_AUTH_NULL: + if (use_json) + json_object_string_add(json, "authentication", + "authenticationNone"); + else + vty_out(vty, " Authentication NULL is enabled\n"); + break; + case OSPF_AUTH_SIMPLE: { + if (use_json) + json_object_string_add(json, "authentication", + "authenticationSimplePassword"); + else + vty_out(vty, + " Simple password authentication enabled\n"); + break; + } + case OSPF_AUTH_CRYPTOGRAPHIC: { + struct crypt_key *ckey; + + if (list_isempty(OSPF_IF_PARAM(oi, auth_crypt))) + return; + + ckey = listgetdata(listtail(OSPF_IF_PARAM(oi, auth_crypt))); + if (ckey) { + if (use_json) { + json_object_string_add(json, "authentication", + "authenticationMessageDigest"); + } else { + vty_out(vty, + " Cryptographic authentication enabled\n"); + vty_out(vty, " Algorithm:MD5\n"); + } + } + break; + } + default: + break; + } +} + static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf, struct interface *ifp, json_object *json_interface_sub, @@ -3686,6 +3734,9 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf, ospf_nbr_count(oi, 0), ospf_nbr_count(oi, NSM_Full)); ospf_bfd_interface_show(vty, ifp, json_interface_sub, use_json); + + /* OSPF Authentication information */ + ospf_interface_auth_show(vty, oi, json_interface_sub, use_json); } } @@ -5800,9 +5851,8 @@ static int show_lsa_summary(struct vty *vty, struct ospf_lsa *lsa, int self, /* LSA common part show. */ vty_out(vty, "%-15pI4", &lsa->data->id); - vty_out(vty, "%-15s %4d 0x%08lx 0x%04x", - inet_ntoa(lsa->data->adv_router), - LS_AGE(lsa), + vty_out(vty, "%-15pI4 %4d 0x%08lx 0x%04x", + &lsa->data->adv_router, LS_AGE(lsa), (unsigned long)ntohl( lsa->data->ls_seqnum), ntohs(lsa->data->checksum)); @@ -5816,10 +5866,13 @@ static int show_lsa_summary(struct vty *vty, struct ospf_lsa *lsa, int self, ntohs(lsa->data->checksum)); json_object_string_add( json_lsa, "lsId", - inet_ntoa(lsa->data->id)); + inet_ntop(AF_INET, &lsa->data->id, + buf, sizeof(buf))); json_object_string_add( json_lsa, "advertisedRouter", - inet_ntoa(lsa->data->adv_router)); + inet_ntop(AF_INET, + &lsa->data->adv_router, + buf, sizeof(buf))); json_object_int_add(json_lsa, "lsaAge", LS_AGE(lsa)); json_object_string_add( @@ -5955,6 +6008,7 @@ static const char *const show_database_header[] = { static void show_ip_ospf_database_header(struct vty *vty, struct ospf_lsa *lsa, json_object *json) { + char buf[PREFIX_STRLEN]; struct router_lsa *rlsa = (struct router_lsa *)lsa->data; if (!json) { @@ -6036,9 +6090,12 @@ static void show_ip_ospf_database_header(struct vty *vty, struct ospf_lsa *lsa, json, "lsaType", lookup_msg(ospf_lsa_type_msg, lsa->data->type, NULL)); json_object_string_add(json, "linkStateId", - inet_ntoa(lsa->data->id)); + inet_ntop(AF_INET, &lsa->data->id, + buf, sizeof(buf))); json_object_string_add(json, "advertisingRouter", - inet_ntoa(lsa->data->adv_router)); + inet_ntop(AF_INET, + &lsa->data->adv_router, + buf, sizeof(buf))); json_object_string_add(json, "lsaSeqNumber", seqnum); json_object_string_add(json, "checksum", checksum); json_object_int_add(json, "length", ntohs(lsa->data->length)); @@ -6083,6 +6140,7 @@ static void show_ip_ospf_database_router_links(struct vty *vty, json_object *json_links = NULL; json_object *json_link = NULL; int metric = 0; + char buf[PREFIX_STRLEN]; if (json) json_links = json_object_new_object(); @@ -6100,10 +6158,13 @@ static void show_ip_ospf_database_router_links(struct vty *vty, link_type_desc[type]); json_object_string_add(json_link, link_id_desc_json[type], - inet_ntoa(rl->link[i].link_id)); + inet_ntop(AF_INET, + &rl->link[i].link_id, + buf, sizeof(buf))); json_object_string_add( json_link, link_data_desc_json[type], - inet_ntoa(rl->link[i].link_data)); + inet_ntop(AF_INET, &rl->link[i].link_data, + buf, sizeof(buf))); json_object_int_add(json_link, "numOfTosMetrics", metric); json_object_int_add(json_link, "tos0Metric", @@ -6158,6 +6219,7 @@ static int show_network_lsa_detail(struct vty *vty, struct ospf_lsa *lsa, json_object *json) { int length, i; + char buf[PREFIX_STRLEN]; json_object *json_attached_rt = NULL; json_object *json_router = NULL; @@ -6187,10 +6249,13 @@ static int show_network_lsa_detail(struct vty *vty, struct ospf_lsa *lsa, json_router = json_object_new_object(); json_object_string_add( json_router, "attachedRouterId", - inet_ntoa(nl->routers[i])); + inet_ntop(AF_INET, &nl->routers[i], + buf, sizeof(buf))); json_object_object_add( json_attached_rt, - inet_ntoa(nl->routers[i]), json_router); + inet_ntop(AF_INET, &(nl->routers[i]), + buf, sizeof(buf)), + json_router); } } @@ -6257,6 +6322,7 @@ static int show_summary_asbr_lsa_detail(struct vty *vty, struct ospf_lsa *lsa, static int show_as_external_lsa_detail(struct vty *vty, struct ospf_lsa *lsa, json_object *json) { + char buf[PREFIX_STRLEN]; int tos = 0; if (lsa != NULL) { @@ -6292,7 +6358,9 @@ static int show_as_external_lsa_detail(struct vty *vty, struct ospf_lsa *lsa, json_object_int_add(json, "metric", GET_METRIC(al->e[0].metric)); json_object_string_add(json, "forwardAddress", - inet_ntoa(al->e[0].fwd_addr)); + inet_ntop(AF_INET, + &(al->e[0].fwd_addr), + buf, sizeof(buf))); json_object_int_add( json, "externalRouteTag", (route_tag_t)ntohl(al->e[0].route_tag)); @@ -6330,6 +6398,7 @@ show_as_external_lsa_stdvty (struct ospf_lsa *lsa) static int show_as_nssa_lsa_detail(struct vty *vty, struct ospf_lsa *lsa, json_object *json) { + char buf[PREFIX_STRLEN]; int tos = 0; if (lsa != NULL) { @@ -6366,7 +6435,9 @@ static int show_as_nssa_lsa_detail(struct vty *vty, struct ospf_lsa *lsa, json_object_int_add(json, "metric", GET_METRIC(al->e[0].metric)); json_object_string_add(json, "nssaForwardAddress", - inet_ntoa(al->e[0].fwd_addr)); + inet_ntop(AF_INET, + &al->e[0].fwd_addr, + buf, sizeof(buf))); json_object_int_add( json, "externalRouteTag", (route_tag_t)ntohl(al->e[0].route_tag)); @@ -6462,6 +6533,7 @@ static void show_lsa_detail(struct vty *vty, struct ospf *ospf, int type, { struct listnode *node; struct ospf_area *area; + char buf[PREFIX_STRLEN]; json_object *json_lsa_type = NULL; json_object *json_areas = NULL; json_object *json_lsa_array = NULL; @@ -6499,7 +6571,10 @@ static void show_lsa_detail(struct vty *vty, struct ospf *ospf, int type, } else { json_lsa_array = json_object_new_array(); json_object_object_add(json_areas, - inet_ntoa(area->area_id), + inet_ntop(AF_INET, + &area->area_id, + buf, + sizeof(buf)), json_lsa_array); } @@ -6523,6 +6598,7 @@ static void show_lsa_detail_adv_router_proc(struct vty *vty, struct in_addr *adv_router, json_object *json) { + char buf[PREFIX_STRLEN]; struct route_node *rn; struct ospf_lsa *lsa; @@ -6542,7 +6618,10 @@ static void show_lsa_detail_adv_router_proc(struct vty *vty, vty, lsa, json_lsa); if (json) json_object_object_add( - json, inet_ntoa(lsa->data->id), + json, + inet_ntop(AF_INET, + &lsa->data->id, + buf, sizeof(buf)), json_lsa); } } @@ -6555,6 +6634,7 @@ static void show_lsa_detail_adv_router(struct vty *vty, struct ospf *ospf, { struct listnode *node; struct ospf_area *area; + char buf[PREFIX_STRLEN]; json_object *json_lstype = NULL; json_object *json_area = NULL; @@ -6587,7 +6667,10 @@ static void show_lsa_detail_adv_router(struct vty *vty, struct ospf *ospf, if (json) json_object_object_add(json_lstype, - inet_ntoa(area->area_id), + inet_ntop(AF_INET, + &area->area_id, + buf, + sizeof(buf)), json_area); } break; @@ -6605,6 +6688,7 @@ static void show_ip_ospf_database_summary(struct vty *vty, struct ospf *ospf, struct route_node *rn; struct ospf_area *area; struct listnode *node; + char buf[PREFIX_STRLEN]; json_object *json_areas = NULL; json_object *json_area = NULL; json_object *json_lsa = NULL; @@ -6665,7 +6749,9 @@ static void show_ip_ospf_database_summary(struct vty *vty, struct ospf *ospf, } if (json) json_object_object_add(json_areas, - inet_ntoa(area->area_id), + inet_ntop(AF_INET, + &area->area_id, + buf, sizeof(buf)), json_area); } @@ -6717,6 +6803,7 @@ static void show_ip_ospf_database_maxage(struct vty *vty, struct ospf *ospf, json_object *json) { struct route_node *rn; + char buf[PREFIX_STRLEN]; json_object *json_maxage = NULL; if (!json) @@ -6732,8 +6819,8 @@ static void show_ip_ospf_database_maxage(struct vty *vty, struct ospf *ospf, if (!json) { vty_out(vty, "Link type: %d\n", lsa->data->type); - vty_out(vty, "Link State ID: %s\n", - inet_ntoa(lsa->data->id)); + vty_out(vty, "Link State ID: %pI4\n", + &lsa->data->id); vty_out(vty, "Advertising Router: %pI4\n", &lsa->data->adv_router); vty_out(vty, "LSA lock count: %d\n", lsa->lock); @@ -6744,15 +6831,21 @@ static void show_ip_ospf_database_maxage(struct vty *vty, struct ospf *ospf, lsa->data->type); json_object_string_add( json_lsa, "linkStateId", - inet_ntoa(lsa->data->id)); + inet_ntop(AF_INET, &lsa->data->id, + buf, sizeof(buf))); json_object_string_add( json_lsa, "advertisingRouter", - inet_ntoa(lsa->data->adv_router)); + inet_ntop(AF_INET, + &lsa->data->adv_router, + buf, sizeof(buf))); json_object_int_add(json_lsa, "lsaLockCount", lsa->lock); - json_object_object_add(json_maxage, - inet_ntoa(lsa->data->id), - json_lsa); + json_object_object_add( + json_maxage, + inet_ntop(AF_INET, + &lsa->data->id, + buf, sizeof(buf)), + json_lsa); } } } @@ -6786,6 +6879,7 @@ static int show_ip_ospf_database_common(struct vty *vty, struct ospf *ospf, int idx_type = 4; int type, ret; struct in_addr id, adv_router; + char buf[PREFIX_STRLEN]; json_object *json_vrf = NULL; if (uj) { @@ -6808,7 +6902,8 @@ static int show_ip_ospf_database_common(struct vty *vty, struct ospf *ospf, /* Show Router ID. */ if (uj) { json_object_string_add(json_vrf, "routerId", - inet_ntoa(ospf->router_id)); + inet_ntop(AF_INET, &ospf->router_id, + buf, sizeof(buf))); } else { vty_out(vty, "\n OSPF Router with ID (%pI4)\n\n", &ospf->router_id); @@ -7138,6 +7233,7 @@ static int show_ip_ospf_database_type_adv_router_common(struct vty *vty, int idx_type = 4; int type, ret; struct in_addr adv_router; + char buf[PREFIX_STRLEN]; json_object *json_vrf = NULL; if (uj) { @@ -7160,7 +7256,8 @@ static int show_ip_ospf_database_type_adv_router_common(struct vty *vty, /* Show Router ID. */ if (uj) { json_object_string_add(json_vrf, "routerId", - inet_ntoa(ospf->router_id)); + inet_ntop(AF_INET, &ospf->router_id, + buf, sizeof(buf))); } else { vty_out(vty, "\n OSPF Router with ID (%pI4)\n\n", &ospf->router_id); @@ -7270,8 +7367,8 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router, continue; ospf_output = true; ret = show_ip_ospf_database_type_adv_router_common( - vty, ospf, idx ? 1 : 0, argc, argv, - use_vrf, json, uj); + vty, ospf, 2, argc, argv, use_vrf, json, + uj); } if (!ospf_output) vty_out(vty, "%% OSPF instance not found\n"); @@ -7283,8 +7380,7 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router, } ret = show_ip_ospf_database_type_adv_router_common( - vty, ospf, idx ? 1 : 0, argc, argv, use_vrf, - json, uj); + vty, ospf, 2, argc, argv, use_vrf, json, uj); } } else { /* Display default ospf (instance 0) info */ @@ -10450,7 +10546,8 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, if (if_lookup_by_index(path->ifindex, ospf->vrf_id)) { - if (path->nexthop.s_addr == 0) { + if (path->nexthop.s_addr + == INADDR_ANY) { if (json) { json_object_string_add( json_nexthop, @@ -10595,7 +10692,8 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf, } if (if_lookup_by_index(path->ifindex, ospf->vrf_id)) { - if (path->nexthop.s_addr == 0) { + if (path->nexthop.s_addr + == INADDR_ANY) { if (json) { json_object_string_add( json_nexthop, @@ -10723,7 +10821,7 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, } if (if_lookup_by_index(path->ifindex, ospf->vrf_id)) { - if (path->nexthop.s_addr == 0) { + if (path->nexthop.s_addr == INADDR_ANY) { if (json) { json_object_string_add( json_nexthop, "ip", @@ -12092,7 +12190,7 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf) } /* Router ID print. */ - if (ospf->router_id_static.s_addr != 0) + if (ospf->router_id_static.s_addr != INADDR_ANY) vty_out(vty, " ospf router-id %pI4\n", &ospf->router_id_static); |
