]> git.proxmox.com Git - mirror_frr.git/blobdiff - ldpd/ldp_vty_exec.c
Merge pull request #5412 from opensourcerouting/bfdd-vrf-fix
[mirror_frr.git] / ldpd / ldp_vty_exec.c
index ed87e213879e6b5d45ffb1e558df994012b01334..66c127abdc982b1f67a0710c49f26f35136c1adf 100644 (file)
@@ -44,9 +44,28 @@ struct show_params {
        int             family;
        union ldpd_addr addr;
        uint8_t         prefixlen;
-       int             capabilities;
        int             detail;
        int             json;
+       union {
+               struct {
+                       struct in_addr lsr_id;
+                       int capabilities;
+               } neighbor;
+               struct {
+                       struct prefix prefix;
+                       int longer_prefixes;
+                       struct in_addr neighbor;
+                       uint32_t local_label;
+                       uint32_t remote_label;
+               } lib;
+               struct {
+                       struct in_addr peer;
+                       uint32_t local_label;
+                       uint32_t remote_label;
+                       char ifname[IFNAMSIZ];
+                       uint32_t vcid;
+               } l2vpn;
+       };
 };
 
 #define LDPBUFSIZ      65535
@@ -232,23 +251,23 @@ show_discovery_detail_adj(struct vty *vty, char *buffer, struct ctl_adj *adj)
        size_t   buflen = strlen(buffer);
 
        snprintf(buffer + buflen, LDPBUFSIZ - buflen,
-           "      LSR Id: %s:0%s", inet_ntoa(adj->id), VTYNL);
+           "      LSR Id: %s:0\n", inet_ntoa(adj->id));
        buflen = strlen(buffer);
        snprintf(buffer + buflen, LDPBUFSIZ - buflen,
-           "          Source address: %s%s",
-           log_addr(adj->af, &adj->src_addr), VTYNL);
+           "          Source address: %s\n",
+           log_addr(adj->af, &adj->src_addr));
        buflen = strlen(buffer);
        snprintf(buffer + buflen, LDPBUFSIZ - buflen,
-           "          Transport address: %s%s",
-           log_addr(adj->af, &adj->trans_addr), VTYNL);
+           "          Transport address: %s\n",
+           log_addr(adj->af, &adj->trans_addr));
        buflen = strlen(buffer);
        snprintf(buffer + buflen, LDPBUFSIZ - buflen,
-           "          Hello hold time: %u secs (due in %u secs)%s",
-           adj->holdtime, adj->holdtime_remaining, VTYNL);
+           "          Hello hold time: %u secs (due in %u secs)\n",
+           adj->holdtime, adj->holdtime_remaining);
        buflen = strlen(buffer);
        snprintf(buffer + buflen, LDPBUFSIZ - buflen,
-           "          Dual-stack capability TLV: %s%s",
-           (adj->ds_tlv) ? "yes" : "no", VTYNL);
+           "          Dual-stack capability TLV: %s\n",
+           (adj->ds_tlv) ? "yes" : "no");
 }
 
 static int
@@ -279,8 +298,8 @@ show_discovery_detail_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) ?
-                   "(no adjacencies)" : "", VTYNL);
+                    "    %s: %s\n", iface->name, (iface->no_adj) ?
+                   "(no adjacencies)" : "");
                break;
        case IMSG_CTL_SHOW_DISC_TNBR:
                tnbr = imsg->data;
@@ -292,9 +311,9 @@ show_discovery_detail_msg(struct vty *vty, struct imsg *imsg,
                    tnbr->af))->trans_addr;
                buflen = strlen(tnbrs_buffer);
                snprintf(tnbrs_buffer + buflen, LDPBUFSIZ - buflen,
-                   "    %s -> %s: %s%s", log_addr(tnbr->af, trans_addr),
+                   "    %s -> %s: %s\n", log_addr(tnbr->af, trans_addr),
                    log_addr(tnbr->af, &tnbr->addr), (tnbr->no_adj) ?
-                   "(no adjacencies)" : "", VTYNL);
+                   "(no adjacencies)" : "");
                break;
        case IMSG_CTL_SHOW_DISC_ADJ:
                adj = imsg->data;
@@ -531,12 +550,12 @@ show_nbr_detail_adj(struct vty *vty, char *buffer, struct ctl_adj *adj)
        switch (adj->type) {
        case HELLO_LINK:
                snprintf(buffer + buflen, LDPBUFSIZ - buflen,
-                   "      Interface: %s%s", adj->ifname, VTYNL);
+                   "      Interface: %s\n", adj->ifname);
                break;
        case HELLO_TARGETED:
                snprintf(buffer + buflen, LDPBUFSIZ - buflen,
-                   "      Targeted Hello: %s%s", log_addr(adj->af,
-                   &adj->src_addr), VTYNL);
+                   "      Targeted Hello: %s\n", log_addr(adj->af,
+                   &adj->src_addr));
                break;
        }
 }
@@ -869,11 +888,10 @@ show_nbr_detail_msg_json(struct imsg *imsg, struct show_params *params,
 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)\n",
-           VTYNL, VTYNL, VTYNL);
+       vty_out (vty, "  Capabilities Sent:\n"
+           "   - Dynamic Announcement (0x0506)\n"
+           "   - Typed Wildcard (0x050B)\n"
+           "   - Unrecognized Notification (0x0603)\n");
        vty_out (vty, "  Capabilities Received:\n");
        if (nbr->flags & F_NBR_CAP_DYNAMIC)
                vty_out (vty,"   - Dynamic Announcement (0x0506)\n");
@@ -1006,6 +1024,12 @@ show_lib_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
 
        switch (imsg->hdr.type) {
        case IMSG_CTL_SHOW_LIB_BEGIN:
+               rt = imsg->data;
+
+               if (params->lib.remote_label != NO_LABEL &&
+                   params->lib.remote_label != rt->remote_label)
+                       return (0);
+               /* FALLTHROUGH */
        case IMSG_CTL_SHOW_LIB_RCVD:
                rt = imsg->data;
 
@@ -1013,9 +1037,6 @@ show_lib_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
                    !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);
 
@@ -1040,7 +1061,7 @@ static int
 show_lib_detail_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
 {
        struct ctl_rt   *rt = NULL;
-       char             dstnet[BUFSIZ];
+       static char      dstnet[BUFSIZ];
        static int       upstream, downstream;
        size_t           buflen;
        static char      sent_buffer[LDPBUFSIZ];
@@ -1048,46 +1069,41 @@ show_lib_detail_msg(struct vty *vty, struct imsg *imsg, struct show_params *para
 
        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\n", dstnet);
-               vty_out (vty, "%-8sLocal binding: label: %s\n", "",
-                   log_label(rt->local_label));
                break;
        case IMSG_CTL_SHOW_LIB_SENT:
+               rt = imsg->data;
+
                upstream = 1;
                buflen = strlen(sent_buffer);
                snprintf(sent_buffer + buflen, LDPBUFSIZ - buflen,
-                   "%12s%s:0%s", "", inet_ntoa(rt->nexthop), VTYNL);
+                   "%12s%s:0\n", "", inet_ntoa(rt->nexthop));
                break;
        case IMSG_CTL_SHOW_LIB_RCVD:
+               rt = imsg->data;
                downstream = 1;
                buflen = strlen(rcvd_buffer);
                snprintf(rcvd_buffer + buflen, LDPBUFSIZ - buflen,
-                   "%12s%s:0, label %s%s%s", "", inet_ntoa(rt->nexthop),
+                   "%12s%s:0, label %s%s\n", "", inet_ntoa(rt->nexthop),
                    log_label(rt->remote_label),
-                   rt->in_use ? " (in use)" : "", VTYNL);
+                   rt->in_use ? " (in use)" : "");
                break;
        case IMSG_CTL_SHOW_LIB_END:
+               rt = imsg->data;
+
+               if (params->lib.remote_label != NO_LABEL &&
+                   !downstream)
+                       break;
+               vty_out(vty, "%s\n", dstnet);
+               vty_out(vty, "%-8sLocal binding: label: %s\n", "",
+                   log_label(rt->local_label));
                if (upstream) {
                        vty_out (vty, "%-8sAdvertised to:\n", "");
                        vty_out(vty, "%s", sent_buffer);
@@ -1171,19 +1187,8 @@ show_lib_detail_msg_json(struct imsg *imsg, struct show_params *params,
 
        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:
                snprintf(dstnet, sizeof(dstnet), "%s/%d",
                    log_addr(rt->af, &rt->prefix), rt->prefixlen);
 
@@ -1202,12 +1207,16 @@ show_lib_detail_msg_json(struct imsg *imsg, struct show_params *params,
                json_object_object_add(json, dstnet, json_lib_entry);
                break;
        case IMSG_CTL_SHOW_LIB_SENT:
+               rt = imsg->data;
+
                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:
+               rt = imsg->data;
+
                json_remote_label = json_object_new_object();
                json_object_string_add(json_remote_label, "neighborId",
                    inet_ntoa(rt->nexthop));
@@ -1411,88 +1420,272 @@ ldp_vty_connect(struct imsgbuf *ibuf)
 }
 
 static int
-ldp_vty_dispatch_msg(struct vty *vty, struct imsg *imsg, enum show_command cmd,
+ldp_vty_dispatch_iface(struct vty *vty, struct imsg *imsg,
     struct show_params *params, json_object *json)
 {
        int      ret;
 
-       switch (cmd) {
-       case SHOW_IFACE:
+       if (params->json)
+               ret = show_interface_msg_json(imsg, params, json);
+       else
+               ret = show_interface_msg(vty, imsg, params);
+
+       return (ret);
+}
+
+static int
+ldp_vty_dispatch_disc(struct vty *vty, struct imsg *imsg,
+    struct show_params *params, json_object *json)
+{
+       int      ret;
+
+       if (params->detail) {
                if (params->json)
-                       ret = show_interface_msg_json(imsg, params, json);
+                       ret = show_discovery_detail_msg_json(imsg, params,
+                           json);
                else
-                       ret = show_interface_msg(vty, imsg, params);
-               break;
-       case SHOW_DISC:
-               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);
+                       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);
+       }
+
+       return (ret);
+}
+
+static int
+ldp_vty_dispatch_nbr(struct vty *vty, struct imsg *imsg,
+    struct show_params *params, json_object *json)
+{
+       static bool      filtered = false;
+       struct ctl_nbr  *nbr;
+       int              ret;
+
+       switch (imsg->hdr.type) {
+       case IMSG_CTL_SHOW_NBR:
+               filtered = false;
+               nbr = imsg->data;
+
+               if (params->neighbor.lsr_id.s_addr != INADDR_ANY &&
+                   params->neighbor.lsr_id.s_addr != nbr->id.s_addr) {
+                       filtered = true;
+                       return (0);
                }
                break;
-       case SHOW_NBR:
-               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);
-               }
+       case IMSG_CTL_SHOW_NBR_DISC:
+       case IMSG_CTL_SHOW_NBR_END:
+               if (filtered)
+                       return (0);
                break;
-       case SHOW_LIB:
-               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);
-               }
+       default:
                break;
-       case SHOW_L2VPN_PW:
+       }
+
+       if (params->neighbor.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_l2vpn_pw_msg_json(imsg, params, json);
+                       ret = show_nbr_msg_json(imsg, params, json);
                else
-                       ret = show_l2vpn_pw_msg(vty, imsg, params);
+                       ret = show_nbr_msg(vty, imsg, params);
+       }
+
+       return (ret);
+}
+
+static int
+ldp_vty_dispatch_lib(struct vty *vty, struct imsg *imsg,
+    struct show_params *params, json_object *json)
+{
+       static bool      filtered = false;
+       struct ctl_rt   *rt = NULL;
+       struct prefix    prefix;
+       int              ret;
+
+       switch (imsg->hdr.type) {
+       case IMSG_CTL_SHOW_LIB_BEGIN:
+               filtered = false;
                break;
-       case SHOW_L2VPN_BINDING:
+       case IMSG_CTL_SHOW_LIB_SENT:
+       case IMSG_CTL_SHOW_LIB_RCVD:
+       case IMSG_CTL_SHOW_LIB_END:
+               if (filtered)
+                       return (0);
+               break;
+       default:
+               break;
+       }
+
+       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) {
+                       filtered = true;
+                       return (0);
+               }
+
+               prefix.family = rt->af;
+               prefix.prefixlen = rt->prefixlen;
+               memcpy(&prefix.u.val, &rt->prefix, sizeof(prefix.u.val));
+               if (params->lib.prefix.family != AF_UNSPEC) {
+                       if (!params->lib.longer_prefixes &&
+                           !prefix_same(&params->lib.prefix, &prefix)) {
+                               filtered = true;
+                               return (0);
+                       } else if (params->lib.longer_prefixes &&
+                           !prefix_match(&params->lib.prefix, &prefix)) {
+                               filtered = true;
+                               return (0);
+                       }
+               }
+
+               if (params->lib.local_label != NO_LABEL &&
+                   params->lib.local_label != rt->local_label) {
+                       filtered = true;
+                       return (0);
+               }
+               break;
+       default:
+               break;
+       }
+
+       switch (imsg->hdr.type) {
+       case IMSG_CTL_SHOW_LIB_SENT:
+       case IMSG_CTL_SHOW_LIB_RCVD:
+               if (params->lib.neighbor.s_addr != INADDR_ANY &&
+                   params->lib.neighbor.s_addr != rt->nexthop.s_addr)
+                       return (0);
+               break;
+       default:
+               break;
+       }
+
+       switch (imsg->hdr.type) {
+       case IMSG_CTL_SHOW_LIB_RCVD:
+               if (params->lib.remote_label != NO_LABEL &&
+                   params->lib.remote_label != rt->remote_label)
+                       return (0);
+               break;
+       default:
+               break;
+       }
+
+       if (params->detail) {
                if (params->json)
-                       ret = show_l2vpn_binding_msg_json(imsg, params, json);
+                       ret = show_lib_detail_msg_json(imsg, params, json);
                else
-                       ret = show_l2vpn_binding_msg(vty, imsg, params);
+                       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);
+       }
+
+       return (ret);
+}
+
+static int
+ldp_vty_dispatch_l2vpn_pw(struct vty *vty, struct imsg *imsg,
+    struct show_params *params, json_object *json)
+{
+       struct ctl_pw   *pw;
+       int              ret;
+
+       switch (imsg->hdr.type) {
+       case IMSG_CTL_SHOW_L2VPN_PW:
+               pw = imsg->data;
+               if (params->l2vpn.peer.s_addr != INADDR_ANY &&
+                   params->l2vpn.peer.s_addr != pw->lsr_id.s_addr)
+                       return (0);
+               if (params->l2vpn.ifname[0] != '\0' &&
+                   strcmp(params->l2vpn.ifname, pw->ifname))
+                       return (0);
+               if (params->l2vpn.vcid && params->l2vpn.vcid != pw->pwid)
+                       return (0);
                break;
        default:
-               return (0);
+               break;
        }
 
+       if (params->json)
+               ret = show_l2vpn_pw_msg_json(imsg, params, json);
+       else
+               ret = show_l2vpn_pw_msg(vty, imsg, params);
+
+       return (ret);
+}
+
+static int
+ldp_vty_dispatch_l2vpn_binding(struct vty *vty, struct imsg *imsg,
+    struct show_params *params, json_object *json)
+{
+       struct ctl_pw   *pw;
+       int              ret;
+
+       switch (imsg->hdr.type) {
+       case IMSG_CTL_SHOW_L2VPN_BINDING:
+               pw = imsg->data;
+               if (params->l2vpn.peer.s_addr != INADDR_ANY &&
+                   params->l2vpn.peer.s_addr != pw->lsr_id.s_addr)
+                       return (0);
+               if (params->l2vpn.local_label != NO_LABEL &&
+                   params->l2vpn.local_label != pw->local_label)
+                       return (0);
+               if (params->l2vpn.remote_label != NO_LABEL &&
+                   params->l2vpn.remote_label != pw->remote_label)
+                       return (0);
+               break;
+       default:
+               break;
+       }
+
+       if (params->json)
+               ret = show_l2vpn_binding_msg_json(imsg, params, json);
+       else
+               ret = show_l2vpn_binding_msg(vty, imsg, params);
+
        return (ret);
 }
 
+static int
+ldp_vty_dispatch_msg(struct vty *vty, struct imsg *imsg, enum show_command cmd,
+    struct show_params *params, json_object *json)
+{
+       switch (cmd) {
+       case SHOW_IFACE:
+               return (ldp_vty_dispatch_iface(vty, imsg, params, json));
+       case SHOW_DISC:
+               return (ldp_vty_dispatch_disc(vty, imsg, params, json));
+       case SHOW_NBR:
+               return (ldp_vty_dispatch_nbr(vty, imsg, params, json));
+       case SHOW_LIB:
+               return (ldp_vty_dispatch_lib(vty, imsg, params, json));
+       case SHOW_L2VPN_PW:
+               return (ldp_vty_dispatch_l2vpn_pw(vty, imsg, params, json));
+       case SHOW_L2VPN_BINDING:
+               return (ldp_vty_dispatch_l2vpn_binding(vty, imsg, params,
+                   json));
+       default:
+               return (0);
+       }
+}
+
 static int
 ldp_vty_dispatch(struct vty *vty, struct imsgbuf *ibuf, enum show_command cmd,
     struct show_params *params)
@@ -1566,7 +1759,9 @@ ldp_vty_get_af(const char *str, int *af)
 }
 
 int
-ldp_vty_show_binding(struct vty *vty, const char *af_str, int detail, int json)
+ldp_vty_show_binding(struct vty *vty, const char *af_str, const char *prefix,
+    int longer_prefixes, const char *neighbor, unsigned long local_label,
+    unsigned long remote_label, const char *detail, const char *json)
 {
        struct imsgbuf           ibuf;
        struct show_params       params;
@@ -1580,8 +1775,20 @@ ldp_vty_show_binding(struct vty *vty, const char *af_str, int detail, int json)
 
        memset(&params, 0, sizeof(params));
        params.family = af;
-       params.detail = detail;
-       params.json = json;
+       params.detail = (detail) ? 1 : 0;
+       params.json = (json) ? 1 : 0;
+       if (prefix) {
+               (void)str2prefix(prefix, &params.lib.prefix);
+               params.lib.longer_prefixes = longer_prefixes;
+       }
+       if (neighbor &&
+           (inet_pton(AF_INET, neighbor, &params.lib.neighbor) != 1 ||
+            bad_addr_v4(params.lib.neighbor))) {
+               vty_out (vty, "%% Malformed address\n");
+               return (CMD_SUCCESS);
+       }
+       params.lib.local_label = local_label;
+       params.lib.remote_label = remote_label;
 
        if (!params.detail && !params.json)
                vty_out (vty, "%-4s %-20s %-15s %-11s %-13s %6s\n", "AF",
@@ -1593,8 +1800,8 @@ ldp_vty_show_binding(struct vty *vty, const char *af_str, int detail, int json)
 }
 
 int
-ldp_vty_show_discovery(struct vty *vty, const char *af_str, int detail,
-    int json)
+ldp_vty_show_discovery(struct vty *vty, const char *af_str, const char *detail,
+    const char *json)
 {
        struct imsgbuf           ibuf;
        struct show_params       params;
@@ -1608,8 +1815,8 @@ ldp_vty_show_discovery(struct vty *vty, const char *af_str, int detail,
 
        memset(&params, 0, sizeof(params));
        params.family = af;
-       params.detail = detail;
-       params.json = json;
+       params.detail = (detail) ? 1 : 0;
+       params.json = (json) ? 1 : 0;
 
        if (!params.detail && !params.json)
                vty_out (vty, "%-4s %-15s %-8s %-15s %9s\n",
@@ -1624,7 +1831,7 @@ ldp_vty_show_discovery(struct vty *vty, const char *af_str, int detail,
 }
 
 int
-ldp_vty_show_interface(struct vty *vty, const char *af_str, int json)
+ldp_vty_show_interface(struct vty *vty, const char *af_str, const char *json)
 {
        struct imsgbuf           ibuf;
        struct show_params       params;
@@ -1639,7 +1846,7 @@ ldp_vty_show_interface(struct vty *vty, const char *af_str, int json)
 
        memset(&params, 0, sizeof(params));
        params.family = af;
-       params.json = json;
+       params.json = (json) ? 1 : 0;
 
        /* header */
        if (!params.json) {
@@ -1653,7 +1860,7 @@ ldp_vty_show_interface(struct vty *vty, const char *af_str, int json)
 }
 
 int
-ldp_vty_show_capabilities(struct vty *vty, int json)
+ldp_vty_show_capabilities(struct vty *vty, const char *json)
 {
        if (json) {
                json_object     *json;
@@ -1695,17 +1902,17 @@ ldp_vty_show_capabilities(struct vty *vty, int json)
        }
 
        vty_out (vty,
-           "Supported LDP Capabilities%s"
-           " * Dynamic Announcement (0x0506)%s"
-           " * Typed Wildcard (0x050B)%s"
-           " * Unrecognized Notification (0x0603)%s\n", VTYNL,
-           VTYNL, VTYNL, VTYNL);
+           "Supported LDP Capabilities\n"
+           " * Dynamic Announcement (0x0506)\n"
+           " * Typed Wildcard (0x050B)\n"
+           " * Unrecognized Notification (0x0603)\n\n");
 
        return (0);
 }
 
 int
-ldp_vty_show_neighbor(struct vty *vty, int capabilities, int detail, int json)
+ldp_vty_show_neighbor(struct vty *vty, const char *lsr_id, int capabilities,
+    const char *detail, const char *json)
 {
        struct imsgbuf           ibuf;
        struct show_params       params;
@@ -1714,11 +1921,17 @@ ldp_vty_show_neighbor(struct vty *vty, int capabilities, int detail, int json)
                return (CMD_WARNING);
 
        memset(&params, 0, sizeof(params));
-       params.capabilities = capabilities;
-       params.detail = detail;
-       params.json = json;
+       params.detail = (detail) ? 1 : 0;
+       params.json = (json) ? 1 : 0;
+       params.neighbor.capabilities = capabilities;
+       if (lsr_id &&
+           (inet_pton(AF_INET, lsr_id, &params.neighbor.lsr_id) != 1 ||
+            bad_addr_v4(params.neighbor.lsr_id))) {
+               vty_out (vty, "%% Malformed address\n");
+               return (CMD_SUCCESS);
+       }
 
-       if (params.capabilities)
+       if (params.neighbor.capabilities)
                params.detail = 1;
 
        if (!params.detail && !params.json)
@@ -1730,7 +1943,8 @@ ldp_vty_show_neighbor(struct vty *vty, int capabilities, int detail, int json)
 }
 
 int
-ldp_vty_show_atom_binding(struct vty *vty, int json)
+ldp_vty_show_atom_binding(struct vty *vty, const char *peer,
+    unsigned long local_label, unsigned long remote_label, const char *json)
 {
        struct imsgbuf           ibuf;
        struct show_params       params;
@@ -1739,14 +1953,23 @@ ldp_vty_show_atom_binding(struct vty *vty, int json)
                return (CMD_WARNING);
 
        memset(&params, 0, sizeof(params));
-       params.json = json;
+       params.json = (json) ? 1 : 0;
+       if (peer &&
+           (inet_pton(AF_INET, peer, &params.l2vpn.peer) != 1 ||
+            bad_addr_v4(params.l2vpn.peer))) {
+               vty_out (vty, "%% Malformed address\n");
+               return (CMD_SUCCESS);
+       }
+       params.l2vpn.local_label = local_label;
+       params.l2vpn.remote_label = remote_label;
 
        imsg_compose(&ibuf, IMSG_CTL_SHOW_L2VPN_BINDING, 0, 0, -1, NULL, 0);
        return (ldp_vty_dispatch(vty, &ibuf, SHOW_L2VPN_BINDING, &params));
 }
 
 int
-ldp_vty_show_atom_vc(struct vty *vty, int json)
+ldp_vty_show_atom_vc(struct vty *vty, const char *peer, const char *ifname,
+    const char *vcid, const char *json)
 {
        struct imsgbuf           ibuf;
        struct show_params       params;
@@ -1755,7 +1978,18 @@ ldp_vty_show_atom_vc(struct vty *vty, int json)
                return (CMD_WARNING);
 
        memset(&params, 0, sizeof(params));
-       params.json = json;
+       params.json = (json) ? 1 : 0;
+       if (peer &&
+           (inet_pton(AF_INET, peer, &params.l2vpn.peer) != 1 ||
+            bad_addr_v4(params.l2vpn.peer))) {
+               vty_out (vty, "%% Malformed address\n");
+               return (CMD_SUCCESS);
+       }
+       if (ifname)
+               strlcpy(params.l2vpn.ifname, ifname,
+                   sizeof(params.l2vpn.ifname));
+       if (vcid)
+               params.l2vpn.vcid = atoi(vcid);
 
        if (!params.json) {
                /* header */