for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area))
if (area->full_nbrs) {
vty_out(vty,
- "For this router-id change to take effect, save config and restart ospfd\n");
+ "For this router-id change to take effect, use “clear ip ospf process” command\n");
return CMD_SUCCESS;
}
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area))
if (area->full_nbrs) {
vty_out(vty,
- "For this router-id change to take effect, save config and restart ospfd\n");
+ "For this router-id change to take effect, use “clear ip ospf process” command\n");
return CMD_SUCCESS;
}
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area))
if (area->full_nbrs) {
vty_out(vty,
- "For this router-id change to take effect, save config and restart ospfd\n");
+ "For this router-id change to take effect, use “clear ip ospf process” command\n");
return CMD_SUCCESS;
}
json_object_boolean_true_add(
json_area,
"nssaTranslatorAlways");
+ else
+ json_object_boolean_true_add(
+ json_area,
+ "nssaTranslatorNever");
} else {
json_object_boolean_true_add(json_area, "abr");
if (area->NSSATranslatorRole
}
} else {
vty_out(vty,
- " It is an NSSA configuration. \n Elected NSSA/ABR performs type-7/type-5 LSA translation. \n");
+ " It is an NSSA configuration.\n Elected NSSA/ABR performs type-7/type-5 LSA translation.\n");
if (!IS_OSPF_ABR(area->ospf))
vty_out(vty,
- " It is not ABR, therefore not Translator. \n");
+ " It is not ABR, therefore not Translator.\n");
else if (area->NSSATranslatorState) {
vty_out(vty, " We are an ABR and ");
if (area->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE)
vty_out(vty,
- "the NSSA Elected Translator. \n");
+ "the NSSA Elected Translator.\n");
else if (area->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS)
vty_out(vty,
- "always an NSSA Translator. \n");
+ "always an NSSA Translator.\n");
+ else
+ vty_out(vty,
+ "never an NSSA Translator.\n");
} else {
vty_out(vty, " We are an ABR, but ");
if (area->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE)
vty_out(vty,
- "not the NSSA Elected Translator. \n");
+ "not the NSSA Elected Translator.\n");
else
vty_out(vty,
- "never an NSSA Translator. \n");
+ "never an NSSA Translator.\n");
}
}
}
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,
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);
}
}
/* 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));
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(
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) {
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));
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();
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",
json_object *json)
{
int length, i;
+ char buf[PREFIX_STRLEN];
json_object *json_attached_rt = NULL;
json_object *json_router = NULL;
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);
}
}
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) {
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));
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) {
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));
{
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;
} 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);
}
struct in_addr *adv_router,
json_object *json)
{
+ char buf[PREFIX_STRLEN];
struct route_node *rn;
struct ospf_lsa *lsa;
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);
}
}
{
struct listnode *node;
struct ospf_area *area;
+ char buf[PREFIX_STRLEN];
json_object *json_lstype = NULL;
json_object *json_area = NULL;
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;
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;
}
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);
}
json_object *json)
{
struct route_node *rn;
+ char buf[PREFIX_STRLEN];
json_object *json_maxage = NULL;
if (!json)
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);
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);
}
}
}
int idx_type = 4;
int type, ret;
struct in_addr id, adv_router;
+ char buf[PREFIX_STRLEN];
json_object *json_vrf = NULL;
if (uj) {
/* 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);
int idx_type = 4;
int type, ret;
struct in_addr adv_router;
+ char buf[PREFIX_STRLEN];
json_object *json_vrf = NULL;
if (uj) {
/* 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);
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");
}
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 */
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,
}
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,
}
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",
return CMD_SUCCESS;
}
+DEFPY (clear_ip_ospf_neighbor,
+ clear_ip_ospf_neighbor_cmd,
+ "clear ip ospf [(1-65535)]$instance neighbor [A.B.C.D$nbr_id]",
+ CLEAR_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Reset OSPF Neighbor\n"
+ "Neighbor ID\n")
+{
+ struct listnode *node;
+ struct ospf *ospf = NULL;
+
+ /* If user does not specify the arguments,
+ * instance = 0 and nbr_id = 0.0.0.0
+ */
+ if (instance != 0) {
+ /* This means clear only the particular ospf process */
+ ospf = ospf_lookup_instance(instance);
+ if (ospf == NULL)
+ return CMD_NOT_MY_INSTANCE;
+ }
+
+ /* Clear all the ospf processes */
+ for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
+ if (!ospf->oi_running)
+ continue;
+
+ ospf_neighbor_reset(ospf, nbr_id, nbr_id_str);
+ }
+
+ return CMD_SUCCESS;
+}
+
+DEFPY (clear_ip_ospf_process,
+ clear_ip_ospf_process_cmd,
+ "clear ip ospf [(1-65535)]$instance process",
+ CLEAR_STR
+ IP_STR
+ "OSPF information\n"
+ "Instance ID\n"
+ "Reset OSPF Process\n")
+{
+ struct listnode *node;
+ struct ospf *ospf = NULL;
+
+ /* Check if instance is not passed as an argument */
+ if (instance != 0) {
+ /* This means clear only the particular ospf process */
+ ospf = ospf_lookup_instance(instance);
+ if (ospf == NULL)
+ return CMD_NOT_MY_INSTANCE;
+ }
+
+ /* Clear all the ospf processes */
+ for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
+ if (!ospf->oi_running)
+ continue;
+
+ ospf_process_reset(ospf);
+ }
+
+ return CMD_SUCCESS;
+}
static const char *const ospf_abr_type_str[] = {
"unknown", "standard", "ibm", "cisco", "shortcut"
"loopback"
};
+static const char *interface_config_auth_str(struct ospf_if_params *params)
+{
+ if (!OSPF_IF_PARAM_CONFIGURED(params, auth_type)
+ || params->auth_type == OSPF_AUTH_NOTSET)
+ return NULL;
+
+ /* Translation tables are not that much help
+ * here due to syntax
+ * of the simple option */
+ switch (params->auth_type) {
+
+ case OSPF_AUTH_NULL:
+ return " null";
+
+ case OSPF_AUTH_SIMPLE:
+ return "";
+
+ case OSPF_AUTH_CRYPTOGRAPHIC:
+ return " message-digest";
+ }
+
+ return "";
+}
+
static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
{
struct listnode *node;
struct crypt_key *ck;
struct route_node *rn = NULL;
struct ospf_if_params *params;
+ const char *auth_str;
int write = 0;
struct ospf *ospf = vrf->info;
}
/* OSPF interface authentication print */
- if (OSPF_IF_PARAM_CONFIGURED(params, auth_type)
- && params->auth_type != OSPF_AUTH_NOTSET) {
- const char *auth_str;
-
- /* Translation tables are not that much help
- * here due to syntax
- * of the simple option */
- switch (params->auth_type) {
-
- case OSPF_AUTH_NULL:
- auth_str = " null";
- break;
-
- case OSPF_AUTH_SIMPLE:
- auth_str = "";
- break;
-
- case OSPF_AUTH_CRYPTOGRAPHIC:
- auth_str = " message-digest";
- break;
-
- default:
- auth_str = "";
- break;
- }
-
+ auth_str = interface_config_auth_str(params);
+ if (auth_str) {
vty_out(vty, " ip ospf authentication%s",
auth_str);
if (params != IF_DEF_PARAMS(ifp) && rn)
{
struct listnode *node;
struct ospf_vl_data *vl_data;
+ const char *auth_str;
char buf[INET_ADDRSTRLEN];
/* Virtual-Link print */
else
vty_out(vty, " area %s virtual-link %pI4\n", buf,
&vl_data->vl_peer);
+ /* Auth type */
+ auth_str = interface_config_auth_str(
+ IF_DEF_PARAMS(oi->ifp));
+ if (auth_str)
+ vty_out(vty,
+ " area %s virtual-link %pI4 authentication%s\n",
+ buf, &vl_data->vl_peer, auth_str);
/* Auth key */
if (IF_DEF_PARAMS(vl_data->vl_oi->ifp)->auth_simple[0]
!= '\0')
}
/* 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);
void ospf_vty_clear_init(void)
{
install_element(ENABLE_NODE, &clear_ip_ospf_interface_cmd);
+ install_element(ENABLE_NODE, &clear_ip_ospf_process_cmd);
+ install_element(ENABLE_NODE, &clear_ip_ospf_neighbor_cmd);
}