124 lines
2.9 KiB
C
124 lines
2.9 KiB
C
#ifndef _TFE_PACKET_IO_H
|
|
#define _TFE_PACKET_IO_H
|
|
|
|
#ifdef __cpluscplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#include "tuple.h"
|
|
#include "tfe_packet_io_fs.h"
|
|
|
|
struct tap_ctx
|
|
{
|
|
int tap_s;
|
|
int tap_c;
|
|
int tap_fd;
|
|
|
|
int eventfd;
|
|
int eventfd_c;
|
|
int eventfd_s;
|
|
|
|
struct io_uring_instance *io_uring_fd;
|
|
struct io_uring_instance *io_uring_c;
|
|
struct io_uring_instance *io_uring_s;
|
|
};
|
|
|
|
struct packet_io_thread_ctx
|
|
{
|
|
pthread_t tid;
|
|
int thread_index;
|
|
|
|
struct tap_ctx *tap_ctx;
|
|
struct session_table *session_table;
|
|
|
|
struct packet_io *ref_io;
|
|
struct tfe_proxy *ref_proxy;
|
|
struct packet_io_fs *ret_fs_state;
|
|
struct acceptor_kni_v4 *ref_acceptor_ctx;
|
|
struct expiry_dablooms_handle *dup_packet_filter;
|
|
|
|
void *logger;
|
|
int session_table_need_reset;
|
|
};
|
|
|
|
struct packet_info
|
|
{
|
|
int is_ipv4;
|
|
int is_e2i_dir;
|
|
int header_len;
|
|
char *header_data;
|
|
|
|
struct tuple4 tuple4;
|
|
struct sids sids;
|
|
struct route_ctx route_ctx;
|
|
struct throughput_metrics rx;
|
|
struct throughput_metrics rx_send_complete;
|
|
};
|
|
|
|
struct session_ctx
|
|
{
|
|
uint64_t policy_ids;
|
|
uint64_t session_id;
|
|
uint8_t is_passthrough;
|
|
uint8_t protocol;
|
|
uint8_t metric_hit;
|
|
char session_addr[128];
|
|
|
|
struct packet_info c2s_info;
|
|
struct packet_info s2c_info;
|
|
struct timespec metrics_last_time;
|
|
|
|
struct metadata *ctrl_meta;
|
|
|
|
struct tfe_cmsg *cmsg;
|
|
|
|
struct packet_io_thread_ctx *ref_thread_ctx;
|
|
};
|
|
|
|
struct acceptor_kni_v4
|
|
{
|
|
int dup_packet_filter_enable;
|
|
int dup_packet_filter_capacity;
|
|
int dup_packet_filter_timeout;
|
|
double dup_packet_filter_error_rate;
|
|
|
|
int debug;
|
|
int firewall_sids;
|
|
int proxy_sids;
|
|
int sce_sids;
|
|
int nr_worker_threads;
|
|
int cpu_affinity_mask[TFE_THREAD_MAX];
|
|
cpu_set_t coremask;
|
|
|
|
struct packet_io *io;
|
|
struct packet_io_fs *packet_io_fs;
|
|
struct tfe_fieldstat_easy_t *metric;
|
|
struct packet_io_thread_ctx work_threads[TFE_THREAD_MAX];
|
|
|
|
struct tfe_proxy *ref_proxy;
|
|
};
|
|
|
|
int is_enable_iouring(struct packet_io *handle);
|
|
|
|
void tfe_tap_ctx_destory(struct tap_ctx *handler);
|
|
struct tap_ctx *tfe_tap_ctx_create(void *ctx);
|
|
|
|
int packet_io_thread_init(struct packet_io *handle, struct packet_io_thread_ctx *thread_ctx, void *logger);
|
|
void packet_io_thread_wait(struct packet_io *handle, struct packet_io_thread_ctx *thread_ctx, int timeout_ms);
|
|
void packet_io_destory(struct packet_io *handle);
|
|
struct packet_io *packet_io_create(const char *profile, int thread_num, cpu_set_t *coremask, void *logger);
|
|
|
|
int packet_io_polling_nf_interface(struct packet_io *handle, int thread_seq, void *ctx);
|
|
void handle_decryption_packet_from_tap(const char *data, int len, void *args);
|
|
void handle_raw_packet_from_tap(const char *data, int len, void *args);
|
|
|
|
// only for test
|
|
int raw_traffic_decapsulate(struct packet *handler, const char *raw_data, int raw_len, char **header, int *header_len, int *is_ipv4);
|
|
|
|
#ifdef __cpluscplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|