diff options
Diffstat (limited to 'ospfd/ospf_vty.c')
| -rw-r--r-- | ospfd/ospf_vty.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index ea73834a66..71275e49d2 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -83,7 +83,8 @@ static void area_id2str(char *buf, int length, struct in_addr *area_id, if (area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD) inet_ntop(AF_INET, area_id, buf, length); else - sprintf(buf, "%lu", (unsigned long)ntohl(area_id->s_addr)); + snprintf(buf, length, "%lu", + (unsigned long)ntohl(area_id->s_addr)); } static int str2metric(const char *str, int *metric) @@ -9263,8 +9264,8 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, char buf1[19]; - snprintf(buf1, 19, "%s/%d", inet_ntoa(rn->p.u.prefix4), - rn->p.prefixlen); + snprintf(buf1, sizeof(buf1), "%s/%d", + inet_ntoa(rn->p.u.prefix4), rn->p.prefixlen); json_route = json_object_new_object(); if (json) { json_object_object_add(json, buf1, json_route); @@ -9997,7 +9998,7 @@ static int config_write_interface(struct vty *vty) static int config_write_network_area(struct vty *vty, struct ospf *ospf) { struct route_node *rn; - uint8_t buf[INET_ADDRSTRLEN]; + char buf[INET_ADDRSTRLEN]; /* `network area' print. */ for (rn = route_top(ospf->networks); rn; rn = route_next(rn)) @@ -10006,12 +10007,12 @@ static int config_write_network_area(struct vty *vty, struct ospf *ospf) /* Create Area ID string by specified Area ID format. */ if (n->area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD) - inet_ntop(AF_INET, &n->area_id, (char *)buf, + inet_ntop(AF_INET, &n->area_id, buf, sizeof(buf)); else - sprintf((char *)buf, "%lu", - (unsigned long int)ntohl( - n->area_id.s_addr)); + snprintf(buf, sizeof(buf), "%lu", + (unsigned long int)ntohl( + n->area_id.s_addr)); /* Network print. */ vty_out(vty, " network %s/%d area %s\n", @@ -10026,13 +10027,13 @@ static int config_write_ospf_area(struct vty *vty, struct ospf *ospf) { struct listnode *node; struct ospf_area *area; - uint8_t buf[INET_ADDRSTRLEN]; + char buf[INET_ADDRSTRLEN]; /* Area configuration print. */ for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { struct route_node *rn1; - area_id2str((char *)buf, sizeof(buf), &area->area_id, + area_id2str(buf, sizeof(buf), &area->area_id, area->area_id_fmt); if (area->auth_type != OSPF_AUTH_NULL) { @@ -10555,14 +10556,21 @@ void ospf_vty_show_init(void) } +static int config_write_interface(struct vty *vty); /* ospfd's interface node. */ -static struct cmd_node interface_node = {INTERFACE_NODE, "%s(config-if)# ", 1}; +static struct cmd_node interface_node = { + .name = "interface", + .node = INTERFACE_NODE, + .parent_node = CONFIG_NODE, + .prompt = "%s(config-if)# ", + .config_write = config_write_interface, +}; /* Initialization of OSPF interface. */ static void ospf_vty_if_init(void) { /* Install interface node. */ - install_node(&interface_node, config_write_interface); + install_node(&interface_node); if_cmd_init(); /* "ip ospf authentication" commands. */ @@ -10668,7 +10676,14 @@ static void ospf_vty_zebra_init(void) #endif /* 0 */ } -static struct cmd_node ospf_node = {OSPF_NODE, "%s(config-router)# ", 1}; +static int ospf_config_write(struct vty *vty); +static struct cmd_node ospf_node = { + .name = "ospf", + .node = OSPF_NODE, + .parent_node = CONFIG_NODE, + .prompt = "%s(config-router)# ", + .config_write = ospf_config_write, +}; static void ospf_interface_clear(struct interface *ifp) { @@ -10741,7 +10756,7 @@ void ospf_vty_clear_init(void) void ospf_vty_init(void) { /* Install ospf top node. */ - install_node(&ospf_node, ospf_config_write); + install_node(&ospf_node); /* "router ospf" commands. */ install_element(CONFIG_NODE, &router_ospf_cmd); |
