summaryrefslogtreecommitdiff
path: root/platform/include/sce.h
blob: 4be243aafa110054bac6f0c15159435b1ebc4569 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#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"

#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 global_metrics *ref_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 addr_tuple4 inner_tuple4;
    struct fixed_num_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