From 9c43aeb47ed9d2330aaf8ca45c6bb2eaeb03951a Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 24 Jan 2012 10:20:49 +0100 Subject: [PATCH] lldpctl: add a flag to display hidden ports --- CHANGELOG | 2 ++ man/lldpctl.8 | 3 +++ src/display.c | 4 ++-- src/lldpctl.c | 10 +++++++--- src/lldpctl.h | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f04924ec..63ea7b69 100644 --- 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. diff --git a/man/lldpctl.8 b/man/lldpctl.8 index 9025632e..dac8c054 100644 --- a/man/lldpctl.8 +++ b/man/lldpctl.8 @@ -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 , diff --git a/src/display.c b/src/display.c index 1c88656f..480381c8 100644 --- a/src/display.c +++ b/src/display.c @@ -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"); diff --git a/src/lldpctl.c b/src/lldpctl.c index 69ec9091..2c35c5a9 100644 --- a/src/lldpctl.c +++ b/src/lldpctl.c @@ -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); diff --git a/src/lldpctl.h b/src/lldpctl.h index 3bf78c25..c66a877f 100644 --- a/src/lldpctl.h +++ b/src/lldpctl.h @@ -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 -- 2.39.5