重构代码目录,改用cmake编译。

This commit is contained in:
zhengchao
2018-09-23 14:30:45 +08:00
parent 9dd63f3dec
commit ef6c330f69
43 changed files with 82 additions and 1004 deletions

5
CMakeLists.txt Normal file
View File

@@ -0,0 +1,5 @@
cmake_minimum_required (VERSION 2.6)
project (maatframe)
add_subdirectory (src)
add_subdirectory (test)
add_subdirectory (tools)

36
src/CMakeLists.txt Normal file
View File

@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 2.6)
project(maatframe)
set(MAAT_FRAME_MAJOR_VERSION 2)
set(MAAT_FRAME_MINOR_VERSION 2)
set(MAAT_FRAME_PATCH_VERSION 20180923)
set(MAAT_FRAME_VERSION ${MAAT_FRAME_MAJOR_VERSION}.${MAAT_FRAME_MINOR_VERSION}.${MAAT_FRAME_PATCH_VERSION})
message(STATUS "Maat Frame, Version: ${MAAT_FRAME_VERSION}")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wall)
add_definitions(-fPIC)
set(MAAT_SRC entry/cJSON.c entry/config_monitor.cpp entry/dynamic_array.cpp entry/gram_index_engine.c entry/interval_index.c entry/json2iris.cpp entry/Maat_api.cpp entry/Maat_command.cpp entry/Maat_rule.cpp entry/Maat_stat.cpp entry/map_str2int.cpp entry/rbtree.c entry/stream_fuzzy_hash.c entry/UniversalBoolMatch.cpp)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../inc/)
include_directories(/opt/MESA/include/MESA/)
# Static Library Output
add_library(maat_frame_static STATIC ${MAAT_SRC})
set_target_properties(maat_frame_static PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(maat_frame_static PROPERTIES OUTPUT_NAME maatframe)
set_target_properties(maat_frame_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
target_include_directories(maat_frame_static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/inc_internal/)
target_include_directories(maat_frame_static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/inc_internal/hiredis)
# Shared Library Output
add_library(maat_frame_shared SHARED ${MAAT_SRC})
set_target_properties(maat_frame_shared PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(maat_frame_shared PROPERTIES OUTPUT_NAME maatframe)
set_target_properties(maat_frame_shared PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(maat_frame_shared PROPERTIES VERSION ${MAAT_FRAME_MAJOR_VERSION}.${MAAT_FRAME_MINOR_VERSION})
set_target_properties(maat_frame_shared PROPERTIES SOVERSION ${MAAT_FRAME_MAJOR_VERSION})
target_include_directories(maat_frame_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/inc_internal/)
target_include_directories(maat_frame_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/inc_internal/hiredis)
target_link_libraries(maat_frame_shared MESA_handle_logger MESA_htable pcre rulescan pthread m pcre MESA_field_stat2 crypto hiredis_vip)

View File

@@ -1226,20 +1226,20 @@ int Maat_scan_proto_addr(Maat_feather_t feather,int table_id
switch(addr->addrtype) switch(addr->addrtype)
{ {
case ADDR_TYPE_IPV4: case ADDR_TYPE_IPV4:
ip_scan_data.ipv4_data.saddr=ntohl(addr->paddr.v4->saddr); ip_scan_data.ipv4_data.saddr=ntohl(addr->v4->saddr);
ip_scan_data.ipv4_data.daddr=ntohl(addr->paddr.v4->daddr); ip_scan_data.ipv4_data.daddr=ntohl(addr->v4->daddr);
ip_scan_data.ipv4_data.sport=ntohs(addr->paddr.v4->source); ip_scan_data.ipv4_data.sport=ntohs(addr->v4->source);
ip_scan_data.ipv4_data.dport=ntohs(addr->paddr.v4->dest); ip_scan_data.ipv4_data.dport=ntohs(addr->v4->dest);
ip_scan_data.ipv4_data.proto=proto; ip_scan_data.ipv4_data.proto=proto;
break; break;
case ADDR_TYPE_IPV6: case ADDR_TYPE_IPV6:
ip_scan_data.rule_type=RULETYPE_IPv6; ip_scan_data.rule_type=RULETYPE_IPv6;
memcpy(ip_scan_data.ipv6_data.saddr,addr->paddr.v6->saddr,sizeof(ip_scan_data.ipv6_data.saddr)); memcpy(ip_scan_data.ipv6_data.saddr,addr->v6->saddr,sizeof(ip_scan_data.ipv6_data.saddr));
ipv6_ntoh(ip_scan_data.ipv6_data.saddr); ipv6_ntoh(ip_scan_data.ipv6_data.saddr);
memcpy(ip_scan_data.ipv6_data.daddr,addr->paddr.v6->daddr,sizeof(ip_scan_data.ipv6_data.daddr)); memcpy(ip_scan_data.ipv6_data.daddr,addr->v6->daddr,sizeof(ip_scan_data.ipv6_data.daddr));
ipv6_ntoh(ip_scan_data.ipv6_data.daddr); ipv6_ntoh(ip_scan_data.ipv6_data.daddr);
ip_scan_data.ipv6_data.sport=ntohs(addr->paddr.v6->source); ip_scan_data.ipv6_data.sport=ntohs(addr->v6->source);
ip_scan_data.ipv6_data.dport=ntohs(addr->paddr.v6->dest); ip_scan_data.ipv6_data.dport=ntohs(addr->v6->dest);
ip_scan_data.ipv6_data.proto=proto; ip_scan_data.ipv6_data.proto=proto;
break; break;
default: default:

View File

@@ -1,40 +0,0 @@
#opt: OPTFLAGS = -O2
#export OPTFLAGS
CC = gcc
CCC = g++
CFLAGS = -Wall -g -fPIC
#GCOV_FLAGS = -fprofile-arcs -ftest-coverage
CFLAGS += $(OPTFLAGS)
#CFLAGS += $(GCOV_FLAGS)
LDDICTATOR = -Wl,-wrap,malloc -Wl,-wrap,calloc -Wl,-wrap,free -Wl,-wrap,realloc
LDFLAGS += -lMESA_handle_logger -lMESA_htable -lpthread -lrt -lm -lrulescan -lpcre -lMESA_field_stat2 -lcrypto -lhiredis_vip
#LDFLAGS += $(LDDICTATOR)
LDFLAGS += $(GCOV_FLAGS)
H_DIR =-I../inc_internal -I../../inc -I/opt/MESA/include/
LIBMAAT = libmaatframe.a
LIBMAAT_SO = libmaatframe.so
OBJS=config_monitor.o Maat_rule.o Maat_api.o Maat_command.o Maat_stat.o UniversalBoolMatch.o dynamic_array.o\
cJSON.o json2iris.o map_str2int.o interval_index.o gram_index_engine.o stream_fuzzy_hash.o rbtree.o
.c.o:
$(CC) -c $(CFLAGS) -I. $(H_DIR) $<
.cpp.o:
$(CCC) -c $(CFLAGS) -I. $(H_DIR) $<
all: $(LIBMAAT) $(LIBMAAT_SO)
$(LIBMAAT_SO): $(OBJS)
$(CCC) -o $(LIBMAAT_SO) -shared $(OBJS) $(LDFLAGS)
cp $(LIBMAAT_SO) ../../lib/
$(LIBMAAT): $(OBJS)
echo making dynamic lib ...
ar cqs $(LIBMAAT) $(OBJS)
cp $(LIBMAAT) ../../lib/
clean:
rm -rf *.o *.gcov *.gcno $(LIBMAAT) *~
opt:
$(MAKE) all

View File

@@ -5,7 +5,7 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>
#include <sfh_internal.h> #include "sfh_internal.h"
#include "stream_fuzzy_hash.h" #include "stream_fuzzy_hash.h"
#include "interval_index.h" #include "interval_index.h"
//#define DEBUG_PRINT //#define DEBUG_PRINT

View File

@@ -1,562 +0,0 @@
#ifndef _APP_STREAM_H_
#define _APP_STREAM_H_
/*************************************************************************************
Update Log:
2014-09-17 LiJia:
(1)<29><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>struct ipaddr<64><EFBFBD><E1B9B9>, <20><><EFBFBD><EFBFBD>ƽ̨<C6BD>ṹstruct layer_addr<64><72><EFBFBD>ڴ<EFBFBD><DAB4>ֲ<EFBFBD><D6B2>ϼ<EFBFBD><CFBC><EFBFBD>;
(2)<29><><EFBFBD><EFBFBD><EFBFBD>½ӿ<C2BD>:
int MESA_kill_tcp_synack(struct streaminfo *stream, const void *raw_pkt);
<09><><EFBFBD><EFBFBD>HMDģʽ<C4A3>µ<EFBFBD>FD.
2014-09-10 LiJia:
(1)<29><><EFBFBD><EFBFBD><EFBFBD>½ӿ<C2BD>:
int MESA_inject_pkt(struct streaminfo *stream, const char *payload,
int payload_len, const void *raw_pkt, UCHAR snd_routedir);
<09><><EFBFBD><EFBFBD>Ӧ<EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><>ԭ<EFBFBD><D4AD>MESA_fakepacket_send_tcp()<29><><EFBFBD><EFBFBD><EFBFBD>˺ܶ<CBBA><DCB6><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>.
**************************************************************************************/
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <stdlib.h>
#include <string.h>
#define USE_MESA_STREAM_HASH (1) /* ʹ<>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3>µ<EFBFBD>HASH<53><48> */
extern int MESA_PLATFORM_VERSION_20140917; /* ƽ̨<C6BD><EFBFBD><E6B1BE> */
#define ADDR_UNSYMMETRY (0) /* 2014-04-25, <20><><EFBFBD>Դ<EFBFBD>XinJing<6E><67><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>, <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>VLAN<41><4E>ַ<EFBFBD><D6B7><EFBFBD>Գ<EFBFBD><D4B3><EFBFBD><EFBFBD><EFBFBD>, <20>˺겻Ӧ<EAB2BB><D3A6><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD> */
#if 0
#define FOR_863 (0) /* for 863<36><33>Ŀ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ǩģ<C7A9><C4A3> */
#define FOR_108 (0)
#define RAW_IP_FRAG_PKT (0) /* 2013-08-21 LiJia add, <20><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>ԭʼIP<49><50>Ƭ<EFBFBD><C6AC> */
#endif
#ifndef UINT8
typedef unsigned char UINT8;
#endif
#ifndef UCHAR
typedef unsigned char UCHAR;
#endif
#ifndef UINT16
typedef unsigned short UINT16;
#endif
#ifndef UINT32
typedef unsigned int UINT32;
#endif
#ifndef UINT64
typedef unsigned long long UINT64;
#endif
//<2F><><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define DIR_C2S 0x01
#define DIR_S2C 0x02
#define DIR_DOUBLE 0x03
//<2F><><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define DIR_ROUTE_UP 0x00
#define DIR_ROUTE_DOWN 0x01
//<2F><>ַ<EFBFBD><D6B7><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>
enum addr_type_t{
__ADDR_TYPE_INIT = 0,
ADDR_TYPE_IPV4, /* 1, <20><><EFBFBD><EFBFBD>IPv4<76><34>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>Ϣ */
ADDR_TYPE_IPV6, /* 2, <20><><EFBFBD><EFBFBD>IPv6<76><36>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>Ϣ */
ADDR_TYPE_VLAN, /* 3 */
ADDR_TYPE_MAC, /* 4 */
ADDR_TYPE_ARP = 5, /* 5 */
ADDR_TYPE_GRE, /* 6 */
ADDR_TYPE_MPLS, /* 7 */
ADDR_TYPE_PPPOE_SES, /* 8 */
ADDR_TYPE_TCP, /* 9 */
ADDR_TYPE_UDP = 10, /* 10 */
ADDR_TYPE_L2TP, /* 11 */
//ADDR_TYPE_STREAM_TUPLE4_V4, /* 12, <20><><EFBFBD>ϵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>IPv4<76><34>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>Ϣ */
//ADDR_TYPE_STREAM_TUPLE4_V6, /* 13, <20><><EFBFBD>ϵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>IPv6<76><36>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>Ϣ */
__ADDR_TYPE_IP_PAIR_V4, /* 14, <20><>IPv4<76><34>ַ<EFBFBD><D6B7> */
__ADDR_TYPE_IP_PAIR_V6, /* 15, <20><>IPv6<76><36>ַ<EFBFBD><D6B7> */
__ADDR_TYPE_MAX, /* 16 */
};
#define TCP_TAKEOVER_STATE_FLAG_OFF 0
#define TCP_TAKEOVER_STATE_FLAG_ON 1
//Ӧ<>ò㿴<C3B2><E3BFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>
#define OP_STATE_PENDING 0
#define OP_STATE_REMOVE_ME 1
#define OP_STATE_CLOSE 2
#define OP_STATE_DATA 3
//Ӧ<>ò㷵<C3B2>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define APP_STATE_GIVEME 0x00
#define APP_STATE_DROPME 0x01
#define APP_STATE_FAWPKT 0x00
#define APP_STATE_DROPPKT 0x10
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>
enum stream_type_t{
STREAM_TYPE_NON = 0, /* <20><><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>, <20><>VLAN, IP<49><50><EFBFBD><EFBFBD> */
STREAM_TYPE_TCP,
STREAM_TYPE_UDP,
STREAM_TYPE_SOCKS4,
STREAM_TYPE_SOCKS5,
STREAM_TYPE_HTTP_PROXY,
STREAM_TYPE_PPPOE,
};
#define PROXY_STATE_SEL 0
#define PROXY_STATE_LINK_IN 1
/* ԭʼ<D4AD><CABC><EFBFBD>ṹ */
typedef struct {
enum addr_type_t low_layer_type; /* ԭʼ<D4AD><CABC><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>MAC(pcap<61><70><EFBFBD><EFBFBD>), Ҳ<><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IPv4(pag<61><67><EFBFBD><EFBFBD>) */
int raw_pkt_len; /* ԭʼ<D4AD><CABC><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD> */
const void *raw_pkt_data; /* ԭʼ<D4AD><CABC>ͷָ<CDB7><D6B8>, <20><><EFBFBD><EFBFBD>low_layer_type<70>ж<EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
struct timeval raw_pkt_ts; /* ԭʼ<D4AD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>ȫΪ0<CEAA><30><EFBFBD><EFBFBD>֧<EFBFBD>ִ˹<D6B4><CBB9><EFBFBD>(<28><>pagģʽ) */
}raw_pkt_t;
// <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
struct proxy_node
{
UINT16 iType; // <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 0 <20><>ʾ<EFBFBD><CABE>Ч
UINT16 uiPort; // <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
UINT16 uiUserLen;
UINT16 uiPwdLen;
UINT16 uiApendLen;
UCHAR opstate; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
UCHAR dealstate; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
UINT32 uiIP; // <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49><50>ַv4, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
UCHAR *pIpv6; // <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49><50>ַ, v6<76><36>ַ
UCHAR *pUser; // <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>
UCHAR *pPwd; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UCHAR *append; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>url
void *apme; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>url
struct proxy_node *pnext;
} ;
typedef struct raw_ipfrag_list{
void *frag_packet;
int pkt_len;
int type; /* IPv4 or IPv6 */
struct raw_ipfrag_list *next;
}raw_ipfrag_list_t;
struct buf_unorder
{
struct buf_unorder *next;
struct buf_unorder *prev;
void *data;
UINT32 len;
UINT32 tcpdatalen;
UINT32 urg_ptr;
char fin;
char urg;
char rst;
unsigned char pad;
UINT32 seq;
UINT32 ack;
raw_ipfrag_list_t *ipfrag_list;
raw_pkt_t raw_pkt; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢ԭʼ<D4AD><CABC> */
};
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>壺*/
struct half_tcpstream
{
UCHAR *data;
UINT32 offset; /*data<74>е<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>TCP<43><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>*/
UINT32 count; /*<2A><><EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊֹ<CEAA><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>*/
UINT32 count_new; /*<2A><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>*/
UINT32 count_ideal; /*<2A><><EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊֹ<CEAA><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>*/
UINT32 pktcout; /*<2A><><EFBFBD><EFBFBD><EFBFBD>ۼƵ<DBBC><C6B5><EFBFBD><EFBFBD>İ<EFBFBD><C4B0><EFBFBD><EFBFBD><EFBFBD>*/
UINT32 totallost; /*<2A><><EFBFBD><EFBFBD><EFBFBD>ۼƶ<DBBC><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
UINT32 seq; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>seq<65><71><EFBFBD><EFBFBD>*/
UINT32 first_data_seq; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ĵ<EFBFBD>seq<65><71><EFBFBD><EFBFBD>*/
UINT32 ack_seq; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>*/
UINT16 window; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>С*/
UCHAR maxunorder; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ*/
UCHAR finstate; /*fin״̬*/
UINT32 pktcout_new; /*<2A><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>İ<EFBFBD><C4B0><EFBFBD><EFBFBD><EFBFBD>*/
UINT32 unorder_cnt;
struct buf_unorder *unorderlist; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
struct buf_unorder *unorderlisttail; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2>ָ<EFBFBD><D6B8>*/
};
/* <20><><EFBFBD><EFBFBD>papp */
struct tuple4 {
u_int saddr;
u_int daddr;
u_short source;
u_short dest;
};
struct tuple6
{
UCHAR saddr[16] ;
UCHAR daddr[16] ;
UINT16 source;
UINT16 dest;
};
/* network-order */
struct stream_tuple4_v4{
UINT32 saddr; /* network order */
UINT32 daddr; /* network order */
UINT16 source; /* network order */
UINT16 dest; /* network order */
};
#ifndef IPV6_ADDR_LEN
#define IPV6_ADDR_LEN (sizeof(struct in6_addr))
#endif
struct stream_tuple4_v6
{
UCHAR saddr[IPV6_ADDR_LEN] ;
UCHAR daddr[IPV6_ADDR_LEN] ;
UINT16 source; /* network order */
UINT16 dest; /* network order */
};
#define GRE_TAG_LEN (4)
struct layer_addr_gre
{
UINT16 gre_id;
};
#define VLAN_ID_MASK (0x0FFF)
#define VLAN_TAG_LEN (4)
struct layer_addr_vlan
{
UINT16 vlan_id; /* network order */
};
struct layer_addr_pppoe_session
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int ver:4;
unsigned int type:4;
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned int type:4;
unsigned int ver:4;
#endif
unsigned char code;
unsigned short session_id;
};
#ifndef MAC_ADDR_LEN
#define MAC_ADDR_LEN (6)
#endif
struct layer_addr_mac
{
UCHAR src_mac[MAC_ADDR_LEN]; /* network order */
UCHAR dst_mac[MAC_ADDR_LEN]; /* network order */
};
struct layer_addr_ipv4
{
UINT32 saddr; /* network order */
UINT32 daddr; /* network order */
/* 2014-04-21 lijia add,
Ϊ<>˿ռ<D5BC><E4A1A2><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD><D4A1><EFBFBD>Ч<EFBFBD><D0A7>, <20><>ǿ<EFBFBD>ư<EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>,
IP<49><50><EFBFBD><EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>Ϣ, TCP<43><50>ֻ<EFBFBD><D6BB>ָ<EFBFBD><D6B8>ָ<EFBFBD><D6B8><EFBFBD>˿<EFBFBD><CBBF>ڴ<EFBFBD>,
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>Ԫ<EFBFBD><D4AA>ʱ, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫget_tuple4()<29><><EFBFBD><EFBFBD>.
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP, <20>˿<EFBFBD><CBBF><EFBFBD>ϢΪ0;
*/
UINT16 source; /* network order */
UINT16 dest; /* network order */
};
struct layer_addr_ipv6
{
UCHAR saddr[IPV6_ADDR_LEN] ; /* network order */
UCHAR daddr[IPV6_ADDR_LEN] ; /* network order */
/* 2014-04-21 lijia add,
Ϊ<>˿ռ<D5BC><E4A1A2><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD><D4A1><EFBFBD>Ч<EFBFBD><D0A7>, <20><>ǿ<EFBFBD>ư<EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>,
IP<49><50><EFBFBD><EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>Ϣ, TCP<43><50>ֻ<EFBFBD><D6BB>ָ<EFBFBD><D6B8>ָ<EFBFBD><D6B8><EFBFBD>˿<EFBFBD><CBBF>ڴ<EFBFBD>,
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>Ԫ<EFBFBD><D4AA>ʱ, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫget_tuple4()<29><><EFBFBD><EFBFBD>.
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP, <20>˿<EFBFBD><CBBF><EFBFBD>ϢΪ0;
*/
UINT16 source;/* network order */
UINT16 dest;/* network order */
};
struct layer_addr_tcp
{
UINT16 source; /* network order */
UINT16 dest; /* network order */
};
struct layer_addr_udp
{
UINT16 source; /* network order */
UINT16 dest; /* network order */
};
struct layer_addr_l2tp
{
UINT32 tunnelid; /* network order */
UINT32 sessionid; /* network order */
};
struct layer_addr
{
UCHAR addrtype; /* <20><>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> enum addr_type_t */
/* Ϊ<>˷<EFBFBD><CBB7><EFBFBD>Ӧ<EFBFBD>ò<EFBFBD><C3B2><EFBFBD>ȡ<EFBFBD><C8A1>ַ, <20>˴<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ʡȥָ<C8A5><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><C7BF>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
union
{
struct stream_tuple4_v4 *tuple4_v4;
struct stream_tuple4_v6 *tuple4_v6;
struct layer_addr_ipv4 *ipv4;
struct layer_addr_ipv6 *ipv6;
struct layer_addr_vlan *vlan;
struct layer_addr_mac *mac;
struct layer_addr_gre *gre;
struct layer_addr_tcp *tcp;
struct layer_addr_udp *udp;
struct layer_addr_pppoe_session *pppoe_ses;
struct layer_addr_l2tp *l2tp;
void *paddr;
};
UCHAR addrlen; /* <20><>ַ<EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD> */
};
/* <20><><EFBFBD><EFBFBD><EFBFBD>˽ṹ<CBBD><E1B9B9><EFBFBD>ں<EFBFBD>papp<70><70><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ʱ, <20><><EFBFBD><EFBFBD>struct layer_addrǿת. */
struct ipaddr
{
UCHAR addrtype;
union
{
struct stream_tuple4_v4 *v4;
struct stream_tuple4_v6 *v6;
}paddr;
// struct tuple4 *paddr;
};
/* to do:
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>, <20><>stream.h<><68><EFBFBD><EFBFBD>, <20>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>stream.h<>IJ<EFBFBD><C4B2><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>ͼ;
*/
struct streaminfo
{
struct layer_addr addr; //<2F><><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>Ϣ
struct streaminfo *pfather;//<2F>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><E1B9B9>
UCHAR type; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UCHAR threadnum; // <20><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
UCHAR dir:2; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч, <20><><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>˫<EFBFBD><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0x01:c-->s; 0x02:s-->c; 0x03 c<-->s; */
UCHAR curdir:2; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч, <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>, 0x01:c-->s; 0x02:s-->c */
UCHAR layer_dir:2; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч, <20><>ǰ<EFBFBD><C7B0><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ĭ<EFBFBD>Ϲ<EFBFBD><CFB9><EFBFBD>"<22><><EFBFBD>˿<EFBFBD><CBBF>ǿͻ<C7BF><CDBB><EFBFBD>"<22><>ͬ */
UCHAR stream_dir:2; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч, <20><><EFBFBD>Ĵ洢<C4B4>ĵ<EFBFBD>ַ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ĭ<EFBFBD>Ϲ<EFBFBD><CFB9><EFBFBD>"<22><><EFBFBD>˿<EFBFBD><CBBF>ǿͻ<C7BF><CDBB><EFBFBD>"<22><>ͬ */
UCHAR dirreverse; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ip<69><70>ַ<EFBFBD><D6B7>ת, <20><><EFBFBD><EFBFBD>"<22><><EFBFBD>˿<EFBFBD><CBBF>ǿͻ<C7BF><CDBB><EFBFBD>"<22><><EFBFBD><EFBFBD><EFBFBD>෴ */
UCHAR opstate; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
UCHAR pktstate; //<2F><><EFBFBD>ӵİ<D3B5><C4B0><EFBFBD><EFBFBD><EFBFBD>
UCHAR routedir; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч, <20><><EFBFBD>˹<EFBFBD>ָ<EFBFBD><D6B8>, <20><><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ͬ, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 0:<3A><><EFBFBD><EFBFBD>; 1:<3A><><EFBFBD><EFBFBD> */
UCHAR addr_use_as_hash; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>addr<64>Ƿ<EFBFBD><C7B7><EFBFBD>ΪHASH<53><48><EFBFBD><EFBFBD><EFBFBD>ͱȽϵIJ<CFB5><C4B2><EFBFBD>, <20><>:MAC<41><43>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
UCHAR stream_killed_flag; /* 2014-08-22 lijia add, <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>, <20>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Kill, ֮<><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>Drop<6F><70>Kill, <20><><EFBFBD><EFBFBD><EFBFBD>ٸ<EFBFBD><D9B8>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD> */
UCHAR __pad__[7]; //<2F><><EFBFBD><EFBFBD>8<EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD>
void *pproject; //ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD>̿<EFBFBD><CCBF><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>ʹ<EFBFBD>ã<EFBFBD>
void *pdetail; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ
const void *p_layer_header; /* ָ<>򱾲<EFBFBD><F2B1BEB2><EFBFBD>ͷ<EFBFBD><CDB7>ָ<EFBFBD><D6B8>, <20><><EFBFBD>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ȡ<EFBFBD><C8A1><EFBFBD>ز<EFBFBD><D8B2><EFBFBD> */
#if 0 //FOR_108, ->pproject
unsigned long stream_id;
#endif
#if 0 //RAW_IP_FRAG_PKT, ->pproject
raw_ipfrag_list_t *ipfrag_list; /* 2013-08-21 LiJia add, ԭʼ<D4AD><CABC>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
#endif
#if 0 //FOR_863, ->pproject
char terminal_tag[40]; /* <20>û<EFBFBD><C3BB><EFBFBD>ǩ */
#endif
};
struct tcpdetail
{
void *pdata; //<2F><><EFBFBD><EFBFBD>
UINT32 datalen; //<2F><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
UINT32 lostlen;
UCHAR multisynflag:4; // multi syn
UCHAR needackflag:2; //<2F><>Ҫ<EFBFBD>ϴ<EFBFBD>ack<63><6B><EFBFBD><EFBFBD>
UCHAR takeoverflag:2;
UCHAR tcpstateflag; // <20><><EFBFBD>ڼ<EFBFBD>¼tcp<63>ĻỰSYN<59><4E><EFBFBD><EFBFBD>״̬
UCHAR link_state; // <20><><EFBFBD>ӵ<EFBFBD>״̬
UCHAR creat_mod;
UINT32 regionid; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
struct half_tcpstream *pclient; //<2F><>client<6E><74>TCP<43><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
struct half_tcpstream *pserver; //<2F><> server<65><72>TCP<43><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
UINT32 serverpkt;
UINT32 clientpkt;
UINT32 servercount;
UINT32 clientcount;
UINT64 creattime;
UINT64 lastmtime;
UINT32 iserverseq; //<2F><><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD>ʱ<EFBFBD><CAB1>ʱ<EFBFBD>洢seq
UINT32 iclientseq; //<2F><><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD>ʱ<EFBFBD><CAB1>ʱ<EFBFBD>洢seq
void *apme; //Ӧ<>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void *pAllpktpme; //<2F><>״̬<D7B4><CCAC>tcp<63><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
struct proxy_node *pproxylist; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><E9B8BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>
};
struct udpdetail
{
void *pdata; //<2F><><EFBFBD><EFBFBD>
UINT32 datalen; //<2F><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
UINT32 regionid; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
UINT32 serverpkt;
UINT32 clientpkt;
UINT32 servercount;
UINT32 clientcount;
UINT64 creattime;
UINT64 lastmtime;
void *apme; //Ӧ<>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
};
//ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD>ʱsession_state״̬
#define SESSION_STATE_PENDING 0x01
#define SESSION_STATE_DATA 0x02
#define SESSION_STATE_CLOSE 0x04
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>ʱ<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>ֵ<EFBFBD><D6B5>
#define PROT_STATE_GIVEME 0x01
#define PROT_STATE_DROPME 0x02
#define PROT_STATE_KILLME 0x04
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
typedef struct _plugin_session_info
{
unsigned short plugid; //plugid<69><64>ƽ̨<C6BD><CCA8><EFBFBD><EFBFBD>
char session_state; //<2F>Ự״̬<D7B4><CCAC>PENDING,DATA,CLOSE
char _pad_; //<2F><><EFBFBD><EFBFBD>
int buflen; //<2F><>ǰ<EFBFBD>ֶγ<D6B6><CEB3><EFBFBD>
long long prot_flag; //<2F><>ǰ<EFBFBD>ֶε<D6B6>flagֵ
void *buf; //<2F><>ǰ<EFBFBD>ֶ<EFBFBD>
void* app_info; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
}stSessionInfo;
#ifdef __cplusplus
extern "C" {
#endif
/*
args:
[IN]:
stream:<3A><><EFBFBD><EFBFBD><E1B9B9>ָ<EFBFBD><D6B8>;
[OUT]
addr_type:<3A><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ADDR_TYPE_IPV4 or ADDR_TYPE_IPV6;
return value:
NULL : error;
NON-NULL : ָ<><D6B8><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>;
*/
struct layer_addr *get_stream_tuple4(struct streaminfo *this_stream);
int get_thread_count(void);
typedef char (*STREAM_CB_FUN_T)(struct streaminfo *pstream,void **pme, int thread_seq,const void *raw_pkt);
typedef char (*IPv4_CB_FUN_T)(struct streaminfo *pstream,unsigned char routedir,int thread_seq, const void *raw_pkt);
typedef char (*IPv6_CB_FUN_T)(struct streaminfo *pstream,unsigned char routedir,int thread_seq, const void *raw_pkt);
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
a_*<2A><> <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
f_*: <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>Ϣ;
raw_pkt: ԭʼ<D4AD><CABC>ָ<EFBFBD><D6B8>, ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ'raw_pkt_t';
pme: ˽<><CBBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD>ʱΪNULL;
thread_seq<65><71><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD>;
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
APP_STATE_GIVEME<4D><45><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򱾺<EFBFBD><F2B1BEBA><EFBFBD><EFBFBD>Ͱ<EFBFBD><CDB0><EFBFBD>
APP_STATE_DROPME<4D><45><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򱾺<EFBFBD><F2B1BEBA><EFBFBD><EFBFBD>Ͱ<EFBFBD><CDB0><EFBFBD>
APP_STATE_FAWPKT<4B><54><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
APP_STATE_DROPPKT<4B><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
*/
char IPv4_ENTRY_EXAMPLE( struct streaminfo *f_stream,unsigned char routedir,int thread_seq, const void *raw_pkt);
char IPv6_ENTRY_EXAMPLE( struct streaminfo *f_stream,unsigned char routedir,int thread_seq,const void *raw_pkt);
char TCP_ENTRY_EXAMPLE(struct streaminfo *a_tcp, void **pme, int thread_seq,const void *raw_pkt);
char UDP_ENTRY_EXAMPLE(struct streaminfo *a_udp, void **pme, int thread_seq,const void *raw_pkt);
int stream_register_tcp_allpkt (STREAM_CB_FUN_T fun);
int stream_register_tcp_takeover (STREAM_CB_FUN_T fun);
int stream_register_tcp (STREAM_CB_FUN_T fun);
int stream_register_udp (STREAM_CB_FUN_T fun);
int stream_register_ip (IPv4_CB_FUN_T fun);
int stream_register_ipv6 (IPv6_CB_FUN_T fun);
void *dictator_malloc(int thread_seq,size_t size);
void dictator_free(int thread_seq,void *pbuf);
void *dictator_realloc(int thread_seq, void* pbuf, size_t size);
char PROT_PROCESS(stSessionInfo* session_info, void **pme, int thread_seq,struct streaminfo *a_stream,void *a_packet);
/* <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ǩ */
//int terminal_tag_probe(struct streaminfo *stream, struct mesa_tcp_hdr *this_tcphdr,void *rawippkt);
const unsigned char *get_terminal_tag(struct streaminfo *stream);
//int MESA_kill_tcp(struct streaminfo *stream, struct ip *a_packet);
int MESA_kill_tcp(struct streaminfo *stream, const void *raw_pkt);
int MESA_kill_tcp_synack(struct streaminfo *stream, const void *raw_pkt);
/*
ARG:
stream: <20><><EFBFBD><EFBFBD><E1B9B9>ָ<EFBFBD><D6B8>;
payload: Ҫ<><D2AA><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>;
payload_len: Ҫ<><D2AA><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8>س<EFBFBD><D8B3><EFBFBD>;
raw_pkt: ԭʼ<D4AD><CABC>ָ<EFBFBD><D6B8>;
snd_routedir: Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵķ<DDB5><C4B7><EFBFBD>, ԭʼ<D4AD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ:stream->routedir ,
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD><CABC>ͬ<EFBFBD><CDAC>, snd_dir = stream->routedir,
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, snd_dir = stream->routedir ^ 3(<28><>1<--->2, 2<--->1<><31><EFBFBD><EFBFBD>ѧת<D1A7><D7AA>);
return value:
-1: error.
>0: <20><><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ݰ<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>(payload_len + <20>ײ<EFBFBD><D7B2><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>);
*/
int MESA_inject_pkt(struct streaminfo *stream, const char *payload, int payload_len, const void *raw_pkt, UCHAR snd_routedir);
/* 2014-07-31 LiJia add, for set one stream unorder number */
int tcp_set_single_stream_max_unorder(struct streaminfo *stream, UCHAR dir, UCHAR unorder_num);
raw_ipfrag_list_t *get_raw_frag_list(struct streaminfo *stream);
//void frags_list_free_one(raw_ipfrag_list_t *frags_list, int);
//raw_ipfrag_list_t *frags_list_merge(raw_ipfrag_list_t *new_merge_list, raw_ipfrag_list_t *old_list);
//raw_ipfrag_list_t *raw_ip_frag_list_attach(int thread_num);
//void raw_ip_frag_list_detach(int thread_num);
unsigned long get_stream_id(struct streaminfo *stream);
void MESA_stream_list_free(struct streaminfo *heap_stream);
struct streaminfo *MESA_stream_list_dup(struct streaminfo *stack_stream, int reverse);
int MESA_stream_list_cmp(struct streaminfo *stream1, struct streaminfo *stream2);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,336 +0,0 @@
#ifndef _APP_STREAM_H_
#define _APP_STREAM_H_
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <stdlib.h>
#include <string.h>
#define FOR_863 (0) /* for 863<36><33>Ŀ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ǩģ<C7A9><C4A3> */
#define FOR_108 (0)
#define RAW_IP_FRAG_PKT (0) /* 2013-08-21 LiJia add, <20><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>ԭʼIP<49><50>Ƭ<EFBFBD><C6AC> */
typedef unsigned char UINT8;
typedef unsigned long long UINT64;
typedef unsigned int UINT32;
typedef unsigned short UINT16;
typedef unsigned char UCHAR;
//<2F><><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define DIR_C2S 0x01
#define DIR_S2C 0x02
#define DIR_DOUBLE 0x03
//<2F><><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define DIR_ROUTE_UP 0x00
#define DIR_ROUTE_DOWN 0x01
//<2F><>ַ<EFBFBD><D6B7><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>
#define ADDR_TYPE_IPV4 1
#define ADDR_TYPE_IPV6 2
#define ADDR_TYPE_VLAN 3
#define TCP_TAKEOVER_STATE_FLAG_OFF 0
#define TCP_TAKEOVER_STATE_FLAG_ON 1
//Ӧ<>ò㿴<C3B2><E3BFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>
#define OP_STATE_PENDING 0
#define OP_STATE_REMOVE_ME 1
#define OP_STATE_CLOSE 2
#define OP_STATE_DATA 3
//Ӧ<>ò㷵<C3B2>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define APP_STATE_GIVEME 0x00
#define APP_STATE_DROPME 0x01
#define APP_STATE_FAWPKT 0x00
#define APP_STATE_DROPPKT 0x10
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>
#define STREAM_TYPE_TCP 1
#define STREAM_TYPE_UDP 2
#define STREAM_TYPE_VLAN 3
#define STREAM_TYPE_SOCKS4 4
#define STREAM_TYPE_SOCKS5 5
#define STREAM_TYPE_HTTP_PROXY 6
#define STREAM_TYPE_MPLS 7
#define PROXY_STATE_SEL 0
#define PROXY_STATE_LINK_IN 1
// <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
struct proxy_node
{
UINT16 iType; // <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 0 <20><>ʾ<EFBFBD><CABE>Ч
UINT16 uiPort; // <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
UINT16 uiUserLen;
UINT16 uiPwdLen;
UINT16 uiApendLen;
UCHAR opstate; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
UCHAR dealstate; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
UINT32 uiIP; // <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49><50>ַv4, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
UCHAR *pIpv6; // <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49><50>ַ, v6<76><36>ַ
UCHAR *pUser; // <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>
UCHAR *pPwd; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UCHAR *append; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>url
void *apme; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>url
struct proxy_node *pnext;
} ;
#if RAW_IP_FRAG_PKT
typedef struct raw_ipfrag_list{
void *frag_packet;
int pkt_len;
int type; /* IPv4 or IPv6 */
struct raw_ipfrag_list *next;
}raw_ipfrag_list_t;
#endif
struct buf_unorder
{
struct buf_unorder *next;
struct buf_unorder *prev;
void *data;
UINT32 len;
UINT32 tcpdatalen;
UINT32 urg_ptr;
char fin;
char urg;
char rst;
unsigned char pad;
UINT32 seq;
UINT32 ack;
#if RAW_IP_FRAG_PKT
raw_ipfrag_list_t *ipfrag_list;
#endif
};
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>壺*/
struct half_tcpstream
{
UCHAR *data;
UINT32 offset; /*data<74>е<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>TCP<43><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>*/
UINT32 count; /*<2A><><EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊֹ<CEAA><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>*/
UINT32 count_new; /*<2A><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>*/
UINT32 count_ideal; /*<2A><><EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊֹ<CEAA><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>*/
UINT32 pktcout; /*<2A><><EFBFBD><EFBFBD><EFBFBD>ۼƵ<DBBC><C6B5><EFBFBD><EFBFBD>İ<EFBFBD><C4B0><EFBFBD><EFBFBD><EFBFBD>*/
UINT32 totallost; /*<2A><><EFBFBD><EFBFBD><EFBFBD>ۼƶ<DBBC><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
UINT32 seq; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>seq<65><71><EFBFBD><EFBFBD>*/
UINT32 first_data_seq; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ĵ<EFBFBD>seq<65><71><EFBFBD><EFBFBD>*/
UINT32 ack_seq; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>*/
UINT16 window; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>С*/
UCHAR maxunorder; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ*/
UCHAR finstate; /*fin״̬*/
UINT32 pktcout_new; /*<2A><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>İ<EFBFBD><C4B0><EFBFBD><EFBFBD><EFBFBD>*/
UINT32 unorder_cnt;
struct buf_unorder *unorderlist; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
struct buf_unorder *unorderlisttail; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2>ָ<EFBFBD><D6B8>*/
};
#ifndef STRUCT_TUPLE4_DEFINED
#define STRUCT_TUPLE4_DEFINED (1)
struct tuple4 {
UINT32 saddr;
UINT32 daddr;
UINT16 source;
UINT16 dest;
};
#endif
struct tuple6
{
UCHAR saddr[16] ;
UCHAR daddr[16] ;
UINT16 source;
UINT16 dest;
};
#define VLAN_ID_LEN 4
struct tuplevlan
{
UCHAR vlan_id[VLAN_ID_LEN];
};
struct tupell2tp
{
UINT32 tunnelid;
UINT32 sessionid;
};
struct ipaddr
{
UCHAR addrtype; //<2F><>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD> ipv6 or ipv4
union
{
struct tuple4 *v4;
struct tuple6 *v6;
}paddr;
// struct tuple4 *paddr;
};
struct streaminfo
{
struct ipaddr addr; //ip<69>˿<EFBFBD><CBBF><EFBFBD>Ϣ
struct streaminfo *pfather;//<2F>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><E1B9B9>
UCHAR type; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UCHAR threadnum; // <20><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
UCHAR dir:2; // <20><><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0x01 c-->s 0x02 s-->c 0x03 c<-->s
UCHAR curdir:2; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>0x01 c-->s 0x02 s-->c
UCHAR dirreverse:4; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ip<69><70>ַ<EFBFBD><D6B7>ת
UCHAR opstate; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
UCHAR pktstate; //<2F><><EFBFBD>ӵİ<D3B5><C4B0><EFBFBD><EFBFBD><EFBFBD>
UCHAR routedir; //<2F><><EFBFBD><EFBFBD>λΪ1<CEAA><31>ʾ<EFBFBD><CABE><EFBFBD>У<EFBFBD>Ϊ0<CEAA><30>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>; <20>ڴ<EFBFBD><DAB4><EFBFBD>ģʽ<C4A3><CABD>,<2C><><37><CEBB>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>豸ID
UCHAR __pad__[2]; //<2F><><EFBFBD><EFBFBD>8<EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD>
void *pproject; //ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD>̿<EFBFBD><CCBF><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>ʹ<EFBFBD>ã<EFBFBD>
void *pdetail; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ
#if FOR_108
unsigned long stream_id;
#endif
#if RAW_IP_FRAG_PKT
raw_ipfrag_list_t *ipfrag_list; /* 2013-08-21 LiJia add, ԭʼ<D4AD><CABC>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
#endif
#if FOR_863
char terminal_tag[40]; /* <20>û<EFBFBD><C3BB><EFBFBD>ǩ */
#endif
};
struct tcpdetail
{
void *pdata; //<2F><><EFBFBD><EFBFBD>
UINT32 datalen; //<2F><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
UINT32 lostlen; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
UCHAR multisynflag:4; // multi syn
UCHAR needackflag:2; //<2F><>Ҫ<EFBFBD>ϴ<EFBFBD>ack<63><6B><EFBFBD><EFBFBD>
UCHAR takeoverflag:2;
UCHAR tcpstateflag; // <20><><EFBFBD>ڼ<EFBFBD>¼tcp<63>ĻỰSYN<59><4E><EFBFBD><EFBFBD>״̬
UCHAR link_state; // <20><><EFBFBD>ӵ<EFBFBD>״̬
UCHAR pad[5];
struct half_tcpstream *pclient; //<2F><>client<6E><74>TCP<43><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
struct half_tcpstream *pserver; //<2F><> server<65><72>TCP<43><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
UINT32 serverpkt;
UINT32 clientpkt;
UINT32 servercount;
UINT32 clientcount;
UINT64 creattime;
UINT64 lastmtime;
UINT32 iserverseq; //<2F><><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD>ʱ<EFBFBD><CAB1>ʱ<EFBFBD>洢seq
UINT32 iclientseq; //<2F><><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD>ʱ<EFBFBD><CAB1>ʱ<EFBFBD>洢seq
void *apme; //Ӧ<>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void *pAllpktpme; //<2F><>״̬<D7B4><CCAC>tcp<63><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
struct proxy_node *pproxylist; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><E9B8BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>
};
struct udpdetail
{
void *pdata; //<2F><><EFBFBD><EFBFBD>
UINT32 datalen; //<2F><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
UINT32 pad;
UINT32 serverpkt;
UINT32 clientpkt;
UINT32 servercount;
UINT32 clientcount;
UINT64 creattime;
UINT64 lastmtime;
void *apme; //Ӧ<>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
};
//ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD>ʱsession_state״̬
#define SESSION_STATE_PENDING 0x01
#define SESSION_STATE_DATA 0x02
#define SESSION_STATE_CLOSE 0x04
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>ʱ<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>ֵ<EFBFBD><D6B5>
#define PROT_STATE_GIVEME 0x01
#define PROT_STATE_DROPME 0x02
#define PROT_STATE_KILLME 0x04
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
typedef struct _plugin_session_info
{
unsigned short plugid; //plugid<69><64>ƽ̨<C6BD><CCA8><EFBFBD><EFBFBD>
char session_state; //<2F>Ự״̬<D7B4><CCAC>PENDING,DATA,CLOSE
char _pad_; //<2F><><EFBFBD><EFBFBD>
int buflen; //<2F><>ǰ<EFBFBD>ֶγ<D6B6><CEB3><EFBFBD>
long long prot_flag; //<2F><>ǰ<EFBFBD>ֶε<D6B6>flagֵ
void *buf; //<2F><>ǰ<EFBFBD>ֶ<EFBFBD>
void* app_info; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
}stSessionInfo;
#ifdef __cplusplus
extern "C" {
#endif
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
a_*<2A><> <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>
f_*: <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>
a_packet: ԭʼip<69><70><EFBFBD><EFBFBD>
pme: ˽<><CBBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD>ʱΪNULL
thread_seq<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD>߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
APP_STATE_GIVEME<4D><45><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򱾺<EFBFBD><F2B1BEBA><EFBFBD><EFBFBD>Ͱ<EFBFBD><CDB0><EFBFBD>
APP_STATE_DROPME<4D><45><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򱾺<EFBFBD><F2B1BEBA><EFBFBD><EFBFBD>Ͱ<EFBFBD><CDB0><EFBFBD>
APP_STATE_FAWPKT<4B><54><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
APP_STATE_DROPPKT<4B><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
*/
char IP_ENTRY( struct streaminfo *f_stream,unsigned char routedir,int thread_seq,struct ip * a_packet);
char IPv6_ENTRY( struct streaminfo *f_stream,unsigned char routedir,int thread_seq,struct ip6_hdr *a_packet);
char TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a_packet);
char UDP_ENTRY(struct streaminfo *a_udp, void **pme, int thread_seq,void *a_packet);
int stream_register_tcp_allpkt (char (*x)(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet));
int stream_register_tcp_takeover (char (*x)(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet));
int stream_register_tcp (char (*x)(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet));
int stream_register_udp (char (*x)(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet));
//int stream_register_ip (char (*x)(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet));
int stream_register_ip (char (*x)(struct streaminfo *f_stream,unsigned char routedir,int thread_seq,struct ip * a_packet));
int stream_register_ipv6 (char (*x)(struct streaminfo *f_stream,unsigned char routedir,int thread_seq,struct ip6_hdr *a_packet));
char * printaddr (struct ipaddr *paddrinfo,int threadindex);
void *dictator_malloc(int thread_seq,int size);
void dictator_free(int thread_seq,void *pbuf);
char PROT_PROCESS(stSessionInfo* session_info, void **pme, int thread_seq,struct streaminfo *a_stream,void *a_packet);
/* <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ǩ */
int terminal_tag_probe(struct streaminfo *stream, struct tcphdr *this_tcphdr,void *rawippkt);
const unsigned char *get_terminal_tag(struct streaminfo *stream);
int MESA_kill_tcp(struct streaminfo *stream, struct ip *a_packet);
#if RAW_IP_FRAG_PKT
extern raw_ipfrag_list_t **G_IP_FRAG_LIST;
void frags_list_free(raw_ipfrag_list_t *frags_list);
raw_ipfrag_list_t *frags_list_merge(raw_ipfrag_list_t *new_merge_list, raw_ipfrag_list_t *old_list);
#endif
#if FOR_108
unsigned long papp_get_streamid();
#endif
#ifdef __cplusplus
}
#endif
#endif

16
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,16 @@
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wall)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../inc/)
include_directories(/opt/MESA/include/MESA/)
add_executable(maat_test maat_test.cpp)
target_link_libraries(maat_test maat_frame_shared)
#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/maat_json.json ${CMAKE_CURRENT_SOURCE_DIR}/maat_json.json COPYONLY)
configure_file(table_info.conf table_info.conf COPYONLY)
configure_file(maat_json.json maat_json.json COPYONLY)
configure_file(reset_redis4maat.sh reset_redis4maat.sh COPYONLY)
file(COPY conf DESTINATION ./)
file(COPY rule DESTINATION ./)
file(COPY testdata DESTINATION ./)
file(COPY testdata_uni2ascii DESTINATION ./)

View File

@@ -1,6 +0,0 @@
LIBS=../lib/libmaatframe.so
INC=-I../inc/ -I/usr/include/MESA/
all:
g++ -o maat_test -g -Wall maat_test.cpp $(INC) $(LIBS) -lMESA_handle_logger
clean:
rm maat_test test.log* -f

View File

@@ -1,5 +0,0 @@
0000000004
123 1 1 1 1 0 anything 1
124 1 1 1 1 0 anything 1
125 1 1 1 1 0 anything 1
126 1 1 1 1 0 anything 1

View File

@@ -1,3 +0,0 @@
0000000002
3 2 100 500 1
6 5 2014 2016 1

View File

@@ -1,8 +0,0 @@
0000000007
0 123 1
1 123 1
0 124 1
2 124 1
3 125 1
4 126 1
5 126 1

View File

@@ -1,4 +0,0 @@
0000000003
2 1 abckkk&123 1 0 0 1
4 3 action=search\&query=(.*) 2 0 0 1
5 4 should_not_hit_any_rule 0 0 0 1

View File

@@ -1,3 +0,0 @@
0000000002
0 0 4 10.0.6.201 255.255.0.0 0 65535 0.0.0.0 255.255.255.255 0 65535 6 0 1
1 0 4 192.168.0.1 255.255.255.255 0 65535 0.0.0.0 255.255.255.255 0 65535 6 0 1

View File

@@ -1,4 +0,0 @@
0000000003
1 192.168.0.1 101
2 192.168.0.2 101
3 192.168.1.1 102

View File

@@ -1,4 +0,0 @@
0000000003
1 3388 99 1
2 3355 66 1
3 cccc 11 1

View File

@@ -1,4 +0,0 @@
0000000003
1 plugname1 1
2 plugname2 1
3 plugname3 1

View File

@@ -1 +0,0 @@
0000000000

View File

@@ -1,7 +0,0 @@
COMPILE 4 ./maat_json.json_iris_tmp/COMPILE.local
GROUP 7 ./maat_json.json_iris_tmp/GROUP.local
TEST_PLUGIN_TABLE 3 ./maat_json.json_iris_tmp/TEST_PLUGIN_TABLE.local
IP_CONFIG 2 ./maat_json.json_iris_tmp/IP_CONFIG.local
CONTENT_SIZE 2 ./maat_json.json_iris_tmp/CONTENT_SIZE.local
HTTP_URL 3 ./maat_json.json_iris_tmp/HTTP_URL.local
QD_ENTRY_INFO 3 ./maat_json.json_iris_tmp/QD_ENTRY_INFO.local

16
tools/CMakeLists.txt Normal file
View File

@@ -0,0 +1,16 @@
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wall)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../inc/)
include_directories(/opt/MESA/include/MESA/)
add_executable(digest_gen digest_gen.c)
add_dependencies(digest_gen maat_frame_shared)
target_link_libraries(digest_gen maat_frame_shared)
add_executable(maat_redis_tool maat_redis_tool.cpp)
add_dependencies(maat_redis_tool maat_frame_shared)
target_link_libraries(maat_redis_tool maat_frame_shared)
target_include_directories(maat_redis_tool PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src/inc_internal/)
target_include_directories(maat_redis_tool PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src/inc_internal/hiredis)

View File

@@ -1,8 +0,0 @@
LIBS= -lmaatframe -lhiredis_vip
INC=-I../inc/ -I ../src/entry/ -I../src/inc_internal/ -I/usr/include/MESA/
all:
g++ -o maat_redis_tool.o -c -g -Wall maat_redis_tool.cpp $(INC)
g++ -o maat_redis_tool maat_redis_tool.o $(LIBS)
g++ -o digest_gen -g digest_gen.c $(INC) $(LIBS)
clean:
rm *.o