diff --git a/inc/tsg_rule.h b/inc/tsg_rule.h index b1c25a6..1fa9eba 100644 --- a/inc/tsg_rule.h +++ b/inc/tsg_rule.h @@ -24,16 +24,11 @@ typedef enum _PULL_RESULT_TYPE PULL_FW_RESULT }PULL_RESULT_TYPE; -enum tsg_protocol{ - TSG_PROTOCOL_UNKNOWN = 0, - TSG_PROTOCOL_SSL, - TSG_PROTOCOL_HTTP -}; #define TSG_DOMAIN_MAX 256 extern Maat_feather_t g_tsg_maat_feather; -int tsg_rule_init(const char *conffile); +int tsg_rule_init(const char *conffile, void *logger); int tsg_scan_nesting_addr(Maat_feather_t maat_feather, const struct streaminfo *a_stream, tsg_protocol_t proto, scan_status_t *mid, Maat_rule_t*result, int result_num); diff --git a/inc/tsg_send_log.h b/inc/tsg_send_log.h index 559df98..6758046 100644 --- a/inc/tsg_send_log.h +++ b/inc/tsg_send_log.h @@ -8,14 +8,6 @@ extern "C" { #endif - -struct _opt_unit_t -{ - int opt_type; - int opt_len; - char *opt_value; -}; - typedef struct _tsg_log { int result_num; @@ -23,9 +15,24 @@ typedef struct _tsg_log struct streaminfo *a_stream; }tsg_log_t; +typedef enum _tld_type +{ + TLD_TYPE_LONG=1, + TLD_TYPE_STRING, + TLD_TYPE_FILE +}TLD_TYPE; -int tsg_sendlog_init(char *filename); -void tsg_send_log(const tsg_log_t* log_msg, struct _opt_unit_t* log_opt, int opt_num, int thread_id); + +typedef void* TLD_handle_t; +typedef void* tsg_log_instance_t; + +extern tsg_log_instance_t g_tsg_log_instance; + +TLD_handle_t TLD_create(int thread_id); +int TLD_append(TLD_handle_t handle, char *key, void *value, TLD_TYPE type); +int TLD_cancel(TLD_handle_t handle); + +int tsg_send_log(tsg_log_instance_t instance, TLD_handle_t handle, tsg_log_t *log_msg, int thread_id); #ifdef __cplusplus diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2d19c2b..dd58965 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8) add_definitions(-fPIC) -set(SRC tsg_entry.cpp tsg_rule.cpp ssl_utils.cpp tsg_send_log.cpp) +set(SRC tsg_entry.cpp tsg_rule.cpp tsg_ssl_utils.cpp tsg_send_log.cpp) include_directories(${CMAKE_SOURCE_DIR}/inc) include_directories(/opt/MESA/include/MESA/) diff --git a/src/tsg_rule.cpp b/src/tsg_rule.cpp index cbe4876..d50fdfe 100644 --- a/src/tsg_rule.cpp +++ b/src/tsg_rule.cpp @@ -2,7 +2,7 @@ #include "MESA/MESA_handle_logger.h" #include "Maat_rule.h" #include "Maat_command.h" -#include "ssl_utils.h" +#include "tsg_ssl_utils.h" #include "tsg_rule.h" enum kni_scan_table{ @@ -16,7 +16,7 @@ const char *g_kni_scan_table_name[SCAN_TABLE_MAX]; int g_kni_scan_tableid[SCAN_TABLE_MAX] = {0}; static void protocol_identify(char *buff, int buff_len, struct _identify_info *result){ - result->protocol = -1; + result->proto = PROTO_MAX; //TODO: http: get from http protocol plugin /* if(is_http){ @@ -29,7 +29,7 @@ static void protocol_identify(char *buff, int buff_len, struct _identify_info *r struct ssl_chello *chello = NULL; chello = ssl_chello_parse((const unsigned char*)buff, buff_len, &chello_status); if(chello_status == CHELLO_PARSE_SUCCESS){ - result->protocol = PROTO_SSL; + result->proto = PROTO_SSL; if(chello->sni == NULL){ result->domain_len = 0; } @@ -66,11 +66,11 @@ int tsg_scan_shared_policy(Maat_feather_t maat_feather, void *pkt, int pkt_len, struct _identify_info *identify_info, scan_status_t *mid, void *logger, int thread_seq){ memset(identify_info, 0, sizeof(*identify_info)); protocol_identify((char*)pkt, pkt_len, identify_info); - if(identify_info->protocol != TSG_PROTOCOL_SSL && identify_info->protocol != TSG_PROTOCOL_HTTP){ + if(identify_info->proto != PROTO_SSL && identify_info->proto != PROTO_HTTP){ return -1; } int tableid; - if(identify_info->protocol == TSG_PROTOCOL_SSL){ + if(identify_info->proto == PROTO_SSL){ tableid = g_kni_scan_tableid[TSG_FIELD_SSL_SNI]; } else{ diff --git a/src/tsg_ssl_utils.cpp b/src/tsg_ssl_utils.cpp index fa297b5..5aed2a9 100644 --- a/src/tsg_ssl_utils.cpp +++ b/src/tsg_ssl_utils.cpp @@ -2,7 +2,7 @@ #include #include #include -#include "ssl_utils.h" +#include "tsg_ssl_utils.h" #define ALLOC(type, number) ((type *)calloc(sizeof(type), number)) #define FREE(p) {free(*p);*p=NULL;}