]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpcli: rename lldpctl to lldpcli.
authorVincent Bernat <bernat@luffy.cx>
Sat, 5 Jan 2013 15:00:33 +0000 (16:00 +0100)
committerVincent Bernat <bernat@luffy.cx>
Sat, 5 Jan 2013 15:00:33 +0000 (16:00 +0100)
We also provide a backward-compatible lldpctl.

NEWS
configure.ac
src/client/Makefile.am
src/client/lldpcli.8 [new file with mode: 0644]
src/client/lldpcli.c [moved from src/client/lldpctl.c with 77% similarity]
src/client/lldpctl.8

diff --git a/NEWS b/NEWS
index 53917d4c8ac0478a7fa76d0e00a7fcfa9a4bf344..ef9a49fc9b383c037ca319aff4147b90f83dc131 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,7 @@ lldpd (0.7.0)
     + OpenBSD support.
     + NetBSD support.
     + Detect interface changes.
-    + CLI for lldpctl.
+    + CLI for lldpctl: lldpcli.
   * Other features:
     + Allow to disable LLDP protocol (with `-ll`). In this case, the
       first enabled protocol will be used when no neighbor is detected.
index 528a8f8bc7472e45d838c53e2e7a1f158095469d..4b69dd351f5375402b4aed2cb51baf75ad0d75b9 100644 (file)
@@ -39,6 +39,7 @@ AC_PROG_CC_C99
 AC_PROG_CXX
 AM_PROG_CC_C_O
 AC_PROG_LIBTOOL
+AC_PROG_LN_S
 
 # Doxygen
 DX_HTML_FEATURE(ON)
index ee13c3aa0da73ba66f4b04c653a957bfd18edc00..590c522007680232c7021cdc28209dc0e850ef21 100644 (file)
@@ -1,26 +1,31 @@
 AM_CFLAGS = -I $(top_srcdir)/include
 
-sbin_PROGRAMS = lldpctl
-dist_man_MANS = lldpctl.8
+sbin_PROGRAMS = lldpcli
+dist_man_MANS = lldpcli.8 lldpctl.8
 
-lldpctl_SOURCES  = client.h lldpctl.c display.c actions.c \
+install-exec-local: lldpcli
+       cd $(DESTDIR)$(sbindir) && $(LN_S) lldpcli lldpctl
+uninstall-local:
+       cd $(DESTDIR)$(sbindir) && rm -f lldpctl
+
+lldpcli_SOURCES  = client.h lldpcli.c display.c actions.c \
        commands.c show.c \
        misc.c \
        writer.h text_writer.c kv_writer.c
-lldpctl_LDADD    = \
+lldpcli_LDADD    = \
        $(top_builddir)/src/libcommon-daemon-client.la \
        $(top_builddir)/src/lib/liblldpctl.la \
        @EDITLINE_LIBS@
-lldpctl_CFLAGS   = $(AM_CFLAGS) @EDITLINE_CFLAGS@
+lldpcli_CFLAGS   = $(AM_CFLAGS) @EDITLINE_CFLAGS@
 
 if USE_XML
-lldpctl_SOURCES += xml_writer.c
-lldpctl_CFLAGS  += @XML2_CFLAGS@
-lldpctl_LDADD   += @XML2_LIBS@
+lldpcli_SOURCES += xml_writer.c
+lldpcli_CFLAGS  += @XML2_CFLAGS@
+lldpcli_LDADD   += @XML2_LIBS@
 endif
 
 if USE_JSON
-lldpctl_SOURCES += json_writer.c
-lldpctl_CFLAGS  += @JANSSON_CFLAGS@
-lldpctl_LDADD   += @JANSSON_LIBS@
+lldpcli_SOURCES += json_writer.c
+lldpcli_CFLAGS  += @JANSSON_CFLAGS@
+lldpcli_LDADD   += @JANSSON_LIBS@
 endif
diff --git a/src/client/lldpcli.8 b/src/client/lldpcli.8
new file mode 100644 (file)
index 0000000..3213723
--- /dev/null
@@ -0,0 +1,482 @@
+.\" Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
+.\" Copyright (c) 2008 Vincent Bernat <bernat@luffy.cx>
+.\"
+.\" Permission to use, copy, modify, and/or distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd $Mdocdate: July 16 2008 $
+.Dt LLDPCLI 8
+.Os
+.Sh NAME
+.Nm lldpcli ,
+.Nm lldpctl
+.Nd control LLDP daemon
+.Sh SYNOPSIS
+.Nm
+.Op Fl dv
+.Op Fl f Ar format
+.Op Ar command ...
+.Nm lldpctl
+.Op Fl dv
+.Op Fl f Ar format
+.Op Ar interfaces ...
+.Sh DESCRIPTION
+The
+.Nm
+program controls
+.Xr lldpd 8
+daemon.
+.Pp
+When no command is specified,
+.Nm
+will start an interactive shell which can be used to input arbitrary
+commands as if they were specified on the command line. This
+interactive shell should provide completion and history support.
+.Pp
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl d
+Enable more debugging information.
+.It Fl v
+Show
+.Nm
+version.
+.It Fl f Ar format
+Choose the output format. Currently
+.Em plain ,
+.Em xml ,
+.Em json
+and
+.Em keyvalue
+formats are available. The default is
+.Em plain .
+.El
+
+.Pp
+When invoked as
+.Nm lldpctl ,
+.Nm
+will display detailed information about each neighbors on the
+specified interfaces or on all interfaces if none are specified. This
+command is mostly kept for backward compatibility with older versions.
+
+.Pp
+The following commands are supported by
+.Nm .
+When there is no ambiguity, the keywords can be abbreviated. For
+example,
+.Cd show neighbors ports eth0 summary
+and
+.Cd sh neigh p eth0 sum
+are the same command.
+
+.Bd -ragged -offset XX
+.Cd exit
+.Bd -ragged -offset XXXXXX
+Quit
+.Nm .
+.Ed
+
+.Cd show neighbors
+.Op ports Ar ethX Op ...
+.Op Cd details | summary
+.Op Cd hidden
+.Bd -ragged -offset XXXXXX
+Display information about each neighbor known by
+.Xr lldpd 8
+daemon. With
+.Cd summary ,
+only a the name and the port description of each remote host will be
+displayed. On the other hand, with
+.Cd details ,
+all available information will be displayed, giving a verbose
+view. When using
+.Cd hidden ,
+also display remote ports hidden by the smart filter. When specifying
+one or several ports, the information displayed is limited to the
+given list of ports.
+.Ed
+
+.Cd watch
+.Op ports Ar ethX Op ...
+.Op Cd details | summary
+.Op Cd hidden
+.Bd -ragged -offset XXXXXX
+Watch for any neighbor changes and report them as soon as they
+happen. When specifying ports, the changes are only reported when
+happening on the given ports.
+.Cd hidden , summary
+and
+.Cd details
+have the same meaning than previously described.
+.Ed
+
+.Cd show configuration
+.Bd -ragged -offset XXXXXX
+Display global configuration of
+.Xr lldpd 8
+daemon.
+.Ed
+
+.Cd update
+.Bd -ragged -offset XXXXXX
+Make
+.Xr lldpd 8
+update its information and send new LLDP PDU on all interfaces.
+.Ed
+
+.Cd configure
+.Op ports Ar ethX Op ...
+.Cd med location coordinate
+.Cd latitude Ar latitude
+.Cd longitude Ar longitude
+.Cd altitude Ar altitude Ar unit
+.Cd datum Ar datum
+.Bd -ragged -offset XXXXXX
+Advertise a coordinate based location on the given ports (or on all
+ports if no port is specified). The format of
+.Ar latitude
+is a decimal floating point number followed either by
+.Em N
+or
+.Em S .
+The format of
+.Ar longitude
+is a decimal floating point number followed either by 
+.Em E
+or
+.Em W .
+.Ar altitude
+is a decimal floating point number followed either by
+.Em m
+when expressed in meters or
+.Em f
+when expressed in floors.
+.Ar datum
+is one of those values:
+.Bl -bullet -compact -offset XXXXXXXX
+.It
+WGS84
+.It
+NAD83
+.It
+NAD83/MLLW
+.El
+.Pp
+A valid use of this command is:
+.D1 configure ports eth0 med location coordinate latitude 48.85667N longitude 2.2014E altitude 117.47m datum WGS84
+.Ed
+
+.Cd configure
+.Op ports Ar ethX Op ...
+.Cd med location address
+.Cd country Ar country
+.Cd Op Ar type value Op ...
+.Bd -ragged -offset XXXXXX
+Advertise a civic address on the given ports (or on all ports if no
+port is specified).
+.Ar country
+is the two-letter code representing the country. The remaining
+arguments should be paired to form the address. The first member of
+each pair indicates the type of the second member which is a free-form
+text. Here is the list of valid types:
+.Bl -bullet -compact -offset XXXXXXXX
+.It
+language
+.It
+country-subdivision
+.It
+county
+.It
+city
+.It
+city-division
+.It
+block
+.It
+street
+.It
+direction
+.It
+trailing-street-suffix
+.It
+street-suffix
+.It
+number
+.It
+number-suffix
+.It
+landmark
+.It
+additional
+.It
+name
+.It
+zip
+.It
+building
+.It
+unit
+.It
+floor
+.It
+room
+.It
+place-type
+.It
+script
+.El
+.Pp
+A valid use of this command is:
+.D1 configure ports eth1 med location address US street Qo Commercial Road Qc city Qo Roseville Qc
+.Ed
+
+.Cd configure
+.Op ports Ar ethX Op ...
+.Cd med location elin
+.Ar number
+.Bd -ragged -offset XXXXXX
+Advertise the availability of an ELIN number. This is used for setting
+up emergency call. If the provided number is too small, it will be
+padded with 0. Here is an example of use:
+.D1 configure ports eth2 med location elin 911
+.Ed
+
+.Cd configure
+.Op ports Ar ethX Op ...
+.Cd med policy
+.Cd application Ar application
+.Op Cd unknown
+.Op Cd vlan Ar vlan
+.Op Cd priority Ar priority
+.Op Cd dscp Ar dscp
+.Bd -ragged -offset XXXXXX
+Advertise a specific network policy for the given ports (or for all
+ports if no port was provided). Only the application type is
+mandatory.
+.Ar application
+should be one of the following values:
+static const struct value_string port_med_policy_map[] = {
+.Bl -bullet -compact -offset XXXXXXXX
+.It
+voice
+.It
+voice-signaling
+.It
+guest-voice
+.It
+guest-voice-signaling
+.It
+softphone-voice
+.It
+video-conferencing
+.It
+streaming-video
+.It
+video-signaling
+.El
+.Pp
+The
+.Cd unknown
+flag tells that the network policy for the specified application type
+is required by the device but is currently unknown. This is used by
+Endpoint Devices, not by Network Connectivity Devices. If not
+specified, the network policy for the given application type is
+defined.
+.Pp
+When a VLAN is specified with
+.Cd vlan
+tells which 802.1q VLAN ID has to be advertised for the network
+policy. A valid value is between 1 and 4094.
+.Cd priority
+allows one to specify IEEE 802.1d / IEEE 802.1p Layer 2 Priority, also
+known as Class of Service (CoS), to be used for the specified
+application type. It should be one of those values:
+.Bl -bullet -compact -offset XXXXXXXX
+.It
+background
+.It
+spare
+.It
+best-effort
+.It
+excellent-effort
+.It
+controlled-load
+.It
+video
+.It
+voice
+.It
+network-control
+.El
+.Pp
+.Ar dscp
+represents the DSCP value to be advertised for the given network
+policy.  DiffServ/Differentiated Services Code Point (DSCP) value as
+defined in IETF RFC 2474 for the specified application type. Value: 0
+(default per RFC 2475) through 63. Note: The class selector DSCP
+values are backwards compatible for devices that only support the old
+IP precedence Type of Service (ToS) format. (See the RFCs for what
+these values mean)
+.Pp
+A valid use of this command is:
+.D1 configure med policy application voice vlan 500 priority voice dscp 46
+.Ed
+
+.Cd configure
+.Op ports Ar ethX Op ...
+.Cd med power pse | pd
+.Cd source Ar source
+.Cd priority Ar priority
+.Cd value Ar value
+.Bd -ragged -offset XXXXXX
+Advertise the LLDP-MED POE-MDI TLV for the given ports or for all
+interfaces if no port is provided.  One can act as a PD (power
+consumer) or a PSE (power provider). No check is done on the validity
+of the parameters while LLDP-MED requires some restrictions:
+.Bl -bullet
+.It
+PD shall never request more power than physical 802.3af class.
+.It
+PD shall never draw more than the maximum power advertised by PSE.
+.It
+PSE shall not reduce power allocated to PD when this power is in use.
+.It
+PSE may request reduced power using conservation mode
+.It
+Being PSE or PD is a global paremeter, not a per-port parameter.
+.Nm
+does not enforce this: a port can be set as PD or PSE. LLDP-MED also
+requires for a PSE to only have one power source (primary or
+backup). Again,
+.Nm
+does not enforce this. Each port can have its own power source. The
+same applies for PD and power priority. LLDP-MED MIB does not allow
+this kind of representation.
+.El
+.Pp
+Valid types are:
+.Bl -tag -width "XXX." -compact -offset XX
+.It Sy pse
+Power Sourcing Entity (power provider)
+.It Sy pd
+Power Device (power consumer)
+.El
+.Pp
+Valid sources are:
+.Bl -tag -width "XXXXXXX" -compact -offset XX
+.It Sy unknown
+Unknown
+.It Sy primary
+For PSE, the power source is the primary power source.
+.It Sy backup
+For PSE, the power source is the backup power source or a power
+conservation mode is asked (the PSE may be running on UPS for
+example).
+.It Sy pse
+For PD, the power source is the PSE.
+.It Sy local
+For PD, the power source is a local source.
+.It Sy both
+For PD, the power source is both the PSE and a local source.
+.El
+.Pp
+Valid priorities are:
+.Bl -tag -width "XXXXXXXXX" -compact -offset XX
+.It Sy unknown
+Unknown priority
+.It Sy critical
+Critical
+.It Sy high
+High
+.It Sy low
+Low
+.El
+.Pp
+.Ar value
+should be the total power in milliwatts required by the PD device or
+available by the PSE device.
+.Pp
+Here is an example of use:
+.D1 configure med power pd source pse priority high value 5000
+.Ed
+
+.Cd configure
+.Op ports Ar ethX Op ...
+.Cd dot3 power pse | pd
+.Op Cd supported
+.Op Cd enabled
+.Op Cd paircontrol
+.Cd powerpairs Ar powerpairs
+.Op Cd class Ar class
+.Op Cd type Ar type Cd source Ar source Cd priority Ar priority Cd requested Ar requested Cd allocated Ar allocated
+.Bd -ragged -offset XXXXXX
+Advertise Dot3 POE-MDI TLV for the given port or for all ports if none
+was provided. One can act as a PD (power consumer) or a PSE (power
+provider). This configuration is distinct of the configuration of the
+transmission of the LLDP-MED POE-MDI TLV but the user should ensure
+the coherency of those two configurations if they are used together.
+.Pp
+.Ar supported
+means that MDI power is supported on the given port while
+.Ar enabled
+means that MDI power is enabled.
+.Ar paircontrol
+is used to indicate if pair selection can be controlled. Valid values
+forr
+.Ar powerpairs
+are:
+.Bl -tag -width "XXXXXX" -compact -offset XX
+.It Sy signal
+The signal pairs only are in use.
+.It Sy spare
+The spare pairs only are in use.
+.El
+.Pp
+When specified,
+.Ar class
+is a number between 0 and 4.
+.Pp
+The remaining parameters are in conformance with 802.3at and are optional.
+.Ar type
+should be either 1 or 2, indicating which if the device conforms to
+802.3at type 1 or 802.3at type 2. Values ofr
+.Ar source
+and
+.Ar priority
+are the same as for LLDP-MED POE-MDI TLV.
+.Ar requested
+and
+.Ar allocated
+are expressed in milliwats.
+.Pp
+Here are two valid uses of this command:
+.D1 configure ports eth3 dot3 power pse supported enabled paircontrol powerpairs spare class 3
+.D1 configure dot3 power pd supported enabled powerpairs spare class 3 type 1 source pse priority low requested 10000 allocated 15000
+.Ed
+
+.Ed
+.Sh FILES
+.Bl -tag -width "/var/run/lldpd.socketXX" -compact
+.It /var/run/lldpd.socket
+Unix-domain socket used for communication with
+.Xr lldpd 8 .
+.El
+.Sh SEE ALSO
+.Xr lldpd 8
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+program was written by
+.An Vincent Bernat Aq bernat@luffy.cx .
similarity index 77%
rename from src/client/lldpctl.c
rename to src/client/lldpcli.c
index 409fb3355a3a1f932f7114683563bb09ce5abb3f..bd28f05aeea375ffe25307397a44572212be907c 100644 (file)
@@ -15,6 +15,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/un.h>
 #include <arpa/inet.h>
 #include <histedit.h>
+#include <libgen.h>
 
 #include "client.h"
 
 #ifdef HAVE___PROGNAME
 extern const char      *__progname;
 #else
-# define __progname "lldpctl"
+# define __progname "lldpcli"
 #endif
 
 /* Global for completion */
@@ -51,7 +53,7 @@ usage()
 
        fprintf(stderr, "\n");
 
-       fprintf(stderr, "see manual page lldpctl(8) for more information\n");
+       fprintf(stderr, "see manual page lldpcli(8) for more information\n");
        exit(1);
 }
 
@@ -66,8 +68,8 @@ prompt(EditLine *el)
 {
        int privileged = is_privileged();
        if (privileged)
-               return "[lldpctl] # ";
-       return "[lldpctl] $ ";
+               return "[lldpcli] # ";
+       return "[lldpcli] $ ";
 }
 
 static int must_exit = 0;
@@ -78,7 +80,7 @@ static int
 cmd_exit(struct lldpctl_conn_t *conn, struct writer *w,
     struct cmd_env *env, void *arg)
 {
-       log_info("lldpctl", "quit lldpctl");
+       log_info("lldpctl", "quit lldpcli");
        must_exit = 1;
        return 1;
 }
@@ -176,6 +178,20 @@ register_commands()
        return root;
 }
 
+static int
+is_lldpctl(const char *name)
+{
+       static int last_result = -1;
+       if (last_result == -1 && name) {
+               char *basec = strdup(name);
+               if (!basec) return 0;
+               char *bname = basename(basec);
+               last_result = (!strcmp(bname, "lldpctl"));
+               free(basec);
+       }
+       return (last_result == -1)?0:last_result;
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -184,10 +200,12 @@ main(int argc, char *argv[])
        lldpctl_conn_t *conn;
        struct writer *w;
 
-       EditLine  *el;
-       History   *elhistory;
+       EditLine  *el = NULL;
+       History   *elhistory = NULL;
        HistEvent  elhistev;
-       Tokenizer *eltok;
+       Tokenizer *eltok = NULL;
+
+       char *interfaces = NULL;
 
        /* Get and parse command line options */
        while ((ch = getopt(argc, argv, "hdvf:")) != -1) {
@@ -215,6 +233,20 @@ main(int argc, char *argv[])
        /* Register commands */
        root = register_commands();
 
+       if (is_lldpctl(argv[0])) {
+               for (int i = optind; i < argc; i++) {
+                       char *prev = interfaces;
+                       if (asprintf(&interfaces, "%s%s%s",
+                               prev?prev:"", prev?",":"", argv[i]) == -1) {
+                               log_warnx("lldpctl", "not enough memory to build list of interfaces");
+                               goto end;
+                       }
+                       free(prev);
+               }
+               must_exit = 1;
+               goto skipeditline;
+       }
+
        /* Init editline */
        log_debug("lldpctl", "init editline");
        el = el_init("lldpctl", stdin, stdout, stderr);
@@ -251,41 +283,44 @@ main(int argc, char *argv[])
                goto end;
        }
 
+skipeditline:
        /* Make a connection */
        log_debug("lldpctl", "connect to lldpd");
        conn = lldpctl_new(NULL, NULL, NULL);
        if (conn == NULL)
                exit(EXIT_FAILURE);
 
-       while (!must_exit) {
+       do {
                const char *line;
                const char **argv;
                int count, n, argc;
 
-               /* Read a new line. */
-               line = el_gets(el, &count);
-               if (line == NULL) break;
-
-               /* Tokenize it */
-               log_debug("lldpctl", "tokenize command line");
-               n = tok_str(eltok, line, &argc, &argv);
-               switch (n) {
-               case -1:
-                       log_warnx("lldpctl", "internal error while tokenizing");
-                       goto end;
-               case 1:
-               case 2:
-               case 3:
-                       /* TODO: handle multiline statements */
-                       log_warnx("lldpctl", "unmatched quotes");
-                       tok_reset(eltok);
-                       continue;
-               }
-               if (argc == 0) {
-                       tok_reset(eltok);
-                       continue;
+               if (!is_lldpctl(NULL)) {
+                       /* Read a new line. */
+                       line = el_gets(el, &count);
+                       if (line == NULL) break;
+
+                       /* Tokenize it */
+                       log_debug("lldpctl", "tokenize command line");
+                       n = tok_str(eltok, line, &argc, &argv);
+                       switch (n) {
+                       case -1:
+                               log_warnx("lldpctl", "internal error while tokenizing");
+                               goto end;
+                       case 1:
+                       case 2:
+                       case 3:
+                               /* TODO: handle multiline statements */
+                               log_warnx("lldpctl", "unmatched quotes");
+                               tok_reset(eltok);
+                               continue;
+                       }
+                       if (argc == 0) {
+                               tok_reset(eltok);
+                               continue;
+                       }
+                       if (elhistory) history(elhistory, &elhistev, H_ENTER, line);
                }
-               if (elhistory) history(elhistory, &elhistev, H_ENTER, line);
 
                /* Init output formatter */
                if      (strcmp(fmt, "plain")    == 0) w = txt_init(stdout);
@@ -298,13 +333,24 @@ main(int argc, char *argv[])
 #endif
                else w = txt_init(stdout);
 
+               if (is_lldpctl(NULL)) {
+                       if (!interfaces) {
+                               argv = (const char*[]){ "show", "neighbors", "details" };
+                               argc = 3;
+                       } else {
+                               argv = (const char*[]){ "show", "neighbors", "ports", interfaces, "details" };
+                               argc = 5;
+                       }
+               }
+
                /* Execute command */
                if (commands_execute(conn, w,
                        root, argc, argv) != 0)
                        log_info("lldpctl", "an error occurred while executing last command");
                w->finish(w);
-               tok_reset(eltok);
-       }
+
+               if (eltok) tok_reset(eltok);
+       } while (!must_exit);
 
        rc = EXIT_SUCCESS;
 end:
@@ -313,5 +359,6 @@ end:
        if (elhistory) history_end(elhistory);
        if (el) el_end(el);
        if (root) commands_free(root);
+       free(interfaces);
        return rc;
 }
index e48bbe20552d4f3da8289571ab51071463999ebb..68a27a17f940f45441c9d3545c9c31130baeb793 100644 (file)
@@ -1,467 +1 @@
-.\" Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
-.\" Copyright (c) 2008 Vincent Bernat <bernat@luffy.cx>
-.\"
-.\" Permission to use, copy, modify, and/or distribute this software for any
-.\" purpose with or without fee is hereby granted, provided that the above
-.\" copyright notice and this permission notice appear in all copies.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.\"
-.Dd $Mdocdate: July 16 2008 $
-.Dt LLDPCTL 8
-.Os
-.Sh NAME
-.Nm lldpctl
-.Nd control LLDP daemon
-.Sh SYNOPSIS
-.Nm
-.Op Fl dv
-.Op Fl f Ar format
-.Op Ar command ...
-.Sh DESCRIPTION
-The
-.Nm
-program controls
-.Xr lldpd 8
-daemon.
-.Pp
-When no command is specified,
-.Nm
-will start an interactive shell which can be used to input arbitrary
-commands as if they were specified on the command line. This
-interactive shell should provide completion and history support.
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl d
-Enable more debugging information.
-.It Fl v
-Show
-.Nm
-version.
-.It Fl f Ar format
-Choose the output format. Currently
-.Em plain ,
-.Em xml ,
-.Em json
-and
-.Em keyvalue
-formats are available. The default is
-.Em plain .
-.El
-.Pp
-
-The following commands are supported. When there is no ambiguity, the
-keywords can be abbreviated. For example,
-.Cd show neighbors ports eth0 summary
-and
-.Cd sh neigh p eth0 sum
-are the same command.
-
-.Bd -ragged -offset XX
-.Cd exit
-.Bd -ragged -offset XXXXXX
-Quit
-.Nm .
-.Ed
-
-.Cd show neighbors
-.Op ports Ar ethX Op ...
-.Op Cd details | summary
-.Op Cd hidden
-.Bd -ragged -offset XXXXXX
-Display information about each neighbor known by
-.Xr lldpd 8
-daemon. With
-.Cd summary ,
-only a the name and the port description of each remote host will be
-displayed. On the other hand, with
-.Cd details ,
-all available information will be displayed, giving a verbose
-view. When using
-.Cd hidden ,
-also display remote ports hidden by the smart filter. When specifying
-one or several ports, the information displayed is limited to the
-given list of ports.
-.Ed
-
-.Cd watch
-.Op ports Ar ethX Op ...
-.Op Cd details | summary
-.Op Cd hidden
-.Bd -ragged -offset XXXXXX
-Watch for any neighbor changes and report them as soon as they
-happen. When specifying ports, the changes are only reported when
-happening on the given ports.
-.Cd hidden , summary
-and
-.Cd details
-have the same meaning than previously described.
-.Ed
-
-.Cd show configuration
-.Bd -ragged -offset XXXXXX
-Display global configuration of
-.Xr lldpd 8
-daemon.
-.Ed
-
-.Cd update
-.Bd -ragged -offset XXXXXX
-Make
-.Xr lldpd 8
-update its information and send new LLDP PDU on all interfaces.
-.Ed
-
-.Cd configure
-.Op ports Ar ethX Op ...
-.Cd med location coordinate
-.Cd latitude Ar latitude
-.Cd longitude Ar longitude
-.Cd altitude Ar altitude Ar unit
-.Cd datum Ar datum
-.Bd -ragged -offset XXXXXX
-Advertise a coordinate based location on the given ports (or on all
-ports if no port is specified). The format of
-.Ar latitude
-is a decimal floating point number followed either by
-.Em N
-or
-.Em S .
-The format of
-.Ar longitude
-is a decimal floating point number followed either by 
-.Em E
-or
-.Em W .
-.Ar altitude
-is a decimal floating point number followed either by
-.Em m
-when expressed in meters or
-.Em f
-when expressed in floors.
-.Ar datum
-is one of those values:
-.Bl -bullet -compact -offset XXXXXXXX
-.It
-WGS84
-.It
-NAD83
-.It
-NAD83/MLLW
-.El
-.Pp
-A valid use of this command is:
-.D1 configure ports eth0 med location coordinate latitude 48.85667N longitude 2.2014E altitude 117.47m datum WGS84
-.Ed
-
-.Cd configure
-.Op ports Ar ethX Op ...
-.Cd med location address
-.Cd country Ar country
-.Cd Op Ar type value Op ...
-.Bd -ragged -offset XXXXXX
-Advertise a civic address on the given ports (or on all ports if no
-port is specified).
-.Ar country
-is the two-letter code representing the country. The remaining
-arguments should be paired to form the address. The first member of
-each pair indicates the type of the second member which is a free-form
-text. Here is the list of valid types:
-.Bl -bullet -compact -offset XXXXXXXX
-.It
-language
-.It
-country-subdivision
-.It
-county
-.It
-city
-.It
-city-division
-.It
-block
-.It
-street
-.It
-direction
-.It
-trailing-street-suffix
-.It
-street-suffix
-.It
-number
-.It
-number-suffix
-.It
-landmark
-.It
-additional
-.It
-name
-.It
-zip
-.It
-building
-.It
-unit
-.It
-floor
-.It
-room
-.It
-place-type
-.It
-script
-.El
-.Pp
-A valid use of this command is:
-.D1 configure ports eth1 med location address US street Qo Commercial Road Qc city Qo Roseville Qc
-.Ed
-
-.Cd configure
-.Op ports Ar ethX Op ...
-.Cd med location elin
-.Ar number
-.Bd -ragged -offset XXXXXX
-Advertise the availability of an ELIN number. This is used for setting
-up emergency call. If the provided number is too small, it will be
-padded with 0. Here is an example of use:
-.D1 configure ports eth2 med location elin 911
-.Ed
-
-.Cd configure
-.Op ports Ar ethX Op ...
-.Cd med policy
-.Cd application Ar application
-.Op Cd unknown
-.Op Cd vlan Ar vlan
-.Op Cd priority Ar priority
-.Op Cd dscp Ar dscp
-.Bd -ragged -offset XXXXXX
-Advertise a specific network policy for the given ports (or for all
-ports if no port was provided). Only the application type is
-mandatory.
-.Ar application
-should be one of the following values:
-static const struct value_string port_med_policy_map[] = {
-.Bl -bullet -compact -offset XXXXXXXX
-.It
-voice
-.It
-voice-signaling
-.It
-guest-voice
-.It
-guest-voice-signaling
-.It
-softphone-voice
-.It
-video-conferencing
-.It
-streaming-video
-.It
-video-signaling
-.El
-.Pp
-The
-.Cd unknown
-flag tells that the network policy for the specified application type
-is required by the device but is currently unknown. This is used by
-Endpoint Devices, not by Network Connectivity Devices. If not
-specified, the network policy for the given application type is
-defined.
-.Pp
-When a VLAN is specified with
-.Cd vlan
-tells which 802.1q VLAN ID has to be advertised for the network
-policy. A valid value is between 1 and 4094.
-.Cd priority
-allows one to specify IEEE 802.1d / IEEE 802.1p Layer 2 Priority, also
-known as Class of Service (CoS), to be used for the specified
-application type. It should be one of those values:
-.Bl -bullet -compact -offset XXXXXXXX
-.It
-background
-.It
-spare
-.It
-best-effort
-.It
-excellent-effort
-.It
-controlled-load
-.It
-video
-.It
-voice
-.It
-network-control
-.El
-.Pp
-.Ar dscp
-represents the DSCP value to be advertised for the given network
-policy.  DiffServ/Differentiated Services Code Point (DSCP) value as
-defined in IETF RFC 2474 for the specified application type. Value: 0
-(default per RFC 2475) through 63. Note: The class selector DSCP
-values are backwards compatible for devices that only support the old
-IP precedence Type of Service (ToS) format. (See the RFCs for what
-these values mean)
-.Pp
-A valid use of this command is:
-.D1 configure med policy application voice vlan 500 priority voice dscp 46
-.Ed
-
-.Cd configure
-.Op ports Ar ethX Op ...
-.Cd med power pse | pd
-.Cd source Ar source
-.Cd priority Ar priority
-.Cd value Ar value
-.Bd -ragged -offset XXXXXX
-Advertise the LLDP-MED POE-MDI TLV for the given ports or for all
-interfaces if no port is provided.  One can act as a PD (power
-consumer) or a PSE (power provider). No check is done on the validity
-of the parameters while LLDP-MED requires some restrictions:
-.Bl -bullet
-.It
-PD shall never request more power than physical 802.3af class.
-.It
-PD shall never draw more than the maximum power advertised by PSE.
-.It
-PSE shall not reduce power allocated to PD when this power is in use.
-.It
-PSE may request reduced power using conservation mode
-.It
-Being PSE or PD is a global paremeter, not a per-port parameter.
-.Nm
-does not enforce this: a port can be set as PD or PSE. LLDP-MED also
-requires for a PSE to only have one power source (primary or
-backup). Again,
-.Nm
-does not enforce this. Each port can have its own power source. The
-same applies for PD and power priority. LLDP-MED MIB does not allow
-this kind of representation.
-.El
-.Pp
-Valid types are:
-.Bl -tag -width "XXX." -compact -offset XX
-.It Sy pse
-Power Sourcing Entity (power provider)
-.It Sy pd
-Power Device (power consumer)
-.El
-.Pp
-Valid sources are:
-.Bl -tag -width "XXXXXXX" -compact -offset XX
-.It Sy unknown
-Unknown
-.It Sy primary
-For PSE, the power source is the primary power source.
-.It Sy backup
-For PSE, the power source is the backup power source or a power
-conservation mode is asked (the PSE may be running on UPS for
-example).
-.It Sy pse
-For PD, the power source is the PSE.
-.It Sy local
-For PD, the power source is a local source.
-.It Sy both
-For PD, the power source is both the PSE and a local source.
-.El
-.Pp
-Valid priorities are:
-.Bl -tag -width "XXXXXXXXX" -compact -offset XX
-.It Sy unknown
-Unknown priority
-.It Sy critical
-Critical
-.It Sy high
-High
-.It Sy low
-Low
-.El
-.Pp
-.Ar value
-should be the total power in milliwatts required by the PD device or
-available by the PSE device.
-.Pp
-Here is an example of use:
-.D1 configure med power pd source pse priority high value 5000
-.Ed
-
-.Cd configure
-.Op ports Ar ethX Op ...
-.Cd dot3 power pse | pd
-.Op Cd supported
-.Op Cd enabled
-.Op Cd paircontrol
-.Cd powerpairs Ar powerpairs
-.Op Cd class Ar class
-.Op Cd type Ar type Cd source Ar source Cd priority Ar priority Cd requested Ar requested Cd allocated Ar allocated
-.Bd -ragged -offset XXXXXX
-Advertise Dot3 POE-MDI TLV for the given port or for all ports if none
-was provided. One can act as a PD (power consumer) or a PSE (power
-provider). This configuration is distinct of the configuration of the
-transmission of the LLDP-MED POE-MDI TLV but the user should ensure
-the coherency of those two configurations if they are used together.
-.Pp
-.Ar supported
-means that MDI power is supported on the given port while
-.Ar enabled
-means that MDI power is enabled.
-.Ar paircontrol
-is used to indicate if pair selection can be controlled. Valid values
-forr
-.Ar powerpairs
-are:
-.Bl -tag -width "XXXXXX" -compact -offset XX
-.It Sy signal
-The signal pairs only are in use.
-.It Sy spare
-The spare pairs only are in use.
-.El
-.Pp
-When specified,
-.Ar class
-is a number between 0 and 4.
-.Pp
-The remaining parameters are in conformance with 802.3at and are optional.
-.Ar type
-should be either 1 or 2, indicating which if the device conforms to
-802.3at type 1 or 802.3at type 2. Values ofr
-.Ar source
-and
-.Ar priority
-are the same as for LLDP-MED POE-MDI TLV.
-.Ar requested
-and
-.Ar allocated
-are expressed in milliwats.
-.Pp
-Here are two valid uses of this command:
-.D1 configure ports eth3 dot3 power pse supported enabled paircontrol powerpairs spare class 3
-.D1 configure dot3 power pd supported enabled powerpairs spare class 3 type 1 source pse priority low requested 10000 allocated 15000
-.Ed
-
-.Ed
-.Sh FILES
-.Bl -tag -width "/var/run/lldpd.socketXX" -compact
-.It /var/run/lldpd.socket
-Unix-domain socket used for communication with
-.Xr lldpd 8 .
-.El
-.Sh SEE ALSO
-.Xr lldpd 8
-.Sh AUTHORS
-.An -nosplit
-The
-.Nm
-program was written by
-.An Vincent Bernat Aq bernat@luffy.cx .
+.so man8/lldpcli.8