]>
git.ipfire.org Git - thirdparty/lldpd.git/blob - src/client/lldpctl.c
ae7a4aa7bf79b4e3c805495c3eeed4a351119292
1 /* -*- mode: c; c-file-style: "openbsd" -*- */
3 * Copyright (c) 2008 Vincent Bernat <bernat@luffy.cx>
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 #include <sys/types.h>
24 #include <sys/socket.h>
26 #include <arpa/inet.h>
32 static void usage(void);
34 #ifdef HAVE___PROGNAME
35 extern const char *__progname
;
37 # define __progname "lldpctl"
44 fprintf(stderr
, "Usage: %s [OPTIONS ...] [INTERFACES ...]\n", __progname
);
45 fprintf(stderr
, "Version: %s\n", PACKAGE_STRING
);
47 fprintf(stderr
, "\n");
49 fprintf(stderr
, "-d Enable more debugging information.\n");
50 fprintf(stderr
, "-a Display all remote ports, including hidden ones.\n");
51 fprintf(stderr
, "-f format Choose output format (plain, keyvalue or xml).\n");
52 fprintf(stderr
, "-L location Enable the transmission of LLDP-MED location TLV for the\n");
53 fprintf(stderr
, " given interfaces. Can be repeated to enable the transmission\n");
54 fprintf(stderr
, " of the location in several formats.\n");
55 fprintf(stderr
, "-P policy Enable the transmission of LLDP-MED Network Policy TLVs\n");
56 fprintf(stderr
, " for the given interfaces. Can be repeated to specify\n");
57 fprintf(stderr
, " different policies.\n");
58 fprintf(stderr
, "-O poe Enable the transmission of LLDP-MED POE-MDI TLV\n");
59 fprintf(stderr
, " for the given interfaces.\n");
60 fprintf(stderr
, "-o poe Enable the transmission of Dot3 POE-MDI TLV\n");
61 fprintf(stderr
, " for the given interfaces.\n");
63 fprintf(stderr
, "\n");
65 fprintf(stderr
, "see manual page lldpctl(8) for more information\n");
70 main(int argc
, char *argv
[])
74 int action
= 0, hidden
= 0;
77 /* Get and parse command line options */
78 while ((ch
= getopt(argc
, argv
, LLDPCTL_ARGS
)) != -1) {
87 fprintf(stdout
, "%s\n", PACKAGE_VERSION
);
107 log_init(debug
, __progname
);
109 if ((action
!= 0) && (getuid() != 0)) {
110 fatalx("mere mortals may not do that, 'root' privileges are required.");
113 conn
= lldpctl_new(NULL
, NULL
, NULL
);
114 if (conn
== NULL
) exit(EXIT_FAILURE
);
116 if (!action
) display_interfaces(conn
, fmt
, hidden
, argc
, argv
);
117 else modify_interfaces(conn
, argc
, argv
, optind
);
119 lldpctl_release(conn
);