From: Vincent Bernat Date: Fri, 12 Dec 2008 21:32:55 +0000 (+0100) Subject: Allow to specify interfaces to display on lldpctl command line X-Git-Tag: 0.3~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ccea83b2194afde0bfe9695760dda45d01c2dba2;p=thirdparty%2Flldpd.git Allow to specify interfaces to display on lldpctl command line --- diff --git a/man/lldpctl.8 b/man/lldpctl.8 index 0179a690..60a0bb6f 100644 --- a/man/lldpctl.8 +++ b/man/lldpctl.8 @@ -18,10 +18,11 @@ .Os .Sh NAME .Nm lldpctl -.Nd control the LLDP daemon +.Nd retrieve neighbors discovered by the LLDP daemon .Sh SYNOPSIS .Nm .Op Fl d +.Op Ar interface ... .Sh DESCRIPTION The .Nm @@ -39,6 +40,9 @@ The options are as follows: .It Fl d Enable more debugging information. .El +.Pp +Optionally, interfaces to display may be specified on the command +line. By default, all interfaces are displayed. .Sh FILES .Bl -tag -width "/var/run/lldpd.socketXX" -compact .It /var/run/lldpd.socket diff --git a/src/lldpctl.c b/src/lldpctl.c index 1e0eae0b..7f9ea63c 100644 --- a/src/lldpctl.c +++ b/src/lldpctl.c @@ -764,7 +764,7 @@ display_vlans(struct lldpd_port *port) int main(int argc, char *argv[]) { - int s; + int s, i; int ch, debug = 1; struct interfaces ifs; #ifdef ENABLE_DOT1 @@ -786,7 +786,7 @@ main(int argc, char *argv[]) default: usage(); } - } + } log_init(debug); memset(sep, '-', 79); @@ -800,6 +800,13 @@ main(int argc, char *argv[]) printf(" LLDP neighbors\n"); printf("%s\n", sep); TAILQ_FOREACH(iff, &ifs, next) { + if (optind < argc) { + for (i = optind; i < argc; i++) + if (strncmp(argv[i], iff->name, IFNAMSIZ) == 0) + break; + if (i == argc) + continue; + } if ((get_chassis(s, &chassis, iff->name) != -1) && (get_port(s, &port, iff->name) != -1)) { printf("Interface: %s\n", iff->name);