}
#endif
+#ifdef ENABLE_CUSTOM
+void
+lldpd_custom_tlv_add(struct lldpd_port *port, struct lldpd_custom *curr)
+{
+ struct lldpd_custom *custom;
+
+ if ((custom = malloc(sizeof(struct lldpd_custom)))) {
+ memcpy(custom, curr, sizeof(struct lldpd_custom));
+ if ((custom->oui_info = malloc(custom->oui_info_len))) {
+ memcpy(custom->oui_info, curr->oui_info, custom->oui_info_len);
+ TAILQ_INSERT_TAIL(&port->p_custom_list, custom, next);
+ } else {
+ free(custom);
+ log_warn("rpc", "could not allocate memory for custom TLV info");
+ }
+ }
+}
+
+void
+lldpd_custom_tlv_cleanup(struct lldpd_port *port, struct lldpd_custom *curr)
+{
+ struct lldpd_custom *custom, *custom_next;
+ for (custom = TAILQ_FIRST(&port->p_custom_list);
+ custom != NULL;
+ custom = custom_next) {
+ custom_next = TAILQ_NEXT(custom, next);
+ if (!memcmp(curr->oui, custom->oui, sizeof(curr->oui)) &&
+ curr->subtype == custom->subtype) {
+ TAILQ_REMOVE(&port->p_custom_list, custom, next);
+ free(custom->oui_info);
+ free(custom);
+ }
+ }
+}
+
+void
+lldpd_custom_list_cleanup(struct lldpd_port *port)
+{
+ struct lldpd_custom *custom, *custom_next;
+ for (custom = TAILQ_FIRST(&port->p_custom_list);
+ custom != NULL;
+ custom = custom_next) {
+ custom_next = TAILQ_NEXT(custom, next);
+ free(custom->oui_info);
+ free(custom);
+ }
+ TAILQ_INIT(&port->p_custom_list);
+}
+#endif
+
/* 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.
port_next = TAILQ_NEXT(port, p_entries);
del = all;
if (!all && expire &&
- (now >= port->p_lastupdate + port->p_chassis->c_ttl)) {
- hardware->h_ageout_cnt++;
- hardware->h_delete_cnt++;
+ (now >= port->p_lastupdate + port->p_ttl)) {
+ if (port->p_ttl > 0) hardware->h_ageout_cnt++;
del = 1;
}
if (del) {
* real list. It is only needed to be called when we
* don't delete the entire list. */
if (!all) TAILQ_REMOVE(&hardware->h_rports, port, p_entries);
+
+ hardware->h_delete_cnt++;
+ /* Register last removal to be able to report lldpStatsRemTablesLastChangeTime */
+ hardware->h_lport.p_lastremove = time(NULL);
lldpd_port_cleanup(port, 1);
free(port);
}
#endif
/* will set these to NULL so we don't free wrong memory */
- free(port->p_id);
- port->p_id = NULL;
- free(port->p_descr);
- port->p_descr = NULL;
if (all) {
+ free(port->p_id);
+ port->p_id = NULL;
+ free(port->p_descr);
+ port->p_descr = NULL;
free(port->p_lastframe);
if (port->p_chassis) { /* chassis may not have been attributed, yet */
port->p_chassis->c_refcount--;
port->p_chassis = NULL;
}
+#ifdef ENABLE_CUSTOM
+ lldpd_custom_list_cleanup(port);
+#endif
}
}
log_debug("alloc", "general configuration cleanup");
free(config->c_mgmt_pattern);
free(config->c_cid_pattern);
+ free(config->c_cid_string);
free(config->c_iface_pattern);
+ free(config->c_perm_ifaces);
free(config->c_hostname);
free(config->c_platform);
free(config->c_description);