return 1;
malformed:
- lldpd_chassis_cleanup(chassis, 1);
- lldpd_port_cleanup(port, 1);
+ lldpd_chassis_cleanup(chassis, true);
+ lldpd_port_cleanup(port, true);
free(port);
return -1;
}
}
void
-lldpd_chassis_cleanup(struct lldpd_chassis *chassis, int all)
+lldpd_chassis_cleanup(struct lldpd_chassis *chassis, bool all)
{
lldpd_chassis_mgmt_cleanup(chassis);
VLOG_DBG("cleanup chassis %s",
}
/* Cleanup a remote port. The before last argument, `expire` is a function that
- * should be called when a remote port is removed. If the last argument is 1,
- * all remote ports are removed.
+ * should be called when a remote port is removed. If the last argument is
+ * true, all remote ports are removed.
*/
void
lldpd_remote_cleanup(struct lldpd_hardware *hw,
void(*expire)(struct lldpd_hardware *,
struct lldpd_port *),
- int all)
+ bool all)
{
struct lldpd_port *port, *port_next;
- int del;
time_t now = time_now();
VLOG_DBG("cleanup remote port on %s", hw->h_ifname);
LIST_FOR_EACH_SAFE (port, port_next, p_entries, &hw->h_rports.p_entries) {
- del = all;
+ bool del = all;
if (!all && expire &&
(now >= port->p_lastupdate + port->p_chassis->c_ttl)) {
hw->h_ageout_cnt++;
hw->h_delete_cnt++;
- del = 1;
+ del = true;
}
if (del) {
if (expire) {
if (!all) {
list_remove(&port->p_entries);
}
- lldpd_port_cleanup(port, 1);
+ lldpd_port_cleanup(port, true);
free(port);
}
}
/* If `all' is true, clear all information, including information that
are not refreshed periodically. Port should be freed manually. */
void
-lldpd_port_cleanup(struct lldpd_port *port, int all)
+lldpd_port_cleanup(struct lldpd_port *port, bool all)
{
/* We set these to NULL so we don't free wrong memory */
/* Cleanup functions */
void lldpd_chassis_mgmt_cleanup(struct lldpd_chassis *);
-void lldpd_chassis_cleanup(struct lldpd_chassis *, int);
+void lldpd_chassis_cleanup(struct lldpd_chassis *, bool all);
void lldpd_remote_cleanup(struct lldpd_hardware *,
- void (*expire)(struct lldpd_hardware *, struct lldpd_port *), int);
-void lldpd_port_cleanup(struct lldpd_port *, int);
+ void (*expire)(struct lldpd_hardware *, struct lldpd_port *), bool all);
+void lldpd_port_cleanup(struct lldpd_port *, bool all);
void lldpd_config_cleanup(struct lldpd_config *);
#endif
{
VLOG_DBG("cleanup hardware port %s", hardware->h_ifname);
- lldpd_port_cleanup(&hardware->h_lport, 1);
+ lldpd_port_cleanup(&hardware->h_lport, true);
if (hardware->h_ops && hardware->h_ops->cleanup) {
hardware->h_ops->cleanup(cfg, hardware);
}
LIST_FOR_EACH_SAFE (hw, hw_next, h_entries, &cfg->g_hardware.h_entries) {
if (!hw->h_flags) {
list_remove(&hw->h_entries);
- lldpd_remote_cleanup(hw, NULL, 1);
+ lldpd_remote_cleanup(hw, NULL, true);
lldpd_hardware_cleanup(cfg, hw);
} else {
- lldpd_remote_cleanup(hw, NULL, 0);
+ lldpd_remote_cleanup(hw, NULL, false);
}
}
} else if (count > cfg->g_config.c_max_neighbors - 1) {
VLOG_DBG("too many neighbors for port %s, drop this new one",
hw->h_ifname);
- lldpd_port_cleanup(port, 1);
- lldpd_chassis_cleanup(chassis, 1);
+ lldpd_port_cleanup(port, true);
+ lldpd_chassis_cleanup(chassis, true);
free(port);
return;
}