|
Packit |
e9ba0d |
/* -*- mode: c; c-file-style: "openbsd" -*- */
|
|
Packit |
e9ba0d |
/*
|
|
Packit |
e9ba0d |
* Copyright (c) 2016 Vincent Bernat <bernat@luffy.cx>
|
|
Packit |
e9ba0d |
*
|
|
Packit |
e9ba0d |
* Permission to use, copy, modify, and/or distribute this software for any
|
|
Packit |
e9ba0d |
* purpose with or without fee is hereby granted, provided that the above
|
|
Packit |
e9ba0d |
* copyright notice and this permission notice appear in all copies.
|
|
Packit |
e9ba0d |
*
|
|
Packit |
e9ba0d |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
Packit |
e9ba0d |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
Packit |
e9ba0d |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
Packit |
e9ba0d |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
Packit |
e9ba0d |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
Packit |
e9ba0d |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
Packit |
e9ba0d |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
Packit |
e9ba0d |
*/
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
#if HAVE_CONFIG_H
|
|
Packit |
e9ba0d |
# include <config.h>
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
#include <stdio.h>
|
|
Packit |
e9ba0d |
#include "compat/compat.h"
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
static void
|
|
Packit |
e9ba0d |
version_display_array(FILE *destination, const char *prefix, const char *const *items)
|
|
Packit |
e9ba0d |
{
|
|
Packit |
e9ba0d |
fprintf(destination, "%s", prefix);
|
|
Packit |
e9ba0d |
size_t count = 0;
|
|
Packit |
e9ba0d |
for (const char *const *p = items; *p; p++, count++)
|
|
Packit |
e9ba0d |
fprintf(destination, "%s%s", count?", ":"", *p);
|
|
Packit |
e9ba0d |
if (count == 0)
|
|
Packit |
e9ba0d |
fprintf(destination, "(none)\n");
|
|
Packit |
e9ba0d |
else
|
|
Packit |
e9ba0d |
fprintf(destination, "\n");
|
|
Packit |
e9ba0d |
}
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
void
|
|
Packit |
e9ba0d |
version_display(FILE *destination, const char *progname, int verbose)
|
|
Packit |
e9ba0d |
{
|
|
Packit |
e9ba0d |
if (!verbose) {
|
|
Packit |
e9ba0d |
fprintf(destination, "%s\n", PACKAGE_VERSION);
|
|
Packit |
e9ba0d |
return;
|
|
Packit |
e9ba0d |
}
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
const char *const lldp_features[] = {
|
|
Packit |
e9ba0d |
#ifdef ENABLE_LLDPMED
|
|
Packit |
e9ba0d |
"LLDP-MED",
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
#ifdef ENABLE_DOT1
|
|
Packit |
e9ba0d |
"Dot1",
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
#ifdef ENABLE_DOT3
|
|
Packit |
e9ba0d |
"Dot3",
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
#ifdef ENABLE_CUSTOM
|
|
Packit |
e9ba0d |
"Custom TLV",
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
NULL};
|
|
Packit |
e9ba0d |
const char *const protocols[] = {
|
|
Packit |
e9ba0d |
#ifdef ENABLE_CDP
|
|
Packit |
e9ba0d |
"CDP",
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
#ifdef ENABLE_FDP
|
|
Packit |
e9ba0d |
"FDP",
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
#ifdef ENABLE_EDP
|
|
Packit |
e9ba0d |
"EDP",
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
#ifdef ENABLE_SONMP
|
|
Packit |
e9ba0d |
"SONMP",
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
NULL};
|
|
Packit |
e9ba0d |
const char *const output_formats[] = {
|
|
Packit |
e9ba0d |
"TEXT",
|
|
Packit |
e9ba0d |
"KV",
|
|
Packit |
e9ba0d |
"JSON",
|
|
Packit |
e9ba0d |
#ifdef USE_XML
|
|
Packit |
e9ba0d |
"XML",
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
NULL};
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
fprintf(destination, "%s %s\n", progname, PACKAGE_VERSION);
|
|
Packit |
e9ba0d |
fprintf(destination, " Built on " BUILD_DATE "\n");
|
|
Packit |
e9ba0d |
fprintf(destination, "\n");
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
/* Features */
|
|
Packit |
e9ba0d |
if (!strcmp(progname, "lldpd")) {
|
|
Packit |
e9ba0d |
version_display_array(destination,
|
|
Packit |
e9ba0d |
"Additional LLDP features: ", lldp_features);
|
|
Packit |
e9ba0d |
version_display_array(destination,
|
|
Packit |
e9ba0d |
"Additional protocols: ", protocols);
|
|
Packit |
e9ba0d |
fprintf(destination,
|
|
Packit |
e9ba0d |
"SNMP support: "
|
|
Packit |
e9ba0d |
#ifdef USE_SNMP
|
|
Packit |
e9ba0d |
"yes\n"
|
|
Packit |
e9ba0d |
#else
|
|
Packit |
e9ba0d |
"no\n"
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
);
|
|
Packit |
e9ba0d |
#ifdef HOST_OS_LINUX
|
|
Packit |
e9ba0d |
fprintf(destination,
|
|
Packit |
e9ba0d |
"Old kernel support: "
|
|
Packit |
e9ba0d |
#ifdef ENABLE_OLDIES
|
|
Packit |
e9ba0d |
"yes"
|
|
Packit |
e9ba0d |
#else
|
|
Packit |
e9ba0d |
"no"
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
" (Linux " MIN_LINUX_KERNEL_VERSION "+)\n");
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
#ifdef ENABLE_PRIVSEP
|
|
Packit |
e9ba0d |
fprintf(destination,
|
|
Packit |
e9ba0d |
"Privilege separation: " "enabled\n");
|
|
Packit |
e9ba0d |
fprintf(destination,
|
|
Packit |
e9ba0d |
"Privilege separation user: " PRIVSEP_USER "\n");
|
|
Packit |
e9ba0d |
fprintf(destination,
|
|
Packit |
e9ba0d |
"Privilege separation group: " PRIVSEP_GROUP "\n");
|
|
Packit |
e9ba0d |
fprintf(destination,
|
|
Packit |
e9ba0d |
"Privilege separation chroot: " PRIVSEP_CHROOT "\n");
|
|
Packit |
e9ba0d |
#else
|
|
Packit |
e9ba0d |
fprintf(destination,
|
|
Packit |
e9ba0d |
"Privilege separation: " "disabled\n");
|
|
Packit |
e9ba0d |
#endif
|
|
Packit |
e9ba0d |
fprintf(destination,
|
|
Packit |
e9ba0d |
"Configuration directory: " SYSCONFDIR "\n");
|
|
Packit |
e9ba0d |
}
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
if (!strcmp(progname, "lldpcli")) {
|
|
Packit |
e9ba0d |
version_display_array(destination,
|
|
Packit |
e9ba0d |
"Additional output formats: ", output_formats);
|
|
Packit |
e9ba0d |
}
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
fprintf(destination, "\n");
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
/* Build */
|
|
Packit |
e9ba0d |
fprintf(destination,
|
|
Packit |
e9ba0d |
"C compiler command: %s\n", LLDP_CC);
|
|
Packit |
e9ba0d |
fprintf(destination,
|
|
Packit |
e9ba0d |
"Linker command: %s\n", LLDP_LD);
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
}
|