[ADD] packet_io framework
This commit is contained in:
35
src/main.cpp
35
src/main.cpp
@@ -2,6 +2,13 @@
|
||||
#include "session_manager.h"
|
||||
#include "plugin_manager.h"
|
||||
#include "http.h"
|
||||
#include "../sdk/include/logger.h"
|
||||
|
||||
struct engine_instance {
|
||||
struct packet_io_config pio_config;
|
||||
};
|
||||
|
||||
struct engine_instance g_engine_instance;
|
||||
|
||||
struct packet_io_loop_arg
|
||||
{
|
||||
@@ -39,19 +46,35 @@ void packet_io_loop(struct packet_io_loop_arg *arg)
|
||||
}
|
||||
|
||||
|
||||
struct packet_io_device *packet_io_init(int worker_thread_num, const char *instance_name, const char *device_name)
|
||||
struct packet_io_device *packet_io_init(int worker_thread_num, const char *device_name)
|
||||
{
|
||||
struct packet_io_instance * instance = packet_io_create(PACKET_IO_PCAP, instance_name);
|
||||
struct packet_io_device *dev = packet_io_open_device(instance, device_name, worker_thread_num, worker_thread_num);
|
||||
return dev;
|
||||
struct packet_io_instance *ppio_instance = packet_io_instance_init(&g_engine_instance.pio_config);
|
||||
if (nullptr == ppio_instance) {
|
||||
log_error(ST_ERR_PIO_INSTANCE, "packet_io instance init failed.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct packet_io_device *ppio_device = packet_io_open_device(ppio_instance, nullptr, worker_thread_num, worker_thread_num);
|
||||
if (nullptr == ppio_device) {
|
||||
log_error(ST_ERR_PIO_DEVICE, "packet_io device open failed.");
|
||||
|
||||
}
|
||||
return ppio_device;
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
//config_manager_init
|
||||
/* global engine instance init */
|
||||
memset(&g_engine_instance, 0, sizeof(g_engine_instance));
|
||||
|
||||
g_engine_instance.pio_config.mode = PACKET_IO_RUN_MODE_PCAP_FILE;
|
||||
strncpy(g_engine_instance.pio_config.dev_name[0], "./test.pcap", sizeof(NAME_MAX_LEN));
|
||||
g_engine_instance.pio_config.dev_cnt = 1;
|
||||
|
||||
/* packet io init */
|
||||
packet_io_instance_init(&g_engine_instance.pio_config);
|
||||
session_manager_session_event_register(http_decoder, SESSION_TYPE_HTTP);
|
||||
//packet_io_init
|
||||
|
||||
|
||||
//create_worker_thread
|
||||
|
||||
|
||||
Reference in New Issue
Block a user