/** * \brief Remove data manager from list, close it and free templates * * \param[in] output_manager Output Manager structure * \param[in] old_manager Data Manager to remove and close */ void output_manager_remove(struct output_manager_config *output_manager, struct data_manager_config *old_manager) { struct data_manager_config *aux_conf = output_manager->data_managers; if (aux_conf == old_manager) { output_manager->data_managers = old_manager->next; } while (aux_conf->next) { if (aux_conf->next == old_manager) { aux_conf->next = old_manager->next; if (output_manager->last == old_manager) { output_manager->last = aux_conf; } break; } else { aux_conf = aux_conf->next; } } if (output_manager->data_managers == NULL) { output_manager->last = NULL; } uint32_t odid = old_manager->observation_domain_id; data_manager_close(&old_manager); if (!output_manager->perman_odid_merge && output_manager->manager_mode != OM_SINGLE) { tm_remove_all_odid_templates(template_mgr, odid); } else { // Single manager -> remove all templates tm_remove_all_templates(template_mgr); } }
/** * \brief Process one template from template set * * \param[in] tmpl template * \param[in] max_len maximal length of this template * \param[in] type type of the template * \param[in] msg_counter message counter * \param[in] input_info input info structure * \param[in] key template key with filled crc and odid * \return length of the template */ static int preprocessor_process_one_template(void *tmpl, int max_len, int type, uint32_t msg_counter, struct input_info *input_info, struct ipfix_template_key *key) { struct ipfix_template_record *template_record; struct ipfix_template *template; int ret; template_record = (struct ipfix_template_record*) tmpl; key->tid = ntohs(template_record->template_id); /* check for withdraw all templates message */ /* these templates are no longer used (checked in data_manager_withdraw_templates()) */ if (input_info->type == SOURCE_TYPE_UDP && ntohs(template_record->count) == 0) { /* got withdrawal message with UDP -> this is wrong */ MSG_WARNING(msg_module, "[%u] Received template withdrawal message over UDP; ignoring...", input_info->odid); return TM_TEMPLATE_WITHDRAW_LEN; } else if ((ntohs(template_record->template_id) == IPFIX_TEMPLATE_FLOWSET_ID || ntohs(template_record->template_id) == IPFIX_OPTION_FLOWSET_ID) && ntohs(template_record->count) == 0) { /* withdraw template or option template */ tm_remove_all_templates(template_mgr, type); /* don't try to parse the withdraw template */ return TM_TEMPLATE_WITHDRAW_LEN; /* check for withdraw template message */ } else if (ntohs(template_record->count) == 0) { ret = tm_remove_template(template_mgr, key); MSG_NOTICE(msg_module, "[%u] Received %s withdrawal message", input_info->odid, (type==TM_TEMPLATE) ? "Template" : "Options template"); /* Log error when removing unknown template */ if (ret == 1) { MSG_WARNING(msg_module, "[%u] %s withdrawal message received for unknown template ID %u", input_info->odid, (type==TM_TEMPLATE) ? "Template" : "Options template", ntohs(template_record->template_id)); } return TM_TEMPLATE_WITHDRAW_LEN; /* check whether template exists */ } else if ((template = tm_get_template(template_mgr, key)) == NULL) {