return E2BIG;
}
-/* Send a shutdown LLDPDU. Should be called only if we have a previously sent
- * LLDPDU. */
-static int
+/* Send a shutdown LLDPDU. */
+int
lldp_send_shutdown(struct lldpd *global,
struct lldpd_hardware *hardware)
{
+ if (hardware->h_lchassis_previous_id == NULL ||
+ hardware->h_lport_previous_id == NULL)
+ return 0;
return _lldp_send(global, hardware,
hardware->h_lchassis_previous_id_subtype,
hardware->h_lchassis_previous_id,
free(buffer);
}
+static void
+lldpd_send_shutdown(struct lldpd_hardware *hardware)
+{
+ struct lldpd *cfg = hardware->h_cfg;
+ if (cfg->g_config.c_receiveonly || cfg->g_config.c_paused) return;
+ if ((hardware->h_flags & IFF_RUNNING) == 0)
+ return;
+
+ /* It's safe to call `lldp_send_shutdown()` because shutdown LLDPU will
+ * only be emitted if LLDP was sent on that port. */
+ if (lldp_send_shutdown(hardware->h_cfg, hardware) != 0)
+ log_warnx("send", "unable to send shutdown LLDPDU on %s",
+ hardware->h_ifname);
+}
+
void
lldpd_send(struct lldpd_hardware *hardware)
{
{
struct lldpd_hardware *hardware, *hardware_next;
log_debug("main", "exit lldpd");
+
+ TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries)
+ lldpd_send_shutdown(hardware);
+
close(cfg->g_ctl);
priv_ctl_cleanup(cfg->g_ctlname);
log_debug("main", "cleanup hardware information");
int levent_make_socket_nonblocking(int);
/* lldp.c */
+int lldp_send_shutdown(PROTO_SEND_SIG);
int lldp_send(PROTO_SEND_SIG);
int lldp_decode(PROTO_DECODE_SIG);