2023-04-03 08:30:49 +00:00
|
|
|
#pragma once
|
2019-11-12 13:35:19 +08:00
|
|
|
|
2020-08-19 16:56:10 +08:00
|
|
|
#include "tsg_label.h"
|
|
|
|
|
|
2020-01-07 13:04:00 +08:00
|
|
|
#define TSG_ACTION_NONE 0x00
|
|
|
|
|
#define TSG_ACTION_MONITOR 0x01
|
|
|
|
|
#define TSG_ACTION_INTERCEPT 0x02
|
2023-05-06 02:23:12 +00:00
|
|
|
#define TSG_ACTION_NO_INTERCEPT 0x03
|
2020-01-07 13:04:00 +08:00
|
|
|
#define TSG_ACTION_DENY 0x10
|
2023-02-07 02:51:03 +00:00
|
|
|
#define TSG_ACTION_SHAPING 0x20
|
2020-01-07 13:04:00 +08:00
|
|
|
#define TSG_ACTION_MANIPULATE 0x30
|
2023-03-01 05:09:34 +00:00
|
|
|
#define TSG_ACTION_S_CHAINING 0x40
|
2023-04-03 08:30:49 +00:00
|
|
|
#define TSG_ACTION_BYPASS 0x60
|
|
|
|
|
#define TSG_ACTION_SHUNT 0x80
|
2023-08-06 10:45:19 +00:00
|
|
|
#define TSG_ACTION_STATISTICS 0x81
|
|
|
|
|
#define TSG_ACTION_MAX 0x81
|
2020-01-07 13:04:00 +08:00
|
|
|
|
2023-04-03 08:30:49 +00:00
|
|
|
enum TSG_SERVICE
|
|
|
|
|
{
|
|
|
|
|
TSG_SERVICE_SECURITY=2,
|
|
|
|
|
TSG_SERVICE_INTERCEPT=3,
|
|
|
|
|
TSG_SERVICE_CHAINING=5,
|
|
|
|
|
TSG_SERVICE_SHAPING=6,
|
|
|
|
|
TSG_SERVICE_PRE_SIGNATURE=7,
|
|
|
|
|
TSG_SERVICE_SIGNATURE=8,
|
2023-08-06 10:45:19 +00:00
|
|
|
TSG_SERVICE_STATISTICS=10,
|
2023-04-03 08:30:49 +00:00
|
|
|
TSG_SERVICE_MAX
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-02 10:39:33 +08:00
|
|
|
enum TSG_METHOD_TYPE
|
2019-12-20 11:15:29 +08:00
|
|
|
{
|
|
|
|
|
TSG_METHOD_TYPE_UNKNOWN=0,
|
|
|
|
|
TSG_METHOD_TYPE_DROP,
|
|
|
|
|
TSG_METHOD_TYPE_REDIRECTION,
|
|
|
|
|
TSG_METHOD_TYPE_BLOCK,
|
|
|
|
|
TSG_METHOD_TYPE_RESET,
|
2021-12-06 11:37:05 +03:00
|
|
|
TSG_METHOD_TYPE_RST,
|
2020-04-16 13:03:56 +08:00
|
|
|
TSG_METHOD_TYPE_ALERT,
|
2021-08-27 19:33:54 +08:00
|
|
|
TSG_METHOD_TYPE_RATE_LIMIT,
|
2021-08-04 02:08:30 +00:00
|
|
|
TSG_METHOD_TYPE_MIRRORED,
|
2023-04-03 08:30:49 +00:00
|
|
|
TSG_METHOD_TYPE_TAMPER,
|
|
|
|
|
TSG_METHOD_TYPE_DEFAULT,
|
|
|
|
|
TSG_METHOD_TYPE_APP_DROP,
|
|
|
|
|
TSG_METHOD_TYPE_ALLOW,
|
|
|
|
|
TSG_METHOD_TYPE_SHUNT,
|
2019-12-20 11:15:29 +08:00
|
|
|
TSG_METHOD_TYPE_MAX
|
|
|
|
|
};
|
|
|
|
|
|
2021-08-01 10:48:19 +00:00
|
|
|
enum ACTION_RETURN_TYPE
|
|
|
|
|
{
|
|
|
|
|
ACTION_RETURN_TYPE_PROT=0,
|
2022-12-23 11:54:29 +08:00
|
|
|
ACTION_RETURN_TYPE_APP,
|
|
|
|
|
ACTION_RETURN_TYPE_TCPALL
|
2021-08-01 10:48:19 +00:00
|
|
|
};
|
|
|
|
|
|
2023-04-03 08:30:49 +00:00
|
|
|
extern struct maat *g_tsg_maat_feather;
|
2019-12-20 11:15:29 +08:00
|
|
|
|
2023-04-03 08:30:49 +00:00
|
|
|
struct maat_rule
|
|
|
|
|
{
|
|
|
|
|
long long rule_id;
|
|
|
|
|
unsigned char action;
|
|
|
|
|
unsigned char service_id;
|
|
|
|
|
unsigned char do_log;
|
2023-04-28 06:03:16 +00:00
|
|
|
unsigned char padding;
|
|
|
|
|
int vsys_id;
|
2023-04-03 08:30:49 +00:00
|
|
|
};
|
2021-08-01 10:48:19 +00:00
|
|
|
|
2023-04-03 08:30:49 +00:00
|
|
|
struct matched_policy_rules
|
|
|
|
|
{
|
|
|
|
|
size_t n_rules;
|
|
|
|
|
struct maat_rule rules[MAX_RESULT_NUM];
|
|
|
|
|
};
|
2021-08-07 17:27:55 +08:00
|
|
|
|
2023-04-28 10:17:10 +08:00
|
|
|
int session_packet_capture_by_rules_notify(const struct streaminfo * a_stream, struct maat_rule * rules, size_t n_rules, int thread_seq);
|
2023-04-03 08:30:49 +00:00
|
|
|
void session_matched_rules_notify(const struct streaminfo *a_stream, TSG_SERVICE service, struct maat_rule *rules, size_t n_rules, int thread_seq);
|
|
|
|
|
size_t tsg_matched_rules_select(struct maat *feather, TSG_SERVICE service, long long *matched_rules, size_t n_matched_rules, struct maat_rule *rules, size_t n_rules);
|
|
|
|
|
size_t tsg_scan_nesting_addr(const struct streaminfo *a_stream, struct maat *feather, enum TSG_PROTOCOL proto, struct maat_state *s_mid, struct maat_rule *rules, size_t n_rules);
|
|
|
|
|
size_t session_matched_rules_copy(const struct streaminfo *a_stream, enum TSG_SERVICE service, struct maat_rule *rules, size_t n_rules);
|
2023-05-06 02:23:12 +00:00
|
|
|
size_t tsg_select_rules_by_service_id(struct maat_rule *matched_rules, size_t n_matched_rules, struct maat_rule *rules, size_t n_rules, enum TSG_SERVICE service_id);
|
2023-05-27 09:37:46 +00:00
|
|
|
size_t tsg_select_rules_by_action(struct maat_rule *matched_rules, size_t n_matched_rules, struct maat_rule *rules, size_t n_rules, unsigned char action);
|
|
|
|
|
|
2023-04-03 08:30:49 +00:00
|
|
|
int tsg_get_fqdn_category_ids(struct maat *feather, char *fqdn, unsigned int *category_ids, int n_category_ids);
|
2021-08-07 17:27:55 +08:00
|
|
|
|
2023-04-03 08:30:49 +00:00
|
|
|
unsigned char tsg_enforing_deny(const struct streaminfo *a_stream, struct maat_rule *p_result, enum TSG_PROTOCOL protocol, enum ACTION_RETURN_TYPE type, const void *user_data);
|
2020-09-28 17:13:39 +08:00
|
|
|
|