}
#endif
+/* If `all' is true, clear all information, including information that
+ are not refreshed periodically. If `all' is true, also free the
+ port. */
void
-lldpd_port_cleanup(struct lldpd_port *port)
+lldpd_port_cleanup(struct lldpd_port *port, int all)
{
#ifdef ENABLE_LLDPMED
int i;
- for (i=0; i < LLDPMED_LOCFORMAT_LAST; i++)
- free(port->p_med_location[i].data);
+ if (all)
+ for (i=0; i < LLDPMED_LOCFORMAT_LAST; i++)
+ free(port->p_med_location[i].data);
#endif
#ifdef ENABLE_DOT1
lldpd_vlan_cleanup(port);
#endif
free(port->p_id);
free(port->p_descr);
- /* Don't free port, we may use this function on statically
- allocated ports */
+ if (all)
+ free(port);
}
void
lldpd_remote_cleanup(struct lldpd *cfg, struct lldpd_hardware *hardware, int reset)
{
if (hardware->h_rport != NULL) {
- lldpd_port_cleanup(hardware->h_rport);
- free(hardware->h_rport);
+ lldpd_port_cleanup(hardware->h_rport, 1);
hardware->h_rport = NULL;
}
if (hardware->h_rchassis != NULL) {
void
lldpd_hardware_cleanup(struct lldpd_hardware *hardware)
{
- lldpd_port_cleanup(&hardware->h_lport);
+ lldpd_port_cleanup(&hardware->h_lport, 1);
free(hardware->h_proto_macs);
free(hardware->h_llastframe);
free(hardware);
#ifdef ENABLE_DOT1
TAILQ_INIT(&hardware->h_lport.p_vlans);
} else {
- lldpd_port_cleanup(&hardware->h_lport);
+ lldpd_port_cleanup(&hardware->h_lport, 0);
#endif
}
cleanup:
lldpd_chassis_cleanup(chassis);
- lldpd_port_cleanup(port);
- free(port);
+ lldpd_port_cleanup(port, 1);
return;
}
void lldpd_vlan_cleanup(struct lldpd_port *);
#endif
void lldpd_remote_cleanup(struct lldpd *, struct lldpd_hardware *, int);
-void lldpd_port_cleanup(struct lldpd_port *);
+void lldpd_port_cleanup(struct lldpd_port *, int);
void lldpd_chassis_cleanup(struct lldpd_chassis *);
/* lldp.c */