summaryrefslogtreecommitdiff
path: root/ldpd/ldp_vty_exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldpd/ldp_vty_exec.c')
-rw-r--r--ldpd/ldp_vty_exec.c943
1 files changed, 837 insertions, 106 deletions
diff --git a/ldpd/ldp_vty_exec.c b/ldpd/ldp_vty_exec.c
index 56a64c84f3..616847b363 100644
--- a/ldpd/ldp_vty_exec.c
+++ b/ldpd/ldp_vty_exec.c
@@ -46,6 +46,8 @@ struct show_params {
int family;
union ldpd_addr addr;
uint8_t prefixlen;
+ int capabilities;
+ int detail;
int json;
};
@@ -55,24 +57,46 @@ static int show_interface_msg(struct vty *, struct imsg *,
struct show_params *);
static int show_interface_msg_json(struct imsg *,
struct show_params *, json_object *);
-static void show_discovery_adj(struct vty *, char *,
- struct ctl_adj *);
static int show_discovery_msg(struct vty *, struct imsg *,
struct show_params *);
-static void show_discovery_adj_json(json_object *,
+static void show_discovery_detail_adj(struct vty *, char *,
struct ctl_adj *);
+static int show_discovery_detail_msg(struct vty *, struct imsg *,
+ struct show_params *);
static int show_discovery_msg_json(struct imsg *,
struct show_params *, json_object *);
-static void show_nbr_adj(struct vty *, char *, struct ctl_adj *);
+static void show_discovery_detail_adj_json(json_object *,
+ struct ctl_adj *);
+static int show_discovery_detail_msg_json(struct imsg *,
+ struct show_params *, json_object *);
+
static int show_nbr_msg(struct vty *, struct imsg *,
struct show_params *);
-static void show_nbr_adj_json(struct ctl_adj *, json_object *);
static int show_nbr_msg_json(struct imsg *, struct show_params *,
json_object *);
+static void show_nbr_detail_adj(struct vty *, char *,
+ struct ctl_adj *);
+static int show_nbr_detail_msg(struct vty *, struct imsg *,
+ struct show_params *);
+static void show_nbr_detail_adj_json(struct ctl_adj *,
+ json_object *);
+static int show_nbr_detail_msg_json(struct imsg *,
+ struct show_params *, json_object *);
+static void show_nbr_capabilities(struct vty *, struct ctl_nbr *);
+static int show_nbr_capabilities_msg(struct vty *, struct imsg *,
+ struct show_params *);
+static void show_nbr_capabilities_json(struct ctl_nbr *,
+ json_object *);
+static int show_nbr_capabilities_msg_json(struct imsg *,
+ struct show_params *, json_object *);
static int show_lib_msg(struct vty *, struct imsg *,
struct show_params *);
+static int show_lib_detail_msg(struct vty *, struct imsg *,
+ struct show_params *);
static int show_lib_msg_json(struct imsg *, struct show_params *,
json_object *);
+static int show_lib_detail_msg_json(struct imsg *,
+ struct show_params *, json_object *);
static int show_l2vpn_binding_msg(struct vty *, struct imsg *,
struct show_params *);
static int show_l2vpn_binding_msg_json(struct imsg *,
@@ -164,22 +188,73 @@ show_interface_msg_json(struct imsg *imsg, struct show_params *params,
return (0);
}
+static int
+show_discovery_msg(struct vty *vty, struct imsg *imsg,
+ struct show_params *params)
+{
+ struct ctl_adj *adj;
+ const char *addr;
+
+ switch (imsg->hdr.type) {
+ case IMSG_CTL_SHOW_DISCOVERY:
+ adj = imsg->data;
+
+ if (params->family != AF_UNSPEC && params->family != adj->af)
+ break;
+
+ vty_out(vty, "%-4s %-15s ", af_name(adj->af),
+ inet_ntoa(adj->id));
+ switch(adj->type) {
+ case HELLO_LINK:
+ vty_out(vty, "%-8s %-15s ", "Link", adj->ifname);
+ break;
+ case HELLO_TARGETED:
+ addr = log_addr(adj->af, &adj->src_addr);
+
+ vty_out(vty, "%-8s %-15s ", "Targeted", addr);
+ if (strlen(addr) > 15)
+ vty_out(vty, "\n%46s", " ");
+ break;
+ }
+ vty_out(vty, "%9u\n", adj->holdtime);
+ break;
+ case IMSG_CTL_END:
+ vty_out(vty, "%s", VTY_NEWLINE);
+ return (1);
+ default:
+ break;
+ }
+
+ return (0);
+}
+
static void
-show_discovery_adj(struct vty *vty, char *buffer, struct ctl_adj *adj)
+show_discovery_detail_adj(struct vty *vty, char *buffer, struct ctl_adj *adj)
{
size_t buflen = strlen(buffer);
snprintf(buffer + buflen, LDPBUFSIZ - buflen,
- " LDP Id: %s:0, Transport address: %s%s",
- inet_ntoa(adj->id), log_addr(adj->af,
- &adj->trans_addr), VTY_NEWLINE);
+ " LSR Id: %s:0%s", inet_ntoa(adj->id), VTY_NEWLINE);
+ buflen = strlen(buffer);
+ snprintf(buffer + buflen, LDPBUFSIZ - buflen,
+ " Source address: %s%s",
+ log_addr(adj->af, &adj->src_addr), VTY_NEWLINE);
+ buflen = strlen(buffer);
+ snprintf(buffer + buflen, LDPBUFSIZ - buflen,
+ " Transport address: %s%s",
+ log_addr(adj->af, &adj->trans_addr), VTY_NEWLINE);
+ buflen = strlen(buffer);
+ snprintf(buffer + buflen, LDPBUFSIZ - buflen,
+ " Hello hold time: %u secs (due in %u secs)%s",
+ adj->holdtime, adj->holdtime_remaining, VTY_NEWLINE);
buflen = strlen(buffer);
snprintf(buffer + buflen, LDPBUFSIZ - buflen,
- " Hold time: %u sec%s", adj->holdtime, VTY_NEWLINE);
+ " Dual-stack capability TLV: %s%s",
+ (adj->ds_tlv) ? "yes" : "no", VTY_NEWLINE);
}
static int
-show_discovery_msg(struct vty *vty, struct imsg *imsg,
+show_discovery_detail_msg(struct vty *vty, struct imsg *imsg,
struct show_params *params)
{
struct ctl_adj *adj;
@@ -207,7 +282,7 @@ show_discovery_msg(struct vty *vty, struct imsg *imsg,
buflen = strlen(ifaces_buffer);
snprintf(ifaces_buffer + buflen, LDPBUFSIZ - buflen,
" %s: %s%s", iface->name, (iface->no_adj) ?
- "xmit" : "xmit/recv", VTY_NEWLINE);
+ "(no adjacencies)" : "", VTY_NEWLINE);
break;
case IMSG_CTL_SHOW_DISC_TNBR:
tnbr = imsg->data;
@@ -220,8 +295,8 @@ show_discovery_msg(struct vty *vty, struct imsg *imsg,
buflen = strlen(tnbrs_buffer);
snprintf(tnbrs_buffer + buflen, LDPBUFSIZ - buflen,
" %s -> %s: %s%s", log_addr(tnbr->af, trans_addr),
- log_addr(tnbr->af, &tnbr->addr), (tnbr->no_adj) ? "xmit" :
- "xmit/recv", VTY_NEWLINE);
+ log_addr(tnbr->af, &tnbr->addr), (tnbr->no_adj) ?
+ "(no adjacencies)" : "", VTY_NEWLINE);
break;
case IMSG_CTL_SHOW_DISC_ADJ:
adj = imsg->data;
@@ -231,17 +306,26 @@ show_discovery_msg(struct vty *vty, struct imsg *imsg,
switch(adj->type) {
case HELLO_LINK:
- show_discovery_adj(vty, ifaces_buffer, adj);
+ show_discovery_detail_adj(vty, ifaces_buffer, adj);
break;
case HELLO_TARGETED:
- show_discovery_adj(vty, tnbrs_buffer, adj);
+ show_discovery_detail_adj(vty, tnbrs_buffer, adj);
break;
}
break;
case IMSG_CTL_END:
rtr_id.s_addr = ldp_rtr_id_get(ldpd_conf);
- vty_out(vty, "Local LDP Identifier: %s:0%s", inet_ntoa(rtr_id),
+ vty_out(vty, "Local:%s", VTY_NEWLINE);
+ vty_out(vty, " LSR Id: %s:0%s", inet_ntoa(rtr_id),
VTY_NEWLINE);
+ if (ldpd_conf->ipv4.flags & F_LDPD_AF_ENABLED)
+ vty_out(vty, " Transport Address (IPv4): %s%s",
+ log_addr(AF_INET, &ldpd_conf->ipv4.trans_addr),
+ VTY_NEWLINE);
+ if (ldpd_conf->ipv6.flags & F_LDPD_AF_ENABLED)
+ vty_out(vty, " Transport Address (IPv6): %s%s",
+ log_addr(AF_INET6, &ldpd_conf->ipv6.trans_addr),
+ VTY_NEWLINE);
vty_out(vty, "Discovery Sources:%s", VTY_NEWLINE);
vty_out(vty, " Interfaces:%s", VTY_NEWLINE);
vty_out(vty, "%s", ifaces_buffer);
@@ -256,8 +340,59 @@ show_discovery_msg(struct vty *vty, struct imsg *imsg,
return (0);
}
+static int
+show_discovery_msg_json(struct imsg *imsg, struct show_params *params,
+ json_object *json)
+{
+ struct ctl_adj *adj;
+ json_object *json_array;
+ json_object *json_adj;
+
+ switch (imsg->hdr.type) {
+ case IMSG_CTL_SHOW_DISCOVERY:
+ adj = imsg->data;
+
+ if (params->family != AF_UNSPEC && params->family != adj->af)
+ break;
+
+ json_object_object_get_ex(json, "adjacencies", &json_array);
+ if (!json_array) {
+ json_array = json_object_new_array();
+ json_object_object_add(json, "adjacencies", json_array);
+ }
+
+ json_adj = json_object_new_object();
+ json_object_string_add(json_adj, "addressFamily",
+ af_name(adj->af));
+ json_object_string_add(json_adj, "neighborId",
+ inet_ntoa(adj->id));
+ switch(adj->type) {
+ case HELLO_LINK:
+ json_object_string_add(json_adj, "type", "link");
+ json_object_string_add(json_adj, "interface",
+ adj->ifname);
+ break;
+ case HELLO_TARGETED:
+ json_object_string_add(json_adj, "type", "targeted");
+ json_object_string_add(json_adj, "peer",
+ log_addr(adj->af, &adj->src_addr));
+ break;
+ }
+ json_object_int_add(json_adj, "helloHoldtime", adj->holdtime);
+
+ json_object_array_add(json_array, json_adj);
+ break;
+ case IMSG_CTL_END:
+ return (1);
+ default:
+ break;
+ }
+
+ return (0);
+}
+
static void
-show_discovery_adj_json(json_object *json, struct ctl_adj *adj)
+show_discovery_detail_adj_json(json_object *json, struct ctl_adj *adj)
{
json_object *json_adj;
json_object *json_array;
@@ -269,15 +404,21 @@ show_discovery_adj_json(json_object *json, struct ctl_adj *adj)
}
json_adj = json_object_new_object();
- json_object_string_add(json_adj, "id", inet_ntoa(adj->id));
+ json_object_string_add(json_adj, "lsrId", inet_ntoa(adj->id));
+ json_object_string_add(json_adj, "sourceAddress", log_addr(adj->af,
+ &adj->src_addr));
json_object_string_add(json_adj, "transportAddress", log_addr(adj->af,
&adj->trans_addr));
- json_object_int_add(json_adj, "holdtime", adj->holdtime);
+ json_object_int_add(json_adj, "helloHoldtime", adj->holdtime);
+ json_object_int_add(json_adj, "helloHoldtimeRemaining",
+ adj->holdtime_remaining);
+ json_object_int_add(json_adj, "dualStackCapabilityTlv",
+ adj->ds_tlv);
json_object_array_add(json_array, json_adj);
}
static int
-show_discovery_msg_json(struct imsg *imsg, struct show_params *params,
+show_discovery_detail_msg_json(struct imsg *imsg, struct show_params *params,
json_object *json)
{
struct ctl_adj *adj;
@@ -294,7 +435,13 @@ show_discovery_msg_json(struct imsg *imsg, struct show_params *params,
switch (imsg->hdr.type) {
case IMSG_CTL_SHOW_DISCOVERY:
rtr_id.s_addr = ldp_rtr_id_get(ldpd_conf);
- json_object_string_add(json, "id", inet_ntoa(rtr_id));
+ json_object_string_add(json, "lsrId", inet_ntoa(rtr_id));
+ if (ldpd_conf->ipv4.flags & F_LDPD_AF_ENABLED)
+ json_object_string_add(json, "transportAddressIPv4",
+ log_addr(AF_INET, &ldpd_conf->ipv4.trans_addr));
+ if (ldpd_conf->ipv6.flags & F_LDPD_AF_ENABLED)
+ json_object_string_add(json, "transportAddressIPv6",
+ log_addr(AF_INET6, &ldpd_conf->ipv6.trans_addr));
json_interfaces = json_object_new_object();
json_object_object_add(json, "interfaces", json_interfaces);
json_targets = json_object_new_object();
@@ -310,10 +457,6 @@ show_discovery_msg_json(struct imsg *imsg, struct show_params *params,
break;
json_interface = json_object_new_object();
- json_object_boolean_true_add(json_interface, "transmit");
- if (!iface->no_adj)
- json_object_boolean_true_add(json_interface, "receive");
-
json_object_object_add(json_interfaces, iface->name,
json_interface);
json_container = json_interface;
@@ -329,10 +472,6 @@ show_discovery_msg_json(struct imsg *imsg, struct show_params *params,
json_target = json_object_new_object();
json_object_string_add(json_target, "sourceAddress",
log_addr(tnbr->af, trans_addr));
- json_object_boolean_true_add(json_target, "transmit");
- if (!tnbr->no_adj)
- json_object_boolean_true_add(json_target, "receive");
-
json_object_object_add(json_targets, log_addr(tnbr->af,
&tnbr->addr), json_target);
json_container = json_target;
@@ -345,10 +484,10 @@ show_discovery_msg_json(struct imsg *imsg, struct show_params *params,
switch(adj->type) {
case HELLO_LINK:
- show_discovery_adj_json(json_container, adj);
+ show_discovery_detail_adj_json(json_container, adj);
break;
case HELLO_TARGETED:
- show_discovery_adj_json(json_container, adj);
+ show_discovery_detail_adj_json(json_container, adj);
break;
}
break;
@@ -361,8 +500,37 @@ show_discovery_msg_json(struct imsg *imsg, struct show_params *params,
return (0);
}
+static int
+show_nbr_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
+{
+ struct ctl_nbr *nbr;
+ const char *addr;
+
+ switch (imsg->hdr.type) {
+ case IMSG_CTL_SHOW_NBR:
+ nbr = imsg->data;
+
+ addr = log_addr(nbr->af, &nbr->raddr);
+
+ vty_out(vty, "%-4s %-15s %-11s %-15s",
+ af_name(nbr->af), inet_ntoa(nbr->id),
+ nbr_state_name(nbr->nbr_state), addr);
+ if (strlen(addr) > 15)
+ vty_out(vty, "\n%48s", " ");
+ vty_out(vty, " %8s\n", nbr->uptime == 0 ? "-" :
+ log_time(nbr->uptime));
+ break;
+ case IMSG_CTL_END:
+ return (1);
+ default:
+ break;
+ }
+
+ return (0);
+}
+
static void
-show_nbr_adj(struct vty *vty, char *buffer, struct ctl_adj *adj)
+show_nbr_detail_adj(struct vty *vty, char *buffer, struct ctl_adj *adj)
{
size_t buflen = strlen(buffer);
@@ -380,9 +548,11 @@ show_nbr_adj(struct vty *vty, char *buffer, struct ctl_adj *adj)
}
static int
-show_nbr_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
+show_nbr_detail_msg(struct vty *vty, struct imsg *imsg,
+ struct show_params *params)
{
struct ctl_nbr *nbr;
+ struct ldp_stats *stats;
struct ctl_adj *adj;
static char v4adjs_buffer[LDPBUFSIZ];
static char v6adjs_buffer[LDPBUFSIZ];
@@ -399,25 +569,54 @@ show_nbr_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
log_addr(nbr->af, &nbr->laddr), ntohs(nbr->lport),
log_addr(nbr->af, &nbr->raddr), ntohs(nbr->rport),
VTY_NEWLINE);
- vty_out(vty, " Session Holdtime: %u sec%s", nbr->holdtime,
- VTY_NEWLINE);
+ vty_out(vty, " Authentication: %s%s",
+ (nbr->auth_method == AUTH_MD5SIG) ? "TCP MD5 Signature" :
+ "none", VTY_NEWLINE);
+ vty_out(vty, " Session Holdtime: %u secs; "
+ "KeepAlive interval: %u secs%s", nbr->holdtime,
+ nbr->holdtime / KEEPALIVE_PER_PERIOD, VTY_NEWLINE);
vty_out(vty, " State: %s; Downstream-Unsolicited%s",
nbr_state_name(nbr->nbr_state), VTY_NEWLINE);
vty_out(vty, " Up time: %s%s", log_time(nbr->uptime),
VTY_NEWLINE);
+
+ stats = &nbr->stats;
+ vty_out(vty, " Messages sent/rcvd:%s", VTY_NEWLINE);
+ vty_out(vty, " - Keepalive Messages: %u/%u%s",
+ stats->kalive_sent, stats->kalive_rcvd, VTY_NEWLINE);
+ vty_out(vty, " - Address Messages: %u/%u%s",
+ stats->addr_sent, stats->addr_rcvd, VTY_NEWLINE);
+ vty_out(vty, " - Address Withdraw Messages: %u/%u%s",
+ stats->addrwdraw_sent, stats->addrwdraw_rcvd, VTY_NEWLINE);
+ vty_out(vty, " - Notification Messages: %u/%u%s",
+ stats->notif_sent, stats->notif_rcvd, VTY_NEWLINE);
+ vty_out(vty, " - Capability Messages: %u/%u%s",
+ stats->capability_sent, stats->capability_rcvd, VTY_NEWLINE);
+ vty_out(vty, " - Label Mapping Messages: %u/%u%s",
+ stats->labelmap_sent, stats->labelmap_rcvd, VTY_NEWLINE);
+ vty_out(vty, " - Label Request Messages: %u/%u%s",
+ stats->labelreq_sent, stats->labelreq_rcvd, VTY_NEWLINE);
+ vty_out(vty, " - Label Withdraw Messages: %u/%u%s",
+ stats->labelwdraw_sent, stats->labelwdraw_rcvd, VTY_NEWLINE);
+ vty_out(vty, " - Label Release Messages: %u/%u%s",
+ stats->labelrel_sent, stats->labelrel_rcvd, VTY_NEWLINE);
+ vty_out(vty, " - Label Abort Request Messages: %u/%u%s",
+ stats->labelabreq_sent, stats->labelabreq_rcvd, VTY_NEWLINE);
+
+ show_nbr_capabilities(vty, nbr);
break;
case IMSG_CTL_SHOW_NBR_DISC:
adj = imsg->data;
switch (adj->af) {
case AF_INET:
- show_nbr_adj(vty, v4adjs_buffer, adj);
+ show_nbr_detail_adj(vty, v4adjs_buffer, adj);
break;
case AF_INET6:
- show_nbr_adj(vty, v6adjs_buffer, adj);
+ show_nbr_detail_adj(vty, v6adjs_buffer, adj);
break;
default:
- fatalx("show_nbr_msg: unknown af");
+ fatalx("show_nbr_detail_msg: unknown af");
}
break;
case IMSG_CTL_SHOW_NBR_END:
@@ -441,8 +640,49 @@ show_nbr_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
return (0);
}
+static int
+show_nbr_msg_json(struct imsg *imsg, struct show_params *params,
+ json_object *json)
+{
+ struct ctl_nbr *nbr;
+ json_object *json_array;
+ json_object *json_nbr;
+
+ switch (imsg->hdr.type) {
+ case IMSG_CTL_SHOW_NBR:
+ nbr = imsg->data;
+
+ json_object_object_get_ex(json, "neighbors", &json_array);
+ if (!json_array) {
+ json_array = json_object_new_array();
+ json_object_object_add(json, "neighbors", json_array);
+ }
+
+ json_nbr = json_object_new_object();
+ json_object_string_add(json_nbr, "addressFamily",
+ af_name(nbr->af));
+ json_object_string_add(json_nbr, "neighborId",
+ inet_ntoa(nbr->id));
+ json_object_string_add(json_nbr, "state",
+ nbr_state_name(nbr->nbr_state));
+ json_object_string_add(json_nbr, "transportAddress",
+ log_addr(nbr->af, &nbr->raddr));
+ json_object_string_add(json_nbr, "upTime",
+ log_time(nbr->uptime));
+
+ json_object_array_add(json_array, json_nbr);
+ break;
+ case IMSG_CTL_END:
+ return (1);
+ default:
+ break;
+ }
+
+ return (0);
+}
+
static void
-show_nbr_adj_json(struct ctl_adj *adj, json_object *adj_list)
+show_nbr_detail_adj_json(struct ctl_adj *adj, json_object *adj_list)
{
char adj_string[128];
@@ -462,12 +702,15 @@ show_nbr_adj_json(struct ctl_adj *adj, json_object *adj_list)
}
static int
-show_nbr_msg_json(struct imsg *imsg, struct show_params *params,
+show_nbr_detail_msg_json(struct imsg *imsg, struct show_params *params,
json_object *json)
{
struct ctl_nbr *nbr;
+ struct ldp_stats *stats;
struct ctl_adj *adj;
json_object *json_nbr;
+ json_object *json_array;
+ json_object *json_counter;
static json_object *json_nbr_sources;
static json_object *json_v4adjs;
static json_object *json_v6adjs;
@@ -477,6 +720,8 @@ show_nbr_msg_json(struct imsg *imsg, struct show_params *params,
nbr = imsg->data;
json_nbr = json_object_new_object();
+ json_object_object_add(json, inet_ntoa(nbr->id), json_nbr);
+
json_object_string_add(json_nbr, "peerId", inet_ntoa(nbr->id));
json_object_string_add(json_nbr, "tcpLocalAddress",
log_addr(nbr->af, &nbr->laddr));
@@ -486,13 +731,109 @@ show_nbr_msg_json(struct imsg *imsg, struct show_params *params,
log_addr(nbr->af, &nbr->raddr));
json_object_int_add(json_nbr, "tcpRemotePort",
ntohs(nbr->rport));
- json_object_int_add(json_nbr, "holdtime", nbr->holdtime);
+ json_object_string_add(json_nbr, "authentication",
+ (nbr->auth_method == AUTH_MD5SIG) ? "TCP MD5 Signature" :
+ "none");
+ json_object_int_add(json_nbr, "sessionHoldtime", nbr->holdtime);
+ json_object_int_add(json_nbr, "keepAliveInterval",
+ nbr->holdtime / KEEPALIVE_PER_PERIOD);
json_object_string_add(json_nbr, "state",
nbr_state_name(nbr->nbr_state));
json_object_string_add(json_nbr, "upTime",
log_time(nbr->uptime));
- json_object_object_add(json, inet_ntoa(nbr->id), json_nbr);
+ /* message_counters */
+ stats = &nbr->stats;
+ json_array = json_object_new_array();
+ json_object_object_add(json_nbr, "sentMessages", json_array);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "keepalive",
+ stats->kalive_sent);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "address",
+ stats->addr_sent);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "addressWithdraw",
+ stats->addrwdraw_sent);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "notification",
+ stats->notif_sent);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "capability",
+ stats->capability_sent);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "labelMapping",
+ stats->labelmap_sent);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "labelRequest",
+ stats->labelreq_sent);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "labelWithdraw",
+ stats->labelwdraw_sent);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "labelRelease",
+ stats->labelrel_sent);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "labelAbortRequest",
+ stats->labelabreq_sent);
+ json_object_array_add(json_array, json_counter);
+
+ json_array = json_object_new_array();
+ json_object_object_add(json_nbr, "receivedMessages", json_array);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "keepalive",
+ stats->kalive_rcvd);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "address",
+ stats->addr_rcvd);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "addressWithdraw",
+ stats->addrwdraw_rcvd);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "notification",
+ stats->notif_rcvd);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "capability",
+ stats->capability_rcvd);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "labelMapping",
+ stats->labelmap_rcvd);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "labelRequest",
+ stats->labelreq_rcvd);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "labelWithdraw",
+ stats->labelwdraw_rcvd);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "labelRelease",
+ stats->labelrel_rcvd);
+ json_object_array_add(json_array, json_counter);
+ json_counter = json_object_new_object();
+ json_object_int_add(json_counter, "labelAbortRequest",
+ stats->labelabreq_rcvd);
+ json_object_array_add(json_array, json_counter);
+
+ /* capabilities */
+ show_nbr_capabilities_json(nbr, json_nbr);
+
+ /* discovery sources */
json_nbr_sources = json_object_new_object();
json_object_object_add(json_nbr, "discoverySources",
json_nbr_sources);
@@ -509,7 +850,7 @@ show_nbr_msg_json(struct imsg *imsg, struct show_params *params,
json_object_object_add(json_nbr_sources, "ipv4",
json_v4adjs);
}
- show_nbr_adj_json(adj, json_v4adjs);
+ show_nbr_detail_adj_json(adj, json_v4adjs);
break;
case AF_INET6:
if (!json_v6adjs) {
@@ -517,10 +858,10 @@ show_nbr_msg_json(struct imsg *imsg, struct show_params *params,
json_object_object_add(json_nbr_sources, "ipv6",
json_v6adjs);
}
- show_nbr_adj_json(adj, json_v6adjs);
+ show_nbr_detail_adj_json(adj, json_v6adjs);
break;
default:
- fatalx("show_nbr_msg_json: unknown af");
+ fatalx("show_nbr_detail_msg_json: unknown af");
}
break;
case IMSG_CTL_SHOW_NBR_END:
@@ -534,6 +875,139 @@ show_nbr_msg_json(struct imsg *imsg, struct show_params *params,
return (0);
}
+void
+show_nbr_capabilities(struct vty *vty, struct ctl_nbr *nbr)
+{
+ vty_out(vty, " Capabilities Sent:%s"
+ " - Dynamic Announcement (0x0506)%s"
+ " - Typed Wildcard (0x050B)%s"
+ " - Unrecognized Notification (0x0603)%s",
+ VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
+ vty_out(vty, " Capabilities Received:%s", VTY_NEWLINE);
+ if (nbr->flags & F_NBR_CAP_DYNAMIC)
+ vty_out(vty, " - Dynamic Announcement (0x0506)%s",
+ VTY_NEWLINE);
+ if (nbr->flags & F_NBR_CAP_TWCARD)
+ vty_out(vty, " - Typed Wildcard (0x050B)%s", VTY_NEWLINE);
+ if (nbr->flags & F_NBR_CAP_UNOTIF)
+ vty_out(vty, " - Unrecognized Notification (0x0603)%s",
+ VTY_NEWLINE);
+}
+
+static int
+show_nbr_capabilities_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
+{
+ struct ctl_nbr *nbr;
+
+ switch (imsg->hdr.type) {
+ case IMSG_CTL_SHOW_NBR:
+ nbr = imsg->data;
+
+ if (nbr->nbr_state != NBR_STA_OPER)
+ break;
+
+ vty_out(vty, "Peer LDP Identifier: %s:0%s", inet_ntoa(nbr->id),
+ VTY_NEWLINE);
+ show_nbr_capabilities(vty, nbr);
+ break;
+ case IMSG_CTL_END:
+ vty_out(vty, "%s", VTY_NEWLINE);
+ return (1);
+ default:
+ break;
+ }
+
+ return (0);
+}
+
+static void
+show_nbr_capabilities_json(struct ctl_nbr *nbr, json_object *json_nbr)
+{
+ json_object *json_array;
+ json_object *json_cap;
+
+ /* sent capabilities */
+ json_array = json_object_new_array();
+ json_object_object_add(json_nbr, "sentCapabilities", json_array);
+
+ /* Dynamic Announcement (0x0506) */
+ json_cap = json_object_new_object();
+ json_object_string_add(json_cap, "description", "Dynamic Announcement");
+ json_object_string_add(json_cap, "tlvType", "0x0506");
+ json_object_array_add(json_array, json_cap);
+
+ /* Typed Wildcard (0x050B) */
+ json_cap = json_object_new_object();
+ json_object_string_add(json_cap, "description", "Typed Wildcard");
+ json_object_string_add(json_cap, "tlvType", "0x050B");
+ json_object_array_add(json_array, json_cap);
+
+ /* Unrecognized Notification (0x0603) */
+ json_cap = json_object_new_object();
+ json_object_string_add(json_cap, "description",
+ "Unrecognized Notification");
+ json_object_string_add(json_cap, "tlvType", "0x0603");
+ json_object_array_add(json_array, json_cap);
+
+ /* received capabilities */
+ json_array = json_object_new_array();
+ json_object_object_add(json_nbr, "receivedCapabilities", json_array);
+
+ /* Dynamic Announcement (0x0506) */
+ if (nbr->flags & F_NBR_CAP_DYNAMIC) {
+ json_cap = json_object_new_object();
+ json_object_string_add(json_cap, "description",
+ "Dynamic Announcement");
+ json_object_string_add(json_cap, "tlvType", "0x0506");
+ json_object_array_add(json_array, json_cap);
+ }
+
+ /* Typed Wildcard (0x050B) */
+ if (nbr->flags & F_NBR_CAP_TWCARD) {
+ json_cap = json_object_new_object();
+ json_object_string_add(json_cap, "description",
+ "Typed Wildcard");
+ json_object_string_add(json_cap, "tlvType", "0x050B");
+ json_object_array_add(json_array, json_cap);
+ }
+
+ /* Unrecognized Notification (0x0603) */
+ if (nbr->flags & F_NBR_CAP_UNOTIF) {
+ json_cap = json_object_new_object();
+ json_object_string_add(json_cap, "description",
+ "Unrecognized Notification");
+ json_object_string_add(json_cap, "tlvType", "0x0603");
+ json_object_array_add(json_array, json_cap);
+ }
+}
+
+static int
+show_nbr_capabilities_msg_json(struct imsg *imsg, struct show_params *params,
+ json_object *json)
+{
+ struct ctl_nbr *nbr;
+ json_object *json_nbr;
+
+ switch (imsg->hdr.type) {
+ case IMSG_CTL_SHOW_NBR:
+ nbr = imsg->data;
+
+ if (nbr->nbr_state != NBR_STA_OPER)
+ break;
+
+ json_nbr = json_object_new_object();
+ json_object_object_add(json, inet_ntoa(nbr->id), json_nbr);
+ show_nbr_capabilities_json(nbr, json_nbr);
+ break;
+ case IMSG_CTL_END:
+ return (1);
+ default:
+ break;
+ }
+
+ return (0);
+}
+
static int
show_lib_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
{
@@ -541,34 +1015,99 @@ show_lib_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
char dstnet[BUFSIZ];
switch (imsg->hdr.type) {
- case IMSG_CTL_SHOW_LIB:
+ case IMSG_CTL_SHOW_LIB_BEGIN:
+ case IMSG_CTL_SHOW_LIB_RCVD:
rt = imsg->data;
+ if (imsg->hdr.type == IMSG_CTL_SHOW_LIB_BEGIN &&
+ !rt->no_downstream)
+ break;
+
if (params->family != AF_UNSPEC && params->family != rt->af)
break;
snprintf(dstnet, sizeof(dstnet), "%s/%d",
log_addr(rt->af, &rt->prefix), rt->prefixlen);
- if (rt->first) {
- vty_out(vty, "%s%s", dstnet, VTY_NEWLINE);
- vty_out(vty, "%-8sLocal binding: label: %s%s", "",
- log_label(rt->local_label), VTY_NEWLINE);
-
- if (rt->remote_label != NO_LABEL) {
- vty_out(vty, "%-8sRemote bindings:%s", "",
- VTY_NEWLINE);
- vty_out(vty, "%-12sPeer Label%s",
- "", VTY_NEWLINE);
- vty_out(vty, "%-12s----------------- "
- "---------%s", "", VTY_NEWLINE);
- } else
- vty_out(vty, "%-8sNo remote bindings%s", "",
- VTY_NEWLINE);
+ vty_out(vty, "%-4s %-20s", af_name(rt->af), dstnet);
+ if (strlen(dstnet) > 20)
+ vty_out(vty, "\n%25s", " ");
+ vty_out(vty, " %-15s %-11s %-13s %6s\n", inet_ntoa(rt->nexthop),
+ log_label(rt->local_label), log_label(rt->remote_label),
+ rt->in_use ? "yes" : "no");
+ break;
+ case IMSG_CTL_END:
+ vty_out(vty, "%s", VTY_NEWLINE);
+ return (1);
+ default:
+ break;
+ }
+
+ return (0);
+}
+
+static int
+show_lib_detail_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
+{
+ struct ctl_rt *rt;
+ char dstnet[BUFSIZ];
+ static int upstream, downstream;
+ size_t buflen;
+ static char sent_buffer[LDPBUFSIZ];
+ static char rcvd_buffer[LDPBUFSIZ];
+
+ switch (imsg->hdr.type) {
+ case IMSG_CTL_SHOW_LIB_BEGIN:
+ case IMSG_CTL_SHOW_LIB_SENT:
+ case IMSG_CTL_SHOW_LIB_RCVD:
+ case IMSG_CTL_SHOW_LIB_END:
+ rt = imsg->data;
+ if (params->family != AF_UNSPEC && params->family != rt->af)
+ return (0);
+ break;
+ default:
+ break;
+ }
+
+ switch (imsg->hdr.type) {
+ case IMSG_CTL_SHOW_LIB_BEGIN:
+ upstream = 0;
+ downstream = 0;
+ sent_buffer[0] = '\0';
+ rcvd_buffer[0] = '\0';
+
+ snprintf(dstnet, sizeof(dstnet), "%s/%d",
+ log_addr(rt->af, &rt->prefix), rt->prefixlen);
+
+ vty_out(vty, "%s%s", dstnet, VTY_NEWLINE);
+ vty_out(vty, "%-8sLocal binding: label: %s%s", "",
+ log_label(rt->local_label), VTY_NEWLINE);
+ break;
+ case IMSG_CTL_SHOW_LIB_SENT:
+ upstream = 1;
+ buflen = strlen(sent_buffer);
+ snprintf(sent_buffer + buflen, LDPBUFSIZ - buflen,
+ "%12s%s:0%s", "", inet_ntoa(rt->nexthop), VTY_NEWLINE);
+ break;
+ case IMSG_CTL_SHOW_LIB_RCVD:
+ downstream = 1;
+ buflen = strlen(rcvd_buffer);
+ snprintf(rcvd_buffer + buflen, LDPBUFSIZ - buflen,
+ "%12s%s:0, label %s%s%s", "", inet_ntoa(rt->nexthop),
+ log_label(rt->remote_label),
+ rt->in_use ? " (in use)" : "", VTY_NEWLINE);
+ break;
+ case IMSG_CTL_SHOW_LIB_END:
+ if (upstream) {
+ vty_out(vty, "%-8sAdvertised to:%s", "", VTY_NEWLINE);
+ vty_out(vty, "%s", sent_buffer);
}
- if (rt->remote_label != NO_LABEL)
- vty_out(vty, "%12s%-20s%s%s", "", inet_ntoa(rt->nexthop),
- log_label(rt->remote_label), VTY_NEWLINE);
+ if (downstream) {
+ vty_out(vty, "%-8sRemote bindings:%s", "", VTY_NEWLINE);
+ vty_out(vty, "%s", rcvd_buffer);
+ } else
+ vty_out(vty, "%-8sNo remote bindings%s", "",
+ VTY_NEWLINE);
break;
case IMSG_CTL_END:
vty_out(vty, "%s", VTY_NEWLINE);
@@ -584,42 +1123,109 @@ static int
show_lib_msg_json(struct imsg *imsg, struct show_params *params,
json_object *json)
{
+ struct ctl_rt *rt;
+ json_object *json_array;
+ json_object *json_lib_entry;
+ char dstnet[BUFSIZ];
+
+ switch (imsg->hdr.type) {
+ case IMSG_CTL_SHOW_LIB_BEGIN:
+ case IMSG_CTL_SHOW_LIB_RCVD:
+ rt = imsg->data;
+
+ if (imsg->hdr.type == IMSG_CTL_SHOW_LIB_BEGIN &&
+ !rt->no_downstream)
+ break;
+
+ json_object_object_get_ex(json, "bindings", &json_array);
+ if (!json_array) {
+ json_array = json_object_new_array();
+ json_object_object_add(json, "bindings", json_array);
+ }
+
+ json_lib_entry = json_object_new_object();
+ json_object_string_add(json_lib_entry, "addressFamily",
+ af_name(rt->af));
+ snprintf(dstnet, sizeof(dstnet), "%s/%d",
+ log_addr(rt->af, &rt->prefix), rt->prefixlen);
+ json_object_string_add(json_lib_entry, "prefix", dstnet);
+ json_object_string_add(json_lib_entry, "neighborId",
+ inet_ntoa(rt->nexthop));
+ json_object_string_add(json_lib_entry, "localLabel",
+ log_label(rt->local_label));
+ json_object_string_add(json_lib_entry, "remoteLabel",
+ log_label(rt->remote_label));
+ json_object_int_add(json_lib_entry, "inUse", rt->in_use);
+
+ json_object_array_add(json_array, json_lib_entry);
+ break;
+ case IMSG_CTL_END:
+ return (1);
+ default:
+ break;
+ }
+
+ return (0);
+}
+
+static int
+show_lib_detail_msg_json(struct imsg *imsg, struct show_params *params,
+ json_object *json)
+{
struct ctl_rt *rt;
char dstnet[BUFSIZ];
- static json_object *json_binding;
+ static json_object *json_lib_entry;
+ static json_object *json_adv_labels;
+ json_object *json_adv_label;
static json_object *json_remote_labels;
json_object *json_remote_label;
switch (imsg->hdr.type) {
- case IMSG_CTL_SHOW_LIB:
+ case IMSG_CTL_SHOW_LIB_BEGIN:
+ case IMSG_CTL_SHOW_LIB_SENT:
+ case IMSG_CTL_SHOW_LIB_RCVD:
+ case IMSG_CTL_SHOW_LIB_END:
rt = imsg->data;
-
if (params->family != AF_UNSPEC && params->family != rt->af)
- break;
+ return (0);
+ break;
+ default:
+ break;
+ }
+ switch (imsg->hdr.type) {
+ case IMSG_CTL_SHOW_LIB_BEGIN:
snprintf(dstnet, sizeof(dstnet), "%s/%d",
log_addr(rt->af, &rt->prefix), rt->prefixlen);
- if (rt->first) {
- json_binding = json_object_new_object();
- json_object_string_add(json_binding, "localLabel",
- log_label(rt->local_label));
+ json_lib_entry = json_object_new_object();
+ json_object_string_add(json_lib_entry, "localLabel",
+ log_label(rt->local_label));
- json_remote_labels = json_object_new_array();
- json_object_object_add(json_binding, "remoteLabels",
- json_remote_labels);
- json_object_object_add(json, dstnet, json_binding);
- }
+ json_adv_labels = json_object_new_array();
+ json_object_object_add(json_lib_entry, "advertisedTo",
+ json_adv_labels);
- if (rt->remote_label != NO_LABEL) {
- json_remote_label = json_object_new_object();
- json_object_string_add(json_remote_label, "nexthop",
- inet_ntoa(rt->nexthop));
- json_object_string_add(json_remote_label, "label",
- log_label(rt->remote_label));
- json_object_array_add(json_remote_labels,
- json_remote_label);
- }
+ json_remote_labels = json_object_new_array();
+ json_object_object_add(json_lib_entry, "remoteLabels",
+ json_remote_labels);
+
+ json_object_object_add(json, dstnet, json_lib_entry);
+ break;
+ case IMSG_CTL_SHOW_LIB_SENT:
+ json_adv_label = json_object_new_object();
+ json_object_string_add(json_adv_label, "neighborId",
+ inet_ntoa(rt->nexthop));
+ json_object_array_add(json_adv_labels, json_adv_label);
+ break;
+ case IMSG_CTL_SHOW_LIB_RCVD:
+ json_remote_label = json_object_new_object();
+ json_object_string_add(json_remote_label, "neighborId",
+ inet_ntoa(rt->nexthop));
+ json_object_string_add(json_remote_label, "label",
+ log_label(rt->remote_label));
+ json_object_int_add(json_remote_label, "inUse", rt->in_use);
+ json_object_array_add(json_remote_labels, json_remote_label);
break;
case IMSG_CTL_END:
return (1);
@@ -825,34 +1431,83 @@ static int
ldp_vty_dispatch_msg(struct vty *vty, struct imsg *imsg, enum show_command cmd,
struct show_params *params, json_object *json)
{
+ int ret;
+
switch (cmd) {
case SHOW_IFACE:
- if (json)
- return (show_interface_msg_json(imsg, params, json));
- return (show_interface_msg(vty, imsg, params));
+ if (params->json)
+ ret = show_interface_msg_json(imsg, params, json);
+ else
+ ret = show_interface_msg(vty, imsg, params);
+ break;
case SHOW_DISC:
- if (json)
- return (show_discovery_msg_json(imsg, params, json));
- return (show_discovery_msg(vty, imsg, params));
+ if (params->detail) {
+ if (params->json)
+ ret = show_discovery_detail_msg_json(imsg,
+ params, json);
+ else
+ ret = show_discovery_detail_msg(vty, imsg,
+ params);
+ } else {
+ if (params->json)
+ ret = show_discovery_msg_json(imsg, params,
+ json);
+ else
+ ret = show_discovery_msg(vty, imsg, params);
+ }
+ break;
case SHOW_NBR:
- if (json)
- return (show_nbr_msg_json(imsg, params, json));
- return (show_nbr_msg(vty, imsg, params));
+ if (params->capabilities) {
+ if (params->json)
+ ret = show_nbr_capabilities_msg_json(imsg,
+ params, json);
+ else
+ ret = show_nbr_capabilities_msg(vty, imsg,
+ params);
+ } else if (params->detail) {
+ if (params->json)
+ ret = show_nbr_detail_msg_json(imsg, params,
+ json);
+ else
+ ret = show_nbr_detail_msg(vty, imsg, params);
+ } else {
+ if (params->json)
+ ret = show_nbr_msg_json(imsg, params, json);
+ else
+ ret = show_nbr_msg(vty, imsg, params);
+ }
+ break;
case SHOW_LIB:
- if (json)
- return (show_lib_msg_json(imsg, params, json));
- return (show_lib_msg(vty, imsg, params));
+ if (params->detail) {
+ if (params->json)
+ ret = show_lib_detail_msg_json(imsg, params,
+ json);
+ else
+ ret = show_lib_detail_msg(vty, imsg, params);
+ } else {
+ if (params->json)
+ ret = show_lib_msg_json(imsg, params, json);
+ else
+ ret = show_lib_msg(vty, imsg, params);
+ }
+ break;
case SHOW_L2VPN_PW:
- if (json)
- return (show_l2vpn_pw_msg_json(imsg, params, json));
- return (show_l2vpn_pw_msg(vty, imsg, params));
+ if (params->json)
+ ret = show_l2vpn_pw_msg_json(imsg, params, json);
+ else
+ ret = show_l2vpn_pw_msg(vty, imsg, params);
+ break;
case SHOW_L2VPN_BINDING:
- if (json)
- return (show_l2vpn_binding_msg_json(imsg, params, json));
- return (show_l2vpn_binding_msg(vty, imsg, params));
+ if (params->json)
+ ret = show_l2vpn_binding_msg_json(imsg, params, json);
+ else
+ ret = show_l2vpn_binding_msg(vty, imsg, params);
+ break;
default:
return (0);
}
+
+ return (ret);
}
static int
@@ -944,8 +1599,14 @@ ldp_vty_show_binding(struct vty *vty, struct vty_arg *args[])
memset(&params, 0, sizeof(params));
params.family = af;
+ params.detail = vty_get_arg_value(args, "detail") ? 1 : 0;
params.json = vty_get_arg_value(args, "json") ? 1 : 0;
+ if (!params.detail && !params.json)
+ vty_out(vty, "%-4s %-20s %-15s %-11s %-13s %6s\n", "AF",
+ "Destination", "Nexthop", "Local Label", "Remote Label",
+ "In Use");
+
imsg_compose(&ibuf, IMSG_CTL_SHOW_LIB, 0, 0, -1, NULL, 0);
return (ldp_vty_dispatch(vty, &ibuf, SHOW_LIB, &params));
}
@@ -967,9 +1628,18 @@ ldp_vty_show_discovery(struct vty *vty, struct vty_arg *args[])
memset(&params, 0, sizeof(params));
params.family = af;
+ params.detail = vty_get_arg_value(args, "detail") ? 1 : 0;
params.json = vty_get_arg_value(args, "json") ? 1 : 0;
- imsg_compose(&ibuf, IMSG_CTL_SHOW_DISCOVERY, 0, 0, -1, NULL, 0);
+ if (!params.detail && !params.json)
+ vty_out(vty, "%-4s %-15s %-8s %-15s %9s\n",
+ "AF", "ID", "Type", "Source", "Holdtime");
+
+ if (params.detail)
+ imsg_compose(&ibuf, IMSG_CTL_SHOW_DISCOVERY_DTL, 0, 0, -1,
+ NULL, 0);
+ else
+ imsg_compose(&ibuf, IMSG_CTL_SHOW_DISCOVERY, 0, 0, -1, NULL, 0);
return (ldp_vty_dispatch(vty, &ibuf, SHOW_DISC, &params));
}
@@ -1006,6 +1676,58 @@ ldp_vty_show_interface(struct vty *vty, struct vty_arg *args[])
}
int
+ldp_vty_show_capabilities(struct vty *vty, struct vty_arg *args[])
+{
+ if (vty_get_arg_value(args, "json")) {
+ json_object *json;
+ json_object *json_array;
+ json_object *json_cap;
+
+ json = json_object_new_object();
+ json_array = json_object_new_array();
+ json_object_object_add(json, "capabilities", json_array);
+
+ /* Dynamic Announcement (0x0506) */
+ json_cap = json_object_new_object();
+ json_object_string_add(json_cap, "description",
+ "Dynamic Announcement");
+ json_object_string_add(json_cap, "tlvType",
+ "0x0506");
+ json_object_array_add(json_array, json_cap);
+
+ /* Typed Wildcard (0x050B) */
+ json_cap = json_object_new_object();
+ json_object_string_add(json_cap, "description",
+ "Typed Wildcard");
+ json_object_string_add(json_cap, "tlvType",
+ "0x050B");
+ json_object_array_add(json_array, json_cap);
+
+ /* Unrecognized Notification (0x0603) */
+ json_cap = json_object_new_object();
+ json_object_string_add(json_cap, "description",
+ "Unrecognized Notification");
+ json_object_string_add(json_cap, "tlvType",
+ "0x0603");
+ json_object_array_add(json_array, json_cap);
+
+ vty_out(vty, "%s%s", json_object_to_json_string_ext(json,
+ JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
+ json_object_free(json);
+ return (0);
+ }
+
+ vty_out(vty,
+ "Supported LDP Capabilities%s"
+ " * Dynamic Announcement (0x0506)%s"
+ " * Typed Wildcard (0x050B)%s"
+ " * Unrecognized Notification (0x0603)%s%s", VTY_NEWLINE,
+ VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
+
+ return (0);
+}
+
+int
ldp_vty_show_neighbor(struct vty *vty, struct vty_arg *args[])
{
struct imsgbuf ibuf;
@@ -1015,8 +1737,17 @@ ldp_vty_show_neighbor(struct vty *vty, struct vty_arg *args[])
return (CMD_WARNING);
memset(&params, 0, sizeof(params));
+ params.capabilities = vty_get_arg_value(args, "capabilities") ? 1 : 0;
+ params.detail = vty_get_arg_value(args, "detail") ? 1 : 0;
params.json = vty_get_arg_value(args, "json") ? 1 : 0;
+ if (params.capabilities)
+ params.detail = 1;
+
+ if (!params.detail && !params.json)
+ vty_out(vty, "%-4s %-15s %-11s %-15s %8s\n",
+ "AF", "ID", "State", "Remote Address", "Uptime");
+
imsg_compose(&ibuf, IMSG_CTL_SHOW_NBR, 0, 0, -1, NULL, 0);
return (ldp_vty_dispatch(vty, &ibuf, SHOW_NBR, &params));
}