diff options
Diffstat (limited to 'ospf6d/ospf6_asbr.c')
| -rw-r--r-- | ospf6d/ospf6_asbr.c | 77 | 
1 files changed, 56 insertions, 21 deletions
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index 0e419cbff6..af99bc0c88 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -1890,7 +1890,8 @@ static char *ospf6_as_external_lsa_get_prefix_str(struct ospf6_lsa *lsa,  	return (buf);  } -static int ospf6_as_external_lsa_show(struct vty *vty, struct ospf6_lsa *lsa) +static int ospf6_as_external_lsa_show(struct vty *vty, struct ospf6_lsa *lsa, +				      json_object *json_obj, bool use_json)  {  	struct ospf6_as_external_lsa *external;  	char buf[64]; @@ -1908,31 +1909,65 @@ static int ospf6_as_external_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)  		 (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T) ? 'T'  								      : '-')); -	vty_out(vty, "     Bits: %s\n", buf); -	vty_out(vty, "     Metric: %5lu\n", -		(unsigned long)OSPF6_ASBR_METRIC(external)); - -	ospf6_prefix_options_printbuf(external->prefix.prefix_options, buf, -				      sizeof(buf)); -	vty_out(vty, "     Prefix Options: %s\n", buf); +	if (use_json) { +		json_object_string_add(json_obj, "bits", buf); +		json_object_int_add(json_obj, "metric", +				    (unsigned long)OSPF6_ASBR_METRIC(external)); +		ospf6_prefix_options_printbuf(external->prefix.prefix_options, +					      buf, sizeof(buf)); +		json_object_string_add(json_obj, "prefixOptions", buf); +		json_object_int_add( +			json_obj, "referenceLsType", +			ntohs(external->prefix.prefix_refer_lstype)); +		json_object_string_add(json_obj, "prefix", +				       ospf6_as_external_lsa_get_prefix_str( +					       lsa, buf, sizeof(buf), 0)); + +		/* Forwarding-Address */ +		json_object_boolean_add( +			json_obj, "forwardingAddressPresent", +			CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F)); +		if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F)) +			json_object_string_add( +				json_obj, "forwardingAddress", +				ospf6_as_external_lsa_get_prefix_str( +					lsa, buf, sizeof(buf), 1)); + +		/* Tag */ +		json_object_boolean_add( +			json_obj, "tagPresent", +			CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T)); +		if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T)) +			json_object_int_add(json_obj, "tag", +					    ospf6_as_external_lsa_get_tag(lsa)); +	} else { +		vty_out(vty, "     Bits: %s\n", buf); +		vty_out(vty, "     Metric: %5lu\n", +			(unsigned long)OSPF6_ASBR_METRIC(external)); -	vty_out(vty, "     Referenced LSType: %d\n", -		ntohs(external->prefix.prefix_refer_lstype)); +		ospf6_prefix_options_printbuf(external->prefix.prefix_options, +					      buf, sizeof(buf)); +		vty_out(vty, "     Prefix Options: %s\n", buf); -	vty_out(vty, "     Prefix: %s\n", -		ospf6_as_external_lsa_get_prefix_str(lsa, buf, sizeof(buf), 0)); +		vty_out(vty, "     Referenced LSType: %d\n", +			ntohs(external->prefix.prefix_refer_lstype)); -	/* Forwarding-Address */ -	if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F)) { -		vty_out(vty, "     Forwarding-Address: %s\n", +		vty_out(vty, "     Prefix: %s\n",  			ospf6_as_external_lsa_get_prefix_str(lsa, buf, -							     sizeof(buf), 1)); -	} +							     sizeof(buf), 0)); + +		/* Forwarding-Address */ +		if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F)) { +			vty_out(vty, "     Forwarding-Address: %s\n", +				ospf6_as_external_lsa_get_prefix_str( +					lsa, buf, sizeof(buf), 1)); +		} -	/* Tag */ -	if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T)) { -		vty_out(vty, "     Tag: %" ROUTE_TAG_PRI "\n", -			ospf6_as_external_lsa_get_tag(lsa)); +		/* Tag */ +		if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T)) { +			vty_out(vty, "     Tag: %" ROUTE_TAG_PRI "\n", +				ospf6_as_external_lsa_get_tag(lsa)); +		}  	}  	return 0;  | 
