AC_CONFIG_LIBOBJ_DIR([src/compat])
AC_FUNC_MALLOC
AC_FUNC_REALLOC
-AC_REPLACE_FUNCS([strlcpy strnlen fgetln])
+AC_SEARCH_LIBS([setproctitle], [util bsd])
+AC_REPLACE_FUNCS([strlcpy strnlen fgetln setproctitle])
AC_CHECK_FUNCS([setresuid setresgid])
+case " $LIBS " in
+ *\ -lbsd\ *)
+ AC_DEFINE(HAVE_LIBBSD, 1, [Define if libbsd is used])
+ ;;
+esac
+
AC_SEARCH_LIBS([__res_init], resolv bind, AC_DEFINE([HAVE_RES_INIT], 1, [Define to indicate that res_init() exists]),
AC_SEARCH_LIBS([res_9_init], resolv bind, AC_DEFINE([HAVE_RES_INIT], 1, [Define to indicate that res_init() exists]),
AC_SEARCH_LIBS([res_init], resolv bind, AC_DEFINE([HAVE_RES_INIT], 1, [Define to indicate that res_init() exists]))))
#include <stdio.h>
#include <stddef.h>
+#ifdef HAVE_LIBBSD
+# include <bsd/stdio.h>
+# include <bsd/string.h>
+# include <bsd/unistd.h>
+#endif
#if !HAVE_STRLCPY
size_t strlcpy(char *, const char *, size_t);
char *fgetln(FILE *, size_t *);
#endif
+#if !HAVE_SETPROCTITLE
+void setproctitle(const char *fmt, ...);
+#endif
+
#if !HAVE_MALLOC
void *malloc(size_t size);
#endif
--- /dev/null
+/* -*- mode: c; c-file-style: "openbsd" -*- */
+/*
+ * Copyright (c) 2013 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.
+ */
+
+void
+setproctitle(const char *fmt, ...)
+{
+ /* Do nothing. */
+}
free(hardware);
}
+static void
+lldpd_count_neighbors(struct lldpd *cfg)
+{
+ struct lldpd_hardware *hardware;
+ struct lldpd_port *port;
+ unsigned neighbors = 0;
+ TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries) {
+ TAILQ_FOREACH(port, &hardware->h_rports, p_entries) {
+ if (!port->p_hidden_in)
+ neighbors++;
+ }
+ }
+ setproctitle("%d neighbor%s", neighbors, (neighbors > 1)?"s":"");
+}
+
static void
notify_clients_deletion(struct lldpd_hardware *hardware,
struct lldpd_port *rport)
#ifdef USE_SNMP
agent_notify(hardware, NEIGHBOR_CHANGE_DELETED, rport);
#endif
+ lldpd_count_neighbors(hardware->h_cfg);
}
static void
}
}
+ lldpd_count_neighbors(cfg);
levent_schedule_cleanup(cfg);
}
hardware->h_ifname);
lldpd_decode(cfg, buffer, n, hardware);
lldpd_hide_all(cfg); /* Immediatly hide */
+ lldpd_count_neighbors(cfg);
free(buffer);
}
lldpd_update_localports(cfg);
log_debug("loop", "update information for local chassis");
lldpd_update_localchassis(cfg);
+ lldpd_count_neighbors(cfg);
}
static void
int cmd;
struct dispatch_actions *a;
+ setproctitle("monitor");
while (!may_read(remote, &cmd, sizeof(int))) {
for (a = actions; a->function != NULL; a++) {
if (cmd == a->msg) {