]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpctl: add a flag to display hidden ports
authorVincent Bernat <bernat@luffy.cx>
Tue, 24 Jan 2012 09:20:49 +0000 (10:20 +0100)
committerVincent Bernat <bernat@luffy.cx>
Tue, 24 Jan 2012 09:20:49 +0000 (10:20 +0100)
CHANGELOG
man/lldpctl.8
src/display.c
src/lldpctl.c
src/lldpctl.h

index f04924ec1369c1f395ba27599de5dc9b23715755..63ea7b69eb89027022e13cf586905be92d3a7932 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,6 @@
 lldpd (0.6)
+  * Features:
+    + Allow lldpctl to display hidden ports.
   * Global changes:
     + Partial rewrite of the SNMP part. Less code.
     + Unit tests for SNMP.
index 9025632e4d63685db154b8bbe6c639545ba7bc8d..dac8c054ab9171ebbb6642fb30153815e8d052c2 100644 (file)
@@ -22,6 +22,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl d
+.Op Fl a
 .Op Fl L Ar location
 .Op Fl P Ar policy
 .Op Fl O Ar poe
@@ -44,6 +45,8 @@ The options are as follows:
 .Bl -tag -width Ds
 .It Fl d
 Enable more debugging information.
+.It Fl a
+Display all remote ports, including those hidden by the smart filter.
 .It Fl f Ar format
 Choose the output format. Currently
 .Em plain ,
index 1c88656f203cc0df0217e22d61571923729ee555..480381c80558c59e4621a1598f7b9fce468ca13f 100644 (file)
@@ -922,7 +922,7 @@ display_age(struct lldpd_port *port)
 }
 
 void
-display_interfaces(int s, const char * fmt, int argc, char *argv[])
+display_interfaces(int s, const char * fmt, int hidden, int argc, char *argv[])
 {
        int i;
        struct writer * w;
@@ -963,7 +963,7 @@ display_interfaces(int s, const char * fmt, int argc, char *argv[])
                if (TAILQ_EMPTY(&hardware->h_rports))
                        continue;
                TAILQ_FOREACH(port, &hardware->h_rports, p_entries) {
-                       if (SMART_HIDDEN(port)) continue;
+                       if (!hidden && SMART_HIDDEN(port)) continue;
                        chassis = port->p_chassis;
 
                        tag_start(w, "interface", "Interface");
index 69ec909196cd1c661ec0341a3084510eca1d77cf..2c35c5a918421aa4aa54899988a2bef1dc5bc506 100644 (file)
@@ -33,7 +33,7 @@ extern const char     *__progname;
 # define __progname "lldpctl"
 #endif
 
-#define LLDPCTL_ARGS "hdf:L:P:O:o:"
+#define LLDPCTL_ARGS "hdaf:L:P:O:o:"
 
 static void
 usage(void)
@@ -43,6 +43,7 @@ usage(void)
        fprintf(stderr, "\n");
 
        fprintf(stderr, "-d          Enable more debugging information.\n");
+       fprintf(stderr, "-a          Display all remote ports, including hidden ones.\n");
        fprintf(stderr, "-f format   Choose output format (plain, keyvalue or xml).\n");
 #ifdef ENABLE_LLDPMED
        fprintf(stderr, "-L location Enable the transmission of LLDP-MED location TLV for the\n");
@@ -701,7 +702,7 @@ main(int argc, char *argv[])
 {
        int ch, s, debug = 1;
        char * fmt = "plain";
-       int action = 0;
+       int action = 0, hidden = 0;
        
        /*
         * Get and parse command line options
@@ -714,6 +715,9 @@ main(int argc, char *argv[])
                case 'd':
                        debug++;
                        break;
+               case 'a':
+                       hidden = 1;
+                       break;
                case 'f':
                        fmt = optarg;
                        break;
@@ -754,7 +758,7 @@ main(int argc, char *argv[])
                fatalx("unable to connect to socket " LLDPD_CTL_SOCKET);
 
        if (!action)
-               display_interfaces(s, fmt, argc, argv);
+               display_interfaces(s, fmt, hidden, argc, argv);
        else
                set_port(s, argc, argv, action);
        
index 3bf78c25776939771e773f00afba46a7c789ee18..c66a877f5b5f9b4d0eebed567d730695235d5c60 100644 (file)
@@ -26,6 +26,6 @@ int  get_port(int, struct lldpd_port *, char *);
 struct lldpd_hardware *get_interface(int, char *);
 
 /* display.c */
-void display_interfaces(int, const char *, int, char **);
+void display_interfaces(int, const char *, int, int, char **);
 
 #endif