//#define CONFIG_DEBUG_WITH_SHELL int main(int argc, char **argv) { struct wifi_callback_funcs wifi2agps_cb; /* if it is not called by init, do nothing*/ #ifndef CONFIG_DEBUG_WITH_SHELL if (getppid() != 1) return 1; #endif wifi2agps_cb.wifi_enabled = wifi2agps_enabled; wifi2agps_cb.wifi_disabled = wifi2agps_disabled; wifi2agps_cb.wifi_associated = wifi2agps_associated; wifi2agps_cb.wifi_disassociated = wifi2agps_disassociated; wifi2agps_cb.wifi_scan_results = wifi2agps_scanned; wifi2agps_init(&wifi2agps_cb); event_loop_run(); return 0; }
/** * Test main methode */ int main(int argc, char **argv) { //Initialize signal handler struct sigaction new_sa; new_sa.sa_handler = sigwait_handler; sigemptyset(&new_sa.sa_mask); new_sa.sa_flags = 0; if (sigaction(SIGCHLD, &new_sa, NULL) == -1) { THROWEXCEPTION("Could not install signal handler."); } #ifdef OBJECT_CACHE_DEBUG struct sigaction term; term.sa_handler = sigterm_handler; sigemptyset(&term.sa_mask); term.sa_flags |= SA_RESTART; sigaction(SIGTERM, &term, 0); sigaction(SIGINT, &term, 0); #endif //Process command line parameters parse_command_line_parameters(argc,argv); //Read config file config_file_descriptor* conf = read_config(config_file); //Init exporter ipfix_exporter* send_exporter; int ret = ipfix_init_exporter(conf->observation_domain_id, &send_exporter); if (ret != 0) { THROWEXCEPTION("ipfix_init_exporter failed!\n"); } #ifdef SUPPORT_COMPRESSION if (conf->compression_method && strlen(conf->compression_method) > 0) { ret = ipfix_init_compression(send_exporter, conf->compression_method, conf->compression_method_params); if (ret) THROWEXCEPTION("Failed to initialize compression module."); } #endif #ifdef SUPPORT_DTLS ipfix_set_dtls_certificate(send_exporter, conf->certificate, conf->certificate_key); ipfix_set_ca_locations(send_exporter, conf->ca, conf->ca_path); #endif //Add collectors from config file init_collectors(conf,send_exporter); //Generate templates msg(MSG_INFO, "Generating templates from config"); generate_templates_from_config(send_exporter,conf); msg(MSG_DIALOG, "LInEx is up and running. Press Ctrl-C to exit."); // Start capturing sessions if (conf->flow_sampling_mode == CRC32SamplingMode && conf->flow_sampling_polynom) set_sampling_polynom(conf->flow_sampling_polynom); msg(MSG_INFO, "Sampling mode is %d and threshold is %d", conf->flow_sampling_mode, conf->flow_sampling_max_value); if (start_flow_capture_session(&flow_session, conf->flow_inactive_timeout, conf->flow_active_timeout, conf->flow_object_cache_size, conf->flow_sampling_mode, conf->flow_sampling_max_value)) msg(MSG_ERROR, "Failed to start capture session."); olsr_capture_session = start_capture_session(); if (!olsr_capture_session) msg(MSG_ERROR, "Failed to start OLSR capture session."); bind_to_interfaces(conf); // Register timer to readd interfaces in case they go down event_loop_add_timer(120000, (event_timer_callback) &bind_to_interfaces, conf); #ifdef SUPPORT_ANONYMIZATION if (conf->anonymization_enabled && init_cryptopan(&flow_session.cryptopan, conf->anonymization_key, conf->anonymization_pad)) { msg(MSG_ERROR, "Failed to initialize CryptoPAN."); return 1; } else if (!conf->anonymization_enabled) { msg(MSG_INFO, "CryptoPAN disabled"); } else { msg(MSG_INFO, "CryptoPAN enabled"); } #endif // Declare IPFIX templates to export monitoring information if (declare_templates(send_exporter)) msg(MSG_ERROR, "Failed to export templates."); //Open XML file FILE* xmlfh = NULL; if(conf->xmlfile != NULL) { xmlfh = fopen(conf->xmlfile, "w"); if (xmlfh == NULL) THROWEXCEPTION("Could not open XML file %s", conf->xmlfile); } // Add timer to export routing tables node_set = kh_init(2); struct export_parameters params = { send_exporter, node_set }; event_loop_add_timer(conf->export_olsr_interval, (void (*)(void *)) &export_full, ¶ms); // Add timer to export flows struct export_flow_parameter flow_param = { send_exporter, &flow_session }; event_loop_add_timer(conf->export_flow_interval, (void (*)(void *)) &export_flows, &flow_param); // Add timer to export records struct export_record_parameters record_params = { send_exporter, conf, xmlfh }; event_loop_add_timer(conf->interval * 1000, (void (*)(void *)) &export_records, &record_params); // Add timer to export capture statistics struct export_capture_parameter capture_statistics_param = { send_exporter, flow_session.capture_session, olsr_capture_session }; event_loop_add_timer(10000, (void (*) (void *)) &export_capture_statistics, &capture_statistics_param); return event_loop_run(); }