diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index 2cffc3a397..adff76ec41 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -684,11 +684,9 @@ static int ospf6_link_lsa_show(struct vty *vty, struct ospf6_lsa *lsa, int prefixnum; char buf[128], options[32]; struct ospf6_prefix *prefix; - const char *p, *mc, *la, *nu; struct in6_addr in6; json_object *json_loop; json_object *json_arr = NULL; - char str[15]; char prefix_string[133]; link_lsa = (struct ospf6_link_lsa *)((caddr_t)lsa->header @@ -720,26 +718,13 @@ static int ospf6_link_lsa_show(struct vty *vty, struct ospf6_lsa *lsa, || current + OSPF6_PREFIX_SIZE(prefix) > end) break; - p = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_P) - ? "P" - : "--"); - mc = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_MC) - ? "MC" - : "--"); - la = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_LA) - ? "LA" - : "--"); - nu = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) - ? "NU" - : "--"); + ospf6_prefix_options_printbuf(prefix->prefix_options, buf, + sizeof(buf)); if (use_json) { json_loop = json_object_new_object(); - snprintf(str, sizeof(str), "%s|%s|%s|%s", p, mc, la, - nu); - json_object_string_add(json_loop, "prefixOption", str); + json_object_string_add(json_loop, "prefixOption", buf); } else - vty_out(vty, " Prefix Options: %s|%s|%s|%s\n", p, - mc, la, nu); + vty_out(vty, " Prefix Options: %s\n", buf); memset(&in6, 0, sizeof(in6)); memcpy(&in6, OSPF6_PREFIX_BODY(prefix), @@ -918,11 +903,9 @@ static int ospf6_intra_prefix_lsa_show(struct vty *vty, struct ospf6_lsa *lsa, char buf[128]; struct ospf6_prefix *prefix; char id[16], adv_router[16]; - const char *p, *mc, *la, *nu; struct in6_addr in6; json_object *json_loop; json_object *json_arr = NULL; - char str[15]; char prefix_string[133]; intra_prefix_lsa = (struct ospf6_intra_prefix_lsa @@ -961,26 +944,13 @@ static int ospf6_intra_prefix_lsa_show(struct vty *vty, struct ospf6_lsa *lsa, || current + OSPF6_PREFIX_SIZE(prefix) > end) break; - p = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_P) - ? "P" - : "--"); - mc = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_MC) - ? "MC" - : "--"); - la = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_LA) - ? "LA" - : "--"); - nu = (CHECK_FLAG(prefix->prefix_options, OSPF6_PREFIX_OPTION_NU) - ? "NU" - : "--"); + ospf6_prefix_options_printbuf(prefix->prefix_options, buf, + sizeof(buf)); if (use_json) { json_loop = json_object_new_object(); - snprintf(str, sizeof(str), "%s|%s|%s|%s", p, mc, la, - nu); - json_object_string_add(json_loop, "prefixOption", str); + json_object_string_add(json_loop, "prefixOption", buf); } else - vty_out(vty, " Prefix Options: %s|%s|%s|%s\n", p, - mc, la, nu); + vty_out(vty, " Prefix Options: %s\n", buf); memset(&in6, 0, sizeof(in6)); memcpy(&in6, OSPF6_PREFIX_BODY(prefix), diff --git a/ospf6d/ospf6_proto.c b/ospf6d/ospf6_proto.c index 864974c9a4..e60d2c7e0e 100644 --- a/ospf6d/ospf6_proto.c +++ b/ospf6d/ospf6_proto.c @@ -60,7 +60,14 @@ void ospf6_prefix_apply_mask(struct ospf6_prefix *op) void ospf6_prefix_options_printbuf(uint8_t prefix_options, char *buf, int size) { - snprintf(buf, size, "xxx"); + const char *dn, *p, *mc, *la, *nu; + + dn = (CHECK_FLAG(prefix_options, OSPF6_PREFIX_OPTION_DN) ? "DN" : "--"); + p = (CHECK_FLAG(prefix_options, OSPF6_PREFIX_OPTION_P) ? "P" : "--"); + mc = (CHECK_FLAG(prefix_options, OSPF6_PREFIX_OPTION_MC) ? "MC" : "--"); + la = (CHECK_FLAG(prefix_options, OSPF6_PREFIX_OPTION_LA) ? "LA" : "--"); + nu = (CHECK_FLAG(prefix_options, OSPF6_PREFIX_OPTION_NU) ? "NU" : "--"); + snprintf(buf, size, "%s|%s|%s|%s|%s", dn, p, mc, la, nu); } void ospf6_capability_printbuf(char capability, char *buf, int size) diff --git a/ospf6d/ospf6_proto.h b/ospf6d/ospf6_proto.h index 3876a98c50..da6b270e01 100644 --- a/ospf6d/ospf6_proto.h +++ b/ospf6d/ospf6_proto.h @@ -69,6 +69,8 @@ struct ospf6_prefix { #define OSPF6_PREFIX_OPTION_LA (1 << 1) /* Local Address */ #define OSPF6_PREFIX_OPTION_MC (1 << 2) /* MultiCast */ #define OSPF6_PREFIX_OPTION_P (1 << 3) /* Propagate (NSSA) */ +#define OSPF6_PREFIX_OPTION_DN \ + (1 << 4) /* DN bit to prevent loops in VPN environment */ /* caddr_t OSPF6_PREFIX_BODY (struct ospf6_prefix *); */ #define OSPF6_PREFIX_BODY(x) ((caddr_t)(x) + sizeof(struct ospf6_prefix))