This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-tsg-service-chaining-…/platform/include/sce.h
2023-11-08 10:20:27 +08:00

124 lines
2.9 KiB
C

#ifndef _SCE_H
#define _SCE_H
#ifdef __cpluscplus
extern "C"
{
#endif
#include <sched.h>
#include "policy.h"
#include "timestamp.h"
#include "packet_io.h"
#include "session_table.h"
#include "global_metrics.h"
#define MAX_THREAD_NUM 128
/******************************************************************************
* Struct Thread Ctx
******************************************************************************/
struct thread_ctx
{
pthread_t tid;
int thread_index;
struct sf_metrics *sf_metrics;
struct session_table *session_table;
struct packet_io *ref_io;
struct sce_ctx *ref_sce_ctx;
struct thread_metrics thread_metrics;
struct global_metrics *ref_global_metrics;
struct policy_enforcer *ref_enforcer;
int session_table_need_reset;
int thread_is_runing;
uint64_t tx_packets_to_sf;
};
/******************************************************************************
* Struct Metadata
******************************************************************************/
struct metadata
{
int write_ref;
uint64_t session_id;
char *raw_data;
int raw_len;
uint16_t l7offset;
int is_e2i_dir;
int is_ctrl_pkt;
int is_decrypted;
struct sids sids;
struct route_ctx route_ctx;
};
struct metadata *metadata_new();
int metadata_is_empty(struct metadata *meta);
void metadata_shallow_copy(struct metadata *dst, struct metadata *src);
void metadata_deep_copy(struct metadata *dst, struct metadata *src);
void metadata_free(struct metadata *meta);
/******************************************************************************
* Struct Session Ctx
******************************************************************************/
struct session_ctx
{
uint64_t session_id;
char *session_addr;
struct four_tuple inner_tuple4;
struct mutable_array rule_ids;
struct metadata *decrypted_meta_i2e;
struct metadata *decrypted_meta_e2i;
struct metadata *raw_meta_i2e;
struct metadata *raw_meta_e2i;
struct metadata *ctrl_meta;
struct selected_chainings chainings;
struct thread_ctx *ref_thread_ctx;
};
struct session_ctx *session_ctx_new();
void session_ctx_free(struct session_ctx *ctx);
/******************************************************************************
* Struct SCE Ctx
******************************************************************************/
struct sce_ctx
{
int enable_debug;
int enable_send_log;
int firewall_sids;
int nr_worker_threads;
int ts_update_interval_ms;
int cpu_affinity_mask[MAX_THREAD_NUM];
cpu_set_t coremask;
struct timestamp *ts;
struct packet_io *io;
struct global_metrics *metrics;
struct policy_enforcer *enforcer;
struct thread_ctx work_threads[MAX_THREAD_NUM];
};
struct sce_ctx *sce_ctx_create(const char *profile);
void sce_ctx_destory(struct sce_ctx *ctx);
#ifdef __cpluscplus
}
#endif
#endif