#include "packet_io.h" #include "session_manager.h" #include "plugin_manager.h" #include "http.h" struct packet_io_loop_arg { struct device *dev; int thread_id; }; void packet_io_loop(struct packet_io_loop_arg *arg) { struct packet *rx_pkt; struct session_event *event; while(1) { int fetch_num = packetio_rx(arg->dev, arg->thread_id, &rx_pkt, 1); if(fetch_num > 0) { event = session_manager_commit(rx_pkt); while(event) { plugin_manager_dispatch(event); event = session_manager_fetch_event(); } //clean session_manager event queue packetio_tx(arg->dev, arg->thread_id, &rx_pkt, 1); } else { //dispatch to time event //dispatch to trigger polling event } } return; } struct device *packetio_init(int worker_thread_num, const char *instance_name, const char *device_name) { struct packetio_instance * instance = packetio_create(instance_name); struct device *dev = packetio_open_device(instance, device_name, worker_thread_num, worker_thread_num); return dev; } int main(int argc, char ** argv) { //config_manager_init session_manager_session_event_register(http_decoder, SESSION_TYPE_HTTP); //packetio_init //create_worker_thread //main_loop return 0; }