/* * Remove all entries from sctpAssocRemAddrTable, which are not marked as valid. * All valid entries are then marked as invalid (to delete them in next cache * load, if the entry is not updated). */ void sctpAssocRemAddrTable_delete_invalid(netsnmp_container *remAddrTable) { netsnmp_container *to_delete = netsnmp_container_find("lifo"); CONTAINER_FOR_EACH(remAddrTable, sctpAssocRemAddrTable_collect_invalid, to_delete); while (CONTAINER_SIZE(to_delete)) { sctpAssocRemAddrTable_entry *entry = CONTAINER_FIRST(to_delete); CONTAINER_REMOVE(remAddrTable, entry); sctpAssocRemAddrTable_entry_free(entry); CONTAINER_REMOVE(to_delete, NULL); } CONTAINER_FREE(to_delete); }
int sctpAssocRemAddrTable_add_or_update(netsnmp_container *remAddrTable, sctpAssocRemAddrTable_entry * entry) { /* * we have full sctpAssocLocalAddrTable entry, update or add it in the container */ sctpAssocRemAddrTable_entry *old; entry->valid = 1; /* * try to find it in the container */ sctpAssocRemAddrTable_entry_update_index(entry); old = CONTAINER_FIND(remAddrTable, entry); if (old != NULL) { /* * update existing entry, don't overwrite the timestamp */ time_t timestamp = old->sctpAssocRemAddrStartTime; if (timestamp == 0 && entry->sctpAssocRemAddrStartTime == 0) timestamp = netsnmp_get_agent_uptime(); /* set the timestamp if it was not set before */ sctpAssocRemAddrTable_entry_copy(entry, old); old->sctpAssocRemAddrStartTime = timestamp; sctpAssocRemAddrTable_entry_free(entry); } else { /* * the entry is new, add it there */ if (entry->sctpAssocRemAddrStartTime == 0) { entry->sctpAssocRemAddrStartTime = netsnmp_get_agent_uptime(); } CONTAINER_INSERT(remAddrTable, entry); } return SNMP_ERR_NOERROR; }
static void sctpAssocRemAddrTable_entry_clear(void *what, void *magic) { sctpAssocRemAddrTable_entry_free(what); }