if (!lsp_table)
return -1;
- /* See if route entry is selected; we really expect only 1 entry here. */
- if (!CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
- return 0;
-
lsp_type = lsp_type_from_rib_type (rib->type);
added = changed = 0;
*/
char *
mpls_label2str (u_int8_t num_labels, mpls_label_t *labels,
- char *buf, int len)
+ char *buf, int len, int pretty)
{
+ char *buf_ptr = buf;
buf[0] = '\0';
- if (num_labels == 1)
- snprintf (buf, len, "%u", labels[0]);
- else if (num_labels == 2)
- snprintf (buf, len, "%u/%u", labels[0], labels[1]);
+
+ if (pretty) {
+ if (num_labels == 1) {
+ label2str(labels[0], buf, len);
+ } else if (num_labels == 2) {
+ label2str(labels[0], buf, len);
+ buf_ptr += strlen(buf);
+
+ snprintf (buf_ptr, len, "/");
+ buf_ptr++;
+
+ label2str(labels[1], buf_ptr, len);
+ }
+ } else {
+ if (num_labels == 1)
+ snprintf (buf, len, "%u", labels[0]);
+ else if (num_labels == 2)
+ snprintf (buf, len, "%u/%u", labels[0], labels[1]);
+ }
return buf;
}
/* Label information */
if (nexthop->nh_label && nexthop->nh_label->num_labels)
{
- vty_out (vty, " label %s",
+ vty_out (vty, ", label %s",
mpls_label2str (nexthop->nh_label->num_labels,
- nexthop->nh_label->label, buf, BUFSIZ));
+ nexthop->nh_label->label, buf, BUFSIZ, 1));
}
vty_out (vty, "%s", VTY_NEWLINE);
json_object *json_nexthops = NULL;
json_object *json_nexthop = NULL;
json_object *json_route = NULL;
+ json_object *json_labels = NULL;
if (json)
{
break;
}
+ if (nexthop->nh_label && nexthop->nh_label->num_labels)
+ {
+ json_labels = json_object_new_array();
+
+ for (int label_index = 0; label_index < nexthop->nh_label->num_labels; label_index++)
+ json_object_array_add(json_labels, json_object_new_int(nexthop->nh_label->label[label_index]));
+
+ json_object_object_add(json_nexthop, "labels", json_labels);
+ }
+
json_object_array_add(json_nexthops, json_nexthop);
}
/* Label information */
if (nexthop->nh_label && nexthop->nh_label->num_labels)
{
- vty_out (vty, " label %s",
+ vty_out (vty, ", label %s",
mpls_label2str (nexthop->nh_label->num_labels,
- nexthop->nh_label->label, buf, BUFSIZ));
+ nexthop->nh_label->label, buf, BUFSIZ, 1));
}
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
if (si->snh_label.num_labels)
vty_out (vty, " label %s",
mpls_label2str (si->snh_label.num_labels,
- si->snh_label.label, buf, sizeof buf));
+ si->snh_label.label, buf, sizeof buf, 0));
vty_out (vty, "%s", VTY_NEWLINE);
if (si->snh_label.num_labels)
vty_out (vty, " label %s",
mpls_label2str (si->snh_label.num_labels,
- si->snh_label.label, buf, sizeof buf));
+ si->snh_label.label, buf, sizeof buf, 0));
vty_out (vty, "%s", VTY_NEWLINE);