2023-02-07 02:51:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
2023-04-03 08:30:49 +00:00
|
|
|
#include "uthash.h"
|
|
|
|
|
#include "tsg_bridge.h"
|
|
|
|
|
|
2023-02-09 07:14:55 +00:00
|
|
|
#include <MESA/stream.h>
|
|
|
|
|
#include <MESA/field_stat2.h>
|
|
|
|
|
#include <ctemplate/template.h>
|
|
|
|
|
|
|
|
|
|
enum TSG_FS2_TYPE
|
|
|
|
|
{
|
|
|
|
|
TSG_FS2_TCP_LINKS=0,
|
|
|
|
|
TSG_FS2_UDP_LINKS,
|
|
|
|
|
TSG_FS2_BYPASS,
|
|
|
|
|
TSG_FS2_HIT_ADDR,
|
|
|
|
|
TSG_FS2_HIT_SHARE,
|
|
|
|
|
TSG_FS2_INTERCEPT,
|
|
|
|
|
TSG_FS2_SHAPING,
|
2023-03-01 05:09:34 +00:00
|
|
|
TSG_FS2_S_CHAINING,
|
|
|
|
|
TSG_FS2_CTRL_OPENING,
|
|
|
|
|
TSG_FS2_CTRL_CLOSING,
|
|
|
|
|
TSG_FS2_CTRL_ACTIVE,
|
|
|
|
|
TSG_FS2_CTRL_RESETALL,
|
2023-05-30 17:54:23 +08:00
|
|
|
TSG_FS2_INJECT_CTRL_SUCCESS,
|
|
|
|
|
TSG_FS2_INJECT_CTRL_FAILED,
|
2023-02-09 07:14:55 +00:00
|
|
|
TSG_FS2_EXCLUSION,
|
|
|
|
|
TSG_FS2_APP_DPKT_RESULT,
|
|
|
|
|
TSG_FS2_APP_Q_RESULT,
|
|
|
|
|
TSG_FS2_APP_USER_RESULT,
|
|
|
|
|
TSG_FS2_APP_BUILT_IN_RESULT,
|
|
|
|
|
TSG_FS2_INJECT_PKT_SUCCESS,
|
|
|
|
|
TSG_FS2_INJECT_PKT_FAILED,
|
|
|
|
|
TSG_FS2_MIRRORED_PKT_SUCCESS,
|
|
|
|
|
TSG_FS2_MIRRORED_BYTE_SUCCESS,
|
|
|
|
|
TSG_FS2_MIRRORED_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LABEL_DEL,
|
|
|
|
|
TSG_FS2_MAX
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum DEPLOY_MODE
|
|
|
|
|
{
|
|
|
|
|
DEPLOY_MODE_MIRROR,
|
|
|
|
|
DEPLOY_MODE_INLINE,
|
|
|
|
|
DEPLOY_MODE_TRANSPARENT,
|
|
|
|
|
DEPLOY_MODE_MAX
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#ifndef MIN
|
|
|
|
|
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef PRINTADDR
|
|
|
|
|
#define PRINTADDR(a, b) ((b)<RLOG_LV_FATAL ? printaddr(&(a->addr), a->threadnum) : "")
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef MAX_TSG_ALL_RESULT_NUM
|
2023-03-01 05:09:34 +00:00
|
|
|
#define MAX_TSG_ALL_RESULT_NUM MAX_RESULT_NUM*3
|
2023-02-09 07:14:55 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef MAX_STRING_LEN32
|
|
|
|
|
#define MAX_STRING_LEN32 32
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-02-07 02:51:03 +00:00
|
|
|
struct reset_argv
|
|
|
|
|
{
|
|
|
|
|
int pkt_num;
|
|
|
|
|
int seed1;
|
|
|
|
|
int seed2;
|
|
|
|
|
int th_flags;
|
|
|
|
|
int dir;
|
|
|
|
|
int remedy;
|
|
|
|
|
};
|
|
|
|
|
|
2023-02-09 07:14:55 +00:00
|
|
|
#ifndef MAX_STRING_LEN128
|
|
|
|
|
#define MAX_STRING_LEN128 128
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-04-03 08:30:49 +00:00
|
|
|
struct id2field
|
|
|
|
|
{
|
|
|
|
|
int type;
|
|
|
|
|
int id;
|
|
|
|
|
char name[MAX_STRING_LEN32];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct tsg_rt_para
|
2023-02-07 02:51:03 +00:00
|
|
|
{
|
|
|
|
|
int level;
|
|
|
|
|
short mirror_switch;
|
|
|
|
|
unsigned short timeout;
|
|
|
|
|
int dynamic_maat_switch;
|
|
|
|
|
int device_seq_in_dc;
|
|
|
|
|
int datacenter_id;
|
|
|
|
|
int scan_signaling_switch;
|
|
|
|
|
int hash_timeout;
|
|
|
|
|
int hash_slot_size;
|
|
|
|
|
int hash_thread_safe;
|
|
|
|
|
int feature_tamper;
|
2023-03-01 05:09:34 +00:00
|
|
|
int service_chaining_sid;
|
|
|
|
|
int shaping_sid;
|
2023-05-06 02:23:12 +00:00
|
|
|
int intercept_sid;
|
2023-04-03 08:30:49 +00:00
|
|
|
int send_resetall;
|
2023-02-07 02:51:03 +00:00
|
|
|
enum DEPLOY_MODE deploy_mode;
|
|
|
|
|
int scan_time_interval;
|
|
|
|
|
int identify_app_max_pkt_num;
|
|
|
|
|
int unknown_app_id;
|
2023-04-03 08:30:49 +00:00
|
|
|
int proto_flag; //enum TSG_PROTOCOL
|
2023-02-07 02:51:03 +00:00
|
|
|
int fs2_field_id[TSG_FS2_MAX];
|
2023-02-09 07:14:55 +00:00
|
|
|
char device_sn[MAX_STRING_LEN128];
|
|
|
|
|
char log_path[MAX_STRING_LEN128];
|
|
|
|
|
char device_id_command[MAX_STRING_LEN128];
|
2023-02-07 02:51:03 +00:00
|
|
|
void *logger;
|
|
|
|
|
struct reset_argv reset;
|
|
|
|
|
screen_stat_handle_t fs2_handle;
|
|
|
|
|
struct l7_protocol *name_by_id;
|
|
|
|
|
struct l7_protocol *id_by_name;
|
|
|
|
|
struct traffic_mirror *mirror_handle;
|
|
|
|
|
ctemplate::Template *tpl_403,*tpl_404;
|
|
|
|
|
ctemplate::Template *tpl_200,*tpl_204;
|
|
|
|
|
ctemplate::Template *tpl_303;
|
2023-04-03 08:30:49 +00:00
|
|
|
};
|
2023-02-07 02:51:03 +00:00
|
|
|
|
2023-04-03 08:30:49 +00:00
|
|
|
extern struct tsg_rt_para g_tsg_para;;
|
2023-02-09 07:14:55 +00:00
|
|
|
extern struct id2field g_tsg_proto_name2id[PROTO_MAX];
|
|
|
|
|
|
2023-04-03 08:30:49 +00:00
|
|
|
struct l7_protocol
|
|
|
|
|
{
|
|
|
|
|
int id; /* first key */
|
|
|
|
|
char name[32]; /* second key */
|
|
|
|
|
UT_hash_handle hh1; /* handle for first hash table */
|
|
|
|
|
UT_hash_handle hh2; /* handle for second hash table */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
long long tsg_get_current_time_ms(void);
|
|
|
|
|
|