]> git.proxmox.com Git - mirror_frr.git/commitdiff
ldpd: provide both a brief and a detailed version of some show commands
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 17 Mar 2017 01:11:15 +0000 (22:11 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 21 Mar 2017 00:42:14 +0000 (21:42 -0300)
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ldpd/control.c
ldpd/ldp_vty.xml
ldpd/ldp_vty_exec.c
ldpd/ldpd.h
ldpd/ldpe.c
ldpd/ldpe.h

index 0bfe0abc9de56bba7c67adeb2e879e40d63e03d6..5c530e1b701163736f876a63206e7deccfb1f9dd 100644 (file)
@@ -242,6 +242,9 @@ control_dispatch_imsg(struct thread *thread)
                case IMSG_CTL_SHOW_DISCOVERY:
                        ldpe_adj_ctl(c);
                        break;
+               case IMSG_CTL_SHOW_DISCOVERY_DTL:
+                       ldpe_adj_detail_ctl(c);
+                       break;
                case IMSG_CTL_SHOW_LIB:
                case IMSG_CTL_SHOW_L2VPN_PW:
                case IMSG_CTL_SHOW_L2VPN_BINDING:
index 966b634c2724cc5dc3466fe3be440015b174882a..141b14d83f4204de743706b4a355210ddcde9060 100644 (file)
 
   <!-- exec mode commands -->
   <subtree name="ldp_show_af">
-    <option name="binding" help="Label Information Base (LIB) information">
-      <option name="json" arg="json" optional="true" help="JavaScript Object Notation" function="ldp_vty_show_binding"/>
+    <option name="binding" help="Label Information Base (LIB) information" function="ldp_vty_show_binding">
+      <option name="json" arg="json" help="JavaScript Object Notation" function="ldp_vty_show_binding"/>
+      <option name="detail" arg="detail" help="Show detailed information">
+        <option name="json" arg="json" optional="true" help="JavaScript Object Notation" function="ldp_vty_show_binding"/>
+      </option>
     </option>
-    <option name="discovery" help="Discovery Hello Information">
-      <option name="json" arg="json" optional="true" help="JavaScript Object Notation" function="ldp_vty_show_discovery"/>
+    <option name="discovery" help="Discovery Hello Information" function="ldp_vty_show_discovery">
+      <option name="json" arg="json" help="JavaScript Object Notation" function="ldp_vty_show_discovery"/>
+      <option name="detail" arg="detail" help="Show detailed information">
+        <option name="json" arg="json" optional="true" help="JavaScript Object Notation" function="ldp_vty_show_discovery"/>
+      </option>
     </option>
     <option name="interface" help="interface information">
       <option name="json" arg="json" optional="true" help="JavaScript Object Notation" function="ldp_vty_show_interface"/>
     <option name="show" help="Show running system information">
       <option name="mpls" help="MPLS information">
         <option name="ldp" help="Label Distribution Protocol">
-          <option name="neighbor" help="Neighbor information">
-            <option name="json" arg="json" optional="true" help="JavaScript Object Notation" function="ldp_vty_show_neighbor"/>
+          <option name="neighbor" help="Neighbor information" function="ldp_vty_show_neighbor">
+            <option name="json" arg="json" help="JavaScript Object Notation" function="ldp_vty_show_neighbor"/>
+            <option name="detail" arg="detail" help="Show detailed information">
+              <option name="json" arg="json" optional="true" help="JavaScript Object Notation" function="ldp_vty_show_neighbor"/>
+            </option>
           </option>
           <include subtree="ldp_show_af"/>
           <select options="address-family" arg="address-family">
index 56a64c84f374ce56c61b30ee7b710e7200203029..d8259df8ef9a5791ed28e76afbfa89f1a5f98d84 100644 (file)
@@ -46,6 +46,7 @@ struct show_params {
        int             family;
        union ldpd_addr addr;
        uint8_t         prefixlen;
+       int             detail;
        int             json;
 };
 
@@ -55,24 +56,38 @@ 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 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,8 +179,48 @@ 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);
 
@@ -179,7 +234,7 @@ show_discovery_adj(struct vty *vty, char *buffer, struct ctl_adj *adj)
 }
 
 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;
@@ -231,10 +286,10 @@ 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;
@@ -256,8 +311,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;
@@ -277,7 +383,7 @@ show_discovery_adj_json(json_object *json, struct ctl_adj *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;
@@ -345,10 +451,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 +467,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,7 +515,7 @@ 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 ctl_adj          *adj;
@@ -411,13 +546,13 @@ show_nbr_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
 
                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 +576,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,7 +638,7 @@ 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;
@@ -509,7 +685,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 +693,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:
@@ -540,6 +716,39 @@ show_lib_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
        struct ctl_rt   *rt;
        char             dstnet[BUFSIZ];
 
+       switch (imsg->hdr.type) {
+       case IMSG_CTL_SHOW_LIB:
+               rt = imsg->data;
+
+               if (params->family != AF_UNSPEC && params->family != rt->af)
+                       break;
+
+               snprintf(dstnet, sizeof(dstnet), "%s/%d",
+                   log_addr(rt->af, &rt->prefix), rt->prefixlen);
+
+               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];
+
        switch (imsg->hdr.type) {
        case IMSG_CTL_SHOW_LIB:
                rt = imsg->data;
@@ -583,6 +792,53 @@ show_lib_msg(struct vty *vty, struct imsg *imsg, struct show_params *params)
 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:
+               rt = imsg->data;
+
+               if (params->family != AF_UNSPEC && params->family != rt->af)
+                       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];
@@ -825,34 +1081,76 @@ 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->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 +1242,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 +1271,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));
 }
 
@@ -1015,8 +1328,13 @@ ldp_vty_show_neighbor(struct vty *vty, struct vty_arg *args[])
                return (CMD_WARNING);
 
        memset(&params, 0, sizeof(params));
+       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 %-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));
 }
index 0a7e1177bc54f468d1c185672cccaee3ee3e7a31..8a138849b9a6d3635c03715b5428e443d95bb6ab 100644 (file)
@@ -77,6 +77,7 @@ enum imsg_type {
        IMSG_CTL_RELOAD,
        IMSG_CTL_SHOW_INTERFACE,
        IMSG_CTL_SHOW_DISCOVERY,
+       IMSG_CTL_SHOW_DISCOVERY_DTL,
        IMSG_CTL_SHOW_DISC_IFACE,
        IMSG_CTL_SHOW_DISC_TNBR,
        IMSG_CTL_SHOW_DISC_ADJ,
index 3bb84e92a992906be803fc525c94a09b031cfa38..de93d7a2d098ac1f26286c629a4def8bebc799e7 100644 (file)
@@ -819,6 +819,21 @@ ldpe_iface_ctl(struct ctl_conn *c, unsigned int idx)
 
 void
 ldpe_adj_ctl(struct ctl_conn *c)
+{
+       struct adj      *adj;
+       struct ctl_adj  *actl;
+
+       RB_FOREACH(adj, global_adj_head, &global.adj_tree) {
+               actl = adj_to_ctl(adj);
+               imsg_compose_event(&c->iev, IMSG_CTL_SHOW_DISCOVERY, 0, 0,
+                   -1, actl, sizeof(struct ctl_adj));
+       }
+
+       imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1, NULL, 0);
+}
+
+void
+ldpe_adj_detail_ctl(struct ctl_conn *c)
 {
        struct iface            *iface;
        struct tnbr             *tnbr;
index 22b75eb008c2723efc24d08d6ea4052efa568768..8f2d1931d900daddb1dac646c6b9d792fb0aec5f 100644 (file)
@@ -207,6 +207,7 @@ void                 ldpe_stop_init_backoff(int);
 struct ctl_conn;
 void            ldpe_iface_ctl(struct ctl_conn *, unsigned int);
 void            ldpe_adj_ctl(struct ctl_conn *);
+void            ldpe_adj_detail_ctl(struct ctl_conn *);
 void            ldpe_nbr_ctl(struct ctl_conn *);
 void            mapping_list_add(struct mapping_head *, struct map *);
 void            mapping_list_clr(struct mapping_head *);