#ifndef _PACKET_IO_H
#define _PACKET_IO_H
#ifdef __cpluscplus
extern "C"
{
#endif
#include "packet.h"
#include "stellar.h"
#define PACKET_IO_LOG_STATE(format, ...) LOG_STATE("packet_io", format, ##__VA_ARGS__)
#define PACKET_IO_LOG_ERROR(format, ...) LOG_ERROR("packet_io", format, ##__VA_ARGS__)
#define PACKET_IO_LOG_DEBUG(format, ...) LOG_DEBUG("packet_io", format, ##__VA_ARGS__)
struct packet_io_stat
uint64_t rx_pkts;
uint64_t tx_pkts;
uint64_t rx_bytes;
uint64_t tx_bytes;
uint64_t keepalive_pkts;
uint64_t keepalive_bytes;
uint64_t drop_pkts;
uint64_t drop_bytes;
uint64_t inject_pkts;
uint64_t inject_bytes;
};
enum packet_io_mode
PACKET_IO_DUMPFILE = 0,
PACKET_IO_MARSIO = 1,
struct packet_io_config
enum packet_io_mode mode;
// for dumpfile
char dumpfile_dir[256];
// for marsio
char app_symbol[64];
char dev_symbol[64];
uint8_t nr_threads;
uint16_t cpu_mask[MAX_THREAD_NUM];
struct packet_io;
struct packet_io *packet_io_new(struct packet_io_config *config);
void packet_io_free(struct packet_io *handle);
void packet_io_print_stat(struct packet_io *handle);
struct packet_io_stat *packet_io_get_stat(struct packet_io *handle);
// return 0 if success, -1 if failed
int packet_io_init(struct packet_io *handle, uint16_t thread_id);
int packet_io_recv(struct packet_io *handle, uint16_t thread_id, struct packet **pkt);
void packet_io_send(struct packet_io *handle, uint16_t thread_id, struct packet *pkt);
}