summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author杨威 <[email protected]>2023-06-20 16:01:35 +0800
committer杨威 <[email protected]>2023-06-26 20:18:26 +0800
commit096bbda71ea301fe6dbdc603b5cbf06bfc0d73ed (patch)
tree7009752d8a71c4f7f4aafcce6263464d5277be80
parentacc0ee76193f032c64dca379acad9c7256d6e13f (diff)
🦄 refactor(Remove obsolete code): makefile and dictator
-rw-r--r--CMakeLists.txt29
-rw-r--r--benchmark/example/Makefile16
-rw-r--r--benchmark/sapp_default_config/etc/sapp.toml3
-rw-r--r--bin/etc/sapp.toml2
-rw-r--r--bin/memchk.sh1
-rw-r--r--bin/memchk.sh.full1
-rw-r--r--bin/memchk.sh.quick1
-rw-r--r--include/private/dictator.h32
-rw-r--r--include/private/sapp_declaration.h1
-rw-r--r--include/private/sapp_global_val.h5
-rw-r--r--include/private/sapp_mem.h2
-rw-r--r--include/private/sapp_private_api.h1
-rw-r--r--include/support/dictator.h30
-rw-r--r--module_test/src/Makefile21
-rw-r--r--module_test/test_case/Makefile16
-rw-r--r--src/Makefile345
-rw-r--r--src/common/Makefile52
-rw-r--r--src/common/sapp_mem.c36
-rw-r--r--src/config/Makefile52
-rw-r--r--src/config/config_parse.cpp2
-rw-r--r--src/dealpkt/Makefile111
-rw-r--r--src/dealpkt/deal_tcp.c36
-rw-r--r--src/dealpkt/plug_support.c41
-rw-r--r--src/entry/CMakeLists.txt10
-rw-r--r--src/entry/Makefile117
-rw-r--r--src/extensions/CMakeLists.txt15
-rw-r--r--src/extensions/Makefile150
-rw-r--r--src/extensions/sapp_assistant.cpp432
-rw-r--r--src/extensions/sapp_metrics.cpp433
-rw-r--r--src/packet_io/CMakeLists.txt26
-rw-r--r--src/packet_io/Makefile195
-rw-r--r--src/plugin/Makefile8
-rw-r--r--src/plugin/src/Makefile40
-rw-r--r--src/project/Makefile41
-rw-r--r--src/project/project_requirement.c26
-rw-r--r--src/project/terminal_tag.c391
-rw-r--r--src/project/terminal_tag.h61
-rw-r--r--src/readme_GBK.txt748
-rw-r--r--src/readme_UTF8.txt748
-rw-r--r--src/sapp_dev/sapp_global_val.c3
-rw-r--r--src/sapp_dev/sapp_init.c27
-rw-r--r--src/support/CMakeLists.txt1
-rw-r--r--src/support/MESA_sleep/Makefile22
-rw-r--r--src/support/MESA_socket_wrap/Makefile9
-rw-r--r--src/support/MESA_socket_wrap/example/Makefile28
-rw-r--r--src/support/MESA_socket_wrap/src/Makefile26
-rw-r--r--src/support/dictator2/lib/.gitignore6
-rw-r--r--src/support/dictator2/readme.txt4
-rw-r--r--src/support/dictator2/src/CMakeLists.txt19
-rw-r--r--src/support/dictator2/src/D_internal/D_kernel_list.cpp88
-rw-r--r--src/support/dictator2/src/D_internal/D_kernel_list.h39
-rw-r--r--src/support/dictator2/src/D_internal/MESA_hash_v2.cpp655
-rw-r--r--src/support/dictator2/src/D_internal/MESA_hash_v2.h262
-rw-r--r--src/support/dictator2/src/D_internal/MESA_list_v2.cpp361
-rw-r--r--src/support/dictator2/src/D_internal/MESA_list_v2.h43
-rw-r--r--src/support/dictator2/src/D_internal/Makefile20
-rw-r--r--src/support/dictator2/src/D_internal/list_common.cpp155
-rw-r--r--src/support/dictator2/src/D_internal/list_common.h18
-rw-r--r--src/support/dictator2/src/D_internal/readme.txt4
-rw-r--r--src/support/dictator2/src/Makefile7
-rw-r--r--src/support/dictator2/src/Makefile_debug43
-rw-r--r--src/support/dictator2/src/Makefile_nodebug44
-rw-r--r--src/support/dictator2/src/dictator.cpp866
-rw-r--r--src/support/dictator2/src/dictator.h30
-rw-r--r--src/support/dictator2/src/dictator_core.h191
-rw-r--r--src/support/dictator2/src/dictator_debuger.cpp816
-rw-r--r--src/support/dictator2/src/dummy_hash.h67
-rw-r--r--src/support/dictator2/src/internal_mp.h11
-rw-r--r--src/support/dictator2/src/mr_hugepage.h20
-rw-r--r--src/support/dictator2/test/Makefile4
-rw-r--r--src/support/dictator2/test/test.cpp90
-rw-r--r--src/support/md5/Makefile13
-rw-r--r--src/support/symbol_check/Makefile24
-rw-r--r--src/support/timestamp_record/Makefile19
-rw-r--r--src/support/tomlc99_wrap/Makefile49
-rw-r--r--src/timer/Makefile52
-rw-r--r--test/CMakeLists.txt2
-rw-r--r--test/MESA_path_trace/Makefile28
-rw-r--r--test/Makefile75
-rw-r--r--test/Makefile_kill24
-rw-r--r--test/Makefile_proxy25
-rw-r--r--test/dpdk_ip_hash/Makefile7
-rw-r--r--test/terminal_tag.c398
-rw-r--r--test/terminal_tag.h61
-rw-r--r--tools/tun_transparent/Makefile13
-rw-r--r--tools/tun_transparent/Makefile.user39
86 files changed, 452 insertions, 8633 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dd9f916..d778ab7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -124,16 +124,12 @@ endif()
# Memory Allocator
set(MEM_POOL "JEMALLOC" CACHE STRING
- " set mem alloc chosen by the user, using DICTATOR as default")
-set_property(CACHE MEM_POOL PROPERTY STRINGS OFF DICTATOR DICTATOR_DEBUG
+ " set mem alloc chosen by the user, using JEMALLOC as default")
+set_property(CACHE MEM_POOL PROPERTY STRINGS OFF
TCMALLOC TCMALLOC_MINI JEMALLOC)
message(STATUS "MEM_POOL='${MEM_POOL}'")
-if(MEM_POOL MATCHES "DICTATOR_DEBUG")
- set(MEM_POOL_DEFINITIONS ${MEM_POOL_DEFINITIONS} -DDICTATOR_DEBUG -DUSE_MEMPOOL=1)
-elseif(MEM_POOL MATCHES "DICTATOR")
- set(MEM_POOL_DEFINITIONS ${MEM_POOL_DEFINITIONS} -DUSE_MEMPOOL=1)
-elseif(MEM_POOL MATCHES "TCMALLOC_MINI")
+if(MEM_POOL MATCHES "TCMALLOC_MINI")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ltcmalloc_minimal -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free")
elseif(MEM_POOL MATCHES "TCMALLOC")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ltcmalloc -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free")
@@ -141,8 +137,6 @@ elseif(MEM_POOL MATCHES "JEMALLOC")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ljemalloc -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free")
endif()
-set(ENABLE_STATIC_LINK ON)
-
# 定义宏 LIBEVENT_ENABLED
option(LIBEVENT_ENABLED "Enable libevent" OFF)
if(LIBEVENT_ENABLED STREQUAL "ON")
@@ -241,23 +235,6 @@ install(FILES bin/etc/necessary_plug_list.conf DESTINATION etc COMPONENT PROFILE
install(FILES bin/etc/well_known_port.conf DESTINATION etc COMPONENT PROFILE)
install(FILES bin/etc/vxlan_sport_service_map.conf DESTINATION etc COMPONENT PROFILE)
-if(ENABLE_STATIC_LINK STREQUAL "OFF")
-
-if(CAPTURE_MODE MATCHES "MARSIO")
- install(FILES ${CMAKE_BINARY_DIR}/src/packet_io/packet_io_marsio.so DESTINATION platform_lib COMPONENT LIBRARY)
-endif()
-
-if(CAPTURE_MODE MATCHES "PCAP")
- install(FILES ${CMAKE_BINARY_DIR}/src/packet_io/packet_io_pcap.so DESTINATION platform_lib COMPONENT LIBRARY)
-endif()
-
-if(CAPTURE_MODE MATCHES "TUN")
- install(FILES ${CMAKE_BINARY_DIR}/src/packet_io/packet_io_tun.so DESTINATION platform_lib COMPONENT LIBRARY)
-endif()
-
-endif()
-
-#install(FILES bin/plug/protocol/conflist_protocol.inf DESTINATION plug/protocol COMPONENT PROFILE)
install(FILES bin/plug/protocol/isakmp_protocol_plug/isakmp_protocol_plug.inf DESTINATION plug/protocol/isakmp_protocol_plug COMPONENT PROFILE)
install(FILES ${CMAKE_BINARY_DIR}/src/extensions/isakmp_protocol_plug.so DESTINATION plug/protocol/isakmp_protocol_plug COMPONENT LIBRARY)
diff --git a/benchmark/example/Makefile b/benchmark/example/Makefile
deleted file mode 100644
index ab1a42f..0000000
--- a/benchmark/example/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-INC=-I/opt/MESA/include
-INC+=-I/opt/MESA/include/MESA
-INC+=-I/opt/MESA/include/MESA/stream_inc
-
-
-LIBS=-L/opt/MESA/lib
-LIBS+=-lgtest -lMESA_handle_logger -lpthread -lsapp_benchmark
-
-all:test_sapp_benchmark_gtest
-
-test_sapp_benchmark_gtest:test_sapp_benchmark_gtest_main.cpp
- ./auto_gen_gtest_functions.sh
- g++ -o $@ $^ auto_gen_gtest_functions.cpp -g -std=c++11 $(INC) $(LIBS)
-
-clean:
- rm -f test_sapp_benchmark_gtest *.o
diff --git a/benchmark/sapp_default_config/etc/sapp.toml b/benchmark/sapp_default_config/etc/sapp.toml
index d52d4fc..cd6ce8f 100644
--- a/benchmark/sapp_default_config/etc/sapp.toml
+++ b/benchmark/sapp_default_config/etc/sapp.toml
@@ -17,9 +17,6 @@
### MESA_load_profile range format: bind_mask="1-5,11-15"
bind_mask=[]
-[MEM]
- dictator_enable=1
-
[PACKET_IO]
[overlay_tunnel_definition]
### note, since 2020-10-01, L2-L3 tunnel(VLAN,MPLS,PPPOE,etc.) is process and offload by mrtunnat,
diff --git a/bin/etc/sapp.toml b/bin/etc/sapp.toml
index a43c93b..d9fd709 100644
--- a/bin/etc/sapp.toml
+++ b/bin/etc/sapp.toml
@@ -17,8 +17,6 @@
### MESA_load_profile range format: bind_mask="1-5,11-15"
bind_mask=[]
-[MEM]
- dictator_enable=1
[PACKET_IO]
[overlay_tunnel_definition]
diff --git a/bin/memchk.sh b/bin/memchk.sh
index cb1e9bc..bb940b4 100644
--- a/bin/memchk.sh
+++ b/bin/memchk.sh
@@ -1,3 +1,2 @@
#!/bin/sh
-sed 's/^[ \t]*dictator_enable=.*/dictator_enable=0/g' -i etc/sapp.toml
valgrind --tool=memcheck --leak-check=full --leak-resolution=high --error-limit=no --undef-value-errors=yes --log-file=valgrind.log $@
diff --git a/bin/memchk.sh.full b/bin/memchk.sh.full
index e4aaa19..17414d6 100644
--- a/bin/memchk.sh.full
+++ b/bin/memchk.sh.full
@@ -1,3 +1,2 @@
#!/bin/sh
-sed 's/^[ \t]*dictator_enable=.*/dictator_enable=0/g' -i etc/sapp.toml
valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --leak-resolution=high --error-limit=no --undef-value-errors=yes --track-origins=yes --show-reachable=yes --log-file=valgrind.log --max-stackframe=7418264 --valgrind-stacksize=1048576 --malloc-fill=AA --free-fill=FE $@
diff --git a/bin/memchk.sh.quick b/bin/memchk.sh.quick
index 2ccc68b..7e07f38 100644
--- a/bin/memchk.sh.quick
+++ b/bin/memchk.sh.quick
@@ -1,3 +1,2 @@
#!/bin/sh
-sed 's/^[ \t]*dictator_enable=.*/dictator_enable=0/g' -i etc/sapp.toml
valgrind --tool=memcheck --leak-check=full --leak-resolution=high --error-limit=no --undef-value-errors=yes --log-file=valgrind.log $@
diff --git a/include/private/dictator.h b/include/private/dictator.h
deleted file mode 100644
index d711c4a..0000000
--- a/include/private/dictator.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* DICATATOR Memory Manager
-* Version 20141115
-*/
-#ifndef _DICTATOR2_H_
-#define _DICTATOR2_H_
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-#include <stddef.h>
-
-void *__wrap_malloc(size_t size);
-void __wrap_free(void *p);
-void *__wrap_realloc(void *ptr, size_t size);
-void *__wrap_calloc(size_t nmemb, size_t size);
-
-void *__dictator_malloc(int t_seq,size_t size);
-void __dictator_free(int t_seq,void*p);
-void *__dictator_realloc(int t_seq,void *ptr, size_t size);
-void *__dictator_calloc(int t_seq,size_t nmemb, size_t size);
-
-void *malloc(size_t size);
-void *calloc(size_t nmemb, size_t size);
-void free(void *p);
-
-#ifdef __cplusplus
-}
-#endif// end extern "C"
-
-#endif
diff --git a/include/private/sapp_declaration.h b/include/private/sapp_declaration.h
index b505ed2..e5260a9 100644
--- a/include/private/sapp_declaration.h
+++ b/include/private/sapp_declaration.h
@@ -86,7 +86,6 @@ extern sapp_global_t *sapp_global_val;
#define g_ipv6_decapsulation_enabled sapp_global_val->config.protocol_feature.ipv6_decapsulation_enabled
#define g_ipv6_send_packet_enabled sapp_global_val->config.protocol_feature.ipv6_send_packet_enabled
#define G_SKIP_NOT_IP_LAYER sapp_global_val->config.protocol_feature.skip_not_ip_layer_over_eth
-#define G_DICTATOR_SW sapp_global_val->config.mem.dictator_enable
//#define sapp_runtime_log(log_level, format, args...) do{if(log_level>=ABBR_SAPP_LOG_LEVEL){MESA_handle_runtime_log(ABBR_SAPP_LOG_HANDLE, log_level, "sapp", format, ##args);}}while(0)
diff --git a/include/private/sapp_global_val.h b/include/private/sapp_global_val.h
index bd7f53d..7255387 100644
--- a/include/private/sapp_global_val.h
+++ b/include/private/sapp_global_val.h
@@ -48,10 +48,6 @@ typedef struct{
long bind_mask; /* bind_mask_array�е�ÿ��������Ϊbit_indexת�ɵ�����ֵ */
}sapp_config_cpu_t;
-typedef struct{
- int dictator_enable;
-}sapp_config_mem_t;
-
typedef struct{
char instance_name[NAME_MAX];
@@ -371,7 +367,6 @@ typedef struct{
typedef struct{
sapp_config_cpu_t cpu;
- sapp_config_mem_t mem;
sapp_config_tools_t tools;
sapp_config_system_t system;
sapp_config_stream_t stream;
diff --git a/include/private/sapp_mem.h b/include/private/sapp_mem.h
index 380d547..d68a0ac 100644
--- a/include/private/sapp_mem.h
+++ b/include/private/sapp_mem.h
@@ -69,8 +69,6 @@ void sapp_mem_stat_output(void);
#define SAPP_GLOBAL_FREE(mem) do{if(mem){sapp_mem_free(SAPP_MEM_FIX_GLOBAL_VAL, MEM_STAT_GLOBAL_THREAD_ID, (void *)mem); mem = NULL;}}while(0)
#endif
-extern int g_sapp_mem_use_dictator;
-
#ifdef __cplusplus
}
#endif
diff --git a/include/private/sapp_private_api.h b/include/private/sapp_private_api.h
index f23980f..cb65cb6 100644
--- a/include/private/sapp_private_api.h
+++ b/include/private/sapp_private_api.h
@@ -1,7 +1,6 @@
#ifndef _SAPP_PRIVATE_API_H_
#define _SAPP_PRIVATE_API_H_ 1
-#include "private/dictator.h"
#include "private/compat.h"
#include "private/deal_ipv4.h"
#include "private/deal_ipv6.h"
diff --git a/include/support/dictator.h b/include/support/dictator.h
deleted file mode 100644
index 5a95132..0000000
--- a/include/support/dictator.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* DICATATOR Memory Manager
-* Version 20141115
-*/
-#ifndef _DICTATOR2_H_
-#define _DICTATOR2_H_
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-void *__wrap_malloc(size_t size);
-void __wrap_free(void *p);
-void *__wrap_realloc(void *ptr, size_t size);
-void *__wrap_calloc(size_t nmemb, size_t size);
-
-void *__dictator_malloc(int t_seq,size_t size);
-void __dictator_free(int t_seq,void*p);
-void *__dictator_realloc(int t_seq,void *ptr, size_t size);
-void *__dictator_calloc(int t_seq,size_t nmemb, size_t size);
-
-void *malloc(size_t size);
-void *calloc(size_t nmemb, size_t size);
-void free(void *p);
-
-#ifdef __cplusplus
-}
-#endif// end extern "C"
-
-#endif
diff --git a/module_test/src/Makefile b/module_test/src/Makefile
deleted file mode 100644
index 233bd20..0000000
--- a/module_test/src/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-all:
- $(MAKE) -f Makefile_v4
-
-clean:
- rm -rf *.o *.so gtest_sapp_v3 gtest_sapp_v4 build/*
-
-#version 3.0
-install3:
- cp gtest_sapp_v3 /home/lijia/run/benchmark_v3/
- cp gtest_sapp.so /home/lijia/run/benchmark_v3/plug/business/gtest_sapp/gtest_sapp.so
-
-#version 4.0
-install:
- $(MAKE) -f Makefile_v4 install
-
-install4:
- $(MAKE) -f Makefile_v4 install
-
-#benchmark
-installb:
- cp sapp_benchmark.so ../sapp_benchmark/plug/business/sapp_benchmark
diff --git a/module_test/test_case/Makefile b/module_test/test_case/Makefile
deleted file mode 100644
index 072f770..0000000
--- a/module_test/test_case/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-INC=-I/opt/MESA/include
-INC+=-I/opt/MESA/include/MESA
-INC+=-I/opt/MESA/include/MESA/stream_inc
-
-
-LIBS=-L/opt/MESA/lib
-LIBS+=-lgtest -lMESA_handle_logger -lpthread -lsapp_benchmark
-
-all:gtest_sapp_by_benchmark
-
-gtest_sapp_by_benchmark:test_function_common.cpp
- ./auto_gen_test_functions.sh
- g++ -o $@ $^ auto_gen_test_functions.cpp -g -std=c++11 $(INC) $(LIBS)
-
-clean:
- rm -f gtest_sapp_by_benchmark *.o
diff --git a/src/Makefile b/src/Makefile
deleted file mode 100644
index 4288742..0000000
--- a/src/Makefile
+++ /dev/null
@@ -1,345 +0,0 @@
-##################### MESA Makefile Common Definition Start #################
-MESA_MAKE_VERSION=20170626
-
-#CC=gcc
-CC=g++
-CCC=g++
-CFLAGS =
-#CFLAGS = -march=native
-#CFLAGS += -D__FAVOR_BSD=1 -D__USE_BSD=1 -D_GNU_SOURCE=1 -Werror -DMESA_SAPP_PLATFORM=1
-CFLAGS += -D__FAVOR_BSD=1 -D__USE_BSD=1 -D_GNU_SOURCE=1 -DMESA_SAPP_PLATFORM=1
-LIBS= -L/opt/MESA/lib
-INC=-I./
-INC+=-I/opt/MESA/include
-OBJS=
-
-target_mode=elf
-
-_MODE_PCAP=pcap
-_MODE_PAG=pag
-_MODE_PPF=ppf
-_MODE_PFRING=pfring
-_MODE_DPDK=dpdk
-_MODE_PAG_N95=pag_n95
-_MODE_TOPSEC=topsec
-_MODE_MARSIO=marsio
-_MODE_SMITH=smith
-_MODE_DPDK_VXLAN=dpdk_vxlan
-_MODE_PAG_MARSIO=pag_marsio
-_MODE_IPFILE=ipfile
-_MODE_TUN=tun
-_MODE_CHK=0
-iomode=tun
-
-_OPT0=0
-_OPT1=1
-_OPT2=2
-_OPT3=3
-_OPT_HIGH_PERF=high_perf
-#default level is 0
-opt=0
-_OPT_CHK=0
-
-_DEBUG_CHK=0
-_DEBUG0=0
-_DEBUG1=1
-_DEBUG2=2
-#default is 2
-debug=2
-__TARGET_MODE_ELF=elf
-__TARGET_MODE_SO=so
-
-ifeq ($(target_mode), $(__TARGET_MODE_ELF))
- #
-else
- ifeq ($(target_mode), $(__TARGET_MODE_SO))
- #CFLAGS += -DSAPP_AS_TARGET_SO=1 -fvisibility=hidden
- CFLAGS += -DSAPP_AS_TARGET_SO=1
- debug=0
- else
- $(error target mode args error, please use make help)
- exit
- endif
-endif
-
-ifeq ($(debug), $(_DEBUG0))
-#do nothing
-_DEBUG_CHK=1
-endif
-
-ifeq ($(debug), $(_DEBUG1))
-CFLAGS += -g
-_DEBUG_CHK=1
-#do nothing
-endif
-ifeq ($(debug), $(_DEBUG2))
-CFLAGS += -g -DDEBUG=1
-_DEBUG_CHK=1
-endif
-
-ifneq ($(_DEBUG_CHK), 0)
-else
- ifeq ($(debug), 0)
- #
- else
- $(error args debug error)
- exit
- endif
-endif
-
-ifeq ($(iomode), $(_MODE_PCAP))
-_MODE_CHK=1
-LIBS += -lpcap
-endif
-ifeq ($(iomode), $(_MODE_PAG))
-LIBS += -lpag -lpthread
-_MODE_CHK=1
-endif
-ifeq ($(iomode), $(_MODE_PPF))
-LIBS += -lppf
-_MODE_CHK=1
-endif
-ifeq ($(iomode), $(_MODE_PFRING))
-LIBS += -lpfring
-_MODE_CHK=1
-endif
-
-ifeq ($(iomode), $(_MODE_DPDK))
-LIBS += -lmarsio
-_MODE_CHK=1
-endif
-
-ifeq ($(iomode), $(_MODE_TOPSEC))
-_MODE_CHK=1
-endif
-
-ifeq ($(iomode), $(_MODE_MARSIO))
-LIBS += -lmarsio
-_MODE_CHK=1
-endif
-
-ifeq ($(iomode), $(_MODE_SMITH))
-LIBS += -lagent_smith
-_MODE_CHK=1
-endif
-
-ifeq ($(iomode), $(_MODE_DPDK_VXLAN))
-LIBS += -lmarsio
-_MODE_CHK=1
-endif
-
-ifeq ($(iomode), $(_MODE_PAG_MARSIO))
-LIBS += -lpag
-_MODE_CHK=1
-endif
-
-ifeq ($(iomode), $(_MODE_IPFILE))
-_MODE_CHK=1
-endif
-
-ifeq ($(iomode), $(_MODE_TUN))
-_MODE_CHK=1
-endif
-
-
-ifneq ($(_MODE_CHK), 0)
-else
- ifeq ($(iomode), "pcap")
- else
- $(error args iomode error)
- exit
- endif
-endif
-
-ifeq ($(opt), $(_OPT0))
-opt=0
-CFLAGS += -O0
-_OPT_CHK=1
-endif
-ifeq ($(opt), $(_OPT1))
-opt=1
-CFLAGS += -O1
-_OPT_CHK=1
-endif
-ifeq ($(opt), $(_OPT2))
-opt=2
-CFLAGS += -O2
-_OPT_CHK=1
-endif
-ifeq ($(opt), $(_OPT3))
-opt=3
-CFLAGS += -O3
-_OPT_CHK=1
-endif
-ifeq ($(opt), $(_OPT_HIGH_PERF))
-opt=2
-CFLAGS += -O2 -DHIGH_PERF=1 -UDEBUG -march=native
-_OPT_CHK=1
-endif
-
-ifneq ($(_OPT_CHK), 0)
-else
- ifeq ($(opt), 0)
- #
- else
- $(error args opt error)
- exit
- endif
-endif
-
-__LINK_MODE_DYNAMIC=dynamic
-__LINK_MODE_STATIC=static
-link_mode=static
-
-ifeq ($(link_mode), $(__LINK_MODE_STATIC))
- CFLAGS += -DLINK_MODE_STATIC=1
-else
- ifeq ($(link_mode), $(__LINK_MODE_DYNAMIC))
- CFLAGS += -DLINK_MODE_DYNAMIC=1
- else
- $(error link_mode args error, please use make help)
- exit
- endif
-endif
-.PHONY:help clean target
-
-export CC
-export CCC
-export CFLAGS
-export LIBS
-export INC
-export iomode
-export debug
-export _OPT_HIGH_PERF
-export _DEBUG0
-export _DEBUG1
-export _DEBUG2
-export _MODE_PCAP
-export _MODE_PAG
-export _MODE_PPF
-export _MODE_PFRING
-export _MODE_DPDK
-export _MODE_TOPSEC
-export _MODE_MARSIO
-export _MODE_SMITH
-export _MODE_DPDK_VXLAN
-export _MODE_IPFILE
-export _MODE_PAG_MARSIO
-export target_mode
-export __TARGET_MODE_ELF
-export __TARGET_MODE_SO
-export link_mode
-export __LINK_MODE_STATIC
-export __LINK_MODE_DYNAMIC
-
-target:all
-
-version:
- @echo -e "MESA Makefile version:\033[31;49;1m $(MESA_MAKE_VERSION)\033[0m"
-
-help:
- @echo -e "MESA Makefile version:\033[31;49;1m $(MESA_MAKE_VERSION)\033[0m"
- @echo "MESA-Makefile usage:"
- @echo -e "\treserved args:"
- @echo -e "\t\t\033[31;49;1m debug={0,1,2},0:release version; 1:-g; 2:-g -DDEBUG, default is 2.\033[0m"
- @echo -e "\t\t\033[31;49;1m opt={0,1,2,3,high_perf}, optimize level, default is 0.\033[0m"
- @echo -e "\t\t\033[31;49;1m iomode={pcap,ppf,pag,prfing,dpdk,tilera,topsec,ipfile,marsio,smith,dpdk_vxlan,pag_marsio}, default is pcap.\033[0m"
- @echo -e "\t\t\033[31;49;1m target_mode={elf, so}, default is elf.\033[0m"
- @echo -e "\t\t\033[31;49;1m link_mode={dynamic, static}, default is dynamic.\033[0m"
-
-##################### MESA Makefile Common Definition End ####################
-
-YES=1
-NO=0
-USE_MEM_POOL=$(YES)
-#USE_MEM_POOL=$(NO)
-USE_PAG_GET_FRAME=$(YES)
-#USE_PAG_GET_FRAME=$(NO)
-INSTALL_PATH=./run
-
-
-
-MD5_STREAM_BASE=$(shell md5sum "../include/public/stream_inc/stream_base.h"|cut -d ' ' -f1)
-MD5_STREAM_ENTRY=$(shell md5sum "../include/public/stream_inc/stream_entry.h"|cut -d ' ' -f1)
-MD5_STREAM_CONTROL=$(shell md5sum "../include/public/stream_inc/stream_control.h"|cut -d ' ' -f1)
-MD5_STREAM_INJECT=$(shell md5sum "../include/public/stream_inc/stream_inject.h"|cut -d ' ' -f1)
-MD5_STREAM_PROJECT=$(shell md5sum "../include/public/stream_inc/stream_project.h"|cut -d ' ' -f1)
-MD5_STREAM_PROXY=$(shell md5sum "../include/public/stream_inc/stream_proxy.h"|cut -d ' ' -f1)
-MD5_STREAM_RAWPKT=$(shell md5sum "../include/public/stream_inc/stream_rawpkt.h"|cut -d ' ' -f1)
-MD5_STREAM_TUNNEL=$(shell md5sum "../include/public/stream_inc/stream_tunnel.h"|cut -d ' ' -f1)
-
-HEADER_CHECK_FLAGS += -DSTREAM_BASE_MD5_CHECK=\"$(MD5_STREAM_BASE)\"
-HEADER_CHECK_FLAGS += -DSTREAM_CONTROL_MD5_CHECK=\"$(MD5_STREAM_CONTROL)\"
-HEADER_CHECK_FLAGS += -DSTREAM_ENTRY_MD5_CHECK=\"$(MD5_STREAM_ENTRY)\"
-HEADER_CHECK_FLAGS += -DSTREAM_INJECT_MD5_CHECK=\"$(MD5_STREAM_INJECT)\"
-HEADER_CHECK_FLAGS += -DSTREAM_PROJECT_MD5_CHECK=\"$(MD5_STREAM_PROJECT)\"
-HEADER_CHECK_FLAGS += -DSTREAM_PROXY_MD5_CHECK=\"$(MD5_STREAM_PROXY)\"
-HEADER_CHECK_FLAGS += -DSTREAM_RAWPKT_MD5_CHECK=\"$(MD5_STREAM_RAWPKT)\"
-HEADER_CHECK_FLAGS += -DSTREAM_TUNNEL_MD5_CHECK=\"$(MD5_STREAM_TUNNEL)\"
-
-GIT_BRANCH=$(shell git symbolic-ref --short -q HEAD)
-GIT_SHA1=$(shell git rev-parse HEAD)
-MAKE_TIME=$(shell date "+%Y-%m-%d_%H:%M:%S")
-VERSION_FLAGS += -DGITVER=\"3.0.0-$(GIT_BRANCH)-$(GIT_SHA1)-$(MAKE_TIME)\"
-
-CFLAGS += ${HEADER_CHECK_FLAGS} ${VERSION_FLAGS}
-CXXFLAGS += ${HEADER_CHECK_FLAGS} ${VERSION_FLAGS}
-
-
-export USE_MEM_POOL
-export USE_PAG_GET_FRAME
-export YES
-export NO
-
-all:
- cd support/tomlc99_wrap; $(MAKE);
- cd support/libping; $(MAKE);
- cd support/avl_tree; $(MAKE);
- cd support/MESA_sleep; $(MAKE);
- cd support/dictator2/src; $(MAKE);
- cd support/md5; $(MAKE);
- cd support/rb_tree; $(MAKE);
- cd support/symbol_check; $(MAKE);
- cd support/timestamp_record; $(MAKE);
- cd support/iknow; $(MAKE);
- cd support/MESA_socket_wrap; $(MAKE);
- cd support/c3_client; $(MAKE);
- cd config; $(MAKE);
- cd common; $(MAKE);
- cd dealpkt; $(MAKE);
- cd packet_io; $(MAKE);
- cd project; $(MAKE);
- cd plugin; $(MAKE);
- cd inner_plug; $(MAKE);
- cd timer; $(MAKE);
- cd entry; $(MAKE);
-
-clean:
- cd common; $(MAKE) clean;
- cd dealpkt; $(MAKE) clean;
- cd packet_io; $(MAKE) clean;
- cd project; $(MAKE) clean;
- cd plugin; $(MAKE) clean;
- cd inner_plug; $(MAKE) clean;
- cd entry; $(MAKE) clean;
- cd config; $(MAKE) clean;
- cd timer; $(MAKE) clean;
- cd support/c3_client; $(MAKE) clean;
- cd support/dictator2/src; $(MAKE) clean;
- cd support/MESA_sleep; $(MAKE) clean;
- cd support/md5; $(MAKE) clean;
- cd support/rb_tree; $(MAKE) clean;
- cd support/symbol_check; $(MAKE) clean;
- cd support/timestamp_record; $(MAKE) clean;
- cd support/iknow; $(MAKE) clean;
- cd support/MESA_socket_wrap; $(MAKE) clean;
- cd support/avl_tree; $(MAKE) clean;
- cd support/libping; $(MAKE) clean;
- cd support/tomlc99_wrap; $(MAKE) clean;
-
-install:
- mkdir -p /opt/MESA/include;
- mkdir -p /opt/MESA/lib;
- cp -r -f include/support/pcap* /opt/MESA/include
- ln -sf /usr/lib64/libpcap.so.1 /opt/MESA/lib/libpcap.so;
- cp packet_io/*.so $(INSTALL_PATH)/platform_lib/
diff --git a/src/common/Makefile b/src/common/Makefile
deleted file mode 100644
index df11f31..0000000
--- a/src/common/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-#opt: OPTFLAGS = -O2
-#export OPTFLAGS
-
-CC = g++
-CCC = g++
-CFLAGS += -Wall
-CFLAGS += -fPIC -shared -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H
-CFLAGS += $(OPTFLAGS)
-CFLAGS += $(PACKET_TAG_863)
-CFLAGS += -DPLATFORM_NSDPF_PAPP=1
-
-LIBPATH = ../lib
-
-H_DIR += $(INC)
-H_DIR += -I../../include
-H_DIR += -I../../include/private
-H_DIR += -I../../include/public
-H_DIR += -I../../include/support
-
-H_DIR += -I/opt/MESA/include
-H_DIR += -I/opt/MESA/include/MESA
-
-TARGET = libcommon.a
-
-OBJS= net_common.o stream_addr_inet.o linux_kernel_jhash.o sapp_log.o
-
-ifeq ($(IIEFD_DUAL_STACK), $(YES))
-CFLAGS += -g -DIIEFD_DUAL_STACK=1
-endif
-
-ifeq ($(USE_MEM_POOL), 1)
-CFLAGS += -DUSE_MEMPOOL=1
-endif
-
-
-all: $(TARGET)
-
-$(TARGET): $(OBJS)
- rm -f $@ ;ar -r $@ $^;
- cp $(TARGET) $(LIBPATH)
-
-.c.o:
- $(CC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-.cpp.o:
- $(CCC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-clean:
- rm -f *.o $(TARGET) *~
-
-opt:
- $(MAKE) all
diff --git a/src/common/sapp_mem.c b/src/common/sapp_mem.c
index 465e58c..e921de0 100644
--- a/src/common/sapp_mem.c
+++ b/src/common/sapp_mem.c
@@ -6,11 +6,7 @@
extern "C" {
#endif
-extern void *__dictator_malloc(int t_seq,size_t size);
-extern void __dictator_free(int t_seq,void*p);
-/* �˴�����ʹ��һ��ȫ�ֱ���, Ϊ���ж��Ƿ�����dictator, ����Ԥ�ȷ����ڴ� */
-int g_sapp_mem_use_dictator = 1;
int g_sapp_global_mem_used_block = 0;
int g_sapp_global_mem_used_bytes = 0;
@@ -61,15 +57,7 @@ void *sapp_mem_malloc(sapp_mem_type_t type, int thread_seq, int size)
sapp_private_mem_t *mhdr;
sapp_mem_used_stat_t *mem_used_stat;
-#if USE_MEMPOOL
- if(g_sapp_mem_use_dictator){
- ptr = __dictator_malloc(thread_seq, size+sizeof(sapp_private_mem_t));
- }else{
- ptr = (char *)malloc(size+sizeof(sapp_private_mem_t));
- }
-#else
ptr = (char *)malloc(size+sizeof(sapp_private_mem_t));
-#endif
mhdr = (sapp_private_mem_t *)ptr;
@@ -99,17 +87,7 @@ void *sapp_mem_calloc(sapp_mem_type_t type, int thread_seq, int size)
char *ptr;
sapp_private_mem_t *mhdr;
sapp_mem_used_stat_t *mem_used_stat;
-
-#if USE_MEMPOOL
- if(g_sapp_mem_use_dictator){
- ptr = __dictator_malloc(thread_seq, size+sizeof(sapp_private_mem_t));
- memset(ptr, 0, size+sizeof(sapp_private_mem_t));
- }else{
- ptr = (char *)calloc(1, size+sizeof(sapp_private_mem_t));
- }
-#else
ptr = (char *)calloc(1, size+sizeof(sapp_private_mem_t));
-#endif
mhdr = (sapp_private_mem_t *)ptr;
@@ -156,19 +134,7 @@ void sapp_mem_free(sapp_mem_type_t type, int thread_seq, void *data)
mem_used_stat->mem_used_block[SAPP_MEM_DYN_MEM_HDR]--;
mem_used_stat->mem_used_bytes[SAPP_MEM_DYN_MEM_HDR] -= sizeof(sapp_private_mem_t);
-
-
-#if USE_MEMPOOL
- if(g_sapp_mem_use_dictator){
- __dictator_free(thread_seq, (void *)mhdr);
- }else{
- free((void *)mhdr);
- }
-#else
- free((void *)mhdr);
-#endif
-
-
+ free((void *)mhdr);
}
void *sapp_mem_realloc(sapp_mem_type_t type, int thread_seq, void *old_ptr, int size)
diff --git a/src/config/Makefile b/src/config/Makefile
deleted file mode 100644
index d76eaaf..0000000
--- a/src/config/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-#opt: OPTFLAGS = -O2
-#export OPTFLAGS
-
-CC = g++
-CCC = g++
-CFLAGS += -Wall
-CFLAGS += -fPIC -shared -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H
-CFLAGS += $(OPTFLAGS)
-CFLAGS += $(PACKET_TAG_863)
-CFLAGS += -DPLATFORM_NSDPF_PAPP=1
-
-LIBPATH = ../lib
-
-H_DIR += $(INC)
-H_DIR += -I../../include
-H_DIR += -I../../include/private
-H_DIR += -I../../include/public
-H_DIR += -I../../include/support
-
-H_DIR += -I/opt/MESA/include
-H_DIR += -I/opt/MESA/include/MESA
-
-TARGET = libconfig.a
-
-OBJS=cmd_args.o config_parse.o
-
-ifeq ($(IIEFD_DUAL_STACK), $(YES))
-CFLAGS += -g -DIIEFD_DUAL_STACK=1
-endif
-
-ifeq ($(USE_MEM_POOL), 1)
-CFLAGS += -DUSE_MEMPOOL=1
-endif
-
-
-all: $(TARGET)
-
-$(TARGET): $(OBJS)
- rm -f $@ ;ar -r $@ $^;
- cp $(TARGET) $(LIBPATH)
-
-.c.o:
- $(CC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-.cpp.o:
- $(CCC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-clean:
- rm -f *.o $(TARGET) *~
-
-opt:
- $(MAKE) all
diff --git a/src/config/config_parse.cpp b/src/config/config_parse.cpp
index 8c9fecb..a469111 100644
--- a/src/config/config_parse.cpp
+++ b/src/config/config_parse.cpp
@@ -1756,8 +1756,6 @@ int sapp_parse_config(void)
}
- /******************************* MEM *********************************/
- tomlc99_wrap_load_int_def(ABBR_CFG_FILE_MAIN_ENTRY, (char *)"MEM", (char *)"dictator_enable", (int *)&pconfig->mem.dictator_enable, 1);
/******************************* PACKET_IO ******************************/
diff --git a/src/dealpkt/Makefile b/src/dealpkt/Makefile
deleted file mode 100644
index c338f28..0000000
--- a/src/dealpkt/Makefile
+++ /dev/null
@@ -1,111 +0,0 @@
-#opt: OPTFLAGS = -O2
-#export OPTFLAGS
-
-CC = g++
-CCC = g++
-CFLAGS += -Wall
-CFLAGS += -fPIC -shared -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H
-CFLAGS += $(OPTFLAGS)
-CFLAGS += $(PACKET_TAG_863)
-CFLAGS += -DPLATFORM_NSDPF_PAPP=1
-
-LIBPATH = ../lib
-
-H_DIR += $(INC)
-
-H_DIR += -I../../include/
-H_DIR += -I../../include/public
-H_DIR += -I../../include/private
-H_DIR += -I../../include/support
-H_DIR += -I/opt/MESA/include
-H_DIR += -I/opt/MESA/include/MESA
-H_DIR += -I/opt/mrzcpd/include
-
-TARGET = libdealpkt.a
-
-OBJS=deal_udp.o deal_tcp.o stream_manage.o callapp.o deal_ipv6.o deal_ipv4.o deal_vlan.o ip_reassembly.o hash.o synflood_detect.o
-OBJS+=deal_ethernet.o deal_arp.o deal_pppoe.o deal_gre.o deal_teredo.o
-OBJS += deal_icmp.o
-OBJS += g_device.o
-OBJS += deal_mpls.o
-OBJS += deal_proxy.o
-OBJS += deal_ppp.o
-OBJS += deal_pptp.o
-OBJS += plug_support.o
-OBJS += deal_l2tp.o
-OBJS += deal_mac_in_mac.o
-OBJS += deal_gprs_tunnel.o
-
-
-ifeq ($(IIEFD_DUAL_STACK), $(YES))
-CFLAGS += -g -DIIEFD_DUAL_STACK=1
-endif
-
-ifeq ($(USE_MEM_POOL), 1)
-CFLAGS += -DUSE_MEMPOOL=1
-endif
-
-ifeq ($(iomode), $(_MODE_PCAP))
-CFLAGS += -DIOMODE_PCAP=1
-endif
-
-ifeq ($(iomode), $(_MODE_PAG))
-CFLAGS += -DIOMODE_PAG=1
-endif
-
-ifeq ($(iomode), $(_MODE_PPF))
-CFLAGS += -DIOMODE_PPF=1
-endif
-
-ifeq ($(iomode), $(_MODE_PFRING))
-CFLAGS += -DIOMODE_PFRING=1
-endif
-
-ifeq ($(iomode), $(_MODE_DPDK))
-CFLAGS += -DIOMODE_DPDK=1
-endif
-
-ifeq ($(iomode), $(_MODE_TOPSEC))
-CFLAGS += -DIOMODE_TOPSEC=1
-endif
-
-ifeq ($(iomode), $(_MODE_IPFILE))
-CFLAGS += -DIOMODE_IPFILE=1
-endif
-
-ifeq ($(iomode), $(_MODE_MARSIO))
-CFLAGS += -DIOMODE_MARSIO=1
-endif
-
-ifeq ($(iomode), $(_MODE_SMITH))
-CFLAGS += -DIOMODE_SMITH=1
-endif
-
-ifeq ($(iomode), $(_MODE_DPDK_VXLAN))
-CFLAGS += -DIOMODE_DPDK_VXLAN=1
-endif
-
-ifeq ($(iomode), $(_MODE_PAG_MARSIO))
-CFLAGS += -DIOMODE_PAG_MARSIO=1
-endif
-
-all: $(TARGET)
-
-$(TARGET): $(OBJS)
- rm -f $@ ;ar -r $@ $^;
- cp $(TARGET) $(LIBPATH)
-
-linux_kernel_jhash.o:linux_kernel_jhash.c
- $(CC) -c $(CFLAGS) -O3 -I. $(H_DIR) $<
-
-.c.o:
- $(CC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-.cpp.o:
- $(CCC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-clean:
- rm -f *.o $(TARGET) *~
-
-opt:
- $(MAKE) all
diff --git a/src/dealpkt/deal_tcp.c b/src/dealpkt/deal_tcp.c
index baa79cd..1db73f8 100644
--- a/src/dealpkt/deal_tcp.c
+++ b/src/dealpkt/deal_tcp.c
@@ -2051,32 +2051,7 @@ static int tcp_save_unorder(struct streaminfo *a_tcp,struct half_tcpstream *rc
struct buf_unorder *packet=NULL;
unsigned int this_seq = ntohl (this_tcphdr->th_seq);
-#if 0 /* 2015-01-12 lijia modify */
- pakiet = (struct buf_unorder*)dictator_malloc(threadnum,sizeof(struct buf_unorder));
- memset(pakiet, 0, sizeof(struct buf_unorder));
-
-/* 2014-10-20 lijia modify, ��IP��Ƭ�����, raw_pkt��tcpdatalen����Ӧ
-raw_pktָ�����һ����Ƭ��, ��tcpdatalen��������ɺ������IP������!
-�ֱ�洢!
-*/
- if(tcpdatalen > 0){
- pakiet->data = dictator_malloc(threadnum,tcpdatalen);
- pakiet->len = tcpdatalen;
- memcpy (pakiet->data, tcpdata, tcpdatalen);
- }
- memcpy(&(pakiet->raw_pkt), stack_raw_pkt, sizeof(raw_pkt_t));
- pakiet->raw_pkt.raw_pkt_data = dictator_malloc(threadnum, stack_raw_pkt->raw_pkt_len);
- memcpy((void *)pakiet->raw_pkt.raw_pkt_data, stack_raw_pkt->raw_pkt_data, stack_raw_pkt->raw_pkt_len);
-
- pakiet->tcpdatalen=tcpdatalen;
- pakiet->fin = (this_tcphdr->th_flags & TH_FIN);
- pakiet->rst = (this_tcphdr->th_flags & TH_RST);
- pakiet->seq = this_seq;
- pakiet->urg = (this_tcphdr->th_flags & TH_URG);
- pakiet->urg_ptr = ntohs (this_tcphdr->th_urp);
-#else
packet = tcp_save_unorder_pkt(a_tcp, this_iphdr, stack_raw_pkt, this_tcphdr, tcpdata, tcpdatalen);
-#endif
for (;;)
{
@@ -2103,18 +2078,8 @@ raw_pktָ�����һ����Ƭ��, ��tcpdatalen��������ɺ������IP������!
|| (p->seq+p->tcpdatalen) == (this_seq+packet->tcpdatalen)
||after(p->seq+p->tcpdatalen,this_seq+packet->tcpdatalen))
{
-#if 0/* 2015-01-12 lijia modify */
- if(pakiet->data){
- dictator_free(threadnum,pakiet->data);
- }
- dictator_free(threadnum,(void *)pakiet->raw_pkt.raw_pkt_data);
- pakiet->data = NULL;
- dictator_free(threadnum,pakiet);
- pakiet = NULL;
-#else
tcp_free_unorder_pkt(threadnum, packet);
-#endif
return PASS;
}
@@ -2846,7 +2811,6 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s
{
pstream_pr = &pindex_tcp->stream;
pstream = &pstream_pr->stream_public;
- //terminal_tag_probe(pstream, this_tcphdr, this_iphdr);
//add by lqy 20130822
pdetail_pr = (struct tcpdetail_private *)(pindex_tcp->stream.stream_public.pdetail);
pdetail = (struct tcpdetail *)(&pdetail_pr->tcpdetail_public);
diff --git a/src/dealpkt/plug_support.c b/src/dealpkt/plug_support.c
index ea7f9e9..c757f33 100644
--- a/src/dealpkt/plug_support.c
+++ b/src/dealpkt/plug_support.c
@@ -1766,20 +1766,6 @@ int get_current_thread_cpu_affinity_id(void)
-extern int project_req_terminal_tag_id;
-/* For863, ����Ӧ�ò�����ȡ��TCP���ж�Ӧ���û���ǩ */
-const unsigned char *get_terminal_tag(struct streaminfo *stream)
-{
- unsigned char *terminal_tag;
-
- if(project_req_terminal_tag_id < 0){
- return NULL;
- }
-
- terminal_tag = (unsigned char *)project_req_get_struct(stream, project_req_terminal_tag_id);
-
- return (const unsigned char *)terminal_tag;
-}
int number_is_2powerN(uint n)
{
@@ -1794,45 +1780,18 @@ int number_is_2powerN(uint n)
void *dictator_malloc(int thread_seq,size_t size)
{
- /*
- if(malloccount%100000==0)
- {
- printf("malloc=%d,free=%d\n",malloccount,freecount);
- }
- */
-
- if(G_DICTATOR_SW){
-#if USE_MEMPOOL
- return __dictator_malloc(thread_seq, size);
-#endif
- }
-
return malloc(size);
}
void dictator_free(int thread_seq,void *pbuf)
{
-#if USE_MEMPOOL
- if(G_DICTATOR_SW){
- __dictator_free(thread_seq, pbuf);
- }
- else
-#endif
- {
#if SAPP_INSECTICIDE
*((char *)pbuf) = 0xFE;
#endif
free(pbuf);
- }
}
void *dictator_realloc(int thread_seq, void *ptr, size_t size)
{
-#if USE_MEMPOOL
- if(G_DICTATOR_SW){
- return __dictator_realloc(thread_seq, ptr, size);
- }
-#endif
-
return realloc(ptr, size);
}
diff --git a/src/entry/CMakeLists.txt b/src/entry/CMakeLists.txt
index e871739..c533670 100644
--- a/src/entry/CMakeLists.txt
+++ b/src/entry/CMakeLists.txt
@@ -28,7 +28,7 @@ add_executable(sapp sapp_main.c)
target_compile_options(sapp PUBLIC ${MEM_POOL_DEFINITIONS})
target_link_libraries(sapp nsl pthread dl m pcap)
target_link_libraries(sapp MESA_handle_logger MESA_prof_load)
-target_link_libraries(sapp sapp_assistant)
+target_link_libraries(sapp sapp_assistant sapp_metrics)
target_link_libraries(sapp breakpad_mini)
target_include_directories(sapp PRIVATE ${SYSTEMD_INCLUDE_DIRS})
@@ -42,18 +42,12 @@ set(SAPP_MODULES timestamp_record md5
packet_io dealpkt project plugctrl common
config timer tomlc99_wrap dpdk_ip_hash
gdev_assistant inline_keepalive libdabloom-static
- sapp_dev sapp_assistant cpu_limit timeout)
+ sapp_dev sapp_assistant sapp_metrics cpu_limit timeout)
if(LIBEVENT_ENABLED STREQUAL "ON")
set(SAPP_MODULES ${SAPP_MODULES} libevent-static)
endif()
-if(MEM_POOL MATCHES "DICTATOR_DEBUG")
- set(SAPP_MODULES ${SAPP_MODULES} dictator2_debug)
-elseif(MEM_POOL MATCHES "DICTATOR")
- set(SAPP_MODULES ${SAPP_MODULES} dictator2)
-endif()
-
target_link_libraries(sapp -Wl,--whole-archive ${SAPP_MODULES} -Wl,--no-whole-archive ${SAPP_DEPEND_DYN_LIB} ${SYSTEMD_LIBRARIES})
target_link_libraries(sapp packet_io_pcap)
diff --git a/src/entry/Makefile b/src/entry/Makefile
deleted file mode 100644
index 636648e..0000000
--- a/src/entry/Makefile
+++ /dev/null
@@ -1,117 +0,0 @@
-ifeq ($(target_mode), $(__TARGET_MODE_ELF))
-TARGET=sapp
-else
-TARGET=MESA_IP_PLUG.so
-endif
-
-all: $(TARGET)
-LIB=
-LIB_PATH=-L../lib -L/opt/mrzcpd/lib
-CFLAGS += -fPIC -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD
-CFLAGS += -DPLATFORM_NSDPF_PAPP=1
-
-ifeq ($(USE_PAG_GET_FRAME), $(YES))
-CFLAGS += -DUSE_PAG_GET_FRAME=1
-else
-CFLAGS += -DUSE_PAG_GET_FRAME=0
-endif
-
-ifeq ($(USE_MEM_POOL), $(YES))
-CFLAGS += -DUSE_MEMPOOL=1
-endif
-
-CFLAGS += -rdynamic
-
-ifeq ($(USE_MEM_POOL), $(YES))
-#LD_DICTATOR = -Wl,-wrap,malloc -Wl,-wrap,calloc -Wl,-wrap,free -Wl,-wrap,realloc
-WHOLE_ARCH=../lib/libdealpkt.a ../lib/libproject.a ../lib/libMESA_sleep.a ../lib/libdictator.a ../lib/libtimestamp_record.a
-WHOLE_ARCH+=../lib/libavltree.a
-WHOLE_ARCH+=../lib/libpacket_io.a
-WHOLE_ARCH+=../lib/libcommon.a
-else
-WHOLE_ARCH=../lib/libdealpkt.a ../lib/libproject.a ../lib/libMESA_sleep.a ../lib/libtimestamp_record.a
-WHOLE_ARCH+=../lib/libavltree.a
-WHOLE_ARCH+=../lib/libpacket_io.a
-WHOLE_ARCH+=../lib/libcommon.a
-endif
-
-ifeq ($(link_mode), $(__LINK_MODE_STATIC))
- WHOLE_ARCH += ../lib/libinner_plug.a
-else
- LIB += -lsapp_assistant
-endif
-LDFLAGS =
-LDFLAGS += $(LD_DICTATOR)
-
-LIB+=../lib/plugctrl.a
-LIB+=../lib/libmd5.a
-LIB+=../lib/librbtree.a
-LIB+= ../lib/libsymbol_check.a
-LIB+= ../lib/libMESA_socket_wrap.a
-ifeq ($(target_mode), $(__TARGET_MODE_SO))
-WHOLE_ARCH += ../lib/libpacket_io.a ../lib/plugctrl.a ../lib/libmd5.a ../lib/librbtree.a ../lib/libsymbol_check.a ../lib/libMESA_socket_wrap.a ../lib/libiknow.a
-endif
-
-WHOLE_ARCH += ../lib/libtomlc99_wrap.a
-WHOLE_ARCH += ../lib/libconfig.a
-WHOLE_ARCH += ../lib/libtimer.a
-
-ifeq ($(debug), $(_DEBUG2))
-LIB += ../lib/libiknow.a -lpcap
-endif
-
-ifeq ($(IIEFD_DUAL_STACK), $(YES))
-CFLAGS += -g -DIIEFD_DUAL_STACK=1
-endif
-ifeq ($(iomode), $(_MODE_DPDK))
-CFLAGS += -DIOMODE_DPDK=1
-endif
-
-INC += -I../../include/
-INC += -I../../include/public
-INC += -I../../include/private
-INC += -I../../include/support
-INC+=-I/opt/MESA/include
-INC+=-I/opt/MESA/include/MESA
-INC+=-I/opt/MESA/include/MESA/stream_inc
-
-LIB += -L/opt/MESA/lib -lpthread -ldl
-LIB += -lMESA_htable -lMESA_handle_logger -lMESA_prof_load
-LIB += -lMESA_field_stat2
-#LIB += -lsapp_assistant
-LIB += -lcjson
-#LIB += -lsesame_door
-LIB += -l event
-
-ifeq ($(iomode), $(_MODE_MARSIO))
-LIB += -lmarsio
-endif
-
-#DEP=support/libMESA_prof_load.so
-#DEP+=support/libMESA_htable.so
-#DEP+=support/libnet_common.so
-#DEP+=support/old_Profile.so
-#DEP+=support/libMESA_handle_logger.so
-#DEP+=support/liblogger.so
-
-iiefd_dual_stack: sapp_main.o sapp_init.o
-
-sapp:sapp_main.o sapp_init.o sapp_global_val.o
- g++ -g -Wl,--export-dynamic -o $@ $(CFLAGS) $(INC) $^ $(LDFLAGS) $(LIB_PATH) -Wl,--whole-archive $(WHOLE_ARCH) -Wl,--no-whole-archive $(LIB)
- cp ../packet_io/*.so ../../bin/platform_lib/;
- cp $@ ../../bin/;
-
-MESA_IP_PLUG.so:sapp_plug.o sapp_init.o sapp_global_val.o
- g++ -g -o $@ -fPIC -shared $^ -Wl,--whole-archive $(WHOLE_ARCH) -Wl,--no-whole-archive $(LIB)
- cp $@ ../../bin/
- cp $@ /opt/MESA/lib/libMESA_IP_PLUG.so
-sapp_plug.o:sapp_plug.c
- g++ -c -g -o $@ -fPIC $^ $(INC) -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DSAPP_AS_TARGET_SO=1
-.c.o:
- $(CC) -c $(CFLAGS) -I. $(INC) $<
-
-.cpp.o:
- $(CCC) -c $(CFLAGS) -I. $(INC) $<
-
-clean:
- rm -f $(TARGET) *.o
diff --git a/src/extensions/CMakeLists.txt b/src/extensions/CMakeLists.txt
index 897f33c..86581af 100644
--- a/src/extensions/CMakeLists.txt
+++ b/src/extensions/CMakeLists.txt
@@ -26,14 +26,9 @@ set_target_properties(isakmp_protocol_plug PROPERTIES PREFIX "")
add_library(inline_keepalive STATIC inline_keepalive.cpp)
-if(ENABLE_STATIC_LINK)
- add_library(sapp_assistant STATIC sapp_assistant.cpp)
- add_library(gdev_assistant STATIC gdev_assistant.c)
-else()
- add_definitions(-fPIC)
- add_library(sapp_assistant SHARED sapp_assistant.cpp)
- add_library(gdev_assistant SHARED gdev_assistant.c)
- install(TARGETS sapp_assistant DESTINATION ${MESA_SDK_PREFIX}/lib/)
- install(TARGETS gdev_assistant DESTINATION ${MESA_SDK_PREFIX}/lib/)
-endif()
+add_library(sapp_assistant STATIC sapp_assistant.cpp)
+add_library(gdev_assistant STATIC gdev_assistant.c)
+
+add_library(sapp_metrics STATIC sapp_metrics.cpp)
+
diff --git a/src/extensions/Makefile b/src/extensions/Makefile
deleted file mode 100644
index 4642a90..0000000
--- a/src/extensions/Makefile
+++ /dev/null
@@ -1,150 +0,0 @@
-#opt: OPTFLAGS = -O2
-#export OPTFLAGS
-
-#CC = g++
-#CCC = g++
-CFLAGS += -Wall
-CFLAGS += -g -fPIC -shared -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H
-CFLAGS += $(OPTFLAGS)
-CFLAGS += -DPLATFORM_NSDPF_PAPP=1
-
-
-RELEASE_PLT_PATH=../../bin/plug/platform
-RELEASE_PRO_PATH=../../bin/plug/protocol
-RELEASE_BIZ_PATH=../../bin/plug/business
-
-H_DIR += $(INC)
-H_DIR += -I../../include/
-H_DIR += -I../../include/public
-H_DIR += -I../../include/private
-H_DIR += -I../../include/support
-H_DIR += -I/opt/MESA/include
-H_DIR += -I/opt/MESA/include/MESA
-H_DIR += -I/opt/mrzcpd/include
-
-LIB=-L/opt/MESA/lib -L/opt/mrzcpd/lib
-
-TARGET = isakmp_protocol_plug.so ipsec_biz_sample.so l2tp_protocol_plug.so l2tp_biz_sample.so
-TARGET += pptp_protocol_plug.so pptp_biz_sample.so
-TARGET += g_device_plug.so
-TARGET += wy_keepalive_plug.so
-
-OBJS=
-
-ifeq ($(link_mode), $(__LINK_MODE_STATIC))
- OBJS += sapp_assistant.o
- TARGET += libinner_plug.a
-else
- TARGET += libsapp_assistant.so
-endif
-
-
-ifeq ($(iomode), $(_MODE_PCAP))
-CFLAGS += -DIOMODE_PCAP=1
-endif
-
-ifeq ($(iomode), $(_MODE_PAG))
-CFLAGS += -DIOMODE_PAG=1
-endif
-
-ifeq ($(iomode), $(_MODE_PPF))
-CFLAGS += -DIOMODE_PPF=1
-endif
-
-ifeq ($(iomode), $(_MODE_PFRING))
-CFLAGS += -DIOMODE_PFRING=1
-endif
-
-ifeq ($(iomode), $(_MODE_DPDK))
-CFLAGS += -DIOMODE_DPDK=1
-endif
-
-ifeq ($(iomode), $(_MODE_TOPSEC))
-CFLAGS += -DIOMODE_TOPSEC=1
-endif
-
-ifeq ($(iomode), $(_MODE_IPFILE))
-CFLAGS += -DIOMODE_IPFILE=1
-endif
-
-ifeq ($(iomode), $(_MODE_MARSIO))
-CFLAGS += -DIOMODE_MARSIO=1
-LIB += -lmarsio
-endif
-
-ifeq ($(iomode), $(_MODE_SMITH))
-CFLAGS += -DIOMODE_SMITH=1
-endif
-
-all: $(TARGET)
-
-libinner_plug.a:sapp_assistant.o gdev_assistant.o
- rm -f $@;
- ar -r $@ $^;
- cp $@ ../lib;
-
-.c.o:
- $(CC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-.cpp.o:
- $(CCC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-
-#isakmp_protocol_plug.so:isakmp_protocol_plug.o
-isakmp_protocol_plug.so:isakmp_protocol_plug_add_nat.o
- $(CC) -o $@ -fPIC -shared -g -Wall $^;
- mkdir -p $(RELEASE_PRO_PATH)/isakmp_protocol_plug;
- cp $@ $(RELEASE_PRO_PATH)/isakmp_protocol_plug/ ;
-
-ipsec_biz_sample.so:ipsec_biz_sample.o
- $(CC) -o $@ -fPIC -shared -g -Wall $^;
- mkdir -p $(RELEASE_BIZ_PATH)/ipsec_biz_sample;
- cp $@ $(RELEASE_BIZ_PATH)/ipsec_biz_sample/ ;
-
-l2tp_protocol_plug.so:l2tp_protocol_plug.o
- $(CC) -o $@ -fPIC -shared -g -Wall $^;
- mkdir -p $(RELEASE_PRO_PATH)/l2tp_protocol_plug;
- cp $@ $(RELEASE_PRO_PATH)/l2tp_protocol_plug/ ;
-
-l2tp_biz_sample.so:l2tp_biz_sample.o
- $(CC) -o $@ -fPIC -shared -g -Wall $^;
- mkdir -p $(RELEASE_BIZ_PATH)/l2tp_biz_sample;
- cp $@ $(RELEASE_BIZ_PATH)/l2tp_biz_sample/ ;
-
-pptp_protocol_plug.so:pptp_protocol_plug.o
- $(CC) -o $@ -fPIC -shared -g -Wall $^;
- mkdir -p $(RELEASE_PRO_PATH)/pptp_protocol_plug;
- cp $@ $(RELEASE_PRO_PATH)/pptp_protocol_plug/ ;
-
-pptp_biz_sample.so:pptp_biz_sample.o
- $(CC) -o $@ -fPIC -shared -g -Wall $^;
- mkdir -p $(RELEASE_BIZ_PATH)/pptp_biz_sample;
- cp $@ $(RELEASE_BIZ_PATH)/pptp_biz_sample/ ;
-
-g_device_plug.so: g_device_plug.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES);
- mkdir -p $(RELEASE_PLT_PATH)/g_device_plug;
- cp $@ $(RELEASE_PLT_PATH)/g_device_plug/
-
-wy_keepalive_plug.so:wy_keepalive_plug.c
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES) $(H_DIR) $(LIB);
- mkdir -p $(RELEASE_PLT_PATH)/wy_keepalive_plug;
-
-libsapp_assistant.so: sapp_assistant.o gdev_assistant.o
- mkdir -p /opt/MESA/lib;
- cp ../lib/libc3client.so /opt/MESA/lib/;
- ldconfig;
- $(CC) -o $@ -shared -fPIC $(H_DIR) $(CFLAGS) $^ $(MODULES) -L/opt/MESA/lib -lMESA_field_stat2;
-
-
-libanti_flood_hijack.so:anti_flood_plug.o anti_flood_hijack.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES);
- mkdir -p $(RELEASE_BIZ_PATH)/anti_flood;
- cp $@ $(RELEASE_BIZ_PATH)/anti_flood/;
- cp $@ /opt/MESA/lib/libanti_flood_hijack.so;
-
-clean:
- rm -f *.o *.so *.a $(TARGET)
-
-opt:
- $(MAKE) all
diff --git a/src/extensions/sapp_assistant.cpp b/src/extensions/sapp_assistant.cpp
index 666605e..4ad351a 100644
--- a/src/extensions/sapp_assistant.cpp
+++ b/src/extensions/sapp_assistant.cpp
@@ -6,13 +6,11 @@
#include "sapp_api.h"
#include "sapp_private_api.h"
#include "sapp_declaration.h"
-#include "field_stat2.h"
-#include "fieldstat.h"
+
#include "marsio.h"
-static int sapp_fs2_init(sapp_global_t *global_parameters);
-static int sapp_fs3_init(sapp_global_t *global_parameters);
+
//extern time_t g_CurrentTime;//add by lqy 20070606
//extern int g_packet_io_thread_num;
@@ -25,7 +23,6 @@ static pthread_t *g_plug_Independent_thread_pid;
static const unsigned char G_BROADCAST_ADDR[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
-int sapp_assistant_version_VERSION_20181024;
extern "C" int MESA_get_dev_ipv4(const char *device, int *ip_add);
extern "C" int MESA_get_dev_mac(const char *device, unsigned char mac[6]);
@@ -872,136 +869,6 @@ extern "C" int sapp_get_device_opt(const char *device, enum sapp_device_opt opt_
return ret;
}
-void sapp_fs2_update_count(int field_index, unsigned long long value)
-{
- if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
- FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
- sapp_global_val->individual_fixed.fs2_runtime.fs_id_count_array[field_index],
- 0, FS_OP_SET, (long long)value);
- }
-}
-
-void sapp_fs2_update_length(int field_index, unsigned long long value)
-{
- if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
- FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
- sapp_global_val->individual_fixed.fs2_runtime.fs_id_length_array[field_index],
- 0, FS_OP_SET, (long long)value);
- }
-}
-
-
-void sapp_fs2_set_latency(int thead_seq, long long time_cost)
-{
- if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
- FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
- sapp_global_val->individual_fixed.fs2_runtime.fs_latency_id_array[thead_seq],
- 0, FS_OP_SET, time_cost);
- }
-}
-
-
-void sapp_fs2_set_plug_entry_latency(int entry_id, long long time_cost)
-{
- if(unlikely(entry_id < 0 || entry_id >= SAPP_MAX_PLUG_ENTRY_NUM)){
- return;
- }
- if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
- FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
- sapp_global_val->individual_fixed.fs2_runtime.fs_latency_plug_entrg_id_array[entry_id],
- 0, FS_OP_SET, time_cost);
- }
-}
-
-/*
- ģ�������������ʱ, ����ÿ����������һ��FS_operate(),
- ��sapp timer�߳�ÿ��һ��ʱ�����sapp_fuzzy_latency_update(), ����filed_stat2����.
-*/
-extern "C" void sapp_fs2_fuzzy_latency_update_per_thread(int thead_seq, long long time_cost)
-{
- sapp_fuzzy_latency_stat_t *this_thread_stat = &sapp_global_val->mthread_volatile[thead_seq]->fuzzy_pkt_latency_stat_per_thread;
-
- if(time_cost < this_thread_stat->min_time_cost){
- this_thread_stat->min_time_cost = time_cost;
- }
-
- if(time_cost > this_thread_stat->max_time_cost){
- this_thread_stat->max_time_cost = time_cost;
- }
-
- this_thread_stat->time_cost_sum += time_cost;
- this_thread_stat->stat_count++;
-}
-
-extern "C" void sapp_fs2_fuzzy_latency_update_per_entry(int thead_seq, int entry_id, long long time_cost)
-{
- sapp_fuzzy_latency_stat_t *this_thread_stat;
- if(unlikely(entry_id < 0 || entry_id >= SAPP_MAX_PLUG_ENTRY_NUM)){
- return;
- }
-
- this_thread_stat = &sapp_global_val->mthread_volatile[thead_seq]->fuzzy_pkt_latency_stat_per_entry_per_thread[entry_id];
-
- if(time_cost < this_thread_stat->min_time_cost){
- this_thread_stat->min_time_cost = time_cost;
- }
-
- if(time_cost > this_thread_stat->max_time_cost){
- this_thread_stat->max_time_cost = time_cost;
- }
-
- this_thread_stat->time_cost_sum += time_cost;
- this_thread_stat->stat_count++;
-
-}
-
-
-/*
- ��sapp timer�����̵߳���, ÿ��һ��ʱ��, �����۵İ�������ʱ����ˢ�¸�field_stat2.
-*/
-void sapp_fuzzy_latency_update(void)
-{
- int tid, entry_id, this_stat_count;
- long long min_latency, max_latency;
- double avg_latency;
- sapp_fuzzy_latency_stat_t *this_thread_stat, *this_entry_stat;
-
- for(tid = 0; tid < g_packet_io_thread_num; tid++){
- this_thread_stat = &sapp_global_val->mthread_volatile[tid]->fuzzy_pkt_latency_stat_per_thread;
- avg_latency = (double)this_thread_stat->time_cost_sum/(double)this_thread_stat->stat_count;
- min_latency = this_thread_stat->min_time_cost;
- max_latency = this_thread_stat->max_time_cost;
- this_stat_count = this_thread_stat->stat_count;
-
- if(this_stat_count > 0){
- memset(this_thread_stat, 0, sizeof(sapp_fuzzy_latency_stat_t));
- this_thread_stat->min_time_cost = 999999999; /* Ҫ��¼��Сֵ, ��ʼ��Ҫ������ֵ */
-
- /* ÿ�θ�������ֵ, ���,��С��ƽ��ֵ */
- sapp_fs2_set_latency(tid, min_latency);
- sapp_fs2_set_latency(tid, max_latency);
- sapp_fs2_set_latency(tid, (long long)avg_latency);
- }
-
- for(entry_id = 1; entry_id < g_plug_global_entry_index; entry_id++){
- this_entry_stat = &sapp_global_val->mthread_volatile[tid]->fuzzy_pkt_latency_stat_per_entry_per_thread[entry_id];
- avg_latency = (double)this_entry_stat->time_cost_sum/(double)this_entry_stat->stat_count;
- min_latency = this_entry_stat->min_time_cost;
- max_latency = this_entry_stat->max_time_cost;
- this_stat_count = this_entry_stat->stat_count;
- if(this_stat_count > 0){
- memset(this_entry_stat, 0, sizeof(sapp_fuzzy_latency_stat_t));
- this_entry_stat->min_time_cost = 999999999; /* Ҫ��¼��Сֵ, ��ʼ��Ҫ������ֵ */
-
- sapp_fs2_set_latency(tid, min_latency);
- sapp_fs2_set_latency(tid, max_latency);
- sapp_fs2_set_plug_entry_latency(entry_id, (long long)avg_latency);
- }
- }
- }
-}
-
-
int sapp_independent_thread_init(void)
{
pthread_mutex_init(&g_plug_Independent_thread_mutex, NULL);
@@ -1012,298 +879,3 @@ int sapp_independent_thread_init(void)
return 0;
}
-
-int sapp_metric_init(void)
-{
- int ret = 0;
- if( sapp_global_val->config.profiling.fs2.enabled == 1)
- {
- sapp_fs2_init(sapp_global_val);
- }
- if( sapp_global_val->config.profiling.fs3.enabled == 1)
- {
- sapp_fs3_init(sapp_global_val);
- }
-
- return ret;
-}
-
-
-static int fs2_plug_entry_historgram_init(sapp_gval_individual_fixed_fs_t *fs_rt)
-{
- int i;
- /* 0������sapp���ò��, index��1��ʼ */
- for(i = 1; i < g_plug_global_entry_index; i++){
- fs_rt->fs_latency_plug_entrg_id_array[i] = FS_register_histogram(fs_rt->fs_metric_handle, //Field Stat���
- FS_CALC_SPEED, //����ۼ�ֵ��˲ʱֵ
- g_plug_global_entry[i].plug_entry_name, //ͳ�������ƣ��ַ���
- 1, //��׷�ٵ���Сֵ
- 1000000, //��׷�ٵ����ֵ
- 2); //���ȣ���С�����λ����Χ1~4
- if(fs_rt->fs_latency_plug_entrg_id_array[i] < 0){
- sapp_runtime_log(RLOG_LV_FATAL, "FS_register_histogram() error, plug name:%s", g_plug_global_entry[i].plug_entry_name);
- return -1;
- }
- }
-
- return 0;
-}
-
-void sapp_fs2_set_tcp_unorder_historgram(int thead_seq, long long unorder_num)
-{
- if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
- FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
- sapp_global_val->individual_fixed.fs2_runtime.fs_tcp_unorder_id_array[thead_seq],
- 0, FS_OP_SET, unorder_num);
- }
-}
-
-static int fs2_tcp_unorder_historgram_init(sapp_gval_individual_fixed_fs_t *fs_rt)
-{
- int i;
- char histogram_name[16];
- /* 0������sapp���ò��, index��1��ʼ */
- for (i = 1; i < g_packet_io_thread_num; i++)
- {
- sprintf(histogram_name, "OoO_num(tid_%d)", i);
- fs_rt->fs_tcp_unorder_id_array[i] =
- FS_register_histogram(fs_rt->fs_metric_handle, // Field Stat���
- FS_CALC_SPEED, //����ۼ�ֵ��˲ʱֵ
- histogram_name, //ͳ�������ƣ��ַ���
- 1, //��׷�ٵ���Сֵ
- 65536, //��׷�ٵ����ֵ
- 2); //���ȣ���С�����λ����Χ1~4
- if (fs_rt->fs_tcp_unorder_id_array[i] < 0)
- {
- sapp_runtime_log(RLOG_LV_FATAL, "FS_fs2_tcp_unorder_historgram_init() error, name:%s",
- histogram_name);
- return -1;
- }
- }
-
- return 0;
-}
-
-/************************ C++ compiler **************************************/
-static int sapp_fs2_init(sapp_global_t *global_paramters)
-{
- void *fs2_handle=NULL;
- int fs2_opt;
- sapp_gval_individual_fixed_fs_t *p_fs2_rt = &global_paramters->individual_fixed.fs2_runtime;
- sapp_config_profiling_metric_t *p_fs2_para = &global_paramters->config.profiling.fs2;
- int fs2_local_enabled = 0;
- int fs2_prometheus_enabled = 0;
-
- if(strlen(p_fs2_para->local_file) > 0)
- {
- fs2_local_enabled = 1;
- }
- if(strlen(p_fs2_para->prometheus_service_uri) > 0 && p_fs2_para->prometheus_service_port > 0)
- {
- fs2_prometheus_enabled = 1;
- }
-
- p_fs2_rt->fs_metric_handle = FS_create_handle();
- if(NULL == p_fs2_rt->fs_metric_handle){
- sapp_log(RLOG_LV_FATAL, 30, 30, "FS_create_handle() error: %s!\n", strerror(errno));
- return -1;
- }
- fs2_handle = p_fs2_rt->fs_metric_handle;
- if(fs2_prometheus_enabled){
- FS_library_set_prometheus_port((unsigned short)p_fs2_para->prometheus_service_port);
- FS_library_set_prometheus_url_path(p_fs2_para->prometheus_service_uri);
- if(FS_library_init() < 0){
- sapp_log(RLOG_LV_FATAL, 30, 30, "FS_library_init() error, port:%d, url:%s\n",
- p_fs2_para->prometheus_service_port,
- p_fs2_para->prometheus_service_uri);
- return -1;
- }
- fs2_opt = 1;
- FS_set_para(fs2_handle, OUTPUT_PROMETHEUS, &fs2_opt, sizeof(int));
- }
-
- FS_set_para(fs2_handle, STAT_CYCLE, &p_fs2_para->refresh_interval_s, sizeof(int));
-
- fs2_opt = 1; /* 1:Rewrite ,2: Append. */
- FS_set_para(fs2_handle, PRINT_MODE, &fs2_opt, sizeof(int));
-
- fs2_opt = 1;
- FS_set_para(fs2_handle, PRINT_TRIGGER, &fs2_opt, sizeof(int));
-
- fs2_opt = 1;
- FS_set_para(fs2_handle, NOT_SEND_METRIC_TO_SERVER, &fs2_opt, sizeof(int));
-
- if(fs2_local_enabled){
- FS_set_para(fs2_handle, OUTPUT_DEVICE, ABBR_FS2_LOG_DATA_FILE, strlen(ABBR_FS2_LOG_DATA_FILE)+1);
- }else{
- sapp_log(RLOG_LV_INFO, 10, 10, "profiling.log.local.enabled is 0, not save local stat log file.\n");
- FS_set_para(fs2_handle, OUTPUT_DEVICE, "/dev/null", strlen("/dev/null") + 1);
- }
- FS_set_para(fs2_handle, APP_NAME, sapp_global_val->config.system.instance_name, strlen(sapp_global_val->config.system.instance_name)+1);
-
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_LINE] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Line_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_LINE] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Line_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Bit");
-
- if((DEPOLYMENT_MODE_INLINE == sapp_global_val->config.packet_io.depolyment_mode_bin)
- || (DEPOLYMENT_MODE_TRANSPARENT == sapp_global_val->config.packet_io.depolyment_mode_bin)){
- p_fs2_rt->fs_id_count_array[SAPP_STAT_ETH_INBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Pkt_Inbound");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_ETH_INBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Bit_Inbound");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_ETH_OUTBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Pkt_Outbound");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_ETH_OUTBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Bit_Outbound");
- }
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_ERROR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Snd_Err_Pkt");
- //pfs_para->fs_id_length_array[SAPP_STAT_SND_ERROR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Snd_Err_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_IPV4] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv4_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_IPV4] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv4_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_IPV6] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv6_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_IPV6] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv6_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bit");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_DUP_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Tcp_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_DUP_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Tcp_Bit");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_LOST_PKT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Lost_Bit");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_LOST_PKT_STREAM_NUM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Lost_STM");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_DUP_IDENTIFY_ERR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Key_Err"); /* dup�ظ���ʶ������key������� */
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_CLOSE_BY_TIMEOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Close_byT");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_CLOSE_BY_KICKOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Close_byK");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bit");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_DUP_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Udp_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_DUP_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Udp_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_CLOSE_BY_TIMEOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Close_byT");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_CLOSE_BY_KICKOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Close_byK");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_NEW] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Link_New");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DEL] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Link_Del");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DATA] = FS_register(fs2_handle, FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Concurrent");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_NEW] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Link_New");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_DEL] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Link_Del");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_MORE] = FS_register(fs2_handle, FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Concurrent");
-
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Tcp_Link_Double");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_C2S");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_S2C");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Tcp_Link_Double_ALL");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_C2S_ALL");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_S2C_ALL");
-
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Udp_Link_Double");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_C2S");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_S2C");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Udp_Link_Double_ALL");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_C2S_ALL");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_S2C_ALL");
-
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_TCP_RST] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Tcp_Rst");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_TCP_SYNACK] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Tcp_S/A");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Udp");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_GLOBAL_BYPASS] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "DDOS_Bypass");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_BYPASS_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_STM");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_BYPASS_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_BYPASS_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_BYPASS_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_STM");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_BYPASS_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_UDP_BYPASS_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_OFFLOAD_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_STM");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_OFFLOAD_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_OFFLOAD_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_Bit");
-
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_OFFLOAD_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_STM");
- p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_OFFLOAD_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_Pkt");
- p_fs2_rt->fs_id_length_array[SAPP_STAT_UDP_OFFLOAD_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_Bit");
-
- if (unlikely(g_timestamp_record_sw))
- {
- if (fs2_tcp_unorder_historgram_init(p_fs2_rt) < 0)
- {
- return -1;
- }
- for (int i = 0; i < g_packet_io_thread_num; i++)
- {
- char histogram_name[16];
- sprintf(histogram_name, "TD_ns(tid_%d)", i);
- p_fs2_rt->fs_latency_id_array[i] = FS_register_histogram(fs2_handle, // Field Stat���
- FS_CALC_SPEED, //����ۼ�ֵ��˲ʱֵ
- histogram_name, //ͳ�������ƣ��ַ���
- 1, //��׷�ٵ���Сֵ
- 1000000, //��׷�ٵ����ֵ
- 2); //���ȣ���С�����λ����Χ1~4
- FS_set_para(fs2_handle, NOT_SEND_METRIC_TO_SERVER, &p_fs2_rt->fs_latency_id_array[i], sizeof(int));
- }
-
- if (fs2_plug_entry_historgram_init(p_fs2_rt) < 0)
- {
- return -1;
- }
- }
- FS_start(fs2_handle);
-
- return 0;
-}
-
-static void sapp_fs2_destroy(sapp_global_t *global_paramters)
-{
- sapp_config_profiling_metric_t *p_fs2_para = &global_paramters->config.profiling.fs2;
- sapp_gval_individual_fixed_fs_t *p_fs2_rt = &global_paramters->individual_fixed.fs2_runtime;
- if (strlen(p_fs2_para->prometheus_service_uri) > 0 && p_fs2_para->prometheus_service_port > 0)
- {
- FS_library_destroy();
- }
-
- if (p_fs2_rt->fs_metric_handle)
- {
- FS_stop(&p_fs2_rt->fs_metric_handle);
- }
-}
-
-static int sapp_fs3_init(sapp_global_t *global_paramters)
-{
- sapp_config_profiling_metric_t *p_fs3_para = &global_paramters->config.profiling.fs3;
- sapp_gval_individual_fixed_fs_t *p_fs3_rt = &global_paramters->individual_fixed.fs3_runtime;
- return 0;
-}
-
-static void sapp_fs3_destroy(sapp_global_t *global_paramters)
-{
- return;
-}
-
-void sapp_metric_destroy(void)
-{
-
- if( sapp_global_val->config.profiling.fs2.enabled == 1)
- {
- sapp_fs2_destroy(sapp_global_val);
- }
- if( sapp_global_val->config.profiling.fs3.enabled == 1)
- {
- sapp_fs3_destroy(sapp_global_val);
- }
-}
-
-
diff --git a/src/extensions/sapp_metrics.cpp b/src/extensions/sapp_metrics.cpp
new file mode 100644
index 0000000..6fd1f63
--- /dev/null
+++ b/src/extensions/sapp_metrics.cpp
@@ -0,0 +1,433 @@
+#include "field_stat2.h"
+#include "fieldstat.h"
+
+#include "sapp_declaration.h"
+
+static int sapp_fs2_init(sapp_global_t *global_parameters);
+static int sapp_fs3_init(sapp_global_t *global_parameters);
+
+
+void sapp_fs2_update_count(int field_index, unsigned long long value)
+{
+ if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
+ FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
+ sapp_global_val->individual_fixed.fs2_runtime.fs_id_count_array[field_index],
+ 0, FS_OP_SET, (long long)value);
+ }
+}
+
+void sapp_fs2_update_length(int field_index, unsigned long long value)
+{
+ if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
+ FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
+ sapp_global_val->individual_fixed.fs2_runtime.fs_id_length_array[field_index],
+ 0, FS_OP_SET, (long long)value);
+ }
+}
+
+
+void sapp_fs2_set_latency(int thead_seq, long long time_cost)
+{
+ if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
+ FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
+ sapp_global_val->individual_fixed.fs2_runtime.fs_latency_id_array[thead_seq],
+ 0, FS_OP_SET, time_cost);
+ }
+}
+
+
+void sapp_fs2_set_plug_entry_latency(int entry_id, long long time_cost)
+{
+ if(unlikely(entry_id < 0 || entry_id >= SAPP_MAX_PLUG_ENTRY_NUM)){
+ return;
+ }
+ if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
+ FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
+ sapp_global_val->individual_fixed.fs2_runtime.fs_latency_plug_entrg_id_array[entry_id],
+ 0, FS_OP_SET, time_cost);
+ }
+}
+
+/*
+ ģ�������������ʱ, ����ÿ����������һ��FS_operate(),
+ ��sapp timer�߳�ÿ��һ��ʱ�����sapp_fuzzy_latency_update(), ����filed_stat2����.
+*/
+extern "C" void sapp_fs2_fuzzy_latency_update_per_thread(int thead_seq, long long time_cost)
+{
+ sapp_fuzzy_latency_stat_t *this_thread_stat = &sapp_global_val->mthread_volatile[thead_seq]->fuzzy_pkt_latency_stat_per_thread;
+
+ if(time_cost < this_thread_stat->min_time_cost){
+ this_thread_stat->min_time_cost = time_cost;
+ }
+
+ if(time_cost > this_thread_stat->max_time_cost){
+ this_thread_stat->max_time_cost = time_cost;
+ }
+
+ this_thread_stat->time_cost_sum += time_cost;
+ this_thread_stat->stat_count++;
+}
+
+extern "C" void sapp_fs2_fuzzy_latency_update_per_entry(int thead_seq, int entry_id, long long time_cost)
+{
+ sapp_fuzzy_latency_stat_t *this_thread_stat;
+ if(unlikely(entry_id < 0 || entry_id >= SAPP_MAX_PLUG_ENTRY_NUM)){
+ return;
+ }
+
+ this_thread_stat = &sapp_global_val->mthread_volatile[thead_seq]->fuzzy_pkt_latency_stat_per_entry_per_thread[entry_id];
+
+ if(time_cost < this_thread_stat->min_time_cost){
+ this_thread_stat->min_time_cost = time_cost;
+ }
+
+ if(time_cost > this_thread_stat->max_time_cost){
+ this_thread_stat->max_time_cost = time_cost;
+ }
+
+ this_thread_stat->time_cost_sum += time_cost;
+ this_thread_stat->stat_count++;
+
+}
+
+
+/*
+ ��sapp timer�����̵߳���, ÿ��һ��ʱ��, �����۵İ�������ʱ����ˢ�¸�field_stat2.
+*/
+void sapp_fuzzy_latency_update(void)
+{
+ int tid, entry_id, this_stat_count;
+ long long min_latency, max_latency;
+ double avg_latency;
+ sapp_fuzzy_latency_stat_t *this_thread_stat, *this_entry_stat;
+
+ for(tid = 0; tid < g_packet_io_thread_num; tid++){
+ this_thread_stat = &sapp_global_val->mthread_volatile[tid]->fuzzy_pkt_latency_stat_per_thread;
+ avg_latency = (double)this_thread_stat->time_cost_sum/(double)this_thread_stat->stat_count;
+ min_latency = this_thread_stat->min_time_cost;
+ max_latency = this_thread_stat->max_time_cost;
+ this_stat_count = this_thread_stat->stat_count;
+
+ if(this_stat_count > 0){
+ memset(this_thread_stat, 0, sizeof(sapp_fuzzy_latency_stat_t));
+ this_thread_stat->min_time_cost = 999999999; /* Ҫ��¼��Сֵ, ��ʼ��Ҫ������ֵ */
+
+ /* ÿ�θ�������ֵ, ���,��С��ƽ��ֵ */
+ sapp_fs2_set_latency(tid, min_latency);
+ sapp_fs2_set_latency(tid, max_latency);
+ sapp_fs2_set_latency(tid, (long long)avg_latency);
+ }
+
+ for(entry_id = 1; entry_id < g_plug_global_entry_index; entry_id++){
+ this_entry_stat = &sapp_global_val->mthread_volatile[tid]->fuzzy_pkt_latency_stat_per_entry_per_thread[entry_id];
+ avg_latency = (double)this_entry_stat->time_cost_sum/(double)this_entry_stat->stat_count;
+ min_latency = this_entry_stat->min_time_cost;
+ max_latency = this_entry_stat->max_time_cost;
+ this_stat_count = this_entry_stat->stat_count;
+ if(this_stat_count > 0){
+ memset(this_entry_stat, 0, sizeof(sapp_fuzzy_latency_stat_t));
+ this_entry_stat->min_time_cost = 999999999; /* Ҫ��¼��Сֵ, ��ʼ��Ҫ������ֵ */
+
+ sapp_fs2_set_latency(tid, min_latency);
+ sapp_fs2_set_latency(tid, max_latency);
+ sapp_fs2_set_plug_entry_latency(entry_id, (long long)avg_latency);
+ }
+ }
+ }
+}
+
+
+
+
+int sapp_metric_init(void)
+{
+ int ret = 0;
+ if( sapp_global_val->config.profiling.fs2.enabled == 1)
+ {
+ sapp_fs2_init(sapp_global_val);
+ }
+ if( sapp_global_val->config.profiling.fs3.enabled == 1)
+ {
+ sapp_fs3_init(sapp_global_val);
+ }
+
+ return ret;
+}
+
+
+static int fs2_plug_entry_historgram_init(sapp_gval_individual_fixed_fs_t *fs_rt)
+{
+ int i;
+ /* 0������sapp���ò��, index��1��ʼ */
+ for(i = 1; i < g_plug_global_entry_index; i++){
+ fs_rt->fs_latency_plug_entrg_id_array[i] = FS_register_histogram(fs_rt->fs_metric_handle, //Field Stat���
+ FS_CALC_SPEED, //����ۼ�ֵ��˲ʱֵ
+ g_plug_global_entry[i].plug_entry_name, //ͳ�������ƣ��ַ���
+ 1, //��׷�ٵ���Сֵ
+ 1000000, //��׷�ٵ����ֵ
+ 2); //���ȣ���С�����λ����Χ1~4
+ if(fs_rt->fs_latency_plug_entrg_id_array[i] < 0){
+ sapp_runtime_log(RLOG_LV_FATAL, "FS_register_histogram() error, plug name:%s", g_plug_global_entry[i].plug_entry_name);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+void sapp_fs2_set_tcp_unorder_historgram(int thead_seq, long long unorder_num)
+{
+ if(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle != NULL){
+ FS_operate(sapp_global_val->individual_fixed.fs2_runtime.fs_metric_handle,
+ sapp_global_val->individual_fixed.fs2_runtime.fs_tcp_unorder_id_array[thead_seq],
+ 0, FS_OP_SET, unorder_num);
+ }
+}
+
+static int fs2_tcp_unorder_historgram_init(sapp_gval_individual_fixed_fs_t *fs_rt)
+{
+ int i;
+ char histogram_name[16];
+ /* 0������sapp���ò��, index��1��ʼ */
+ for (i = 1; i < g_packet_io_thread_num; i++)
+ {
+ sprintf(histogram_name, "OoO_num(tid_%d)", i);
+ fs_rt->fs_tcp_unorder_id_array[i] =
+ FS_register_histogram(fs_rt->fs_metric_handle, // Field Stat���
+ FS_CALC_SPEED, //����ۼ�ֵ��˲ʱֵ
+ histogram_name, //ͳ�������ƣ��ַ���
+ 1, //��׷�ٵ���Сֵ
+ 65536, //��׷�ٵ����ֵ
+ 2); //���ȣ���С�����λ����Χ1~4
+ if (fs_rt->fs_tcp_unorder_id_array[i] < 0)
+ {
+ sapp_runtime_log(RLOG_LV_FATAL, "FS_fs2_tcp_unorder_historgram_init() error, name:%s",
+ histogram_name);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+/************************ C++ compiler **************************************/
+static int sapp_fs2_init(sapp_global_t *global_paramters)
+{
+ void *fs2_handle=NULL;
+ int fs2_opt;
+ sapp_gval_individual_fixed_fs_t *p_fs2_rt = &global_paramters->individual_fixed.fs2_runtime;
+ sapp_config_profiling_metric_t *p_fs2_para = &global_paramters->config.profiling.fs2;
+ int fs2_local_enabled = 0;
+ int fs2_prometheus_enabled = 0;
+
+ if(strlen(p_fs2_para->local_file) > 0)
+ {
+ fs2_local_enabled = 1;
+ }
+ if(strlen(p_fs2_para->prometheus_service_uri) > 0 && p_fs2_para->prometheus_service_port > 0)
+ {
+ fs2_prometheus_enabled = 1;
+ }
+
+ p_fs2_rt->fs_metric_handle = FS_create_handle();
+ if(NULL == p_fs2_rt->fs_metric_handle){
+ sapp_log(RLOG_LV_FATAL, 30, 30, "FS_create_handle() error: %s!\n", strerror(errno));
+ return -1;
+ }
+ fs2_handle = p_fs2_rt->fs_metric_handle;
+ if(fs2_prometheus_enabled){
+ FS_library_set_prometheus_port((unsigned short)p_fs2_para->prometheus_service_port);
+ FS_library_set_prometheus_url_path(p_fs2_para->prometheus_service_uri);
+ if(FS_library_init() < 0){
+ sapp_log(RLOG_LV_FATAL, 30, 30, "FS_library_init() error, port:%d, url:%s\n",
+ p_fs2_para->prometheus_service_port,
+ p_fs2_para->prometheus_service_uri);
+ return -1;
+ }
+ fs2_opt = 1;
+ FS_set_para(fs2_handle, OUTPUT_PROMETHEUS, &fs2_opt, sizeof(int));
+ }
+
+ FS_set_para(fs2_handle, STAT_CYCLE, &p_fs2_para->refresh_interval_s, sizeof(int));
+
+ fs2_opt = 1; /* 1:Rewrite ,2: Append. */
+ FS_set_para(fs2_handle, PRINT_MODE, &fs2_opt, sizeof(int));
+
+ fs2_opt = 1;
+ FS_set_para(fs2_handle, PRINT_TRIGGER, &fs2_opt, sizeof(int));
+
+ fs2_opt = 1;
+ FS_set_para(fs2_handle, NOT_SEND_METRIC_TO_SERVER, &fs2_opt, sizeof(int));
+
+ if(fs2_local_enabled){
+ FS_set_para(fs2_handle, OUTPUT_DEVICE, ABBR_FS2_LOG_DATA_FILE, strlen(ABBR_FS2_LOG_DATA_FILE)+1);
+ }else{
+ sapp_log(RLOG_LV_INFO, 10, 10, "profiling.log.local.enabled is 0, not save local stat log file.\n");
+ FS_set_para(fs2_handle, OUTPUT_DEVICE, "/dev/null", strlen("/dev/null") + 1);
+ }
+ FS_set_para(fs2_handle, APP_NAME, sapp_global_val->config.system.instance_name, strlen(sapp_global_val->config.system.instance_name)+1);
+
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_LINE] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Line_Pkt");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_LINE] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Line_Bit");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Pkt");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_ETHERNET] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Eth_Bit");
+
+ if((DEPOLYMENT_MODE_INLINE == sapp_global_val->config.packet_io.depolyment_mode_bin)
+ || (DEPOLYMENT_MODE_TRANSPARENT == sapp_global_val->config.packet_io.depolyment_mode_bin)){
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_ETH_INBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Pkt_Inbound");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_ETH_INBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Bit_Inbound");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_ETH_OUTBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Pkt_Outbound");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_ETH_OUTBOUND] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Bit_Outbound");
+ }
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Pkt");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_UNKNOWN] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Unknown_Bit");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_ERROR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Snd_Err_Pkt");
+ //pfs_para->fs_id_length_array[SAPP_STAT_SND_ERROR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Snd_Err_Bit");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_IPV4] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv4_Pkt");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_IPV4] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv4_Bit");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_IPV6] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv6_Pkt");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_IPV6] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Ipv6_Bit");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Pkt");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bit");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_DUP_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Tcp_Pkt");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_DUP_TCP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Tcp_Bit");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_LOST_PKT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Lost_Bit");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_LOST_PKT_STREAM_NUM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Lost_STM");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_DUP_IDENTIFY_ERR] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Key_Err"); /* dup�ظ���ʶ������key������� */
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_CLOSE_BY_TIMEOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Close_byT");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_CLOSE_BY_KICKOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Close_byK");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Pkt");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bit");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_RCV_DUP_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Udp_Pkt");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_RCV_DUP_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Dup_Udp_Bit");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_CLOSE_BY_TIMEOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Close_byT");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_CLOSE_BY_KICKOUT] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Close_byK");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_NEW] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Link_New");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DEL] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Link_Del");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DATA] = FS_register(fs2_handle, FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Concurrent");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_NEW] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Link_New");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_DEL] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Link_Del");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_MORE] = FS_register(fs2_handle, FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Concurrent");
+
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Tcp_Link_Double");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_C2S");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_S2C");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Tcp_Link_Double_ALL");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_C2S_ALL");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_STREAM_TOTAL_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Tcp_Link_S2C_ALL");
+
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Udp_Link_Double");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_C2S");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_S2C");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE] = FS_register(fs2_handle, FS_STYLE_STATUS,FS_CALC_CURRENT, "Udp_Link_Double_ALL");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_C2S] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_C2S_ALL");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_STREAM_TOTAL_S2C] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "Udp_Link_S2C_ALL");
+
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_TCP_RST] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Tcp_Rst");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_TCP_SYNACK] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Tcp_S/A");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_SND_UDP] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Send_Udp");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_GLOBAL_BYPASS] = FS_register(fs2_handle,FS_STYLE_STATUS, FS_CALC_CURRENT, "DDOS_Bypass");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_BYPASS_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_STM");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_BYPASS_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_Pkt");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_BYPASS_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Bypass_Bit");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_BYPASS_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_STM");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_BYPASS_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_Pkt");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_UDP_BYPASS_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Bypass_Bit");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_OFFLOAD_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_STM");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_TCP_OFFLOAD_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_Pkt");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_TCP_OFFLOAD_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Tcp_Offload_Bit");
+
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_OFFLOAD_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_STM");
+ p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_OFFLOAD_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_Pkt");
+ p_fs2_rt->fs_id_length_array[SAPP_STAT_UDP_OFFLOAD_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_Bit");
+
+ if (unlikely(g_timestamp_record_sw))
+ {
+ if (fs2_tcp_unorder_historgram_init(p_fs2_rt) < 0)
+ {
+ return -1;
+ }
+ for (int i = 0; i < g_packet_io_thread_num; i++)
+ {
+ char histogram_name[16];
+ sprintf(histogram_name, "TD_ns(tid_%d)", i);
+ p_fs2_rt->fs_latency_id_array[i] = FS_register_histogram(fs2_handle, // Field Stat���
+ FS_CALC_SPEED, //����ۼ�ֵ��˲ʱֵ
+ histogram_name, //ͳ�������ƣ��ַ���
+ 1, //��׷�ٵ���Сֵ
+ 1000000, //��׷�ٵ����ֵ
+ 2); //���ȣ���С�����λ����Χ1~4
+ FS_set_para(fs2_handle, NOT_SEND_METRIC_TO_SERVER, &p_fs2_rt->fs_latency_id_array[i], sizeof(int));
+ }
+
+ if (fs2_plug_entry_historgram_init(p_fs2_rt) < 0)
+ {
+ return -1;
+ }
+ }
+ FS_start(fs2_handle);
+
+ return 0;
+}
+
+static void sapp_fs2_destroy(sapp_global_t *global_paramters)
+{
+ sapp_config_profiling_metric_t *p_fs2_para = &global_paramters->config.profiling.fs2;
+ sapp_gval_individual_fixed_fs_t *p_fs2_rt = &global_paramters->individual_fixed.fs2_runtime;
+ if (strlen(p_fs2_para->prometheus_service_uri) > 0 && p_fs2_para->prometheus_service_port > 0)
+ {
+ FS_library_destroy();
+ }
+
+ if (p_fs2_rt->fs_metric_handle)
+ {
+ FS_stop(&p_fs2_rt->fs_metric_handle);
+ }
+}
+
+static int sapp_fs3_init(sapp_global_t *global_paramters)
+{
+ sapp_config_profiling_metric_t *p_fs3_para = &global_paramters->config.profiling.fs3;
+ sapp_gval_individual_fixed_fs_t *p_fs3_rt = &global_paramters->individual_fixed.fs3_runtime;
+ return 0;
+}
+
+static void sapp_fs3_destroy(sapp_global_t *global_paramters)
+{
+ return;
+}
+
+void sapp_metric_destroy(void)
+{
+
+ if( sapp_global_val->config.profiling.fs2.enabled == 1)
+ {
+ sapp_fs2_destroy(sapp_global_val);
+ }
+ if( sapp_global_val->config.profiling.fs3.enabled == 1)
+ {
+ sapp_fs3_destroy(sapp_global_val);
+ }
+}
diff --git a/src/packet_io/CMakeLists.txt b/src/packet_io/CMakeLists.txt
index 0cc23c1..f739c7f 100644
--- a/src/packet_io/CMakeLists.txt
+++ b/src/packet_io/CMakeLists.txt
@@ -19,40 +19,24 @@ add_definitions(-fPIC)
#always add libpcap
set(PACKET_IO_SOURCE ${PACKET_IO_SOURCE} packet_io_pcap.c)
-if(ENABLE_STATIC_LINK)
- add_library(packet_io_pcap STATIC ${PACKET_IO_SOURCE})
-else()
- add_library(packet_io_pcap SHARED ${PACKET_IO_SOURCE})
-endif()
+add_library(packet_io_pcap STATIC ${PACKET_IO_SOURCE})
+
set_target_properties(packet_io_pcap PROPERTIES PREFIX "")
if(CAPTURE_MODE MATCHES "PAG")
set(PACKET_IO_SOURCE packet_io_pag_marsio.c)
- if(ENABLE_STATIC_LINK)
- add_library(packet_io_pag_marsio STATIC ${PACKET_IO_SOURCE})
- else()
- add_library(packet_io_pag_marsio SHARED ${PACKET_IO_SOURCE})
- endif()
+ add_library(packet_io_pag_marsio STATIC ${PACKET_IO_SOURCE})
endif()
if(CAPTURE_MODE MATCHES "MARSIO")
set(PACKET_IO_SOURCE packet_io_marsio.c)
- if(ENABLE_STATIC_LINK)
- add_library(packet_io_marsio STATIC ${PACKET_IO_SOURCE})
- else()
- add_library(packet_io_marsio SHARED ${PACKET_IO_SOURCE})
- endif()
- ##target_link_libraries(packet_io_marsio marsio)
+ add_library(packet_io_marsio STATIC ${PACKET_IO_SOURCE})
set_target_properties(packet_io_marsio PROPERTIES PREFIX "")
endif()
if(CAPTURE_MODE MATCHES "TUN")
set(PACKET_IO_SOURCE packet_io_tun.c)
- if(ENABLE_STATIC_LINK)
- add_library(packet_io_tun STATIC ${PACKET_IO_SOURCE})
- else()
- add_library(packet_io_tun SHARED ${PACKET_IO_SOURCE})
- endif()
+ add_library(packet_io_tun STATIC ${PACKET_IO_SOURCE})
endif()
set(PACKET_IO_STATIC_SOURCE cycle_pkt_dump_through_write_offset.c packet_io_lib_load.c
diff --git a/src/packet_io/Makefile b/src/packet_io/Makefile
deleted file mode 100644
index fd0d3c4..0000000
--- a/src/packet_io/Makefile
+++ /dev/null
@@ -1,195 +0,0 @@
-#opt: OPTFLAGS = -O2
-#export OPTFLAGS
-
-#CC = g++
-#CCC = g++
-CFLAGS += -Wall
-CFLAGS += -fPIC -shared -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H
-CFLAGS += $(OPTFLAGS)
-CFLAGS += $(PACKET_TAG_863)
-CFLAGS += -DPLATFORM_NSDPF_PAPP=1
-
-ifeq ($(USE_PAG_GET_FRAME), 1)
-CFLAGS += -DUSE_PAG_GET_FRAME=1
-endif
-
-RELEASE_PATH=../../bin/platform_lib/
-LIBPATH = -L../lib -L/opt/mrzcpd/lib
-DEP = ../support/libnet_common.so
-
-H_DIR += $(INC)
-H_DIR += -I../../include/
-H_DIR += -I../../include/public
-H_DIR += -I../../include/private
-H_DIR += -I../../include/support
-H_DIR += -I/opt/MESA/include
-H_DIR += -I/opt/MESA/include/MESA
-H_DIR += -I/opt/mrzcpd/include
-
-OBJS=sendpacket.o packet_io.o packet_io_log.o
-OBJS+=packet_io_lib_load.o
-OBJS+=packet_io_status.o
-OBJS+=packet_io_status_new.o
-#OBJS += cycle_pkt_dump.o
-#OBJS += cycle_pkt_dump_unix.o
-OBJS += cycle_pkt_dump_through_write_offset.o
-OBJS += packet_io_device.o
-OBJS += sapp_compat_old_papp_api.o
-OBJS += sapp_inject.o
-
-
-DLL_LIB=
-#ifeq ($(iomode), $(_MODE_PCAP))
-CFLAGS += -DIOMODE_PCAP=1
-DLL_LIB += packet_io_pcap.so
-ifeq ($(link_mode), $(__LINK_MODE_STATIC))
- OBJS += packet_io_pcap.o
-endif
-#endif
-
-ifeq ($(iomode), $(_MODE_PAG))
-CFLAGS += -DIOMODE_PAG=1
-DLL_LIB += packet_io_pag.so
- ifeq ($(link_mode), $(__LINK_MODE_STATIC))
- OBJS += packet_io_pag.o
- endif
-endif
-
-ifeq ($(iomode), $(_MODE_PPF))
-CFLAGS += -DIOMODE_PPF=1
-DLL_LIB += packet_io_ppf.so
-endif
-
-ifeq ($(iomode), $(_MODE_PFRING))
-CFLAGS += -DIOMODE_PFRING=1
-DLL_LIB += packet_io_pfring.so
-endif
-
-ifeq ($(iomode), $(_MODE_DPDK))
-CFLAGS += -DIOMODE_DPDK=1
-DLL_LIB += packet_io_dpdk.so
-endif
-
-ifeq ($(iomode), $(_MODE_TOPSEC))
-CFLAGS += -DIOMODE_TOPSEC=1
-DLL_LIB += packet_io_topsec.so
-endif
-
-ifeq ($(iomode), $(_MODE_IPFILE))
-CFLAGS += -DIOMODE_IPFILE=1
-DLL_LIB += packet_io_ipfile.so
-endif
-
-ifeq ($(iomode), $(_MODE_MARSIO))
-CFLAGS += -DIOMODE_MARSIO=1
-DLL_LIB += packet_io_marsio.so
- ifeq ($(link_mode), $(__LINK_MODE_STATIC))
- OBJS += packet_io_marsio.o
- endif
-endif
-
-ifeq ($(iomode), $(_MODE_SMITH))
-CFLAGS += -DIOMODE_SMITH=1
-DLL_LIB += packet_io_agent_smith.so
-endif
-
-ifeq ($(IIEFD_DUAL_STACK), $(YES))
-CFLAGS += -g -DIIEFD_DUAL_STACK=1
-endif
-
-ifeq ($(iomode), $(_MODE_DPDK_VXLAN))
-CFLAGS += -DIOMODE_DPDK_VXLAN=1
-DLL_LIB += packet_io_dpdk_vxlan.so
-endif
-
-ifeq ($(iomode), $(_MODE_PAG_MARSIO))
-CFLAGS += -DIOMODE_PAG_MARSIO=1
-DLL_LIB += packet_io_pag_marsio.so
-endif
-
-ifeq ($(iomode), $(_MODE_TUN))
-CFLAGS += -DIOMODE_TUN=1
-DLL_LIB += packet_io_tun.so
-ifeq ($(link_mode), $(__LINK_MODE_STATIC))
- OBJS += packet_io_tun.o
-endif
-endif
-
-
-TARGET = libpacket_io.a
-
-ifeq ($(debug), $(_DEBUG2))
-OBJS += iknow_info.o
-endif
-
-all: $(TARGET) $(DLL_LIB)
-
-.c.o:
- $(CC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-.cpp.o:
- $(CCC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-
-$(TARGET): $(OBJS)
- rm -f $@ ;ar -r $@ $^;
- cp $(TARGET) ../lib
-
-packet_io_pcap.so:packet_io_pcap.o
- $(CC) -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -lpcap;
- cp $@ $(RELEASE_PATH)
-
-packet_io_pag.so:packet_io_pag.o
- #$(CC) -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -lpag;
- gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -lpag;
- cp $@ $(RELEASE_PATH)
-
-packet_io_ppf.so:packet_io_ppf.o
- $(CC) -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -lppf;
- cp $@ $(RELEASE_PATH)
-
-packet_io_pfring.so:packet_io_pfring.o
- $(CC) -o $@ -fPIC -shared -g -Wall $^ $(IBPATH) $(LIBS) -lpfring;
- cp $@ $(RELEASE_PATH)
-
-packet_io_qnf.so:packet_io_qnf.o
- $(CC) -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -lqnfapi;
- cp $@ $(RELEASE_PATH)
-
-packet_io_dpdk.so:packet_io_dpdk.o
- $(CC) -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH) -lmarsio;
- cp $@ $(RELEASE_PATH)
-
-packet_io_topsec.so:packet_io_topsec.o
- gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH) -lpag;
- cp $@ $(RELEASE_PATH)
-
-packet_io_ipfile.so:packet_io_ipfile.o
- gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH);
- cp $@ $(RELEASE_PATH)
-
-packet_io_agent_smith.so:packet_io_agent_smith.o
- gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH) -lagent_smith;
- cp $@ $(RELEASE_PATH)
-
-packet_io_marsio.so:packet_io_marsio.o
- gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH) -lmarsio;
- cp $@ $(RELEASE_PATH)
-
-packet_io_dpdk_vxlan.so:packet_io_dpdk_vxlan.o
- $(CC) -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH) -lmarsio;
- cp $@ $(RELEASE_PATH)
-
-packet_io_pag_marsio.so:packet_io_pag_marsio.o
- gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH) -lmarsio;
- cp $@ $(RELEASE_PATH)
-
-packet_io_tun.so:packet_io_tun.o
- gcc -o $@ -fPIC -shared -g -Wall $^ $(LIBPATH) $(LIBS) -L$(LIBPATH);
- cp $@ $(RELEASE_PATH)
-
-clean:
- rm -f *.o packet_io*.so *.a $(TARGET) $(DLL_LIB) *~
-
-opt:
- $(MAKE) all
diff --git a/src/plugin/Makefile b/src/plugin/Makefile
deleted file mode 100644
index 93781cd..0000000
--- a/src/plugin/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-all:
- cd src && $(MAKE)
- cp ./lib/plugctrl.a ../lib
-clean:
- cd src && $(MAKE) clean
-opt:
- $(MAKE) all
-
diff --git a/src/plugin/src/Makefile b/src/plugin/src/Makefile
deleted file mode 100644
index 39d64f7..0000000
--- a/src/plugin/src/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-
-CC = gcc
-CFLAGS += -g -Wall -fPIC
-CFLAGS += $(OPTFLAGS)
-OBJECTS = plugin_proc.o plugin.o plugin_platform.o plugin_protocol.o plugin_business.o
-TARGET = plugctrl.a
-
-INCS = -I../inc
-INCS += -I../../../include/
-INCS += -I../../../include/public
-INCS += -I../../../include/private
-INCS += -I../../../include/support
-INCS +=-I/opt/MESA/include/MESA
-LIB =
-
-LIBPATH += ../lib
-
-.cpp.o:
- $(CC) -c -o $@ $(CFLAGS) $(INCS) $<
-
-.c.o:
- $(CC) -c -o $@ $(CFLAGS) $(INCS) $<
-
-.PHONY: all clean
-all:$(SUPPORT) $(TARGET)
-$(TARGET):$(OBJECTS)
-#$(TARGET):$(OBJECTS) $(LIB)
- ar -rs $(TARGET) $^
- cp $(TARGET) $(LIBPATH)
-
-plugin_proc.o:plugin_proc.c
-plugin.o:plugin.c
-plugin_platform.o:plugin_platform.c
-plugin_protocol.o:plugin_protocol.c
-plugin_business.o:plugin_business.c
-
-
-clean:
- rm -f $(TARGET) $(OBJECTS) *.a
-
diff --git a/src/project/Makefile b/src/project/Makefile
deleted file mode 100644
index 82dca3a..0000000
--- a/src/project/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-#opt: OPTFLAGS = -O2
-#export OPTFLAGS
-
-#CC = g++
-#CCC = g++
-CFLAGS += -Wall
-CFLAGS += -fPIC -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H
-CFLAGS += $(OPTFLAGS)
-CFLAGS += -DPLATFORM_NSDPF_PAPP=1
-
-LIBPATH = ../lib
-
-H_DIR += $(INC)
-H_DIR += -I../../include/
-H_DIR += -I../../include/public
-H_DIR += -I../../include/private
-H_DIR += -I../../include/support
-H_DIR += -I/opt/MESA/include/MESA
-
-TARGET = libproject.a
-
-OBJS= project_requirement.o
-#terminal_tag.o
-OBJS+= raw_ip_frag_list.o
-
-.c.o:
- $(CC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-.cpp.o:
- $(CCC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-all: $(TARGET)
-
-$(TARGET): $(OBJS)
- rm -f $@ ;ar -r $@ $^;
- cp $(TARGET) $(LIBPATH)
-clean:
- rm -f *.o $(TARGET) *~
-
-opt:
- $(MAKE) all
diff --git a/src/project/project_requirement.c b/src/project/project_requirement.c
index 00ef898..3440b08 100644
--- a/src/project/project_requirement.c
+++ b/src/project/project_requirement.c
@@ -8,7 +8,6 @@ extern "C" {
#include "MESA_list.h"
//extern int g_packet_io_thread_num;
-extern int project_req_terminal_tag_init(void);
extern int raw_ip_frag_list_v4_init(void);
extern int raw_ip_frag_list_v6_init(void);
extern void del_last_rn(char *data, int max_len);
@@ -441,29 +440,6 @@ static int teredo_identify_init(void)
return G_UDP_TEREDO_IDENTIFY_PROJECT_ID;
}
-
-static void terminal_tag_free_struct(int thread_num, void *project_req_value)
-{
- dictator_free(thread_num, project_req_value);
-}
-
-int project_req_terminal_tag_id = -1;
-
-int project_req_terminal_tag_init(void)
-{
- int project_req_id;
-
- project_req_id = project_producer_register("terminal_tag", "struct", terminal_tag_free_struct);
- if(project_req_id >= 0){
- project_req_terminal_tag_id = project_req_id;
- }else{
- /* �����ļ�û��'terminal_tag'��, �رմ˹��� */
- project_req_terminal_tag_id = -1;
- }
-
- return 0;
-}
-
static void udp_flow_stat_free(int thread_seq, void *project_req_value)
{
sapp_mem_free(SAPP_MEM_DYN_UDP_FLOW_STAT, thread_seq, project_req_value);
@@ -527,8 +503,6 @@ int project_requirement_global_init(void)
//parse_project_req_conf();
- /* ƽ̨����projectģ���ʼ��, �����Ƿ�����ȡ���������ļ����� */
- //project_req_terminal_tag_init();
/* projectע���Ϊ��̬, ����project_list.conf������,
����������Щ���ù���Ϊ����ǰ����,���Ǽ��һ��project_list.conf�Ƿ����, �������򲻿��� */
diff --git a/src/project/terminal_tag.c b/src/project/terminal_tag.c
deleted file mode 100644
index 1ba4453..0000000
--- a/src/project/terminal_tag.c
+++ /dev/null
@@ -1,391 +0,0 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __FAVOR_BSD
-#define __FAVOR_BSD 1
-#endif
-
-#include "sapp_api.h"
-#include "sapp_private_api.h"
-
-//pcap_t* pcap_handle;
-//#define GET_TAG_DEVICE "eth1"
-//#define GET_TAG_FILTER "tcp[13]=0x02 and host 10.0.6.187"
-
-//static int terminal_tag_switch = 0;
-static int project_req_terminal_tag_id = -1;
-
-#define TERMINAL_TAG_SIZE_MAX (48)
-
-unsigned char terminal_tag_checksum_hash(unsigned char rand_num,
- unsigned int ip_addr, unsigned short dev_id)
-{
- unsigned char checksum_key = 0x5A;
- unsigned char *p;
-
- checksum_key += rand_num;
- p = (unsigned char *)&ip_addr;
- checksum_key += p[0];
- checksum_key += p[1];
- checksum_key += p[2];
- checksum_key += p[3];
- p = (unsigned char *)&dev_id;
- checksum_key += p[0];
- checksum_key += p[1];
-
- return checksum_key;
-}
-
-unsigned char terminal_tag_checksum(struct terminal_tag_t *terminal_tag,
- unsigned char checksum_key)
-{
- unsigned char checksum = 0x77;
- unsigned char *p = (unsigned char *)terminal_tag;
-
- terminal_tag->check_sum = 0;
-
- checksum += p[0];
- checksum += p[1];
- checksum += p[2];
- checksum += p[3];
- checksum += p[4];
- checksum += p[5];
- checksum += p[6];
- checksum += p[7];
- checksum += p[8];
- checksum += p[9];
- checksum += checksum_key;
-
- return checksum;
-}
-
-unsigned char terminal_tag_encrypt_hash(unsigned char rand_num, unsigned int ip_addr)
-{
- unsigned char encrypt_key = 0xA5;
- unsigned char *p;
-
- encrypt_key ^= rand_num;
- p = (unsigned char *)&ip_addr;
- encrypt_key ^= p[0];
- encrypt_key ^= p[1];
- encrypt_key ^= p[2];
- encrypt_key ^= p[3];
-
- return encrypt_key;
-}
-
-static void *terminal_tag_create_struct(int thread_num)
-{
- void *info = dictator_malloc(thread_num, TERMINAL_TAG_SIZE_MAX);
- memset(info, 0, TERMINAL_TAG_SIZE_MAX);
-
- return info;
-}
-
-static void terminal_tag_transform(struct terminal_tag_t *terminal_tag,
- struct streaminfo *stream, unsigned char *stack_tag_string)
-{
- char ip_str[16];
- unsigned char *mac;
- struct stream_tuple4_v4 *st4;
- int sip_addr;
- void *stream_tag_value;
-
- if(ADDR_TYPE_IPV4 == stream->addr.addrtype){
- st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- sip_addr = st4->saddr;
- }else{
- return; /* ��֧��ipv6 */
- }
-
- switch(terminal_tag->type)
- {
- case TERMINAL_ADDR_TYPE_MAC:
- mac = (unsigned char *)terminal_tag->local_addr.local_mac;
- snprintf((char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX, "%s:%05u:%02x%02x-%02x%02x-%02x%02x",
- "M",ntohs(terminal_tag->dev_id), mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);
- break;
-
- case TERMINAL_ADDR_TYPE_IP:
- inet_ntop(AF_INET, &terminal_tag->local_addr.local_ip.ipaddr, ip_str, 16);
- snprintf((char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX, "%s:%05u:%s",
- "I", ntohs(terminal_tag->dev_id), ip_str);
- break;
-
- case TERMINAL_ADDR_TYPE_TRACE:
- // to do!
- break;
-
- case TERMINAL_ADDR_TYPE_GLOBAL_SIP:
- break;
-
- default:
- inet_ntop(AF_INET, &sip_addr, ip_str, 16);
- snprintf((char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX, "%s:%s", "G:00000", ip_str);
- break;
- }
-
-#if 0
- if(terminal_tag->type < 2)
- {
- printf("Tagv4 is: %s\n", stream->terminal_tag);
- }
- //mac = (unsigned char *)terminal_tag;
- //printf("Clear-bin is: %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n",
- //mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[6],mac[7],mac[8],mac[9]);
-#endif
-
- stream_tag_value = terminal_tag_create_struct(stream->threadnum);
- strncpy((char *)stream_tag_value, (const char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX);
- project_req_add_struct(stream, project_req_terminal_tag_id, stream_tag_value);
-
- return;
-}
-
-static int terminal_tag_checksum_check(struct terminal_tag_t *terminal_tag_clear,
- struct streaminfo *stream, unsigned char *stack_tag_string)
-{
- unsigned char checksum_key;
- unsigned char raw_checksum, new_checksum;
- struct stream_tuple4_v4 *st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- int dip_addr;
-
- if(ADDR_TYPE_IPV4 == stream->addr.addrtype){
- st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- dip_addr = st4->daddr;
- }else{
- return -1; /* ��֧��ipv6 */
- }
-
- checksum_key = terminal_tag_checksum_hash(terminal_tag_clear->random,
- dip_addr,
- ntohs(terminal_tag_clear->dev_id));
-
- raw_checksum = terminal_tag_clear->check_sum;
-
- new_checksum = terminal_tag_checksum(terminal_tag_clear, checksum_key);
-
- if(raw_checksum != new_checksum)
- {
- //printf("Checksum error!\n");
- goto err; /* У��Ͳ��ԣ����ܴ�����󡢻򱻴۸ġ������α��� */
- }
-
- switch(terminal_tag_clear->type)
- {
- case TERMINAL_ADDR_TYPE_MAC:
- break;
-
- case TERMINAL_ADDR_TYPE_IP: /* IP����,���������ֽ�����������У�� */
- if(IP_STRUCT_MAGIC != terminal_tag_clear->local_addr.local_ip.ip_magic_num)
- {
- goto err;
- }
- break;
-
- default: /* �û���ǩ�豸���ӵı�־ֻ����MAC��IP */
- return -1;
- break;
- }
-
- terminal_tag_transform(terminal_tag_clear, stream, stack_tag_string);
- return 0;
-
-err:
- return -1;
-}
-
-/* �û���ǩ���� */
-static int terminal_tag_decrypt(struct terminal_tag_t *terminal_tag_enc,
- struct streaminfo *stream, unsigned char *stack_tag_string)
-{
- struct terminal_tag_t terminal_tag;
- unsigned char rand_num, encrypt_key;
- unsigned char *clear, *encrypt;
- struct stream_tuple4_v4 *st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- int dip_addr;
-
- if(ADDR_TYPE_IPV4 == stream->addr.addrtype){
- st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- dip_addr = st4->daddr;
- }else{
- return -1; /* ��֧��ipv6 */
- }
-
- /* copy��һ����ʱ�ռ䣬���޸�ԭʼ���ݰ� */
- memcpy(&terminal_tag, terminal_tag_enc, sizeof(struct terminal_tag_t));
-
-#if 0
- unsigned char * mac = (unsigned char *)&terminal_tag;
- printf("Encrypt-bin is: %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n",
- mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[6],mac[7],mac[8],mac[9]);
-#endif
-
- clear = (unsigned char *)&terminal_tag;
- encrypt = (unsigned char *)terminal_tag_enc;
-
- clear[0] = ror(encrypt[0], 4);
- rand_num = terminal_tag.random;
-
- encrypt_key = terminal_tag_encrypt_hash(rand_num, dip_addr);
-
- /* ������һ���ֽڣ�type��random�ֶβ�����˷�ʽ���� */
-
- clear[1] = encrypt[1] ^ encrypt_key;
- clear[2] = encrypt[2] ^ encrypt_key;
- clear[3] = encrypt[3] ^ encrypt_key;
- clear[4] = encrypt[4] ^ encrypt_key;
- clear[5] = encrypt[5] ^ encrypt_key;
- clear[6] = encrypt[6] ^ encrypt_key;
- clear[7] = encrypt[7] ^ encrypt_key;
- clear[8] = encrypt[8] ^ encrypt_key;
- clear[9] = encrypt[9] ^ encrypt_key;
-
- return terminal_tag_checksum_check(&terminal_tag, stream, stack_tag_string);
-}
-
-
-static int terminal_tag_trace(struct streaminfo *stream, unsigned char *stack_tag_string)
-{
- struct terminal_tag_t terminal_tag;
- /* ��Դϵͳ��ѯ */
- /* to do:
- terminal_tag_trace();
- if(err)
- {
- goto def_tag;
- }
- terminal_tag_clear->type = TERMINAL_ADDR_TYPE_TRACE;
- */
- terminal_tag.type = TERMINAL_ADDR_TYPE_GLOBAL_SIP;
- terminal_tag_transform(&terminal_tag, stream, stack_tag_string);
- return 0;
-}
-
-
-static int terminal_tag_set_ipv6(struct streaminfo *stream, unsigned char *stack_tag_string, const void *rawippkt)
-{
- void *stream_tag_value;
- const struct mesa_ip6_hdr *ip6h = (struct mesa_ip6_hdr *)rawippkt;
-
- /* ��ʱʹ��IPv6��Դ��ַ��Ϊv6_tag */
- if(NULL == inet_ntop(AF_INET6, &ip6h->ip6_src, (char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX))
- {
- return -1;
- }
-
- stream_tag_value = terminal_tag_create_struct(stream->threadnum);
- strncpy((char *)stream_tag_value, (const char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX);
- project_req_add_struct(stream, project_req_terminal_tag_id, stream_tag_value);
-
- return 0;
-}
-
-
-/* �豸��ȡ�û�TAG, �ж��Ƿ���ȷ�����ܺ����stream�ṹ�� */
-int terminal_tag_probe(struct streaminfo *stream, struct tcphdr *api_tcp_hdr,
- const void *rawippkt)
-{
- struct mesa_tcp_hdr *this_tcphdr;
- unsigned char *stream_tag_string = NULL;
- unsigned char stack_tag_string[TERMINAL_TAG_SIZE_MAX];
- u_int8_t *option;
- int tcp_hdr_len;
- u_int16_t option_len;
- int ret = 0;
-
- if(likely(-1 == project_req_terminal_tag_id)){
- return -1;
- }
-
- this_tcphdr = (struct mesa_tcp_hdr *)api_tcp_hdr;
- option = (u_int8_t *)this_tcphdr + 20; /* TCP��׼ͷ������=20 */
- tcp_hdr_len = 4 * this_tcphdr->th_off;
-
- stream_tag_string = (unsigned char *)project_req_get_struct(stream, project_req_terminal_tag_id);
- if((NULL != stream_tag_string) && (stream_tag_string[0] != '\0')){ /* �Ѿ���ȡ����ǩ */
- return 0;
- }
-
- if(ADDR_TYPE_IPV6 == stream->addr.addrtype)
- {
- return terminal_tag_set_ipv6(stream, stack_tag_string, rawippkt);
- }else if(ADDR_TYPE_IPV4 != stream->addr.addrtype){
- return -1;
- }
-
- if(this_tcphdr->th_flags != TH_SYN)
- {
- ret = -2;
- goto trace_tag;
- }
- tcp_hdr_len -= 20;
- if(tcp_hdr_len < TCP_SYN_TAG_LEN)
- {
- ret = -3;
- goto trace_tag;
- }
-
- while(tcp_hdr_len > 0)
- {
- switch(*option)
- {
- case 0: /* type=0ԭ����ѡ���������׷������ѡ�����Ҫ���������� */
- case 1:
- option_len = 1;
- break;
-
- case TCP_SYN_TAG_TYPE:
- option_len = *(option+1);
- if(TCP_SYN_TAG_LEN == option_len)
- {
- ret = terminal_tag_decrypt((struct terminal_tag_t *)(option+2), stream, stack_tag_string);
- if(0 == ret)
- {
- return 0;
- }
- }
- break;
-
- default:
- option_len = *(option+1);
- }
- if(0 == option_len)
- {
- goto trace_tag;
- }
- if(option_len > tcp_hdr_len)
- {
- goto trace_tag;
- }
- option += option_len;
- tcp_hdr_len -= option_len;
- }
-
-trace_tag:
- return terminal_tag_trace(stream, stack_tag_string);
- //return -1;
-}
-
-char terminal_tag_tcp_all_entry(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a_packet)
-{
- const struct mesa_ip4_hdr *ip4h = (const struct mesa_ip4_hdr *)a_packet;
-
- if(OP_STATE_PENDING == a_tcp->pktstate){
- terminal_tag_probe(a_tcp, (struct tcphdr *)((char *)a_packet + ip4h->ip_hl*4), a_packet);
- }
-
- return APP_STATE_DROPME;
-}
-
-int terminal_tag_init(void)
-{
- return 0;
-}
-
-
-#ifdef __cplusplus
-}
-#endif
-
diff --git a/src/project/terminal_tag.h b/src/project/terminal_tag.h
deleted file mode 100644
index 335ce39..0000000
--- a/src/project/terminal_tag.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef _TERMINAL_TAG_H_
-#define _TERMINAL_TAG_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "mesa_net.h"
-#include <stdio.h>
-#include <sys/types.h>
-
-#define TERMINAL_MODULE_NAME "terminal_tag"
-
-#define TCP_SYN_TAG_TYPE (0xF1)
-#define TCP_SYN_TAG_LEN (12) /* 6BMAC+2B�豸ID+1B����+1BУ���+1B����+1B���� */
-#define TCP_HDR_MAX_LEN (60) /* TCPͷ����󳤶� */
-
-#define rol(x,n) (((x)<<(n)) | ((x)>>(8*sizeof(x)-(n))))
-#define ror(x,n) (((x)>>(n)) | ((x)<<(8*sizeof(x)-(n))))
-
-
-#define IP_STRUCT_MAGIC (0x8633)
-struct local_ip_t{
- unsigned int ipaddr; /* �ն��豸����IP, ������ */
- unsigned short ip_magic_num; /* ħ��,�洢IPʱ����������ֽ�,��������֤ */
-}BYTE_ALIGNED(1); //sizeof(this)=6B
-
-union local_addr_t{
- unsigned char local_mac[6]; /* �ն��豸MAC��ַ */
- struct local_ip_t local_ip; /* �ն��豸����IP�ṹ */
-}BYTE_ALIGNED(1); //sizeof(this)=6B
-
-#define TERMINAL_ADDR_TYPE_MAC (0)
-#define TERMINAL_ADDR_TYPE_IP (1)
-#define TERMINAL_ADDR_TYPE_TRACE (2)
-#define TERMINAL_ADDR_TYPE_GLOBAL_SIP (3)
-struct terminal_tag_t{
-#if __BYTE_ORDER == __BIG_ENDIAN
- unsigned char type:2; /* ����������ȡ��ʽ, 1:MAC; 2:IP */
- unsigned char random:6; /* �����,���ڼ��� */
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned char random:6; /* �����,���ڼ��� */
- unsigned char type:2; /* ����������ȡ��ʽ, 1:MAC; 2:IP */
-#endif
-
- unsigned char check_sum; /* У��ͣ�������������֤����α�� */
- unsigned short dev_id; /* �豸ID (����ID���������� */
- union local_addr_t local_addr; /* �豸������ַ�ṹ */
-}BYTE_ALIGNED(1); //sizeof(this)=10B
-
-extern unsigned char terminal_tag_encrypt_hash(unsigned char rand_num, unsigned int ip_addr);
-extern unsigned char terminal_tag_checksum_hash(unsigned char rand_num, unsigned int ip_addr, unsigned short dev_id);
-extern unsigned char terminal_tag_checksum(struct terminal_tag_t *terminal_tag,unsigned char checksum_key);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
diff --git a/src/readme_GBK.txt b/src/readme_GBK.txt
deleted file mode 100644
index 0743e2d..0000000
--- a/src/readme_GBK.txt
+++ /dev/null
@@ -1,748 +0,0 @@
-#if 0
-1.�����ִ�����Ҫ��������
- 1����ɵײ����ݰ��Ļ�ȡ�� ֧�ֶ������ݻ�ȡ��ʽpag��ppf��pfring��
- 2) ���tcp��udp������ԭ����
- 3) ��ɲ�����ع���
-*********************************************************************
-20130802 ������
-1)tcp��������ʱ��Ϊ�˿��������Ե����������е�������
-2)���ӿ��ƿ��أ�ѡ�������ӵķ�ʽ
-****************************************************************************
-20130803 ������ �Ż�����ԭģ��Ĵ���
-1) ÿ��������ʱ��������˿ںţ�������ʱ������
- �������С�˿�Ϊ�����ʱ��ͨ��syn�жϳ��󣬵ߵ���Ԫ�飻
- ÿ����������hashʱ���ڽ����жϣ�ֱ������Ԫ�飻
-2) ��������hashʱ������Ԫ���С�������򣬲����λ����findstreamʱ��ǰ��ã����ٲ���ʱ�ļ��㣻
-3) dealpkt���ֵĴ���������������ó��ܹ��������еĴ��룬������������ stack��support
-4) ��д���Բ��ֵĶ������Ժ����������в��ԣ�
-****************************************************************************
-20130805 ������
-1) ���������Ķ˿ڵĸ�Ϊ�ж���������;
-2��˫�����յ�����������ֱ�ӽ������ݱ����𵽱�����ʵ���ӵ�Ŀ��;
-****************************************************************************
-20130813 ������
-1)tcp�����IJ��Ҹ�Ϊ�۰����
-*********************************************************************************************
-20130821 ���
-1)���ij��Ŀ����: ���IP�����ɶ��IP��Ƭ���������, Ӧ�ò������Ի�ȡ����ԭʼIP��Ƭ��,
- ������raw_ipfrag_list�ṹ, ����streaminfo�ṹ������ԭʼIP��Ƭ�б�ͷָ��.
- �޸�stream.h��dealpkt.c��dealtcp.c��deal_ipv4.c��deal_ipv6.c��ip_reassembly.c����IP��Ƭ��ش���.
-****************************************************************************
-20130822 ������
-1)����tcpȫ���ص��ӿڣ�ȫ���ص�ʱ���ܻ�û��pdetail��
-2)Ϊ���ܹ��ж���ȷ�Ƿ���pdetail��֮ǰ����pdetail��Ϣ���洢synseq�ķ�ʽ���ٿ��У������˱���������ʱ��¼seq
- ͬʱ��Ϊ���ܹ�ͬʱ֧������ģʽ������pktstate�����ں��������ĵı���pktallme
- pktstate�ı任�߼����£���һ����Ϊpending������к�����Ҫ���Ϊdata��������Ҫ��Ϊclose��������̭ʱΪclose
-3)����ȫ����ȡ��������ʱ,������fin��rst������̭����ֻ�ܵ���̭
-4)Ϊ���ڲ�ͬtcp�ӿ�����£����غ����ܹ�ͳһ������������������������Ҫ����xxstat��xxpme��
-5) streaimindex��ΪԤ�ȷ�����Ҫ�ĸ�����������Ϊ�˷�ֹ�����������е���tcp_free_stream֮���ֽ���ʹ�ó���Ұָ��
- ����һ�ֱ���ķ�����û������**���ӿڱȽ��鷳����δʹ��
-
-6������takeoverģʽ��Ŀǰֻ֧��ע��һ���ӹܺ�����
-7) syn+rst�ı���Ҳ��������
-**********************************************************************
-20130826 ������
-1) mkstreamhash ��frand����hash�������һ�ο����� ���Ҵ󲿷����Ϊ0�����hash��ͻ�����ֻ�õ�ַ��������
-
-**********************************************************************
-20130917,18 ������
- 1) hash_add_stream ������streamaddlistǰ���У�����streamaddlist����̭һЩ���Ӻ�����
- hash_add_stream���õ�֮ǰ���ҵĽ��Ϊ������
- 2) ÿ����̭��������ĿΪ��������Ŀ��2%
-
-******************************************************************************************
-20130922 ���
-1)����NPacket������ʽ, �������"CAPTURE_MODE=$(LINK_NP)", ��Ӧ�����ļ�"capdatamodlel=5"
-******************************************************************************************
-20140302 ������ ��dealpkt��platform �ϲ�֮ǰ�ĸ����޸�
-1)dealpktĿ¼����ipv6֧��
-2)dealpktĿ¼�ϲ�֮ǰ�޸ĵ�tcp_allpkt�ӿڣ�������
-3)dealpktĿ¼�ϲ�֮ǰ�޸ĵĶ��������ֲ��bug
-4)dealpktĿ¼��dealpkt.c dealtcp.cδ����108��ش��룬
- call_appδ����863_control�Ĵ���
-5)�ϲ�plugin ֧�ֲ����������
- (1)������ýӿڣ�plugctrl_proc() ��(�޲���)
- (2)�������ã�
- a���Զ�ɨ������㡢ҵ��㡢���ݲ�������ļ����²��(Ĭ��·���ֱ���./plug/protocol,./plug/business,./plug/general����ͨ��./wyqd.conf�в������Ĵ�·��)���������ʼ��������
- b������IP_ENTRY,TCP_ENTRY,UDP_ENTRY�������ָ��ֱ���ص���Ӧ�����������ϣ�
- c������������ں���ָ�룬���������ʱʹ�ã�
-******************************************************************************************
-20140322 ������ Ϊ��֧�ִ���Ƕ�ף������������޸�
-1)tcp����ԭ�����ֻ�е�����data״̬�󣬲ŷ���pdetail�Ŀռ䣻�����޸�Ϊ
- ��һ�����ͷ���pdetail�Ŀռ䣬������data��ŷ���half�Ŀռ�
-2)���¹�����stream�ṹ��Ķ��壬
- ԭ��������ص�һЩ������ȫ������pdetail������apme�ȣ�
-3)�����Ĺ������������ĵ�ַ��hash���ö���ַ�ݹ���бȽ�
-4)���������˶�vlan�Ĵ���������������
-******************************************************************************************
-20140323 ������ Ϊ��֧��Ӧ�ò�����������޸�
-1) tcpdetail�ṹ��������proxylistָ�룬��¼�������
-2) proxylist�����룬�ͷţ��д�����������ƣ�
-3) �����ṹ�����Դ�pme,opstate���������������ص����еĽӿں���
-******************************************************************
-20140406 ���
-1)���Ӷ������Ĵ�����������֧������Ƕ��ģʽ;
-2)�޸�stream.h��ADDR_TYPE_IPV4��ַ���Ͷ��壬���ٴ�������IPv4��ַ����Ԫ�飬
- ����������IPv4��ַ��, ��Ԫ��ʹ��struct stream_tuple4��ʾ;
-3)ϸ���ֲ�ṹ��TCP�㲻�ٴ洢��Ԫ����Ϣ�����ǽ��洢����Ķ˿���Ϣ��
- ����HASH�Լ���ַ�Ƚ�ʱ����ͨ��fstream�ҵ�IP��ַ;
-4)�޸ļ���HASH������HASH��ͻ��ıȽϺ���;
-5)��ij��Ŀ������Ӧ�ã����ǩ��stream_id��ԭʼIP��Ƭ�����벢ģ�黯��
- ʹ�ÿ���������ij��ģ�������;
-6)�ѵײ㲶�����װ��.soģʽ���ڲ�ͬ�IJ���ģʽ���л�ʱ��ֻҪ�޸������ļ����ɣ�����ӱ��롣
-******************************************************************
-20140422 ���
-1)Ϊ�˴���Ч�ʣ������ڴ�ռ�ã��������ȡ��Ԫ��������ԣ�
- ��TCP��UDP�Ķ˿ڴ洢��IP�㣬TCP����ָ��ָ��IP��˿��ڴ棬������ֱ�ӻ�ȡ��Ԫ����Ϣ��
-******************************************************************
-20140515 ���
-���863-UDP����ԭ����Ӳ������������QNF�����ӿ�.
-******************************************************************
-20140616 ���
-1)����project����ģ�飬��stream->pproject�ṹ�У�����������ض��Ӧ����Ϣ;
-******************************************************************
-20140619 ���
-1)����raw_pkt_t�ṹ���洢�Ӳ������ȡ��ԭʼ����Ϣ;
-2)�����ں�������ԭʼ������;
-3)�޸�IP��Ƭ�������̣�֧���������Ƕ��ģʽ
-******************************************************************
-20140721 ���
-1)IP��Ƭ����HASH֧�ֶ��Ƕ��ģʽ;
-2)��ԭIP��Ƭ����HASHģ��ijɻ���MESA_htableʵ��;
-******************************************************************
-20140901 ���
-1)����ģʽ�£�Ӧ�ÿ��ܻ����ԭʼ�������Ӷ�ԭʼ������У�鹦�ܡ�
-******************************************************************
-20140910 ���
-1)����MESA_inject_pkt()�����ӿڣ���������������ٴ�������.
-******************************************************************
-20140922 ���
-1)����MESA_kill_tcp_synack()�ӿ�, ����IP-HMD����ƭ����;
-******************************************************************
-20141011 ���
-1)���Ӷ�ȡ�����ļ�����maxrandval, randkeyval������ʶ��ϵͳ������RST��;
-2)fd������ƽ̨ʵ��, ���������ΪMESA_kill_tcp()�ǿɿ��ģ�
-******************************************************************
-20141113 ���
-1)�޸Ĵ��������е�ַ��תʱ����TCP�������Ҵ�������޷�ʶ��ijЩ����BUG��
-******************************************************************
-20141115 ���
-1)����MESA_kill_connection()���������˿���ʵ��MESA_kill_tcp()ԭ�й����⣬
- �������ڴ���ģʽ�£��Ի������ķ�TCPЭ����fd(drop packet).
-******************************************************************
-20141120 ���
-1)����pcap�����ģʽ��������ʾ��Ԥ�⴦��ʱ��.
-******************************************************************
-20141125 ���
-1)�޸�pcapģʽ��, ���̷߳���BUG������ģʽ(pag��pfring��dpdk�ȵ�)����Ӱ�졣
-2)����pluninģ�飬version:2014-11-24
-******************************************************************
-20141127 ���
-1)�޸��������������ֵ����255��չΪ65535, �޸���stream.h�й���maxunorder�Ķ���.
-******************************************************************
-20141202 ���
-1)�޸���pcap����ģʽ�£������̵߳���freeall_stream()���ڹ����̵߳��µ�BUG;
-2)����ƽ̨��packet_io_lib�汾�ŶԱ��жϣ������һ�»��ӡ������Ϣ;
-3)�޸���̭UDP��ʱ��pktstateû����ȷ����ΪCLOSE״̬BUG;
-4)�����ļ�����"UdpStreamTimeout"�� �������ÿ���UDP����ԭʱ����ʱ��̭ʱ��;
- ����"load_plug_switch", ���ڶ�̬�����Ƿ���ز��;
-5)������sysinfo.logͳ����Ϣ��ʾ.
-******************************************************************
-20141204 ���
-1)�޸���pagģʽ������ʱ��IPv4��IPv6����ʱ��BUG,
- �ڶ���Makefile������"USE_PAG_GET_FRAME",
- ���ݻ���ѡ���Ƿ�ʹ��pag_get_frame()ֱ�ӻ�ȡmac��.
-******************************************************************
-20141205 ���
-1)�޸�IPv6-UDP���ݰ�, �ڿ���UDP����ԭ�������, �޷��ҵ���Ӧ����, ���HASH��ͻ������ըBUG��
-******************************************************************
-20141208 ���
-1)����build_net_layer_gre()���������Թ����GREЭ���rst��.
-******************************************************************
-20141211 ���
-1)�޸���IP��Ƭ�����İ�������������MESA_kill_tcp()��BUG;
-2)�޸�MESA_kill_tcp()���������BUG;
-3)ԭʼ���ṹraw_pkt_t������__magic__, ������papp��sappƽ̨֮������ԭʼ��void *��ʵ������.
-******************************************************************
-20141217 ���
-1)����pagģʽ�£�ʹ��pag_get_frame�ӿڹ���, �ö���Makefile��USE_PAG_GET_FRAMEѡ�����;
-2)�޸�����ԭ��data������ʱ���Դ�˿�ΪԴ�Ĺ���;
-3)�޸�����������ϵͳ��׼��exit()�� ��ɳ����˳�ʱĪ�������BUG.
-******************************************************************
-20141219 ���
-1)Ϊ�˼���֮ǰ���, �޸�IPv4, IPv6����ԭʼ��ָ��Ϊ����IP��ָ��.
-******************************************************************
-20141223 ���, ������
-1������SAPP_PKT_CB_FUN_T�ص��������ͣ�
- char SAPP_PKT_EXAMPLE(const struct streaminfo *pstream, const void *this_hdr, const void *raw_pkt);
-******************************************************************
-20141224 ���
-1���޸�stream.h�����ڲ��������ⲿ�������룬���ݹ��ܵIJ�ͬ����stream.h�ֲ�Ϊ:
- #include "stream_inc/stream_base.h"
- #include "stream_inc/stream_proxy.h"
- #include "stream_inc/stream_project.h"
- #include "stream_inc/stream_inject.h"
- #include "stream_inc/stream_control.h"
- #include "stream_inc/stream_entry.h"
- #include "stream_inc/stream_rawpkt.h"
-******************************************************************
-20141225 ���
-1)��ip��Ƭ�������͵İ�����Pkttype��ʶ��������������ʶ��.
-2)������һЩ��������Э�����ʹ���, ��vlan��pppoe��ppp�ķ����ݴ����Э��.
-******************************************************************
-20141226 ���
-1)����PPP��GREЭ��Ľ���;
-******************************************************************
-20141230 ���
-1)����addr_type_to_string()���������ڲ�����Э���ַ�����ַ���;
-2)����get_this_layer_header()�����ڲ����ȡ����ͷ����ַ;
-3)�޸�STREAM_CB_FUN_T�ص�������"ԭʼ��"��������Ϊ�����²�IP���ͷ��,
- ������ȫԭʼ��Ӧʹ��SAPP_STREAM_FUN_T���ͻص�.
-******************************************************************
-20141231 ������ ���
-1)ƽ̨ͬʱ֧�ִ�ԭʼ���ͱ����ͷ�Ľӿڣ����ӻص��������Ͷ��壬
- �޸�callapp.c��stream_register_xxx��stream_process_xxxϵ�к���.
-2)�ϲ�dictator2��20141217�汾.
-******************************************************************
-20150104 ���
-1)�޸�stream_base.h, ��pkttype�ƶ���struct layer_addr�ṹ��,
- ��routedir��չΪuchar����;
- ����MESA_dir_reverse()����, ���ڷ���ʱ����routedir.
- stream.h���Ӱ汾�ź�MD5��ֵ֤.
-2)����MESA_fakepacket_xxxϵ�к���.
-******************************************************************
-20150107 ������
-1)reset�ؽ�����ʱ�����ü�����
-2) �ж�syn�Ƿ��ش������� ��ԭ����(thisseq+1 == rcv->first_data_seq)
-��Ϊ( rcv->first_data_seq-thisseq <=1)
-3) Ϊ�˷�ֹsyn���õ�����syn�ڵ�һ���������棬��Ϊ�ȵ���tcp���ٵ���tcpall
-4) ����3�����޸ģ�����ÿ����������ʱrst����Ҫ����ԭʼ����free_stream�ĺ���
-******************************************************************
-20150112 ���
-1)�޸�tcp_deal_data_stream,tcp_save_unorder,deal_tcp_stream�Ⱥ����IJ���,
- ����Iphdr��tcphdr���������ڴ���������IP��Ƭ����
-2)FD����ʱ�����ж�������ֻ��tcpdatalen > 0ʱ,�ż�������MESA_kill_tcp,
- �Է�ֹ�����򱾻����͵�RST���ֱ�����;
-******************************************************************
-20150123 ������
-1) pkttype ����PKT_TYPE_TCPREORDER����Ҫÿ�������˸�ֵ
-2) proxy���ӶԵ�ַ������ת��
-******************************************************************
-20150126 lqy yw
-1) pkttype ����PKT_TYPE_TCPRESTRAS �����ش����ĵ�����
-2) tcp_stream_free����˳���Ƚ���tcp���ٽ���tcpall
-3) pkttype ���������������pktipflagtype
-******************************************************************
-20150129 ��ѣ�������, ����
-1)sapp����-v����������ʶ��汾����, �����ṩ�Ŀ�ִ���ļ�Ҫstrip, ͨ��nm�����޷��鿴.
-2)sapp����libsesame_door,��������ƽ̨ʹ�÷�Χ,����������Ȩ;
-3)callapp��֧��udp_raw�ӿ�
-4)����������ģ��򿪽������������ű�Ϊȫ�ֿɼ�
-******************************************************************
-20150203 ���
-1)�����ĸ���ַת������:
- const char *stream_addr_list_ntop_outward(const struct streaminfo *pstream);
- const char *stream_addr_list_ntop_inward(const struct streaminfo *pstream);
- const struct streaminfo *stream_addr_list_pton_outward(const char *addr_list_str, int thread_index);
- const struct streaminfo *stream_addr_list_pton_inward(const char *addr_list_str, int thread_index);
- �޸�stream_base.h, �������Ϻ�������.
-2)�������Ͷ���PKT_TYPE_IP_FRAG;
- ����stream_register_ip_frag, stream_register_ipv6_frag��ں���.
-******************************************************************
-20150205 ���
-1)���ӻ���PPP,GREЭ���RST�����칦�ܣ�
- ��GREû�д�������Ŀǰֻ�ܵ�����RST.
-*****************************************************************
-20150210 ������
-1) ����tcp���ӵ�����˫��ʱmax_unorderδ���õ�����
-2) nouse״̬����syn��ʶ�������ӣ������ܹ����������Ľ������̣�
-3) ����fin״̬���������δ��tcpall�ӿ�ʱ��tcp���½����ӽ��д���
- ����tcpall�ӿں���Щ�������ᱻtcp����
- tcpall�ӿڵ���������tcp���������ı任��
- ������Э��ջ�ĽǶȣ�����tcpall�ӿں�Ĵ����������ģ�
- �����ж��ӵ�����ǣ�tcp��Ԫ�鸴�ã����ֶ���syn�����Ӳ�����������
-*****************************************************************
-20150225 ������
-1)��¼tcp���ĵ��ص�����internal�����ӱ���tcpoverlen
-2)tcplen>0���Ǵ�fin��rst�ȱ�־�����ݰ�����������
-3������syn�����һ�����ݰ������������ñ�־λΪtcpunorder
-4)����dictator2 ��20150215�汾
-******************************************************************
-20150226 ���
-1)�޸�stream_base.h, ����ַת�������ӿڱ��Ϊ:
-int stream_addr_list_ntop(const struct streaminfo *pstream, char *dst, int size);
-int stream_addr_list_pton(const char *addr_list_str, void *dst, int size, int thread_index);
-******************************************************************
-20150306 ���
-1)�������ģʽ��, IPv6���޷��ص���BUG.
-******************************************************************
-20150311 ���
-1)���IP��Ƭ�����ͬʱ��TCP�����������BUG,
- (֮ǰ�ѽ��, ������20150126�潫pkttype�����, û�ж�pktipflagtype��ֵ, ��BUG����).
-******************************************************************
-20150312 ���
-1)�޸�raw_ip_frag_listģ�飬v4��v6���ҵ�BUG.
-******************************************************************
-20150316 ����
-1)1-plugin.c:1259 add funelem->called_flag =1;
-�������pending״̬û�е���ҵ�������ÿ��data״̬������pending�ı�ʾ
-2-pending ����called_flag�ij�ʼ��
-3-close���ӶԵ��õ��ж�:����ò�����������ù����ߵ�ǰ�ֶ��Ǹò����
- ��Ҫ���ֶβ���close״̬���ã����򲻵���
-******************************************************************
-20150319 ���
-1)�޸�tcp_change_stream_todata()����, TCP�����ṹ�ڴ�й¶BUG.
-2)ƽ̨����ʹ��liblogger.so.
-******************************************************************
-20150311,25 ������, ���
-1������plugin��_20150325�汾
-2) �޸����������ж���cout_ideal�����ù���
-3��0319�޸�tcp_change_stream_todata()����, TCP�����ṹ�ڴ�й¶BUG .
-4��0311�����򻺴�����ݣ������ж��Ƿ����ش��ص������������
-5���޸��˶���seq�ıȽ�ʱ���ֵ������Ϊ��after��before�����Ƚ�
-6) ȥ�����ϰ汾��logger������ΪMESA_handle_logger
-7) �޸�test_app.so, TCP����ͳ����Ϣ����BUG.
-******************************************************************
-20150327 ���
-1)�޸�mac_n2p_fun()BUG.
-******************************************************************
-20150409 ���
-1)�޸����ò���MaxUdpStreams=0ʱ, UDP����õ���pdetailΪNULL��BUG.
-******************************************************************
-20150415 ��ѣ�������
-�ϲ�papp��20150401��BUG�޸�:
-1)�޸�deal_tcp.c ��������Ĵ����߼�
- ���ڴﵽ���������Ŀ�����ӣ��������ֳ�����������������������������
- �����������cout_ideal�����������У�ֻ�е���Ŵ�ʱ�Ŵ�
-******************************************************************
-20150416 ���
-1)����cycle_pkt_dump����, ���������������BUG���޷���������.
- main.conf������3��������:
- [pkt_dump]
- pkt_dump_switch=0 //�ܿ���
- pkt_dump_file_max_size=10000 //��λ:MB, ÿ���߳�
- pkt_dump_file_root_dir=/dev/shm //pcap�洢·��, �Ƽ�/dev/shm, �ٶȿ�
-******************************************************************
-20150430 ���
-1)�޸������ļ������ӳ�ʱʱ����Ч����.
- LinkTimeout=0, ����TCP
- UdpResetTime=0, ����UDP
-*********************************************************************
-20150507 ���
-1)������TCP������, �½�������,������������HASH����ͻ��ͳ�ơ�
-*********************************************************************
-20150508 ���
-1)����UDP������ͳ��.
-*********************************************************************
-20150512 ���
-1)�޸�GRE���س���Ϊ0ʱ, Invalid read��BUG.
-*********************************************************************
-20150526 ���
-1)�޸�pkt_dumpģ��, ���ź��ж϶�д�����BUG.
-*********************************************************************
-20150610 ���
-1)�޸�����ʱ��̭BUG.
-*********************************************************************
-20150612 ������
-1)�޸�del_stream_by_time()������β����̭BUG.
-*********************************************************************
-20150615 ���
-1)�޸�MAC��ַsrc,dst���������ķ���һ������.
-*********************************************************************
-20150702 ���
-1)����GRE-IPv6Э��Ľ�����
-*********************************************************************
-20150703 ���
-1)main.conf��������ѡ��"skip_not_ip_layer", ����˫ջ�����޷����ͷ�IP���ص�RST�����⡣
-*********************************************************************
-20150715 ���
-1)�޸�����BUG��ԭ��:
- ��HASH�����Ƚϵ�ַʱ��ֻ�Ƚ���IP�����˶˿ڣ�����һ��HASH-SLOT���ж����ͻ��ʱ��
- ���������Щ��Ԫ���IP������ͬ�ģ���ô�ͻ���ɺ������°�������Ϊ����������һ���֣�
- �����ᱻʶ���һ������.
-2)���Ӵӳ���������������������������ͳ����Ϣ��
-*********************************************************************
-20150902 ���
-1) ����iknow, �����ȡ���ࡢ����ϸ�ĸ�����Ϣ;
-*********************************************************************
-20150908 ���
-1) �޸�pkt_dumpģ��, ��������������ʷ���ܴ�С, ��ֹ����Ƶ���������������дӲ��;
-*********************************************************************
-20150916 ���
-1)����MESA_sleep(), ��ֹ��2.6.32�ں����ϣ�usleep(1)CPUռ���ʹ�������.
-*********************************************************************
-20150922 ���
-1)�޸�Iknow�ص������ӿڶ���.
-*********************************************************************
-20150928 ���
-1)�޸�pcap����ģ���ȡԭʼ����BUG, Ӧ��ʹ��caplen������Len,
- ��Ϊ����û�м�-s0ѡ����ʵ�ʲ���ij��ȱ����۰���С.
-*********************************************************************
-20150929 ���
-1)����topsec������ӿ�, ����ľ���豸��Ŀ, ���ٵ���ά��һ����֧�汾.
-*********************************************************************
-20151014 ���
-1)����MESA_sleep��ƽ̨,���usleep()�ڸ��ں˰汾��CPUռ����̫������.
-*********************************************************************
-20151027 ���
-1)�޸����ܰ����з�ʽʶ�𱾻�������RST����BUG��
-*********************************************************************
-20151030 ���
-1)�޸�teredoʶ��׼ȷ����;
-2)�޸�sysinfo.h��غ궨��, ijЩ��start�ɰ��г�ͻ, ���sysinfo.log������׼;
-*********************************************************************
-20151102 �����ƣ����
-1)�޸�������������������DROPPKT�����ƽ̨�������������������ʹCPUռ���ʸߵ�BUG;
-*********************************************************************
-20151104 ���
-1)�޸�TCP��UDP����ԭ֮��û�и���IP��Ƭ״̬��־BUG.
-*********************************************************************
-20151105 ���
-1)�޸�pkt_dumpģ�����ܽϲ�����;
-*********************************************************************
-20151106 ���
-1)�޸�pkt_dumpģ��, ����SIGSEGV�ź�, ���źŴ��������е���sync(), ��֤����segment fault��pcap�������ı��浽Ӳ��;
-*********************************************************************
-20151109 ���
-1)�޸�pkt_dumpģ�飬����BPF-Filter���˹���.
-*********************************************************************
-20151112 ���
-1)�����º���tcp_set_single_stream_drop_by_time(),
- ���õ�ǰ�����ٸ���RST��FIN�ȱ�־����, ֻ�ܵȳ�ʱ��������LRU��β��free.
- ����ijЩҵ��ʹ�õ�������FD����ʹ��.
-*********************************************************************
-20151112-2 ���
-1)���Ӻ���MESA_set_stream_opt(), ���ڿ��Ƶ������ӵ�����,
- ʹ������setsockopt�ķ�ʽ, �������Ӷ�������.
-*********************************************************************
-20151118 ���
-1)ȥ������ģʽ�¶԰������Ƿ񳬹�MTU�ļ��, ��Ϊ��TSOģʽ��, ���������������е������ȼ����ֽڵ����,
- ����Ӧ�ò���Ī�������ղ�ȫ���ݡ�
-*********************************************************************
-20151125 ���
-1)���ƽ̨�ڸ߰汾ϵͳ�±��뾯��ʹ���;
-2)�ر�Iknow��DEBUG��ӡ��Ϣ;
-
-*********************************************************************
-20151207 ���
-1)�޸��������ṹ, ��IP�Ͷ˿ڰ���һ����ַ����, ��ͨIPv4, IPv6Э��ֻ��һ��streaminfo�ṹ,
- TCP�㲻��ͨ��pfatherָ��ָ��IP���ַ,
- �ɽ�Լ�ڴ���������;
-*********************************************************************
-20151209 ���
-1)��������: skip_ethernet_layer,
- ���ڿ����Ƿ�����ethernet��, ���ٴ���MAC��ַ��Ϣ, �������Ч��.
-
-*********************************************************************
-20151215 ���
-1)HASH��ͻ��������LRU����, �����ʹ����Ƶ����������������һ��, ��߲���Ч��;
-2)ʹ��LINUX�ں�HASHʱ, һ��makehash������Եõ����HASHֵ,
- ʹ��һ��HASH����ȷ����HASH_SLOT��λ��,
- ��ʹ����һ��HASH���ڿ��ٱȽϵ�ַ�Ƿ����.
-
-*********************************************************************
-20151223 ���
-1)��������������, �����������ݰ����ֽ���,
- ���²����δ�õ���ǰ���ݰ�, ��ʵ���ֽ����Ѿ�����, ���¼�����׼ȷ,
- ���޸�.
-*********************************************************************
-************************* 2016 year *********************************
-*********************************************************************
-2016-01-19 ���
-1)�޸���IP-PORT�ϲ�֮��, inet_addr_list����BUG��
-*********************************************************************
-2016-06-08 ���
-1)�޸��ڰ�data������ʱ, ������TCPALL�����, ����������DROP, ��Ȼ�����TCP������߼�, ����HMD����Ч����.
-*********************************************************************
-2016-06-15 ���
-1)���Ӷ�����ACK������, �������ļ�discard_ack����;
-2)�޸�FD����ʱ, ��ԭ������3��RST, ����Ϊ1��.
-*********************************************************************
-2016-06-21 ���
-1)����������:kill_tcp_remedy, ���ڿ����Ƿ���FD���ȹ���.
-*********************************************************************
-2016-09-01 ���
-1)for soq��Ŀ, ���Ӷ�����Э��L2TP, PPTP, IPSEC�����Ӽ������־��¼��
- ����stream_tunnel.h.
-*********************************************************************
-2016-09-30 ���
-1)�޸�IPv6��Ƭ�����߳�ID���ô���, �����ڿ���dictator��coredump, ��������ͨmallocģʽ������.
-*********************************************************************
-2016-10-09 ���
-1)�޸�stream_inject.h, ����MESA_kill_tcp_feedback()�ȴ��������ܵĺ����ӿ�.
-*********************************************************************
-2016-10-12 ���
-1)����L2TP���FD����.
-*********************************************************************
-2016-11-10 ���
-1)���WY������������--ij��������������������ݰ�, �����������ȴ�, ���뱻�������ϵ���,
- ����POLLING���Ͳ�����, ��֤�����ݰ�ʱ, Ҳ����ô˽ӿڵIJ��.
-*********************************************************************
-2016-11-24 ���
-1)�޸�sappĿ¼�ṹ, ��ԭ��test���Ϊ����Ŀ¼run, ��Դ��Ŀ¼entry, ���ڲ�������copy.
-*********************************************************************
-2016-12-01 ���
-1)����PPPЭ�����CHAP��֤���û�������.
-*********************************************************************
-2016-12-05 ���
-1)�޸�stream_base.h, ����layer_addr_ntop(), layer_addr_prefix_ntop().
-*********************************************************************
-2016-12-15 ���
-1)��ǿIPv4����ʽ��У��, ���Ӷ԰��ضϵ�������ж�;
-1)�޸�pptp HASH����ʧ�ܺ�û��free��BUG.
-*********************************************************************
-2016-12-20 ֣��, ���
-1)����dictator, �޸�realloc BUG.
-*********************************************************************
-2016-12-21 ���
-1)����stream_addr_list_ntop, stream_addr_list_pton�Ⱥ���, �޸ĵ�ַ�ַ���ǰ׺����, ���׶�.
-*********************************************************************
-2016-12-22 ���
-1)�޸�ƽ̨�ڷ�X86ƽ̨���޷���������;
-2)�޸�dictator��ʼ����ȡ�����ļ�˳��BUG.
-*********************************************************************
-2016-12-26 ����, ���
-1)�����޸�plungin, �������ʧ�ܺ�, ����dlclose�ر�dlopen�򿪵��ļ����;
-*********************************************************************
-2016-12-27 ���
-1)�޸�pptp���������ҵ����ʱ, streaminfo�ṹ��ΪNULL��BUG;
-*********************************************************************
-2016-12-29 ���
-1)�޸�pptp�����޷�����inject����BUG(��ʱֻ֧��˫��������inject, ���������޷�֧��);
-
-*********************************************************************
-************************* 2017 year *********************************
-*********************************************************************
-
-*********************************************************************
-2017-01-03 ���
-1)����L2tp������HASH��ͻ��������, ������ֵ���ٴ�������.
-2)�޸�TCP������BUG, tcp_reset_stream()����ǰ���Ƴ�lru_list, ��tcp_deal_unorder()������,
- ���ܻ��ٵ���tcp_change_stream_tonouse(), �ٴε���streamleavlist, ��ʹplist->head, tail��ΪNULL.
-*********************************************************************
-2017-01-05 ���
-1)�޸�PPTP, L2TPЭ�������hash�㷨, ���ٳ�ͻ��.
-*********************************************************************
-2017-01-09 ���
-1)��2016-12-26, �������ʧ�ܺ�, ����dlclose�ر�dlopen�򿪵��ļ�����ķ�������ɳ���������޷��鿴��������ջ,
- ���Բ�������dlclose���;
-2)�޸Ĵ�ip_frag_list���ܺ�, UDP��ʱ����ʱ����ڴ�й©��BUG;
-3)�޸�����MESA_kill_tcp_feedback()������, MESA_sendpacket_iplayer()�Ⱥ���, �ڵ���packet_io_send_fake_pkt()ʱ, ���ݲ�������BUG.
-*********************************************************************
-2017-01-20 ���
-1)pcapģʽ����dictator��, �������˳�ʱfree�̲߳��ǰ������߳�, ���dictator assertʧ��.
-*********************************************************************
-2017-02-10 ���
-1)layer_addr_ntop()����OpenVPN��;
-2)�޸�l2tp, pptp��Ԫ��HASH�㷨������HASH��ͻ;
-3)��ʱ����SAPP_INSECTICIDE�꣬���ڼ��Ī�������BUG�������緢�����⡣
-*********************************************************************
-2017-02-11 ���
-1)����TCP-RST, UDP����ͳ�Ƽ�����
-*********************************************************************
-2017-02-16 ���
-1)�޸�get_stream_carry_tunnel_type()����PPTP, L2TP��ʶ��BUG��
-*********************************************************************
-2017-02-24 ���
-1)��DPDK��ʼ��ʱ�󶨵�ǰ�̵߳�ijCPU����, ���º�����̬�����������̶߳�Ĭ�ϼ̳������Ϊ, ȫ�󶨵�ͬһ������,
- �޸�packet_io��plug_proc�ij�ʼ��˳��
-*********************************************************************
-2017-04-07 ���
-1)�����µ�pag_marsioģʽ, ��Ҫ����ʹ��marsio��pag_get_frame�ӿڣ���֮ǰZhuanyong������pag_get_frame���֡�
-*********************************************************************
-2017-04-21 ���
-1)����327��Ipfile����ģʽ��
-*********************************************************************
-2017-05-11 ���
-1)main.conf���������ļ�ipentry_priority_over_ipfrag�����ڿ���IP���IPFRAG��������ȼ�;
-2)���Ӱ�����PKT_TYPE_IP_FRAG_LAST����ʾͬ����һ��ԭʼIP�������һ��IP��Ƭ����
-*********************************************************************
-2017-05-15 ���
-1)֧��marsio-4.1ԭ���ӿ�.
-*********************************************************************
-2017-05-24 ���
-1)֧�ֽ�sapp��Ϊһ����̬���ӿ�.so, �ɹ��ص�����ƽ̨�ϵ�IP_entry, ��������TCP����ԭ��streaminfo���ֱ�����һ�µ�ʱ��,
- ��Ϊ���ʹ��ʱ��Ĭ��ʹ�ù̶�Ŀ¼/home/mesasoft/sapp.
-*********************************************************************
-2017-06-08 ��ѣ�����
-1)��wangyan����ܶ�����Ϊ���ʵ��, ����callapp.c��������������̣����¼�����������ʱ�ȡ�
-*********************************************************************
-2017-06-12 ���
-1)ƽ̨�޸�����̭����, ҵ���������ö����ij�ʱʱ��, ���UDP��һ��ʱ���ް�����, Ҳ������������������̭��
-*********************************************************************
-2017-06-27 ���
-1)���GDEV����ģʽ���޸ĵײ��շ����ӿڣ�
-2)����stream_base.h, stream_inject.h, stream_rawpkt.h;
-3)��GDEV���������Ƴ�ƽ̨����Ϊ�����������;
-4)���Ӽ��ʵ�����л�����stream_inc�͵�ǰsapp�汾��һ�£���ӡ���湦�ܡ�
-
-*********************************************************************
-2017-06-28 ���
-1)���Ӽ��ʵ�����л�����stream_inc�͵�ǰsapp�汾��һ�£���ӡ���湦�ܡ�
-*********************************************************************
-2017-07-10 ���
-1)marsioģʽ�������Ӵ�main.conf�л�ȡapp_name���ܣ�
-2)�޸�UDP��ʱ��̭���ƣ���reset��ǰ���⣬��������̭������ʱ������
-*********************************************************************
-2017-08-03 ���
-1)����TCP�������Ʋ�Զ�ISN����;
-1)����TCP�������Ʋ�Զ��ܼƽ����ֽ�������;
-*********************************************************************
-2017-08-08 ���
-1)�޸�tcpdump_mesa, ֧��ָ�������߳�ID
-*********************************************************************
-2017-08-24 ���
-1)�޸�tcpdump_mesa, ���Ӳ��������ʣ���ֹ�ڴ����������¶�����
-*********************************************************************
-2017-09-04 ���
-1)���Ӻ���sapp_get_platform_opt(), �������ȡƽ̨�ڲ���������������ֽ����ȡ�
-2)marsio4����֧��runtime��⣬ƽ̨����runtime.log����¼����������ʱ��
-3)�ϲ�����������ISN��ȱ��, ����ͨ��C2S�����SYN,ACK���������S2C��ISN.
-*********************************************************************
-2017-09-05 ���
-1)�޸�tcp��ȡsyn��ѡ��dir�������BUG;
-*********************************************************************
-2017-09-21 ���,����
-1)���ӻص�����platform_register_action_judge, ƽ̨���յİ�ת������ֵPASS or DROP���ⲿ�������.
-2)�޸IJ������ģ�飬����ֵ����ҵ��������, FD or JC����;
-3)�޸�Ĭ�ϲ�ʶ������ת������, GDEVģʽ��ΪDROP;
-*********************************************************************
-2017-09-26 ���
-1)�޸�2017-05-11�޸�ip_entry��ip_frag_entry�������ȼ�������IP�������ip_frag_entry��BUG.
-*********************************************************************
-
-2017-09-28 ���
-1)���Ӱ�ҵ��ű���ܣ�WY������ֻ����Ӧ��������gdev��������ҵ���;
-*********************************************************************
-2017-10-03 ���
-1)���ӽ���TCP��ͷ��ѡ��TCP_OPT_MULTI_PATH_TCP, ��ѡ��������ҿ��ܳ���8�ֽڣ�
- ԭ�нṹ�����ã�Ϊ��������ͬʱ֧����ѡ�
- ����struct tcp_option_ext�ṹ��
- ������MESA_get_tcp_pkt_opts_ext().
-*********************************************************************
-2017-10-10 ���
-1)�޸���DDPģʽ��tcpdump_mesa�İ�����λ�ã����Բ���DDP�ڷ�װ��ԭʼ����
-*********************************************************************
-2017-10-16 ���
-1)�����ж���Ԫ�����õ��жϡ�
-2)����iknow_switch�����ļ�, iknow���ܿ��Թر�, Ĭ�Ͽ���.
-3)����symbol_conflict_check�����ļ�, �����������Թر�, Ĭ�Ͽ���.
-*********************************************************************
-2017-10-19 ���
-1)����anti_floodģ��, ���ڵ���SYN_flood, DNS_flood����;
-2)�޸�TCPALL���, �������SYN, SYN/ACK����������Ϊ����Ԫ������, �������Ӷ����±��ֲ�Ϊ��������BUG.
-*********************************************************************
-2017-10-26 ���
-1)Gserial_sendϵ�к������ӷ�����־, ����WY�����²�������.
-2)����field_stat���.
-*********************************************************************
-2017-10-31 ���
-1)�޸���pcap.h, libpcap.so�ڴ��µ�ϵͳ��ȱʧ����һ���޷�����������
-2)�޸�PPTP����Э�飬��PPPͷ��ѹ����û�л�ȡPPTP��������ʱ���޷����������⡣
-*********************************************************************
-2017-11-09 ���
-1)Gserial_sendϵ�к���������ip, tcp, udp��Э������ͳ�ơ�
-2)����pcap.h, �ڴ��»����Ͽ��Ա���ͨ��.
-*********************************************************************
-2017-11-13 ���
-1)����GDEV���������ȡ�ӿ�, ����ͳ��;
-*********************************************************************
-2017-11-24 ���
-1)VxLanģʽPPP��HDLC��װ, MAC��ַΪ�����������, ���������ж��㲥���鲥�Ȳ���.
-*********************************************************************
-2017-12-08 ���
-1)�޸�ƽ̨����TCPALL����߼�, �ȵ���TCPALL, �����TCP;
-2)����һ�������װ���RST��SEQ=0�İ���ƽ̨���Բ�������
-*********************************************************************
-2017-12-20 ���
-1)l2tp_protocol_plug�޸���ַ�������ȳ���ΧBUG;
-2)����TCP����ԭ����, ��Ԫ�������ж������һ������ʱ����, ̫������Ϊ�Ƕ�������, ����.
-
-*********************************************************************
-************************* 2018 year *********************************
-*********************************************************************
-
-2018-01-19 lijia add,
-1-���tcpdump_mesaͬʱ����ʱ, ���������ӻ���ռ��һ�����ӵ�������, ��ʹ�õ�һ�����ӵĹ�������,
- ����TCP�������ӵ�ȷ�ϻ���, ���sapp���ظ�ȷ�ϰ�, tcpdump_mesa����������.
-
-2-���Ӷ�������, ���ʹ��-a����ָ��perceptiveģʽ, sapp�ڷ��Ͱ�ʱ, ��ԴMAC��ַ�ϴ������,
- tcpdump_mesa�������Ƿ�����, ��ȷ���м��Ƿ��ж���, ���˼�����.
-*********************************************************************
-2018-02-28 ���
-1)�޸�����Ҫ��������ʱ, gdev�Լ��������BUG;
-2)�޸�vxlanģʽ��, �����㲥���鲥�����ж��߼�.
-*********************************************************************
-2018-03-02 lijia add,
-1������ģʽFDЧ�����ã�����FD������GDEV�·������ܣ����������������FD�ʡ�
-*********************************************************************
-2018-03-13 ���
-1)�޸�teredo�����DZ�׼�˿��޷�ʶ������.
-*********************************************************************
-2018-03-23 ���
-1) �޸�GDEV�����·����BUG.
-*********************************************************************
-2018-04-17 ����
-1)����Ӧ�ö���ͨ�������ļ�PLUGINFO��ã��ù������ܿ����ӣ�����sapp����Ҫ��ԭ����ע�͵�����plugin.c:733�С�
-*********************************************************************
-2018-04-25 ���
-1)�޸�get_this_layer_header()����, ������ʱ��̭ʱ��BUG;
-*********************************************************************
-2018-07-10 ���
-1)�޸�private_ip��ʶ�����BUG;
-*********************************************************************
-2018-08-01 ���
-1)���3x7��Ŀ�����Ӱ���3x7���ݰ�ͷ���ܣ����ڲ�ԭʼ���ݰ���ע��ipv4_entry();
-*********************************************************************
-2018-08-03 ���
-1)�޸�IPͷ����ⲻ֧��ESP����, ����IPSECҵ�񱻶���.
-*********************************************************************
-2018-09-23 ���
-1)���Ӷ�MAC_IN_MAC���������ʽ�Ĵ���;
-2)�޸�MAC_IN_MAC��װ��ʽ��, RST����BUG.
-3)�޸��жϹ㲥���鲥���ж��߼�, vxlanģʽ�¶���vxlan��װ�����ݰ������жϣ�
-4)֧��IPV6����.
-*********************************************************************
-2018-10-13 ���
-1)�޸�IP��ͷ��⺯��, ��Э�������ֶεļ��, ��ֹ����ijЩ������Э������ݰ�.
-*********************************************************************
-2018-10-19 ���
-1)�޸�field_stat���TCP����������BUG.
-*********************************************************************
-2018-10-24 ���
-1)���Ӷ�MAC_IN_MAC�ĵ�ַ����, ���л�ȡGDEV_ID, LINK_ID, LINK_DIR�Ȳ���.
-*********************************************************************
-2018-11-02 ���
-1)�޸�mpls_hdrͷ���������;
-2)�������Ƕ��MPLS���ݰ�.
-*********************************************************************
-2018-11-05 ����
-1)�޸�Դ��, ����cmake����.
-*********************************************************************
-2018-11-08 ����
-1.����gprs tunnelЭ��ʶ���߼���ʹ��identify_gtp������ȡ��ԭ�еĽ�ʶ��˿ڵ��߼�
-2.����packet_io_send_fake_pkt_gdev�����߼�����ȷ�ļ���ƫ����д��������ʱ��data��datalen
-3.����packet_io_send_fake_pkt������ע�뷢����ֱ�ӵ���packet_io_send_fake_pkt_by_gdev
-4.MESA_send_handle����raw_udp_fd���ڴ�udp���ؿ�ʼ����ע���
-6.����Gserial_sendpacket_ipv6_layer()����, ���Է����ѹ���õ�IPV6���ݰ�.
-*********************************************************************
-2018-11-09 ����
-1.����TODO������Ҫ�̶ȷּ�
-2.�Ƴ�runĿ¼�µ�log�ļ�
-3.����GTP�����߼������ӶԴ�seq��Ϣ�Ĵ����������ڵ�ַ��
-*********************************************************************
-2018-11-12 ����,���
-1.����GTP�����߼�, ���ӶԶ˵�ַ(TEID,SEQ��)�����߼���
-*********************************************************************
-2018-11-16 ���
-1)֧��cmake, �벢���汾����ͬ��.
-
-*********************************************************************
-**************************** 2019 Year ******************************
-*********************************************************************
-2019-05-15 ���
-1)sapp version 4.0!
-2)������������ļ���ʽ;
-3)֧�������в���;
-4)�����ش���´������汾����......
-#endif
diff --git a/src/readme_UTF8.txt b/src/readme_UTF8.txt
deleted file mode 100644
index 3e0f411..0000000
--- a/src/readme_UTF8.txt
+++ /dev/null
@@ -1,748 +0,0 @@
-#if 0
-1.本部分代码主要两个功能
- 1)完成底层数据包的获取, 支持多种数据获取方式pag,ppf,pfring,
- 2) 完成tcp、udp的流还原功能
- 3) 完成插件挂载功能
-*********************************************************************
-20130802 刘庆云
-1)tcp建立链接时,为了抗攻击,对单侧流必须有第三个包
-2)增加控制开关,选择建立链接的方式
-****************************************************************************
-20130803 刘庆云 优化流还原模块的处理
-1) 每个包到来时按照两侧端口号,建立临时流表;
- 如果出现小端口为服务端时,通过syn判断出后,颠倒四元组;
- 每个流表进行hash时不在进行判断,直接用四元组;
-2) 流表加入hash时按照四元组大小进行排序,插入的位置在findstream时提前算好,减少插入时的计算;
-3) dealpkt部分的代码重新梳理,后得出能够独立运行的代码,不在依赖外层的 stack,support
-4) 编写测试部分的独立测试函数,并进行测试;
-****************************************************************************
-20130805 刘庆云
-1) 建立流表的端口的改为判断主机序列;
-2)双向流收到第三个包后,直接进入数据表,起到保护真实链接的目标;
-****************************************************************************
-20130813 刘庆云
-1)tcp流表的查找改为折半查找
-*********************************************************************************************
-20130821 李佳
-1)针对某项目需求: 如果IP包是由多个IP分片包重组而成, 应用层插件可以获取所有原始IP分片包,
- 新增加raw_ipfrag_list结构, 并在streaminfo结构中添加原始IP分片列表头指针.
- 修改stream.h、dealpkt.c、dealtcp.c、deal_ipv4.c、deal_ipv6.c、ip_reassembly.c等与IP分片相关代码.
-****************************************************************************
-20130822 刘庆云
-1)增加tcp全包回调接口,全包回调时可能会没有pdetail,
-2)为了能够判断正确是否有pdetail,之前服用pdetail信息来存储synseq的方式不再可行,增加了变量用于临时记录seq
- 同时,为了能够同时支持两种模式增加了pktstate和用于函数上下文的变量pktallme
- pktstate的变换逻辑如下:第一个包为pending,如果有函数需要则该为data,如无需要改为close,链接淘汰时为close
-3)当有全包获取函数挂载时,正常的fin,rst不会淘汰链接只能等淘汰
-4)为了在不同tcp接口情况下,挂载函数能够统一管理,函数调用链表函数需要传入xxstat和xxpme;
-5) streaimindex改为预先分配需要的个数,这样是为了防止当处理过程中调用tcp_free_stream之后又进行使用出现野指针
- 另外一种避免的方法是没错传入**,接口比较麻烦,暂未使用
-
-6)增加takeover模式,目前只支持注册一个接管函数;
-7) syn+rst的报文也建立链接
-**********************************************************************
-20130826 刘庆云
-1) mkstreamhash 用frand参与hash运算多了一次拷贝, 并且大部分情况为0,造成hash冲突,因此只用地址参与运算
-
-**********************************************************************
-20130917,18 刘庆云
- 1) hash_add_stream 必须在streamaddlist前进行,否则streamaddlist内淘汰一些链接后会造成
- hash_add_stream利用的之前查找的结果为错误结果
- 2) 每次淘汰的链接数目为总链接数目的2%
-
-******************************************************************************************
-20130922 李佳
-1)增加NPacket捕包方式, 编译参数"CAPTURE_MODE=$(LINK_NP)", 对应配置文件"capdatamodlel=5"
-******************************************************************************************
-20140302 刘庆云 从dealpkt到platform 合并之前的各种修改
-1)dealpkt目录增加ipv6支持
-2)dealpkt目录合并之前修改的tcp_allpkt接口,调整等
-3)dealpkt目录合并之前修改的丢包计数分侧的bug
-4)dealpkt目录中dealpkt.c dealtcp.c未合入108相关代码,
- call_app未合入863_control的代码
-5)合并plugin 支持插件管理功能
- (1)程序调用接口:plugctrl_proc() ;(无参数)
- (2)程序作用:
- a、自动扫描解析层、业务层、兼容插件三个文件夹下插件(默认路径分别是./plug/protocol,./plug/business,./plug/general,可通过./wyqd.conf中参数更改此路径),调用其初始化函数;
- b、并将IP_ENTRY,TCP_ENTRY,UDP_ENTRY三个入口指针分别挂载到对应函数调用链上;
- c、保存其他入口函数指针,解析层调用时使用;
-******************************************************************************************
-20140322 刘庆云 为了支持代理嵌套,进行了若干修改
-1)tcp部分原来设计只有当进入data状态后,才分配pdetail的空间;现在修改为
- 流一建立就分配pdetail的空间,当进入data后才分配half的空间
-2)重新规整了stream结构体的定义,
- 原来和流相关的一些变量,全部移入pdetail,包括apme等;
-3)流表的管理,用最里层的地址做hash,用多层地址递归进行比较
-4)初步添加了对vlan的处理函数,待完善
-******************************************************************************************
-20140323 刘庆云 为了支持应用层代理,进行修改
-1) tcpdetail结构体内增加proxylist指针,记录代理情况
-2) proxylist的申请,释放,有代理解析层控制;
-3) 代理结构体内自带pme,opstate,用这两个变量回调所有的接口函数
-******************************************************************
-20140406 李佳
-1)增加对隧道的处理,理论上支持无限嵌套模式;
-2)修改stream.h中ADDR_TYPE_IPV4地址类型定义,不再代表基于IPv4地址的四元组,
- 而是真正的IPv4地址对, 四元组使用struct stream_tuple4表示;
-3)细化分层结构,TCP层不再存储四元组信息,而是仅存储本层的端口信息,
- 计算HASH以及地址比较时,再通过fstream找到IP地址;
-4)修改计算HASH函数、HASH冲突后的比较函数;
-5)将某项目的特殊应用,如标签、stream_id、原始IP分片包剥离并模块化,
- 使用开关灵活控制某个模块的启用;
-6)把底层捕包库封装成.so模式,在不同的捕包模式间切换时,只要修改配置文件即可,无需从编译。
-******************************************************************
-20140422 李佳
-1)为了处理效率,减少内存占用,及插件获取四元组的易用性,
- 将TCP、UDP的端口存储于IP层,TCP层用指针指向IP层此块内存,即可以直接获取四元组信息。
-******************************************************************
-20140515 李佳
-针对863-UDP流还原测试硬件环境,增加QNF捕包接口.
-******************************************************************
-20140616 李佳
-1)增加project管理模块,在stream->pproject结构中,可以任意挂载多个应用信息;
-******************************************************************
-20140619 李佳
-1)增加raw_pkt_t结构,存储从捕包库获取的原始包信息;
-2)插件入口函数增加原始包参数;
-3)修改IP分片重组流程,支持隧道多层嵌套模式
-******************************************************************
-20140721 李佳
-1)IP分片重组HASH支持多层嵌套模式;
-2)将原IP分片重组HASH模块改成基于MESA_htable实现;
-******************************************************************
-20140901 李佳
-1)串联模式下,应用可能会误改原始包,增加对原始包数据校验功能。
-******************************************************************
-20140910 李佳
-1)增加MESA_inject_pkt()发包接口,简化造包操作,减少传参数量.
-******************************************************************
-20140922 李佳
-1)增加MESA_kill_tcp_synack()接口, 用于IP-HMD的欺骗连接;
-******************************************************************
-20141011 李佳
-1)增加读取配置文件变量maxrandval, randkeyval,用于识别系统发出的RST包;
-2)fd补救由平台实现, 插件可以认为MESA_kill_tcp()是可靠的!
-******************************************************************
-20141113 李佳
-1)修改创建连接有地址翻转时,因TCP流表查找错误,造成无法识别某些流的BUG。
-******************************************************************
-20141115 李佳
-1)增加MESA_kill_connection()函数,除了可以实现MESA_kill_tcp()原有功能外,
- 还可以在串联模式下,对基于流的非TCP协议做fd(drop packet).
-******************************************************************
-20141120 李佳
-1)增加pcap读大包模式进度条显示,预测处理时间.
-******************************************************************
-20141125 李佳
-1)修改pcap模式下, 多线程分流BUG,其他模式(pag、pfring、dpdk等等)不受影响。
-2)更新plunin模块,version:2014-11-24
-******************************************************************
-20141127 李佳
-1)修改最大乱序包数最大值,由255扩展为65535, 修改了stream.h中关于maxunorder的定义.
-******************************************************************
-20141202 李佳
-1)修改在pcap读包模式下,读包线程调用freeall_stream()早于工作线程导致的BUG;
-2)增加平台和packet_io_lib版本号对比判断,如果不一致会打印警告信息;
-3)修改淘汰UDP流时,pktstate没有正确设置为CLOSE状态BUG;
-4)配置文件增加"UdpStreamTimeout", 用于设置开启UDP流还原时,超时淘汰时间;
- 增加"load_plug_switch", 用于动态开启是否加载插件;
-5)增加了sysinfo.log统计信息显示.
-******************************************************************
-20141204 李佳
-1)修复在pag模式下运行时,IPv4和IPv6共存时的BUG,
- 在顶级Makefile中增加"USE_PAG_GET_FRAME",
- 根据环境选择是否使用pag_get_frame()直接获取mac包.
-******************************************************************
-20141205 李佳
-1)修复IPv6-UDP数据包, 在开启UDP流还原的情况下, 无法找到对应的流, 造成HASH冲突链表爆炸BUG。
-******************************************************************
-20141208 李佳
-1)增加build_net_layer_gre()函数,可以构造带GRE协议的rst包.
-******************************************************************
-20141211 李佳
-1)修改因IP分片重组后的包,而触发调用MESA_kill_tcp()的BUG;
-2)修改MESA_kill_tcp()计算包长度BUG;
-3)原始包结构raw_pkt_t中增加__magic__, 用于在papp和sapp平台之间区分原始包void *的实际类型.
-******************************************************************
-20141217 李佳
-1)增加pag模式下,使用pag_get_frame接口功能, 用顶层Makefile的USE_PAG_GET_FRAME选项控制;
-2)修改流还原按data建连接时,以大端口为源的规则;
-3)修改了因重载了系统标准库exit(), 造成程序退出时莫名其妙的BUG.
-******************************************************************
-20141219 李佳
-1)为了兼容之前插件, 修改IPv4, IPv6层插件原始包指针为本层IP包指针.
-******************************************************************
-20141223 李佳, 刘庆云
-1)增加SAPP_PKT_CB_FUN_T回调函数类型:
- char SAPP_PKT_EXAMPLE(const struct streaminfo *pstream, const void *this_hdr, const void *raw_pkt);
-******************************************************************
-20141224 李佳
-1)修改stream.h,将内部变量与外部变量分离,根据功能的不同,将stream.h分拆为:
- #include "stream_inc/stream_base.h"
- #include "stream_inc/stream_proxy.h"
- #include "stream_inc/stream_project.h"
- #include "stream_inc/stream_inject.h"
- #include "stream_inc/stream_control.h"
- #include "stream_inc/stream_entry.h"
- #include "stream_inc/stream_rawpkt.h"
-******************************************************************
-20141225 李佳
-1)将ip分片重组类型的包,用Pkttype标识,用于流管理层识别.
-2)增加了一些不常见的协议类型处理, 如vlan、pppoe、ppp的非数据传输层协议.
-******************************************************************
-20141226 李佳
-1)增加PPP和GRE协议的解析;
-******************************************************************
-20141230 李佳
-1)增加addr_type_to_string()函数,用于插件输出协议地址类型字符串;
-2)增加get_this_layer_header(),用于插件获取本层头部地址;
-3)修改STREAM_CB_FUN_T回调函数的"原始包"参数,改为传输下层IP层的头部,
- 真正的全原始包应使用SAPP_STREAM_FUN_T类型回调.
-******************************************************************
-20141231 刘庆云 李佳
-1)平台同时支持传原始包和本层包头的接口,增加回调函数类型定义,
- 修改callapp.c中stream_register_xxx和stream_process_xxx系列函数.
-2)合并dictator2的20141217版本.
-******************************************************************
-20150104 李佳
-1)修改stream_base.h, 将pkttype移动至struct layer_addr结构中,
- 将routedir扩展为uchar类型;
- 新增MESA_dir_reverse()函数, 用于发包时反向routedir.
- stream.h增加版本号和MD5验证值.
-2)增加MESA_fakepacket_xxx系列函数.
-******************************************************************
-20150107 刘庆云
-1)reset重建链接时,重置计数器
-2) 判断syn是否重传的条件 从原来的(thisseq+1 == rcv->first_data_seq)
-改为( rcv->first_data_seq-thisseq <=1)
-3) 为了防止syn重置的链接syn在第一个链接里面,改为先调用tcp,再调用tcpall
-4) 由于3)的修改,对于每个链接重置时rst,需要传递原始包给free_stream的函数
-******************************************************************
-20150112 李佳
-1)修改tcp_deal_data_stream,tcp_save_unorder,deal_tcp_stream等函数的参数,
- 增加Iphdr和tcphdr参数,用于传递重组后的IP分片包。
-2)FD补救时增加判断条件,只有tcpdatalen > 0时,才继续调用MESA_kill_tcp,
- 以防止攻击或本机发送的RST包又被捕获;
-******************************************************************
-20150123 刘庆云
-1) pkttype 增加PKT_TYPE_TCPREORDER,需要每个包来了赋值
-2) proxy增加对地址的虚拟转换
-******************************************************************
-20150126 lqy yw
-1) pkttype 增加PKT_TYPE_TCPRESTRAS 增加重传报文的类型
-2) tcp_stream_free重置顺序,先进行tcp,再进行tcpall
-3) pkttype 分离成两个变量,pktipflagtype
-******************************************************************
-20150129 李佳,刘庆云, 刘洋
-1)sapp增加-v参数,用于识别版本功能, 对外提供的可执行文件要strip, 通过nm命令无法查看.
-2)sapp内置libsesame_door,用于限制平台使用范围,保护软件产权;
-3)callapp内支持udp_raw接口
-4)插件管理更改;打开解析层插件,符号表为全局可见
-******************************************************************
-20150203 李佳
-1)新增四个地址转换函数:
- const char *stream_addr_list_ntop_outward(const struct streaminfo *pstream);
- const char *stream_addr_list_ntop_inward(const struct streaminfo *pstream);
- const struct streaminfo *stream_addr_list_pton_outward(const char *addr_list_str, int thread_index);
- const struct streaminfo *stream_addr_list_pton_inward(const char *addr_list_str, int thread_index);
- 修改stream_base.h, 增加以上函数声明.
-2)增加类型定义PKT_TYPE_IP_FRAG;
- 增加stream_register_ip_frag, stream_register_ipv6_frag入口函数.
-******************************************************************
-20150205 李佳
-1)增加基于PPP,GRE协议的RST包构造功能,
- 因GRE没有创建流,目前只能单向发送RST.
-*****************************************************************
-20150210 刘庆云
-1) 修正tcp链接单流变双流时max_unorder未设置的问题
-2) nouse状态看到syn标识重置链接,这样能够看到新流的建立过程;
-3) 对于fin状态后的数据在未开tcpall接口时,tcp会新建链接进行处理
- 而开tcpall接口后,这些包都不会被tcp看到
- tcpall接口的引入引起tcp处理包数的变换,
- 从正常协议栈的角度,引入tcpall接口后的处理是正常的;
- 但是有恶劣的情况是,tcp四元组复用,而又丢了syn的链接不能正常处理
-*****************************************************************
-20150225 刘庆云
-1)记录tcp报文的重叠长度internal内增加变量tcpoverlen
-2)tcplen>0但是带fin,rst等标志的数据包不建立链接
-3)对于syn后面第一个数据包乱序的情况,置标志位为tcpunorder
-4)更新dictator2 到20150215版本
-******************************************************************
-20150226 李佳
-1)修改stream_base.h, 将地址转换函数接口变更为:
-int stream_addr_list_ntop(const struct streaminfo *pstream, char *dst, int size);
-int stream_addr_list_pton(const char *addr_list_str, void *dst, int size, int thread_index);
-******************************************************************
-20150306 李佳
-1)解决隧道模式下, IPv6层无法回调的BUG.
-******************************************************************
-20150311 李佳
-1)解决IP分片重组包同时在TCP层是乱序包的BUG,
- (之前已解决, 后来在20150126版将pkttype分离后, 没有对pktipflagtype赋值, 此BUG重现).
-******************************************************************
-20150312 李佳
-1)修复raw_ip_frag_list模块,v4和v6混乱的BUG.
-******************************************************************
-20150316 刘洋
-1)1-plugin.c:1259 add funelem->called_flag =1;
-否则如果pending状态没有调用业务层插件,每个data状态都会有pending的标示
-2-pending 增加called_flag的初始化
-3-close增加对调用的判断:如果该插件曾经被调用过或者当前字段是该插件所
- 需要的字段才在close状态调用,否则不调用
-******************************************************************
-20150319 李佳
-1)修改tcp_change_stream_todata()函数, TCP半流结构内存泄露BUG.
-2)平台不再使用liblogger.so.
-******************************************************************
-20150311,25 刘庆云, 李佳
-1)更新plugin到_20150325版本
-2) 修改了乱序报文中对于cout_ideal的重置过程
-3)0319修改tcp_change_stream_todata()函数, TCP半流结构内存泄露BUG .
-4)0311对乱序缓存的数据,增加判断是否有重传重叠,如有则矫正
-5)修改了对于seq的比较时出现的问题改为用after,before函数比较
-6) 去掉了老版本的logger,更新为MESA_handle_logger
-7) 修改test_app.so, TCP层插件统计信息错误BUG.
-******************************************************************
-20150327 李佳
-1)修改mac_n2p_fun()BUG.
-******************************************************************
-20150409 李佳
-1)修改配置参数MaxUdpStreams=0时, UDP插件得到的pdetail为NULL的BUG.
-******************************************************************
-20150415 李佳,刘庆云
-合并papp在20150401的BUG修复:
-1)修改deal_tcp.c 对乱序包的处理逻辑
- 对于达到最大乱序数目的链接,乱序中又出现乱序的情况,跳出本次乱序处理;
- 对于乱序包的cout_ideal重置条件进行,只有当序号大时才从
-******************************************************************
-20150416 李佳
-1)增加cycle_pkt_dump功能, 解决在线流量出了BUG,无法重现问题.
- main.conf中新增3个配置项:
- [pkt_dump]
- pkt_dump_switch=0 //总开关
- pkt_dump_file_max_size=10000 //单位:MB, 每个线程
- pkt_dump_file_root_dir=/dev/shm //pcap存储路径, 推荐/dev/shm, 速度快
-******************************************************************
-20150430 李佳
-1)修改配置文件对连接超时时间无效问题.
- LinkTimeout=0, 用于TCP
- UdpResetTime=0, 用于UDP
-*********************************************************************
-20150507 李佳
-1)新增加TCP连接数, 新建连接数,销毁连接数,HASH表冲突数统计。
-*********************************************************************
-20150508 李佳
-1)增加UDP连接数统计.
-*********************************************************************
-20150512 李佳
-1)修复GRE负载长度为0时, Invalid read的BUG.
-*********************************************************************
-20150526 李佳
-1)修复pkt_dump模块, 因信号中断读写错误的BUG.
-*********************************************************************
-20150610 李佳
-1)修复流超时淘汰BUG.
-*********************************************************************
-20150612 刘庆云
-1)修复del_stream_by_time()从链表尾部淘汰BUG.
-*********************************************************************
-20150615 李佳
-1)修复MAC地址src,dst与流创建的反向不一致问题.
-*********************************************************************
-20150702 李佳
-1)增加GRE-IPv6协议的解析。
-*********************************************************************
-20150703 李佳
-1)main.conf增加配置选项"skip_not_ip_layer", 用于双栈环境无法发送非IP承载的RST包问题。
-*********************************************************************
-20150715 李佳
-1)修复丢流BUG,原因:
- 在HASH函数比较地址时,只比较了IP忘记了端口,当在一个HASH-SLOT中有多个冲突链时,
- 如果凑巧这些四元组的IP都是相同的,那么就会造成后续的新包被误认为是已有流的一部分,
- 而不会被识别成一个新流.
-2)增加从程序启动以来,处理的所有流数统计信息。
-*********************************************************************
-20150902 李佳
-1) 集成iknow, 方便获取更多、更详细的辅助信息;
-*********************************************************************
-20150908 李佳
-1) 修改pkt_dump模块, 可以设置所有历史包总大小, 防止程序频繁重启造成无限制写硬盘;
-*********************************************************************
-20150916 李佳
-1)集成MESA_sleep(), 防止在2.6.32内核以上,usleep(1)CPU占用率过高问题.
-*********************************************************************
-20150922 李佳
-1)修改Iknow回调函数接口定义.
-*********************************************************************
-20150928 李佳
-1)修改pcap捕包模块获取原始包长BUG, 应该使用caplen而不是Len,
- 因为可能没有加-s0选项,造成实际捕获的长度比理论包长小.
-*********************************************************************
-20150929 李佳
-1)增加topsec捕包库接口, 用于木马设备项目, 不再单独维护一个分支版本.
-*********************************************************************
-20151014 李佳
-1)增加MESA_sleep到平台,解决usleep()在高内核版本下CPU占用率太高问题.
-*********************************************************************
-20151027 李佳
-1)修复不能按已有方式识别本机发出的RST包的BUG。
-*********************************************************************
-20151030 李佳
-1)修改teredo识别不准确问题;
-2)修改sysinfo.h相关宏定义, 某些与start旧版有冲突, 造成sysinfo.log计数不准;
-*********************************************************************
-20151102 刘庆云,李佳
-1)修改因乱序包触发插件返回DROPPKT,造成平台乱序包链表逐渐增长,致使CPU占用率高的BUG;
-*********************************************************************
-20151104 李佳
-1)修改TCP、UDP流还原之后,没有更新IP分片状态标志BUG.
-*********************************************************************
-20151105 李佳
-1)修改pkt_dump模块性能较差问题;
-*********************************************************************
-20151106 李佳
-1)修改pkt_dump模块, 捕获SIGSEGV信号, 在信号处理函数中调用sync(), 保证触发segment fault的pcap包真正的保存到硬盘;
-*********************************************************************
-20151109 李佳
-1)修改pkt_dump模块,增加BPF-Filter过滤功能.
-*********************************************************************
-20151112 李佳
-1)增加新函数tcp_set_single_stream_drop_by_time(),
- 设置当前流不再根据RST、FIN等标志结束, 只能等超时、或移至LRU队尾后被free.
- 用于某些业务使用第三方的FD补救使用.
-*********************************************************************
-20151112-2 李佳
-1)增加函数MESA_set_stream_opt(), 用于控制单个链接的属性,
- 使用类似setsockopt的方式, 不再增加独立函数.
-*********************************************************************
-20151118 李佳
-1)去掉捕包模式下对包长度是否超过MTU的检查, 因为在TSO模式下, 本机捕包经常会有单包长度几万字节的情况,
- 导致应用层插件莫名其妙收不全数据。
-*********************************************************************
-20151125 李佳
-1)解决平台在高版本系统下编译警告和错误;
-2)关闭Iknow的DEBUG打印信息;
-
-*********************************************************************
-20151207 李佳
-1)修改流创建结构, 将IP和端口绑定在一个地址集合, 普通IPv4, IPv6协议只需一个streaminfo结构,
- TCP层不再通过pfather指针指向IP层地址,
- 可节约内存和提高性能;
-*********************************************************************
-20151209 李佳
-1)增加配置参数: skip_ethernet_layer,
- 用于控制是否跳过ethernet层, 不再处理MAC地址信息, 提高运行效率.
-
-*********************************************************************
-20151215 李佳
-1)HASH冲突链表增加LRU机制, 将最近使用最频繁的流放于链表第一个, 提高查找效率;
-2)使用LINUX内核HASH时, 一次makehash计算可以得到多个HASH值,
- 使用一个HASH用于确定在HASH_SLOT的位置,
- 再使用另一个HASH用于快速比较地址是否相等.
-
-*********************************************************************
-20151223 李佳
-1)在乱序包的情况下, 先增加了数据包和字节数,
- 导致插件还未拿到当前数据包, 但实际字节数已经增加, 导致计数不准确,
- 已修复.
-*********************************************************************
-************************* 2016 year *********************************
-*********************************************************************
-2016-01-19 李佳
-1)修复因将IP-PORT合并之后, inet_addr_list函数BUG。
-*********************************************************************
-2016-06-08 李佳
-1)修改在按data建连接时, 调用了TCPALL插件后, 即便插件返回DROP, 仍然会调用TCP插件的逻辑, 导致HMD不生效问题.
-*********************************************************************
-2016-06-15 李佳
-1)增加丢弃纯ACK包功能, 靠配置文件discard_ack控制;
-2)修改FD补救时, 由原来发送3个RST, 减少为1个.
-*********************************************************************
-2016-06-21 李佳
-1)增加配置项:kill_tcp_remedy, 用于控制是否开启FD补救功能.
-*********************************************************************
-2016-09-01 李佳
-1)for soq项目, 增加对隧道协议L2TP, PPTP, IPSEC的连接检测与日志记录。
- 新增stream_tunnel.h.
-*********************************************************************
-2016-09-30 李佳
-1)修复IPv6分片重组线程ID设置错误, 导致在开启dictator后coredump, 而是用普通malloc模式无问题.
-*********************************************************************
-2016-10-09 李佳
-1)修改stream_inject.h, 增加MESA_kill_tcp_feedback()等带反馈功能的函数接口.
-*********************************************************************
-2016-10-12 李佳
-1)增加L2TP协议的FD功能.
-*********************************************************************
-2016-11-10 李佳
-1)针对WY发包特殊需求--某插件不论网络中有无数据包, 都不能阻塞等待, 必须被持续不断调用,
- 新增POLLING类型插件入口, 保证无数据包时, 也会调用此接口的插件.
-*********************************************************************
-2016-11-24 李佳
-1)修改sapp目录结构, 将原来test拆分为运行目录run, 和源码目录entry, 便于部署批量copy.
-*********************************************************************
-2016-12-01 李佳
-1)增加PPP协议解析CHAP认证的用户名功能.
-*********************************************************************
-2016-12-05 李佳
-1)修改stream_base.h, 增加layer_addr_ntop(), layer_addr_prefix_ntop().
-*********************************************************************
-2016-12-15 李佳
-1)增强IPv4包格式的校验, 增加对包截断等情况的判断;
-1)修复pptp HASH插入失败后没有free的BUG.
-*********************************************************************
-2016-12-20 郑超, 李佳
-1)更新dictator, 修复realloc BUG.
-*********************************************************************
-2016-12-21 李佳
-1)更新stream_addr_list_ntop, stream_addr_list_pton等函数, 修改地址字符串前缀命名, 更易读.
-*********************************************************************
-2016-12-22 李佳
-1)修复平台在非X86平台下无法编译问题;
-2)修改dictator初始化读取配置文件顺序BUG.
-*********************************************************************
-2016-12-26 刘洋, 李佳
-1)刘洋修改plungin, 插件加载失败后, 调用dlclose关闭dlopen打开的文件句柄;
-*********************************************************************
-2016-12-27 李佳
-1)修改pptp解析层调用业务插件时, streaminfo结构体为NULL的BUG;
-*********************************************************************
-2016-12-29 李佳
-1)修改pptp隧道无法反向inject包的BUG(暂时只支持双向流反向inject, 单向流仍无法支持);
-
-*********************************************************************
-************************* 2017 year *********************************
-*********************************************************************
-
-*********************************************************************
-2017-01-03 李佳
-1)增加L2tp解析层HASH冲突严重问题, 超过阈值后不再处理新流.
-2)修改TCP流管理BUG, tcp_reset_stream()将当前流移出lru_list, 在tcp_deal_unorder()函数中,
- 可能会再调用tcp_change_stream_tonouse(), 再次调用streamleavlist, 致使plist->head, tail都为NULL.
-*********************************************************************
-2017-01-05 李佳
-1)修改PPTP, L2TP协议解析层hash算法, 减少冲突率.
-*********************************************************************
-2017-01-09 李佳
-1)因2016-12-26, 插件加载失败后, 调用dlclose关闭dlopen打开的文件句柄的方案会造成程序崩溃且无法查看函数调用栈,
- 所以不再主动dlclose句柄;
-2)修改打开ip_frag_list功能后, UDP超时重置时造成内存泄漏的BUG;
-3)修改增加MESA_kill_tcp_feedback()函数后, MESA_sendpacket_iplayer()等函数, 在调用packet_io_send_fake_pkt()时, 传递参数错误BUG.
-*********************************************************************
-2017-01-20 李佳
-1)pcap模式启用dictator后, 读包完退出时free线程不是包处理线程, 造成dictator assert失败.
-*********************************************************************
-2017-02-10 李佳
-1)layer_addr_ntop()增加OpenVPN协议;
-2)修改l2tp, pptp二元组HASH算法,减少HASH冲突;
-3)临时增加SAPP_INSECTICIDE宏,用于检查莫名其妙的BUG,尽量早发现问题。
-*********************************************************************
-2017-02-11 李佳
-1)增加TCP-RST, UDP发包统计计数;
-*********************************************************************
-2017-02-16 李佳
-1)修改get_stream_carry_tunnel_type()对于PPTP, L2TP的识别BUG。
-*********************************************************************
-2017-02-24 李佳
-1)因DPDK初始化时绑定当前线程到某CPU核心, 导致后续动态创建的所有线程都默认继承这个行为, 全绑定到同一个核心,
- 修改packet_io和plug_proc的初始化顺序。
-*********************************************************************
-2017-04-07 李佳
-1)增加新的pag_marsio模式, 主要用于使用marsio的pag_get_frame接口,和之前Zhuanyong网卡的pag_get_frame区分。
-*********************************************************************
-2017-04-21 李佳
-1)集成327的Ipfile读包模式。
-*********************************************************************
-2017-05-11 李佳
-1)main.conf增加配置文件ipentry_priority_over_ipfrag,用于控制IP层和IPFRAG层调用优先级;
-2)增加包类型PKT_TYPE_IP_FRAG_LAST,表示同属于一个原始IP包的最后一个IP分片包。
-*********************************************************************
-2017-05-15 李佳
-1)支持marsio-4.1原生接口.
-*********************************************************************
-2017-05-24 李佳
-1)支持将sapp做为一个动态链接库.so, 可挂载到其他平台上的IP_entry, 减少联调TCP流还原及streaminfo各种变量不一致的时间,
- 做为插件使用时,默认使用固定目录/home/mesasoft/sapp.
-*********************************************************************
-2017-06-08 李佳,刘洋
-1)将wangyan保活功能独立做为插件实现, 更新callapp.c与插件管理相关流程,如记录插件包处理延时等。
-*********************************************************************
-2017-06-12 李佳
-1)平台修改流淘汰机制, 业务插件可设置独立的超时时间, 如果UDP流一段时间无包到达, 也不会因流表满而遭淘汰。
-*********************************************************************
-2017-06-27 李佳
-1)针对GDEV串联模式,修改底层收发包接口;
-2)更新stream_base.h, stream_inject.h, stream_rawpkt.h;
-3)将GDEV保护功能移出平台,做为独立插件运行;
-4)增加检测实际运行环境的stream_inc和当前sapp版本不一致,打印警告功能。
-
-*********************************************************************
-2017-06-28 李佳
-1)增加检测实际运行环境的stream_inc和当前sapp版本不一致,打印警告功能。
-*********************************************************************
-2017-07-10 李佳
-1)marsio模式,则增加从main.conf中获取app_name功能;
-2)修改UDP超时淘汰机制,除reset当前流外,还可以淘汰其他超时的流;
-*********************************************************************
-2017-08-03 李佳
-1)增加TCP单向流推测对端ISN功能;
-1)增加TCP单向流推测对端总计接收字节数功能;
-*********************************************************************
-2017-08-08 李佳
-1)修改tcpdump_mesa, 支持指定捕包线程ID
-*********************************************************************
-2017-08-24 李佳
-1)修改tcpdump_mesa, 增加捕包采样率,防止在大流量环境下丢包。
-*********************************************************************
-2017-09-04 李佳
-1)增加函数sapp_get_platform_opt(), 供插件获取平台内部参数,如包数、字节数等。
-2)marsio4不再支持runtime检测,平台增加runtime.log,记录单包处理延时;
-3)合并单向流处理ISN的缺陷, 可以通过C2S方向的SYN,ACK包,推算出S2C的ISN.
-*********************************************************************
-2017-09-05 李佳
-1)修改tcp获取syn包选项dir方向参数BUG;
-*********************************************************************
-2017-09-21 李佳,刘洋
-1)增加回调函数platform_register_action_judge, 平台最终的包转发返回值PASS or DROP由外部插件决定.
-2)修改插件管理模块,返回值根据业务插件类型, FD or JC决定;
-3)修改默认不识别流量转发策略, GDEV模式下为DROP;
-*********************************************************************
-2017-09-26 李佳
-1)修复2017-05-11修改ip_entry和ip_frag_entry调用优先级,导致IP包会调用ip_frag_entry的BUG.
-*********************************************************************
-
-2017-09-28 李佳
-1)增加按业务号保活功能,WY保活插件只在主应用下设置gdev保活插件的业务号;
-*********************************************************************
-2017-10-03 李佳
-1)增加解析TCP包头部选项TCP_OPT_MULTI_PATH_TCP, 因选项不定长,且可能超过8字节,
- 原有结构不适用,为了向后兼容同时支持新选项,
- 新增struct tcp_option_ext结构,
- 及函数MESA_get_tcp_pkt_opts_ext().
-*********************************************************************
-2017-10-10 李佳
-1)修改在DDP模式下tcpdump_mesa的包捕获位置,可以捕获DDP内封装的原始包。
-*********************************************************************
-2017-10-16 李佳
-1)增加判断四元组重用的判断。
-2)增加iknow_switch配置文件, iknow功能可以关闭, 默认开启.
-3)增加symbol_conflict_check配置文件, 符号名检查可以关闭, 默认开启.
-*********************************************************************
-2017-10-19 李佳
-1)增加anti_flood模块, 用于抵御SYN_flood, DNS_flood攻击;
-2)修改TCPALL插件, 因乱序的SYN, SYN/ACK包,被误认为是四元组重用, 重置连接而导致被分拆为两个流的BUG.
-*********************************************************************
-2017-10-26 李佳
-1)Gserial_send系列函数增加发包日志, 便于WY环境下查找问题.
-2)增加field_stat输出.
-*********************************************************************
-2017-10-31 李佳
-1)修复因pcap.h, libpcap.so在纯新的系统上缺失,第一次无法编译的情况;
-2)修复PPTP隧道协议,因PPP头部压缩且没有获取PPTP控制连接时,无法解析的问题。
-*********************************************************************
-2017-11-09 李佳
-1)Gserial_send系列函数发包按ip, tcp, udp分协议类型统计。
-2)内置pcap.h, 在纯新机器上可以编译通过.
-*********************************************************************
-2017-11-13 李佳
-1)增加GDEV保活计数获取接口, 便于统计;
-*********************************************************************
-2017-11-24 李佳
-1)VxLan模式PPP或HDLC封装, MAC地址为驱动随机填充的, 不能用于判定广播、组播等操作.
-*********************************************************************
-2017-12-08 李佳
-1)修改平台调用TCPALL插件逻辑, 先调用TCPALL, 后调用TCP;
-2)对于一个流的首包是RST且SEQ=0的包,平台忽略不处理。
-*********************************************************************
-2017-12-20 李佳
-1)l2tp_protocol_plug修复地址解析长度超范围BUG;
-2)更新TCP流还原机制, 四元组重用判断与最后一个包的时间间隔, 太短则认为是恶意逃逸, 丢弃.
-
-*********************************************************************
-************************* 2018 year *********************************
-*********************************************************************
-
-2018-01-19 lijia add,
-1-多个tcpdump_mesa同时启动时, 后续的连接会抢占第一个连接的数据流, 但使用第一个连接的过滤条件,
- 增加TCP命令连接的确认机制, 如果sapp不回复确认包, tcpdump_mesa不启动捕包.
-
-2-增加丢包计数, 如果使用-a参数指定perceptive模式, sapp在发送包时, 在源MAC地址上打上序号,
- tcpdump_mesa检查序号是否连续, 以确认中间是否有丢包, 丢了几个包.
-*********************************************************************
-2018-02-28 李佳
-1)修复插重要件不保活时, gdev仍继续保活的BUG;
-2)修改vxlan模式下, 丢弃广播、组播包的判断逻辑.
-*********************************************************************
-2018-03-02 lijia add,
-1)因并联模式FD效果不好,增加FD补救向GDEV下发规则功能,依靠串联丢包提高FD率。
-*********************************************************************
-2018-03-13 李佳
-1)修复teredo隧道非标准端口无法识别问题.
-*********************************************************************
-2018-03-23 李佳
-1) 修复GDEV规则下发插件BUG.
-*********************************************************************
-2018-04-17 刘洋
-1)主从应用都是通过配置文件PLUGINFO获得,该功能由总控添加,不过sapp中需要将原功能注释掉,即plugin.c:733行。
-*********************************************************************
-2018-04-25 李佳
-1)修复get_this_layer_header()函数, 在流超时淘汰时的BUG;
-*********************************************************************
-2018-07-10 李佳
-1)修改private_ip段识别错误BUG;
-*********************************************************************
-2018-08-01 李佳
-1)针对3x7项目,增加剥离3x7数据包头功能,将内层原始数据包再注入ipv4_entry();
-*********************************************************************
-2018-08-03 李佳
-1)修复IP头部检测不支持ESP问题, 导致IPSEC业务被丢弃.
-*********************************************************************
-2018-09-23 李佳
-1)增加对MAC_IN_MAC回流镜像格式的处理;
-2)修复MAC_IN_MAC封装格式下, RST发送BUG.
-3)修改判断广播和组播的判断逻辑, vxlan模式下对于vxlan封装的数据包不做判断;
-4)支持IPV6发包.
-*********************************************************************
-2018-10-13 李佳
-1)修改IP包头检测函数, 对协议类型字段的检查, 防止误丢弃某些不常见协议的数据包.
-*********************************************************************
-2018-10-19 李佳
-1)修改field_stat输出TCP并发连接数BUG.
-*********************************************************************
-2018-10-24 李佳
-1)增加对MAC_IN_MAC的地址解析, 从中获取GDEV_ID, LINK_ID, LINK_DIR等参数.
-*********************************************************************
-2018-11-02 李佳
-1)修改mpls_hdr头部定义错误;
-2)解析多层嵌套MPLS数据包.
-*********************************************************************
-2018-11-05 杨威
-1)修改源码, 适配cmake编译.
-*********************************************************************
-2018-11-08 杨威
-1.更新gprs tunnel协议识别逻辑,使用identify_gtp函数,取代原有的仅识别端口的逻辑
-2.更新packet_io_send_fake_pkt_gdev函数逻辑,正确的计算偏移填写发包内容时的data和datalen
-3.更新packet_io_send_fake_pkt,对于注入发包,直接调用packet_io_send_fake_pkt_by_gdev
-4.MESA_send_handle新增raw_udp_fd用于从udp负载开始发送注入包
-6.增加Gserial_sendpacket_ipv6_layer()函数, 可以发送已构造好的IPV6数据包.
-*********************************************************************
-2018-11-09 杨威
-1.整理TODO,按重要程度分级
-2.移除run目录下的log文件
-3.更新GTP处理逻辑,增加对带seq消息的处理并保存在地址中
-*********************************************************************
-2018-11-12 杨威,李佳
-1.更新GTP处理逻辑, 增加对端地址(TEID,SEQ等)更新逻辑。
-*********************************************************************
-2018-11-16 李佳
-1)支持cmake, 与并联版本部分同步.
-
-*********************************************************************
-**************************** 2019 Year ******************************
-*********************************************************************
-2019-05-15 李佳
-1)sapp version 4.0!
-2)从新设计配置文件格式;
-3)支持命令行参数;
-4)其他重大更新待后续版本升级......
-#endif
diff --git a/src/sapp_dev/sapp_global_val.c b/src/sapp_dev/sapp_global_val.c
index 4613f44..7fd3902 100644
--- a/src/sapp_dev/sapp_global_val.c
+++ b/src/sapp_dev/sapp_global_val.c
@@ -224,9 +224,6 @@ void sapp_gval_init(void)
{
int tseq;
- /* ��һ�����ж��Ƿ�ʹ��dictator,��ֵӰ��������ڴ���� ����,��������sapp_mem_xxϵ�к����޷����� */
- tomlc99_wrap_load_int_def(g_cmd_args_main_cfg_file, (char *)"MEM", (char *)"dictator_enable", (int *)&g_sapp_mem_use_dictator, 1);
-
/* �ڴ�ͳ�Ƶ������������Ǵ洢��ȫ�ֱ�����, �������м��������е�������, �˴�ֱ����ϵͳ��calloc, �������� */
sapp_global_val = (sapp_global_t *)calloc(1, sizeof(sapp_global_t));
g_sapp_global_mem_used_block++;
diff --git a/src/sapp_dev/sapp_init.c b/src/sapp_dev/sapp_init.c
index cfc2150..528cb78 100644
--- a/src/sapp_dev/sapp_init.c
+++ b/src/sapp_dev/sapp_init.c
@@ -25,7 +25,6 @@ extern void sesame_open_door(const char *lock_path, const char *lock_name);
/* (0:pag,1:pcap,2:dumpfile,3:pfring,4:DPDK,5:ppf,6:NPacket,7:qnf,8:N95,9:pcap-dumpfile-list, 10:topsec) */
//int cap_mode = 2;
//int top_mode = 0;
-//extern int G_DICTATOR_SW;
extern struct global_stream **G_MESA_GLOBAL_STREAM;
//static int __times = 0;
//int g_timestamp_record_sw = 0;
@@ -75,27 +74,6 @@ static void forbid_call_exit_in_running_state(void)
}
-/* 2016-09-22 lijia add, dictator�ڵ�һ�α�����ʱ�г�ʼ������, ��ֹ���߳������ͻ, ƽ̨�ȵ���һ�� */
-static void sapp_dictator_init(void)
-{
-#if USE_MEMPOOL
- void *tmp;
- if(G_DICTATOR_SW){
- tmp = __wrap_malloc(1);
- assert(tmp != NULL);
- __wrap_free(tmp);
-
- tmp = malloc(1);
- assert(tmp != NULL);
- free(tmp);
- }else{
- sapp_printf("\033[33m[Warning]dictator is not enable, maybe slow down performance, please check 'sapp.toml -> dictator_enable'.\033[0m\n");
- }
-#else
- sapp_printf("\033[33m[Warning]sapp is compiled without dictator.\033[0m\n");
-#endif
-}
-
static void sapp_platform_finish_up(void)
{
/*
@@ -139,11 +117,6 @@ int MESA_platform_init(int argc, char *argv[])
ABBR_CURRENT_TIME = time(NULL);
ABBR_SAPP_START_TIME = time(NULL);
- /* 2016-09-22 lijia add, dictator�ڵ�һ�α�����ʱ�г�ʼ������, ��ֹ���߳������ͻ, ƽ̨�ȵ���һ��, ��Ҫ��ȡ�����ļ����� */
- //MESA_load_profile_int_def("conf/main.conf","Module", "dictator_switch", &G_DICTATOR_SW, 1);
- sapp_dictator_init();
-
-
ipv4_frag_init(g_iThreadNum, 1024 * 512);
ipv6_frag_init(g_iThreadNum, 1024 * 256);
tcp_set_stream_num(max_tcp_stream_num*3,max_tcp_stream_num,max_tcp_stream_num*2);
diff --git a/src/support/CMakeLists.txt b/src/support/CMakeLists.txt
index d1fb998..270f71d 100644
--- a/src/support/CMakeLists.txt
+++ b/src/support/CMakeLists.txt
@@ -5,7 +5,6 @@ add_subdirectory(symbol_check)
add_subdirectory(MESA_sleep)
add_subdirectory(md5)
add_subdirectory(MESA_socket_wrap/src)
-add_subdirectory(dictator2/src)
add_subdirectory(tomlc99_wrap)
add_subdirectory(dpdk_rte_hash)
add_subdirectory(cpu_limit)
diff --git a/src/support/MESA_sleep/Makefile b/src/support/MESA_sleep/Makefile
deleted file mode 100644
index 9315625..0000000
--- a/src/support/MESA_sleep/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-all:demo libMESA_sleep.so libMESA_sleep.a
-
-
-
-demo:demo.o libMESA_sleep.so
- gcc -g -Wall demo.o -o demo -lpthread ./libMESA_sleep.so
-demo.o: demo.c
- gcc -g -c demo.c -o demo.o -W
-
-libMESA_sleep.so:MESA_sleep.o
- gcc -o $@ -fPIC -shared $^ -lpthread
-
-libMESA_sleep.a:MESA_sleep.o
- ar -cr $@ $^
- cp $@ ../../lib/
-
-#MESA_sleep.o:MESA_sleep.c
-MESA_sleep.o:mesa_sleep_nowatchBGT.c
- gcc -g -Wall -fPIC -shared -c $^ -o $@
-clean:
- rm -f *.o demo libMESA_sleep.so libMESA_sleep.a
-
diff --git a/src/support/MESA_socket_wrap/Makefile b/src/support/MESA_socket_wrap/Makefile
deleted file mode 100644
index 2f9c182..0000000
--- a/src/support/MESA_socket_wrap/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-CFLAGS = -O2 -Wall
-export CFLAGS
-
-all:
- cd src; $(MAKE)
- cd example;$(MAKE)
-clean:
- cd src; $(MAKE) clean
- cd example; $(MAKE) clean
diff --git a/src/support/MESA_socket_wrap/example/Makefile b/src/support/MESA_socket_wrap/example/Makefile
deleted file mode 100644
index a1279a4..0000000
--- a/src/support/MESA_socket_wrap/example/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-CC=gcc
-CCC=gcc
-
-TARGET=MESA_sock_example multi_thread_example udp_example test_read tcp_example
-
-all:$(TARGET)
-
-INC=-I../include
-LIBPATH=-L../lib
-LIB=-lpthread ../lib/libMESA_socket_wrap.a
-
-multi_thread_example:multi_thread_example.c
- $(CC) $(CFLAGS) -o $@ $(INC) $^ $(LIBPATH) $(LIB)
-
-MESA_sock_example:MESA_sock_example.c
- $(CC) $(CFLAGS) -o $@ $(INC) $^ $(LIBPATH) $(LIB)
-
-tcp_example:tcp_example.c
- $(CC) $(CFLAGS) -o $@ $(INC) $^ $(LIBPATH) $(LIB)
-
-udp_example:udp_example.c
- $(CC) $(CFLAGS) -o $@ $(INC) $^ $(LIBPATH) $(LIB)
-
-test_read:test_read.c
- $(CC) $(CFLAGS) -o $@ $(INC) $^ $(LIBPATH) $(LIB)
-
-clean:
- rm -f *.o $(TARGET)
diff --git a/src/support/MESA_socket_wrap/src/Makefile b/src/support/MESA_socket_wrap/src/Makefile
deleted file mode 100644
index dddf620..0000000
--- a/src/support/MESA_socket_wrap/src/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-CC=gcc -g -fPIC
-CCC=gcc -g -fPIC
-
-TARGET=libMESA_socket_wrap.a libMESA_socket_wrap.so
-INC=-I../include
-LIBPATH=../lib
-
-OBJS=MESA_socket_wrap.o
-
-all:$(TARGET)
-
-.c.o:
- $(CC) -c $(CFLAGS) -I. $(INC) $<
-
-.cpp.o:
- $(CCC) -c $(CFLAGS) -I. $(INC) $<
-
-libMESA_socket_wrap.a: $(OBJS)
- echo making lib ...
- (rm -f $@ ;ar -r $@ $^; cp $@ $(LIBPATH); cp $@ ../../../lib/)
-
-libMESA_socket_wrap.so: $(OBJS)
- $(CC) -o $@ $^ -shared
-
-clean:
- rm -f *.o $(TARGET)
diff --git a/src/support/dictator2/lib/.gitignore b/src/support/dictator2/lib/.gitignore
deleted file mode 100644
index 1c2ee5e..0000000
--- a/src/support/dictator2/lib/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-SI/
-*.log
-*.o
-*.so
-bin/avrule/
-bin/avlog/
diff --git a/src/support/dictator2/readme.txt b/src/support/dictator2/readme.txt
deleted file mode 100644
index 247b571..0000000
--- a/src/support/dictator2/readme.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-LDDICTATOR = -Wl,-wrap,malloc -Wl,-wrap,calloc -Wl,-wrap,free -Wl,-wrap,realloc
-Define above variable in Makefile,then use this variable as a ld parameter to enable dictator.
-This is enough for shared dynamic library(.so).
-Further more,final executable file need to link with libdictator.a or libdictator_debug.a to include dictator binary. \ No newline at end of file
diff --git a/src/support/dictator2/src/CMakeLists.txt b/src/support/dictator2/src/CMakeLists.txt
deleted file mode 100644
index d5f0315..0000000
--- a/src/support/dictator2/src/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-cmake_minimum_required(VERSION 2.8...3.10)
-
-include_directories(${MESA_SDK_PREFIX}/include)
-include_directories(${MESA_SDK_PREFIX}/include/MESA)
-#include_directories(${CMAKE_SOURCE_DIR}/packet_io)
-#include_directories(${CMAKE_SOURCE_DIR}/project)
-#include_directories(${CMAKE_SOURCE_DIR}/include)
-#include_directories(${CMAKE_SOURCE_DIR}/include/support)
-#include_directories(${CMAKE_SOURCE_DIR}/dealpkt)
-
-add_definitions(${MEM_POOL_DEFINITIONS} -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H)
-add_library(dictator2 STATIC dictator.cpp dictator_debuger.cpp
- D_internal/D_kernel_list.cpp D_internal/list_common.cpp
- D_internal/MESA_hash_v2.cpp D_internal/MESA_list_v2.cpp)
-
-add_library(dictator2_debug STATIC dictator.cpp dictator_debuger.cpp
- D_internal/D_kernel_list.cpp D_internal/list_common.cpp
- D_internal/MESA_hash_v2.cpp D_internal/MESA_list_v2.cpp)
-target_compile_definitions(dictator2_debug PRIVATE "-DDICTATOR_DEBUG") \ No newline at end of file
diff --git a/src/support/dictator2/src/D_internal/D_kernel_list.cpp b/src/support/dictator2/src/D_internal/D_kernel_list.cpp
deleted file mode 100644
index d1131e8..0000000
--- a/src/support/dictator2/src/D_internal/D_kernel_list.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-#include <stdio.h>
-#include <assert.h>
-#include "D_kernel_list.h"
-
-void D_kernel_list_init(struct D_kernel_list_head *head)
-{
- assert(head);
- head->next = head;
- head->prev = head;
-}
-
-void D_kernel_list_destroy(struct D_kernel_list_head *head,\
- void (*my_list_free_cb)(struct D_kernel_list_head *del))
-{
- struct D_kernel_list_head *cur, *next;
-
- assert(head && my_list_free_cb);
-
- cur = head->next;
- while(head != cur)
- {
- next = cur->next;
- my_list_free_cb(cur);
- cur = next;
- }
-}
-
-inline static void __D_kernel_list_delete(struct D_kernel_list_head *prev, struct D_kernel_list_head *next)
-{
- next->prev = prev;
- prev->next = next;
-}
-
-void D_kernel_list_delete(struct D_kernel_list_head *head,struct D_kernel_list_head *del)
-{
- __D_kernel_list_delete(del->prev, del->next);
-}
-
-inline static void __D_kernel_list_insert(struct D_kernel_list_head *new_node,
- struct D_kernel_list_head *prev, struct D_kernel_list_head *next)
-{
- next->prev = new_node;
- new_node->next = next;
- new_node->prev = prev;
- prev->next = new_node;
-}
-
-void D_kernel_list_add_head(struct D_kernel_list_head *head,
- struct D_kernel_list_head *new_node)
-{
- __D_kernel_list_insert(new_node, head, head->next);
-}
-
-void D_kernel_list_add_tail(struct D_kernel_list_head *head,
- struct D_kernel_list_head *new_node)
-{
- __D_kernel_list_insert(new_node, head->prev, head);
-}
-
-struct D_kernel_list_head * D_kernel_list_get_head(struct D_kernel_list_head *head)
-{
- struct D_kernel_list_head*p=NULL;
- if(LIST_IS_EMPTY(head))
- {
- return NULL;
- }
- p=head->next;
- D_kernel_list_delete(head, p);
- return p;
-}
-struct D_kernel_list_head * D_kernel_list_get_tail(struct D_kernel_list_head *head)
-{
- struct D_kernel_list_head*p=NULL;
- if(LIST_IS_EMPTY(head))
- {
- return NULL;
- }
- p=head->prev;
- D_kernel_list_delete(head, p);
- return p;
-}
-void D_kernel_list_move_head(struct D_kernel_list_head *head,
- struct D_kernel_list_head *node)
-{
- D_kernel_list_delete(node->prev, node->next);
- __D_kernel_list_insert(node, head, head->next);
-}
-
diff --git a/src/support/dictator2/src/D_internal/D_kernel_list.h b/src/support/dictator2/src/D_internal/D_kernel_list.h
deleted file mode 100644
index 6968f03..0000000
--- a/src/support/dictator2/src/D_internal/D_kernel_list.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef _D_KERNEL_LIST_
-#define _D_KERNEL_LIST_
-
-#include <pthread.h>
-
-struct D_kernel_list_head{
- struct D_kernel_list_head *next, *prev;
-};
-
-#ifndef offsetof
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
-#ifndef container_of
-#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-#endif
-
-
-#define D_kernel_list_entry(ptr, type, member) container_of(ptr, type, member)
-
-#define LIST_IS_EMPTY(_head) (((_head)->next == (_head)) ? 1 : 0 )
-
-#define D_kernel_list_for_each_safe(pos, n, head) \
- for (pos = (head)->next, n = pos->next; pos != (head); \
- pos = n, n = pos->next)
-
-void D_kernel_list_init(struct D_kernel_list_head *head);
-void D_kernel_list_add_head(struct D_kernel_list_head *head, struct D_kernel_list_head *new_node);
-void D_kernel_list_add_tail(struct D_kernel_list_head *head,struct D_kernel_list_head *new_node);
-void D_kernel_list_delete(struct D_kernel_list_head *head,struct D_kernel_list_head *del);
-void D_kernel_list_move_head(struct D_kernel_list_head *head, struct D_kernel_list_head *node);
-void D_kernel_list_destroy(struct D_kernel_list_head *head, void (*my_list_free)(struct D_kernel_list_head *del));
-struct D_kernel_list_head * D_kernel_list_get_head(struct D_kernel_list_head *head);
-struct D_kernel_list_head * D_kernel_list_get_tail(struct D_kernel_list_head *head);
-
-#endif
-
diff --git a/src/support/dictator2/src/D_internal/MESA_hash_v2.cpp b/src/support/dictator2/src/D_internal/MESA_hash_v2.cpp
deleted file mode 100644
index d6b9219..0000000
--- a/src/support/dictator2/src/D_internal/MESA_hash_v2.cpp
+++ /dev/null
@@ -1,655 +0,0 @@
-#include <stdio.h>
-#include <time.h>
-#include <unistd.h>
-#include "MESA_hash_v2.h"
-#include "MESA_list_v2.h"
-#include "list_common.h"
-#include "../dictator.h"
-
-#if MESA_HASH_DEBUG
-static int *hash_slot_list_num; /* ���ڼ�¼ÿ��slot�ҽ������ڵ����� */
-static int max_slot_list_num = 0; /* ÿ��slot����ͻ�� */
-#endif
-#ifndef MAX
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef MIN
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
-/*
- * hash implementation, xh, 2001-07-26
- */
-
-/*Developer Notice:
- in hash_add function,hash table MALLOC memory for keys and RECORD data pointer,
- which means need NOT malloc memory for keys before call hash_add. zhengchao
-
- 2013-05, LiJia, add thread safe implement.
-*/
-
-
-/*
- �����ܼ�������ͻ��ÿN��Hash-slot����һ��������,
- (HASH_Index % HASH_TABLE_MUTEX_NUM)��ֵ��ͬ��item����һ��mutex.
-*/
-#define HASH_TABLE_MUTEX_NUM (256)
-
-
-static HASH_INLINE int D_INTERNAL___MESA_hash_mutex_unlock(MESA_hash_tab_v2_t * table,uint index)
-{
- if(table->is_thread_safe){
- return pthread_mutex_unlock(&table->htable_mutex[index%HASH_TABLE_MUTEX_NUM]);
- }
- return 0;
-}
-
-
-static HASH_INLINE int D_INTERNAL___MESA_hash_mutex_lock(MESA_hash_tab_v2_t * table, uint index)
-{
- if(table->is_thread_safe){
- return pthread_mutex_lock(&table->htable_mutex[index%HASH_TABLE_MUTEX_NUM]);
- }
- return 0;
-}
-
-static int D_INTERNAL___MESA_hash_time_list_insert(MESA_hash_tab_v2_t *table,
- hash_elem_v2_t *hash_elem, uint index)
-{
- int ret = 0;
- MESA_queue_head_v2_t *list_head;
-
- if(table->is_thread_safe){
- list_head = &table->hlist_head[index%HASH_TABLE_MUTEX_NUM];
- }else{
- list_head = &table->hlist_head[0];
- }
-
- D_INTERNAL_MESA_q_join_tail_v2(list_head, &hash_elem->list_node);
-
- return ret;
-}
-
-static HASH_INLINE void D_INTERNAL___MESA_hash_time_list_delete(MESA_hash_tab_v2_t *table,
- hash_elem_v2_t *hash_elem, uint index)
-{
- MESA_queue_head_v2_t *list_head;
-
- if(table->is_thread_safe){
- list_head = &table->hlist_head[index%HASH_TABLE_MUTEX_NUM];
- }else{
- list_head = &table->hlist_head[0];
- }
- D_INTERNAL_MESA_q_leave_list_v2(list_head, &hash_elem->list_node);
-
- return;
-}
-
-static HASH_INLINE int D_INTERNAL___MESA_hash_time_list_lru(MESA_hash_tab_v2_t *table,
- hash_elem_v2_t *hash_elem, uint index)
-{
- int ret = 0;
- MESA_queue_head_v2_t *list_head;
-
- if(table->is_thread_safe){
- list_head = &table->hlist_head[index%HASH_TABLE_MUTEX_NUM];
- }else{
- list_head = &table->hlist_head[0];
- }
-
- D_INTERNAL_MESA_q_move_tail_v2(list_head, &hash_elem->list_node);
-
- return ret;
-}
-
-
-/*
- search HASH-table whether has duplicate key.
-*/
-static HASH_INLINE hash_elem_v2_t *D_INTERNAL___MESA_hash_key_search(MESA_hash_tab_v2_t * table,
- uchar * key, uint size, uint index)
-{
- hash_elem_v2_t * ptr;
- for(ptr = table->elems[index]; NULL != ptr; ptr = ptr->next) {
- if(!table->key_comp(ptr->key, ptr->size, key, size))
- break;
- }
-
- return ptr;
-}
-
-static HASH_INLINE void D_INTERNAL___MESA_hash_list_insert(MESA_hash_tab_v2_t * table,
- hash_elem_v2_t * ptr, uint index)
-{
- ptr->prev = NULL;
- ptr->next = table->elems[index];
- if(NULL != table->elems[index]){
- table->elems[index]->prev = ptr;
- }
- table->elems[index] = ptr;
-
- table->elem_count++;
-}
-
-static HASH_INLINE void D_INTERNAL___MESA_hash_list_delete(MESA_hash_tab_v2_t * table,
- hash_elem_v2_t * ptr, uint index)
-{
- if(NULL != ptr->prev){
- ptr->prev->next = ptr->next;
- }else{
- table->elems[index] = ptr->next;
- }
-
- if(NULL != ptr->next){
- ptr->next->prev = ptr->prev;
- }
-
- table->elem_count--;
-}
-
-static HASH_INLINE hash_elem_v2_t *D_INTERNAL___MESA_hash_alloc_resource(
- uchar * key, uint size, void * data, uint index
- ,IMP_t*p_mempool)
-{
- hash_elem_v2_t *ptr = NULL;
- if(NULL == (ptr = (hash_elem_v2_t*)block_alloc(sizeof(hash_elem_v2_t),p_mempool))){
- goto err_1;
- }
- if(NULL == (ptr->key = (unsigned char*)block_alloc(size,p_mempool))) {
- goto err_2;
- }
- memcpy(ptr->key, key, size);
- ptr->size = size;
- ptr->data = data; /* lijia comment, dataָ����ڴ��ǵ���������� */
- ptr->list_node.nextele = NULL;
- ptr->list_node.preele = NULL;
- ptr->list_node.quiddity = (void *)ptr;
- ptr->op_time = HASH_TIME_NOW();
- ptr->hash_index = index;
- return ptr;
-
-err_2:
- block_free(ptr,p_mempool);
-err_1:
- return NULL;
-}
-
-
-static HASH_INLINE void D_INTERNAL___MESA_hash_free_resource(MESA_hash_tab_v2_t * table,
- hash_elem_v2_t *ptr, void (* func)(void *))
-{
- IMP_t *p_mempool=table->p_mempool;
- if(NULL != func){
- func(ptr->data);
- }else if(NULL != table->free){
- table->free(ptr->data);
- }
- block_free(ptr->key,p_mempool);
- block_free(ptr,p_mempool);
-}
-
-
-static HASH_INLINE void D_INTERNAL___MESA_hash_del_node(MESA_hash_tab_v2_t * table,
- hash_elem_v2_t * ptr, uint index, void (* func)(void *))
-{
- D_INTERNAL___MESA_hash_list_delete(table, ptr, index);
- D_INTERNAL___MESA_hash_time_list_delete(table, ptr, index);
- D_INTERNAL___MESA_hash_free_resource(table, ptr, func);
-}
-
-/*
- kick out a oldest node from HASH-table if elements number exceed threshold,
- or the node's operate time expired.
-*/
-static void D_INTERNAL___MESA_hash_eliminate(MESA_hash_tab_v2_t *table, uint index)
-{
- MESA_list_index_v2_t *list_head, *oldest_node;
- hash_elem_v2_t *hash_elem;
- int do_eliminate = 0;
- if(table->is_thread_safe){
- list_head = &table->hlist_head[index%HASH_TABLE_MUTEX_NUM];
- }else{
- list_head = &table->hlist_head[0];
- }
-
- oldest_node = D_INTERNAL_MESA_q_read_head_v2(list_head);
- if(oldest_node){
- hash_elem = (hash_elem_v2_t *)oldest_node->quiddity;
- if((table->max_elem_num != 0)
- && (table->elem_count > table->max_elem_num)){ /* too many elements */
- do_eliminate |= 0x01;
- }else if((table->expire_time != 0)
- &&(hash_elem->op_time + table->expire_time < HASH_TIME_NOW())){ /* time expired */
- do_eliminate |= 0x10;
- }
- if(do_eliminate != 0){
- if(table->expire){
- table->expire(hash_elem->data);
- }
- D_INTERNAL___MESA_hash_del_node(table ,hash_elem, hash_elem->hash_index, NULL);
- //printf("eliminate a oldest element!\n");
- }
- }
-}
-
-/*
- * name: D_INTERNAL___default_hash_key2index
- * functionality: computes index from key, default key2index implementation
- * if previous hash_create() call did not provide such a function;
- * params:
- * table: with which table are you dealing, we want this param be present
- * because we may need size of table to compute the key;
- * key: what is the label;
- * size: how long is the label;
- * returns:
- * index in given table for given key, never fails;
- */
-#if 0
-static uint D_INTERNAL___default_hash_key2index(MESA_hash_tab_v2_t * table, uchar * key, uint size)
-{
- uchar * c;
- uint h, g;
-
- for (c = key, h = 0; c - key < size; c ++) {
- h = (h << 2) + c[0];
- if(0 != (g = (h & 0xf0000000))) {
- h = h ^ (g >> 24);
- h = h ^ g;
- }
- }
- return h % table->size;
-}
-#else
-/* BKDR Hash Function */
-static uint D_INTERNAL___default_hash_key2index(MESA_hash_tab_v2_t * table, uchar *str, uint size)
-{
- uint i;
- uint seed = 131; // 31 131 1313 13131 131313 etc..
- uint hash = 0;
- uint cmp_size=MIN(size,96);
- for(i = 0; i < cmp_size; i++){
- if((i&0x7)<3)
- hash = hash * seed + (*str++);
- else
- *str++;
- }
-
- return (hash % table->size);
-}
-#endif
-
-/*
- * name: D_INTERNAL___default_hash_key_comp
- * functionality: compares two key;
- * params:
- * key1, key2: what are the labels;
- * size1, size2: how long are them;
- * returns:
- * 0, if two keys are identical; (just a simple memcmp() );
- * 1, no.
- */
-static int D_INTERNAL___default_hash_key_comp(uchar * key1, uint size1, uchar * key2, uint size2)
-{
- if(size1 != size2) return 1;
- return memcmp(key1, key2, size1);
-}
-
-/* �����Ƿ�2��N�η� */
-static HASH_INLINE int D_INTERNAL_number_is_2N(uint n)
-{
-#if 0
- uint s;
- for(s = n; s != 0; ) {
- if(0x01 != s && 0x01 == (0x01 & s)) return 0;
- s = s >> 1;
- }
-#else
- if(n & (n-1)){
- return 0;
- }
-#endif
-
- return 1;
-}
-
-/*
- * name: hash_create
- * functionality: allocats memory for hash slots, and fill in hash structure;
- * param:
- * table: caller allocated hash table structure, gets filled in;
- * is_thread_safe:1:create thread safe hashtable; 0:create hashtable without thread safe insurance;
- * size: how big do you want the table to be, must be 2^N;
- * max_elem_num: the maximum elements of the HASH-table,0 means infinite;
- * key_comp: hash key compare function, use default function if NULL;
- * key2index: hash key->index computing function, use default function if NULL;
- * data_free: release resources function, only free attached data pointer if NULL;
- * data_expire: if expire_time > 0, call this function when a element expire, can be NULL;
- * eliminate_type: the algorithm of elimanate a expired element, 0:FIFO; 1:LRU.
- * expire_time: the element expire time in second, 0 means infinite.
- * returns:
- * 0, success;
- * -1, memory failure;
- * -2, parameter not acceptable;
- */
-int D_INTERNAL_MESA_hash_create_v2(MESA_hash_tab_v2_t * table, uint is_thread_safe,
- uint size, uint max_elem_num,
- key_comp_t * key_comp,
- key2index_t * key2index,
- void (* data_free)(void *),
- void (* data_expire)(void *),
- int eliminate_type,
- int expire_time,
- IMP_t* p_mempool)
-{
- int i=0,j, ret = 0;
-
- if(D_INTERNAL_number_is_2N(size) == 0){
- return -2;
- }
-
- table->elems = (hash_elem_v2_t**)mmap_alloc(sizeof(hash_elem_v2_t *) * size);
- if(NULL == table->elems)
- return -1;
- memset(table->elems, 0, sizeof(hash_elem_v2_t *) * size);
- table->size = size;
- if(NULL == key_comp) table->key_comp = D_INTERNAL___default_hash_key_comp;
- else table->key_comp = key_comp;
- if(NULL == key2index) table->key2index = D_INTERNAL___default_hash_key2index;
- else table->key2index = key2index;
- table->expire = data_expire;
- //if(NULL == data_free) return -1; /* 2013-05-06 modify, can be NULL */
- table->free = data_free;
- table->elem_count = 0;
- table->max_elem_num = max_elem_num;
- //table->threshold_lo = 0;
- //table->threshold_hi = size;
- table->eliminate_type = eliminate_type;
- table->expire_time = expire_time;
- table->is_thread_safe = is_thread_safe;
- table->p_mempool=p_mempool;
- if(table->is_thread_safe){
- table->htable_mutex = (pthread_mutex_t *)mmap_alloc(sizeof(pthread_mutex_t) * HASH_TABLE_MUTEX_NUM);
- if(NULL == table->htable_mutex){
- ret = -1;
- goto err_1;
- }
- for(i = 0; i < HASH_TABLE_MUTEX_NUM; i++){
- if(pthread_mutex_init(&table->htable_mutex[i], NULL)!=0){
- ret = -1;
- goto err_2;
- }
- }
- table->hlist_head = (MESA_list_index_v2_t *)mmap_alloc(sizeof(MESA_list_index_v2_t) * HASH_TABLE_MUTEX_NUM);
- if(NULL == table->hlist_head){
- ret = -1;
- goto err_2;
- }
- for(i=0;i<HASH_TABLE_MUTEX_NUM;i++){
- D_INTERNAL_MESA_list_init_v2(&table->hlist_head[i]);
- }
- }else{
- table->hlist_head = (MESA_list_index_v2_t *)mmap_alloc(sizeof(MESA_list_index_v2_t));
- if(NULL == table->hlist_head){
- ret = -1;
- goto err_2;
- }
- D_INTERNAL_MESA_list_init_v2(&table->hlist_head[0]);
- }
-
- return 0;
-
-err_2:
- for(j = 0; j < i; j++){
- pthread_mutex_destroy(&table->htable_mutex[j]);
- }
- mmap_free(table->htable_mutex);
-err_1:
- mmap_free(table->elems);
- return ret;
-}
-
-/*
- * frees table->elems and chains attached to each element of it.
- * always returns 0.
- */
-int D_INTERNAL_MESA_hash_destroy_v2(MESA_hash_tab_v2_t * table, void (* func)(void *))
-{
- int i;
- hash_elem_v2_t * cur;
- IMP_t* p_mempool=table->p_mempool;
- for(i = 0; i < (int)table->size; i ++) {
- while(NULL != table->elems[i]) {
- cur = table->elems[i];
- if(NULL != func) func(cur->data);
- else if(NULL != table->free) table->free(cur->data);
- table->elems[i] = (table->elems[i])->next;
- block_free(cur->key,p_mempool);
- block_free(cur,p_mempool);
- }
- }
- if(table->is_thread_safe){
- for(i=0;i<HASH_TABLE_MUTEX_NUM;i++)
- pthread_mutex_destroy(&table->htable_mutex[i]);
- mmap_free(table->htable_mutex);
- }
- mmap_free(table->hlist_head);
- mmap_free(table->elems);
- table->elems = NULL;
- table->size = 0;
-
- return 0;
-}
-
-/*
- * adds data identified by key to table.
- * table->elems always points to the newest added element.
- * no two elements should have a same key, although them may have a same index.
- * returns:
- * -1, if duplicate is found;
- * -2, if memory fails;
- * 0, success.
- */
-int D_INTERNAL_MESA_hash_add_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size,
- void * data)
-{
- uint index;
- hash_elem_v2_t * ptr;
- int ret = 0;
- IMP_t *p_mempool=table->p_mempool;
- index = table->key2index(table, key, size);
-
- D_INTERNAL___MESA_hash_mutex_lock(table,index);
- if(D_INTERNAL___MESA_hash_key_search(table,key,size,index)){ /* already exist */
- ret = -1;
- goto err;
- }
- ptr = D_INTERNAL___MESA_hash_alloc_resource(key, size, data, index,p_mempool);
- if(NULL == ptr){
- ret = -2;
- goto err;
- }
- D_INTERNAL___MESA_hash_list_insert(table, ptr, index);
- D_INTERNAL___MESA_hash_time_list_insert(table, ptr, index);
-
- D_INTERNAL___MESA_hash_eliminate(table,index);
-
- D_INTERNAL___MESA_hash_mutex_unlock(table,index);
-
-#if MESA_HASH_DEBUG
- hash_slot_list_num[index]++;
- if(max_slot_list_num < hash_slot_list_num[index]){
- max_slot_list_num = hash_slot_list_num[index];
- printf("Hash table max list num:%d\n", max_slot_list_num);
- }
-#endif
-
- return 0;
-
-err:
- D_INTERNAL___MESA_hash_mutex_unlock(table,index);
- return ret;
-}
-
-
-
-/*
- * name: hash_del
- * functionality: deletes item from table.
- * param:
- * table: from which table do you want to delete;
- * key : what is the label;
- * size : how long is the label;
- * func : callback function to clean up data attached to hash items,
- if this pointer is NULL will call "data_free" in MESA_hash_create(),
- * returns:
- * 0, success;
- * -1, no such thing;
- */
-int D_INTERNAL_MESA_hash_del_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size,
- void (* func)(void *))
-{
- uint index;
- hash_elem_v2_t * ptr;
- int ret = 0;
- index = table->key2index(table, key, size);
-
- D_INTERNAL___MESA_hash_mutex_lock(table,index);
- ptr = D_INTERNAL___MESA_hash_key_search(table,key,size,index);
- if(NULL == ptr){
- ret = -1;
- goto err; /* success, maybe? why? */
- }
-
- D_INTERNAL___MESA_hash_del_node(table ,ptr, index, func);
-
- //D_INTERNAL___MESA_hash_eliminate(table,index);
-
- D_INTERNAL___MESA_hash_mutex_unlock(table,index);
-
- return ret;
-
-err:
- D_INTERNAL___MESA_hash_mutex_unlock(table,index);
- return ret;
-}
-
-/*
- * name: hash_sel
- * functionality: selects item from table;
- * param:
- * table: from which table do you want to select;
- * key: what is the label;
- * size: how long is the label;
- *
- * return:
- * not NULL :pointer to attached data;
- * NULL :not found(thus be careful if you are attaching NULL data on purpose).
- */
-void *D_INTERNAL_MESA_hash_sel_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size)
-{
- uint index;
- hash_elem_v2_t * ptr;
- void *ret;
- index = table->key2index(table, key, size);
- D_INTERNAL___MESA_hash_mutex_lock(table,index);
- D_INTERNAL___MESA_hash_eliminate(table,index); /* 2013-09-12 LiJia modify, ����̭�ٲ���,����Ὣ�鵽�Ľ����̭���ַ��ظ��˵����� */
- ptr = D_INTERNAL___MESA_hash_key_search(table,key,size,index);
- if(NULL != ptr){
- ret = ptr->data;
- if(HASH_ELIMINATE_ALGO_LRU==table->eliminate_type){
- ptr->op_time = HASH_TIME_NOW();
- D_INTERNAL___MESA_hash_time_list_lru(table, ptr, index);
- }
- }else{
- ret = NULL;
- }
-
- D_INTERNAL___MESA_hash_mutex_unlock(table,index);
-
- return ret;
-}
-
-/*
- * name: hash_sel
- * functionality: selects item from table;
- * in param:
- * table: from which table do you want to select;
- * key : what is the label;
- * size : how long is the label;
- * cb : call this function when found the attached data;
- * arg : the argument of "cb" function.
- * out param:
- * cb_ret: the return value of the function "cb".
- * return:
- * not NULL :pointer to attached data;
- * NULL :not found(thus be careful if you are attaching NULL data on purpose).
- */
-void *D_INTERNAL_MESA_hash_sel_with_cb_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size,
- hash_cb_t *cb, void *arg, int *cb_ret)
-{
- uint index;
- hash_elem_v2_t * ptr;
- void *ret;
-
- index = table->key2index(table, key, size);
- D_INTERNAL___MESA_hash_mutex_lock(table,index);
- D_INTERNAL___MESA_hash_eliminate(table,index);/* 2013-09-12 LiJia modify, ����̭�ٲ���,����Ὣ�鵽�Ľ����̭���ַ��ظ��˵����� */
- ptr = D_INTERNAL___MESA_hash_key_search(table,key,size,index);
- if(NULL != ptr){
- ret = ptr->data;
- if(HASH_ELIMINATE_ALGO_LRU == table->eliminate_type){
- ptr->op_time = HASH_TIME_NOW();
- D_INTERNAL___MESA_hash_time_list_lru(table, ptr, index);
- }
- if(cb){
- *cb_ret = cb(ptr->data, arg);
- }
- }else{
- ret = NULL;
- if(cb){
- *cb_ret = cb(NULL, arg);
- }
- }
-
- D_INTERNAL___MESA_hash_mutex_unlock(table,index);
-
- return ret;
-}
-
-int D_INTERNAL_MESA_hash_iterate_v2(MESA_hash_tab_v2_t * table, void (* func)(uchar * key, uint size, void * data))
-{
- int i;
- hash_elem_v2_t * ptr;
-
- if(NULL == func){
- return 0;
- }
-
- for(i = 0; i < (int)table->size; i++) {
- D_INTERNAL___MESA_hash_mutex_lock(table, i/(table->size/HASH_TABLE_MUTEX_NUM));
- for(ptr = table->elems[i]; NULL != ptr; ptr = ptr->next)
- func(ptr->key, ptr->size, ptr->data);
- D_INTERNAL___MESA_hash_mutex_unlock(table, i/(table->size/HASH_TABLE_MUTEX_NUM));
- }
-
- return 0;
-}
-
-int D_INTERNAL_MESA_hash_iterate_v2_2(MESA_hash_tab_v2_t * table, void (* func)(uchar * key, uint size, void * data, void * u), void * user)
-{
- int i;
- hash_elem_v2_t * ptr;
-
- if(NULL == func){
- return 0;
- }
- for(i = 0; i < (int)table->size; i ++) {
- D_INTERNAL___MESA_hash_mutex_lock(table, i/(table->size/HASH_TABLE_MUTEX_NUM));
- for(ptr = table->elems[i]; NULL != ptr; ptr = ptr->next)
- func(ptr->key, ptr->size, ptr->data, user);
- D_INTERNAL___MESA_hash_mutex_unlock(table, i/(table->size/HASH_TABLE_MUTEX_NUM));
- }
-
- return 0;
-}
-
diff --git a/src/support/dictator2/src/D_internal/MESA_hash_v2.h b/src/support/dictator2/src/D_internal/MESA_hash_v2.h
deleted file mode 100644
index 52d5c19..0000000
--- a/src/support/dictator2/src/D_internal/MESA_hash_v2.h
+++ /dev/null
@@ -1,262 +0,0 @@
-#ifndef _LIB_HASH_H_INCLUDED_
-#define _LIB_HASH_H_INCLUDED_
-
-
-/*
- * general purpose hash table implementation.
- *
- * xiang hong
- * 2002-07-28
- *History:
- *2012-03-23 zhengchao add thread safe option and link expire feature;
- */
-
-
-
-#include <errno.h>
-#include <string.h>
-#include <pthread.h>
-#include "MESA_list_v2.h"
-#include "list_common.h"
-#include "../internal_mp.h"
-#define MESA_HASH_DEBUG (0)
-
-#if MESA_HASH_DEBUG
-#define HASH_INLINE
-#else
-#define HASH_INLINE inline
-#endif
-
-
-/*
- �˺궨���������ȡ��ǰʱ�䣬���Բ��Ǿ���ʱ�䣬����һ��ÿ��1������������
- Ϊ�˼��ٵ���time(NULL)�����Ĵ���.
- �Ƽ�����:
- �½�һ���̣߳���ij������ÿ��һ������һ��.
-*/
-#if 1
-#define HASH_TIME_NOW() time(NULL)
-#else
-extern volatile unsigned int G_TIMER; /* �˱�������һ���߳���ÿ��1������һ�� */
-#define HASH_TIME_NOW() (time_t)G_TIMER
-#endif
-
-#ifndef uchar
-#define uchar unsigned char
-#endif
-#ifndef uint
-#define uint unsigned int
-#endif
-
-#define HASH_THRESHOLD_MAX 65536
-#define HASH_THRESHOLD_MIN 0
-#define HASH_THRESHOLD_MAX_DELTA 32768
-#define HASH_THRESHOLD_MIN_DELTA 16
-
-#define HASH_ELIMINATE_ALGO_FIFO (0) /* by default */
-#define HASH_ELIMINATE_ALGO_LRU (1)
-
-struct __hash_tab_v2;
-
-/*
- * hash key compare function prototype, see hash_key_comp().
- * return value:
- * 0:key1 and key2 are equal;
- * other:key1 and key2 not equal.
- */
-typedef int key_comp_t(uchar * key1, uint size1, uchar * key2, uint size2);
-
-/*
- * hash key->index computing function prototype, see hash_key2index().
- */
-typedef uint key2index_t(struct __hash_tab_v2 * tab, uchar * key, uint size);
-
-typedef int hash_cb_t(void *data, void *arg);
-
-/*
- * hash element structure.
- *
- * key : a copy of key;
- * size: size of key;
- * hash_index: index which use this key and key2index_t() calculated;
- * data: pointer to attached data;
- * prev, next: pointer to prev and next item;
- */
-typedef struct struct_hash_elem {
- uchar *key;
- void *data;
- uint size;
- uint hash_index;
- time_t op_time;
- struct struct_hash_elem *prev;
- struct struct_hash_elem *next;
- MESA_list_index_v2_t list_node;
-} hash_elem_v2_t;
-
-/*
- * hash structure.
- *
- * size: number of slots;
- * key_comp: pointer to the function that compares 2 keys;
- * key2index: pointer to the function that computes index from key;
- * expire: pointer to the function that do somthing when data expired;
- * free: pointer to the function that cleans up attached data;
- * elems: array of slots;
- * elem_count: number of items;
- * threshold_lo, threshold_hi: low and high threshold; when elem_count reaches
- * one of them, an iteration will be launched to clean up expired items;
- */
-typedef struct __hash_tab_v2 {
- uint size;
- uint is_thread_safe;
- key_comp_t * key_comp;
- key2index_t * key2index;
- void (* expire)(void * data);
- void (* free)(void * data);
- hash_elem_v2_t ** elems;
- unsigned int max_elem_num;
- volatile uint elem_count;
- //uint threshold_lo;
- //uint threshold_hi;
- int eliminate_type;
- int expire_time;
- pthread_mutex_t *htable_mutex;
- //MESA_queue_head_t *hlist_head;
- MESA_list_index_v2_t *hlist_head;
- IMP_t* p_mempool;
-} MESA_hash_tab_v2_t;
-
-/*
- * name: hash_create
- * functionality: allocats memory for hash slots, and fill in hash structure;
- * param:
- * table: caller allocated hash table structure, gets filled in;
- * is_thread_safe:1:create thread safe hashtable; 0:create hashtable without thread safe insurance;
- * size: how big do you want the table to be, must be 2^N;
- * max_elem_num: the maximum elements of the HASH-table,0 means infinite;
- * key_comp: hash key compare function, use default function if NULL;
- * key2index: hash key->index computing function, use default function if NULL;
- * data_free: release resources function, only free attached data pointer if NULL;
- * data_expire: if expire_time > 0, call this function when a element expire, can be NULL;
- * eliminate_type: the algorithm of elimanate a expired element, 0:FIFO; 1:LRU.
- * expire_time: the element expire time in second, 0 means infinite.
- * returns:
- * 0, success;
- * -1, memory failure;
- * -2, parameter not acceptable;
- */
-int D_INTERNAL_MESA_hash_create_v2(MESA_hash_tab_v2_t * table,
- uint is_thread_safe ,
- uint size,
- uint max_elem_num,
- key_comp_t * key_comp,
- key2index_t * key2index,
- void (* data_free)(void *),
- void (* data_expire)(void *),
- int eliminate_type,
- int expire_time,
- IMP_t * mempool);
-
-/*
- * name: hash_destroy
- * functionality: cleans up hash structure, frees memory occupied;
- * param:
- * table: who is the victim;
- * func: callback function to clean up data attached to hash items;
- * returns:
- * always returns 0;
- */
-int D_INTERNAL_MESA_hash_destroy_v2(MESA_hash_tab_v2_t * table, void (* func)(void *));
-
-/*
- * name: hash_add
- * functionality: adds item to table, call hash_expire() if elem_count gets
- * bigger than threshold_hi, and adjust threshold;
- * param:
- * table: to which table do you want to add;
- * key: what is the label;
- * size: how long is the label;
- * data: what data do you want to attach;
- * returns:
- * >0 success,return hash elems' linklist size
- * -1, duplicates found and can't add this one;
- * -2, memory failure;
- */
-int D_INTERNAL_MESA_hash_add_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size, void * data);
-
-/*
- * name: hash_del
- * functionality: deletes item from table.
- * param:
- * table: from which table do you want to delete;
- * key : what is the label;
- * size : how long is the label;
- * func : callback function to clean up data attached to hash items,
- if this pointer is NULL will call "data_free" in MESA_hash_create(),
- * returns:
- * 0, success;
- * -1, no such thing;
- */
-int D_INTERNAL_MESA_hash_del_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size,
- void (* func)(void *));
-
-/*
- * name: hash_sel
- * functionality: selects item from table;
- * param:
- * table: from which table do you want to select;
- * key : what is the label;
- * size : how long is the label;
- *
- * return:
- * not NULL :pointer to attached data;
- * NULL :not found(thus be careful if you are attaching NULL data on purpose).
- */
-void * D_INTERNAL_MESA_hash_sel_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size);
-
-/*
- * name: hash_sel
- * functionality: selects item from table;
- * in param:
- * table: from which table do you want to select;
- * key : what is the label;
- * size : how long is the label;
- * cb : call this function when found the attached data;
- * arg : the argument of "cb" function.
- * out param:
- * cb_ret: the return value of the function "cb".
- * return:
- * not NULL :pointer to attached data;
- * NULL :not found(thus be careful if you are attaching NULL data on purpose).
- */
-void *D_INTERNAL_MESA_hash_sel_with_cb_v2(MESA_hash_tab_v2_t * table, uchar * key, uint size,
- hash_cb_t *cb, void *arg, int *cb_ret);
-
-/*
- * name: hash_iterate
- * functionality: iterates each hash item;
- * params:
- * table: what table is to be iterated;
- * func: what do you want to do to each attached data item;
- * returns:
- * 0: iterates all items;
- * -3: can't get lock in non-block mode;
- */
-int D_INTERNAL_MESA_hash_iterate_v2(MESA_hash_tab_v2_t * table, void (* func)(uchar * key, uint size, void * data));
-int D_INTERNAL_MESA_hash_iterate_v2_2(MESA_hash_tab_v2_t * table, void (* func)(uchar * key, uint size, void * data, void * u), void * user);
-
-#if 0
-/*
- * name: hash_expire
- * functionality: iterates each item and deletes those that are expired;
- * params:
- * table: what table do you want to check;
- * returns:
- * always 0;
- */
-int MESA_hash_expire(MESA_hash_tab_v2_t * table);
-#endif
-
-#endif /* _LIB_HASH_H_INCLUDED_ */
-
-
diff --git a/src/support/dictator2/src/D_internal/MESA_list_v2.cpp b/src/support/dictator2/src/D_internal/MESA_list_v2.cpp
deleted file mode 100644
index bd5a22d..0000000
--- a/src/support/dictator2/src/D_internal/MESA_list_v2.cpp
+++ /dev/null
@@ -1,361 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include <linux/types.h>
-#include <linux/stddef.h>
-#include <assert.h>
-#include "MESA_list_v2.h"
-#include "list_common.h"
-
-
-
-extern void D_INTERNAL_list_count_init(void **list_count);
-extern void D_INTERNAL_list_count_inc(void **list_count);
-extern void D_INTERNAL_list_count_dec(void **list_count);
-
-#if MESA_LIST_CHECK != 0
-/*Function:Check the intergrity of the list,to dectect memory mess.
-*Input: Queue Head,data check call back function
-*Output: return a number below zero,if the queue got a problem,else return 0;
-*Author:[email protected] at 20100913
-*/
-#if 0
-static int MESA_q_list_check(const MESA_queue_head_v2_t *qhead_obj,int(*quiddity_check)(const void *))
-{
- MESA_list_index_v2_t *p=NULL, *head=NULL;
-// int linked_ele_number=0;
- int ret=0;
-// return 0;
- if(qhead_obj->listcount==0)
- {
- if(qhead_obj->head!=NULL||qhead_obj->head!=NULL)
- {
- ret=-1;
- }
- goto exit;
- }
-
- if(qhead_obj->head==NULL||qhead_obj->tail==NULL)
- {
- ret=-2;
- goto exit;
- }
- if(qhead_obj->listcount>1){
- if(qhead_obj->head->preele!=NULL||qhead_obj->head->nextele==NULL)
- {
- ret=-3;
- goto exit;
- }
- if(qhead_obj->tail->preele==NULL||qhead_obj->tail->nextele!=NULL)
- {
- ret=-4;
- goto exit;
- }
-
- head = p = qhead_obj->head;
- p = p->nextele;
- while(p != head)
- {
- if(p == NULL) break;
- if(p == head){
- ret = -5; /* has a cycle */
- goto exit;
- }
- p = p->nextele;
- }
- }
- /*
- pre=qhead_obj->head;
- p=pre->nextele;
- while(p!=NULL){
- linked_ele_number++;
-
- //Is the declared size equal to element linked number;
- if(linked_ele_number > qhead_obj->listcount)
- {
- ret=-5;
- goto exit;
- }
-
- //Is element's preele pointer equal to its preele
- if(pre!=p->preele)
- {
- ret=-6;
- goto exit;
- }
- if(quiddity_check!=NULL){
- if(0>quiddity_check(p->quiddity))
- {
- ret =-7;
- goto exit;
- }
- }
- pre=p;
- p=p->nextele;
- }
- //Is the last element equal to tail
- if(pre!=qhead_obj->tail)
- {
- ret=-8;
- goto exit;
- }
- if(linked_ele_number !=qhead_obj->listcount-1)
- {
- ret=-9;
- goto exit;
- }
- */
-exit:
- if(ret<0)
- {
- return ret;
- }
- else
- {
- return 1;
- }
-
-}
-#endif
-
-#if 2==MESA_LIST_CHECK
-/*Simple check,not raversal*/
-static int D_INTERNAL_MESA_q_is_item_in_list_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj){
-// MESA_list_index_v2_t* pre=lindex_obj->preele;
-// MESA_list_index_v2_t*next=lindex_obj->nextele;
- MESA_list_index_v2_t*p=NULL;
- int i, num;
-
- if(D_INTERNAL_common_list_empty_careful(qhead_obj)){
- return 0;
- }
-
- p = qhead_obj->nextele;
- num = D_INTERNAL_MESA_get_list_count_v2(qhead_obj);
- i = 0;
- while((p != qhead_obj) && (i <= num))
- {
- if(p == lindex_obj)
- {
- return 1;
- }
- p=p->nextele;
- i++;
- }
-
- return 0;
-
-}
-#endif
-
-/*every MESA_list_index_v2_t leaves list,its pre and next will be set NULL
- * In Configuration Transmiiter project, not null element will consider in list,
- * pre and next is NULL only if there's one element in list only*/
-static int D_INTERNAL_MESA_q_is_item_in_list_quick_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj)
-{
- //empty list
- if(D_INTERNAL_common_list_empty_careful((struct common_list_index *)qhead_obj)){
- return 0;
- }
-
- //have more element
- if(lindex_obj->nextele==NULL || lindex_obj->preele==NULL){
- return 0;
- }
- if(lindex_obj->nextele->preele != lindex_obj){
- return 0;
- }
- if(lindex_obj->preele->nextele != lindex_obj){
- return 0;
- }
-
- return 1;
-
-}
-#endif
-
-void D_INTERNAL_list_count_init(void **list_count)
-{
- long *p_c = (long *)list_count;
- *p_c = 0;
-}
-
-void D_INTERNAL_list_count_inc(void **list_count)
-{
- long *p_c = (long *)list_count;
- long c = *p_c;
- *p_c = c + 1;
-}
-
-void D_INTERNAL_list_count_dec(void **list_count)
-{
- long *p_c = (long *)list_count;
- long c = *p_c;
- *p_c = c - 1;
-}
-
-
-/*************************** �ⲿ���ýӿ� ********************************/
-
-
-/*
- ��һ��ʹ��MESA_listģ��ʱ��������ô˳�ʼ��ģ��.
-*/
-int D_INTERNAL_MESA_list_init_v2(MESA_queue_head_v2_t *head)
-{
- D_INTERNAL_COMMON_LIST_INIT_HEAD((struct common_list_index *)head);
- D_INTERNAL_list_count_init(&head->quiddity);
- return 0;
-}
-
-/* ��Ϊheadʹ��ʱ, "quiddity"��Ϊһ��long�ͱ���,���ڴ洢����Ԫ������ */
-long D_INTERNAL_MESA_get_list_count_v2(const MESA_queue_head_v2_t *head)
-{
- return (long)head->quiddity;
-}
-
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_read_next_v2(MESA_queue_head_v2_t *head,MESA_list_index_v2_t *lindex_obj)
-{
- return (lindex_obj->nextele == head) ? NULL: lindex_obj->nextele;
-}
-
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_read_pre_v2(MESA_queue_head_v2_t *head, MESA_list_index_v2_t *lindex_obj)
-{
- return (lindex_obj->preele == head) ? NULL: lindex_obj->nextele;
-}
-
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_read_head_v2(const MESA_queue_head_v2_t *qhead_obj)
-{
- if(D_INTERNAL_common_list_empty_careful((struct common_list_index *)qhead_obj)){
- return NULL;
- }
- return qhead_obj->nextele;
-}
-
-
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_get_head_v2(MESA_queue_head_v2_t *qhead_obj)
-{
- MESA_list_index_v2_t *out;
- if(D_INTERNAL_common_list_empty_careful((struct common_list_index *)qhead_obj)){
- return NULL;
- }
- out = qhead_obj->nextele;
- D_INTERNAL_common_list_del((struct common_list_index *)out);
- D_INTERNAL_list_count_dec(&qhead_obj->quiddity);
-
- return out;
-}
-
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_get_tail_v2(MESA_queue_head_v2_t *qhead_obj)
-{
- MESA_list_index_v2_t *out;
- if(D_INTERNAL_common_list_empty_careful((struct common_list_index *)qhead_obj)){
- return NULL;
- }
- out = qhead_obj->preele;
- D_INTERNAL_common_list_del((struct common_list_index *)out);
- D_INTERNAL_list_count_dec(&qhead_obj->quiddity);
-
- return out;
-}
-
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_tail_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj)
-{
- D_INTERNAL_common_list_add_tail((struct common_list_index *)lindex_obj, (struct common_list_index *)qhead_obj);
- D_INTERNAL_list_count_inc(&qhead_obj->quiddity);
-
- return lindex_obj;
-}
-
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_head_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj)
-{
- D_INTERNAL_common_list_add((struct common_list_index *)lindex_obj, (struct common_list_index *)qhead_obj);
- D_INTERNAL_list_count_inc(&qhead_obj->quiddity);
-
- return lindex_obj;
-}
-
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_list_n_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *place_next, MESA_list_index_v2_t *new_obj)
-{
- D_INTERNAL_common_list_add((struct common_list_index *)new_obj, (struct common_list_index *)place_next);
- D_INTERNAL_list_count_inc(&qhead_obj->quiddity);
- return new_obj;
-}
-
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_list_p_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *new_obj, MESA_list_index_v2_t *place_pre)
-{
- D_INTERNAL_common_list_add((struct common_list_index *)new_obj, (struct common_list_index *)place_pre->preele);
- D_INTERNAL_list_count_inc(&qhead_obj->quiddity);
- return new_obj;
-}
-
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_leave_list_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj)
-{
-#if 1==MESA_LIST_CHECK
- if(0 == D_INTERNAL_MESA_q_is_item_in_list_quick_v2(qhead_obj, lindex_obj)){
- //return NULL;
- assert(0); //critical
- }
-#elif 2==MESA_LIST_CHECK
- if(0 == D_INTERNAL_MESA_q_is_item_in_list_v2(qhead_obj, lindex_obj)){
- //return NULL;
- assert(0); //critical
- }
-#endif
- D_INTERNAL_common_list_del((struct common_list_index *)lindex_obj);
- D_INTERNAL_list_count_dec(&qhead_obj->quiddity);
-
- return lindex_obj;
-}
-
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_move_head_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj)
-{
-#if 1==MESA_LIST_CHECK
- if(0 == D_INTERNAL_MESA_q_is_item_in_list_quick_v2(qhead_obj, lindex_obj)){
- //return NULL;
- assert(0); //critical
- }
-#elif 2==MESA_LIST_CHECK
- if(0 == D_INTERNAL_MESA_q_is_item_in_list_v2(qhead_obj, lindex_obj)){
- //return NULL;
- assert(0); //critical
- }
-#endif
- D_INTERNAL_common_list_move((struct common_list_index *)lindex_obj, (struct common_list_index *)qhead_obj);
-
- return lindex_obj;
-}
-
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_move_tail_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj)
-{
-#if 1==MESA_LIST_CHECK
- if(0 == D_INTERNAL_MESA_q_is_item_in_list_quick_v2(qhead_obj,lindex_obj)){
- //return NULL;
- assert(0); //critical
- }
-#elif 2==MESA_LIST_CHECK
- if(0 == D_INTERNAL_MESA_q_is_item_in_list_v2(qhead_obj, lindex_obj)){
- //return NULL;
- assert(0); //critical
- }
-#endif
- D_INTERNAL_common_list_move_tail((struct common_list_index *)lindex_obj, (struct common_list_index *)qhead_obj);
-
- return lindex_obj;
-}
-
-void D_INTERNAL_MESA_q_destroy_v2(MESA_queue_head_v2_t *qhead_obj, void (* cb)(MESA_list_index_v2_t *))
-{
- MESA_list_index_v2_t *del;
-
- while(!D_INTERNAL_common_list_empty_careful((struct common_list_index *)qhead_obj)){
- del = qhead_obj->nextele;
- D_INTERNAL_common_list_del((struct common_list_index *)del);
- if(del->quiddity && cb){
- cb(del);
- }
- }
-
- return;
-}
-
-
diff --git a/src/support/dictator2/src/D_internal/MESA_list_v2.h b/src/support/dictator2/src/D_internal/MESA_list_v2.h
deleted file mode 100644
index 8dbb098..0000000
--- a/src/support/dictator2/src/D_internal/MESA_list_v2.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef _MESA_LIST_V2_H_
-#define _MESA_LIST_V2_H_
-
-
-#define MESA_LIST_CHECK (1) /* 0:no check; 1:quick check; 2:careful check */
-
-typedef struct list_index_v2{
- struct list_index_v2 *nextele;
- struct list_index_v2 *preele;
- void *quiddity;
-}MESA_list_index_v2_t;
-
-typedef struct list_index_v2 MESA_queue_head_v2_t;
-
-
-/*
- ��һ��ʹ��MESA_listģ��ʱ��������ô˳�ʼ��ģ��!!!
-*/
-int D_INTERNAL_MESA_list_init_v2(MESA_queue_head_v2_t *head);
-
-long D_INTERNAL_MESA_get_list_count_v2(const MESA_queue_head_v2_t *head);
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_read_head_v2(const MESA_queue_head_v2_t *qhead_obj);
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_get_head_v2(MESA_queue_head_v2_t *qhead_obj);
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_get_tail_v2(MESA_queue_head_v2_t *qhead_obj);
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_tail_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj);
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_head_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj);
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_leave_list_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj);
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_move_head_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj);
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_move_tail_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj);
-void D_INTERNAL_MESA_q_destroy_v2(MESA_queue_head_v2_t *qhead_obj, void (* cb)(MESA_list_index_v2_t *));
-
-/* insert "new_obj" between "op_place" and "op_place->nextele" */
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_list_n_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *op_place, MESA_list_index_v2_t *new_obj);
-
-/* insert "new_obj" between "op_place->preele" and "op_place" */
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_join_list_p_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *new_obj, MESA_list_index_v2_t *op_place);
-
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_read_next_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj);
-MESA_list_index_v2_t *D_INTERNAL_MESA_q_read_pre_v2(MESA_queue_head_v2_t *qhead_obj, MESA_list_index_v2_t *lindex_obj);
-
-#endif
-
-
diff --git a/src/support/dictator2/src/D_internal/Makefile b/src/support/dictator2/src/D_internal/Makefile
deleted file mode 100644
index 4432e91..0000000
--- a/src/support/dictator2/src/D_internal/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-CC=gcc
-CCC=g++ -O2
-
-CFLAGS=-g -Wall -fPIC
-LIBPATH=../
-
-OBJS=MESA_hash_v2.o D_kernel_list.o MESA_list_v2.o list_common.o
-
-.c.o:
- $(CC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-.cpp.o:
- $(CCC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-libMESA_hash_v2.a: $(OBJS)
- echo making lib ...
- (rm -f $@ ;ar -r $@ $^; cp $(OBJS) $(LIBPATH);)
-
-clean:
- rm -f *.o libMESA_hash_v2.a
diff --git a/src/support/dictator2/src/D_internal/list_common.cpp b/src/support/dictator2/src/D_internal/list_common.cpp
deleted file mode 100644
index ca6a1b0..0000000
--- a/src/support/dictator2/src/D_internal/list_common.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-#include <stdio.h>
-#include "list_common.h"
-
-
-/*************************** �ڲ�ʵ�ֽӿ� ********************************/
-
-/*
- * Simple doubly linked list implementation.
- *
- * Some of the internal functions ("__xxx") are useful when
- * manipulating whole lists rather than single entries, as
- * sometimes we already know the next/prev entries and we can
- * generate better code by using them directly rather than
- * using the generic single-entry routines.
- */
-
-void D_INTERNAL_COMMON_LIST_INIT_HEAD(struct common_list_index *head)
-{
- head->nextele = head;
- head->preele = head;
-}
-
-
-/*
- * Insert a new entry between two known consecutive entries.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void D_INTERNAL___common_list_add(struct common_list_index *new_list,
- struct common_list_index *prev,
- struct common_list_index *next)
-{
- next->preele = new_list;
- new_list->nextele = next;
- new_list->preele = prev;
- prev->nextele = new_list;
-}
-
-/**
- * list_add - add a new entry
- * @new: new entry to be added
- * @head: list head to add it after
- *
- * Insert a new entry after the specified head.
- * This is good for implementing stacks.
- * lijia comment: list_add()���½ڵ����head��head->next֮��.
- */
-void D_INTERNAL_common_list_add(struct common_list_index *new_list, struct common_list_index *head)
-{
- D_INTERNAL___common_list_add(new_list, head, head->nextele);
-}
-
-
-/**
- * list_add_tail - add a new entry
- * @new: new entry to be added
- * @head: list head to add it before
- *
- * Insert a new entry before the specified head.
- * This is useful for implementing queues.
- * lijia comment: list_add_tail()���½ڵ����head��head->prev֮��.
- */
-void D_INTERNAL_common_list_add_tail(struct common_list_index *new_list, struct common_list_index *head)
-{
- D_INTERNAL___common_list_add(new_list, head->preele, head);
-}
-
-/*
- * Delete a list entry by making the prev/next entries
- * point to each other.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void D_INTERNAL___common_list_del(struct common_list_index * prev, struct common_list_index * next)
-{
- next->preele = prev;
- prev->nextele = next;
-}
-
-static inline void D_INTERNAL___common_list_del_entry(struct common_list_index *entry)
-{
- D_INTERNAL___common_list_del(entry->preele, entry->nextele);
- entry->nextele = NULL;
- entry->preele = NULL;
-}
-
-/**
- * list_del - deletes entry from list.
- * @entry: the element to delete from the list.
- * Note: list_empty() on entry does not return true after this, the entry is
- * in an undefined state.
- */
-
-void D_INTERNAL_common_list_del(struct common_list_index *entry)
-{
- D_INTERNAL___common_list_del(entry->preele, entry->nextele);
- entry->nextele = NULL;
- entry->preele = NULL;
-}
-
-
-/**
- * list_move - delete from one list and add as another's head
- * @list: the entry to move
- * @head: the head that will precede our entry
- */
-void D_INTERNAL_common_list_move(struct common_list_index *list, struct common_list_index *head)
-{
- D_INTERNAL___common_list_del_entry(list);
- D_INTERNAL_common_list_add(list, head);
-}
-
-/**
- * list_move_tail - delete from one list and add as another's tail
- * @list: the entry to move
- * @head: the head that will follow our entry
- */
-void D_INTERNAL_common_list_move_tail(struct common_list_index *list, struct common_list_index *head)
-{
- D_INTERNAL___common_list_del_entry(list);
- D_INTERNAL_common_list_add_tail(list, head);
-}
-
-#if 0
-/**
- * list_empty - tests whether a list is empty
- * @head: the list to test.
- */
-static int list_empty(const struct common_list_index *head)
-{
- return head->nextele == head;
-}
-#endif
-
-/**
- * list_empty_careful - tests whether a list is empty and not being modified
- * @head: the list to test
- *
- * Description:
- * tests whether a list is empty _and_ checks that no other CPU might be
- * in the process of modifying either member (next or prev)
- *
- * NOTE: using list_empty_careful() without synchronization
- * can only be safe if the only activity that can happen
- * to the list entry is list_del_init(). Eg. it cannot be used
- * if another CPU could re-list_add() it.
- */
-int D_INTERNAL_common_list_empty_careful(const struct common_list_index *head)
-{
- struct common_list_index *next = head->nextele;
- return (next == head) && (next == head->preele);
-}
-
diff --git a/src/support/dictator2/src/D_internal/list_common.h b/src/support/dictator2/src/D_internal/list_common.h
deleted file mode 100644
index 6ef3dd0..0000000
--- a/src/support/dictator2/src/D_internal/list_common.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef _LIST_COMMON_H_
-#define _LIST_COMMON_H_
-
-struct common_list_index{
- struct common_list_index *nextele;
- struct common_list_index *preele;
-};
-
-void D_INTERNAL_COMMON_LIST_INIT_HEAD(struct common_list_index *head);
-int D_INTERNAL_common_list_empty_careful(const struct common_list_index *head);
-void D_INTERNAL_common_list_add(struct common_list_index *new_list, struct common_list_index *head);
-void D_INTERNAL_common_list_add_tail(struct common_list_index *new_list, struct common_list_index *head);
-void D_INTERNAL_common_list_del(struct common_list_index *entry);
-void D_INTERNAL_common_list_move(struct common_list_index *list, struct common_list_index *head);
-void D_INTERNAL_common_list_move_tail(struct common_list_index *list, struct common_list_index *head);
-
-#endif
-
diff --git a/src/support/dictator2/src/D_internal/readme.txt b/src/support/dictator2/src/D_internal/readme.txt
deleted file mode 100644
index fc87961..0000000
--- a/src/support/dictator2/src/D_internal/readme.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-���ļ������ڲ�Դ���룬��Ϊ����.a�⣬һ�㲻���ⷢ����
-�����ṩlibMESA_hash_v2.a��MESA_list.h��MESA_hash_v2.h
-
-MESA_list_v2Ϊ�������̰߳�ȫ�Ķ���,�ֽ�������. \ No newline at end of file
diff --git a/src/support/dictator2/src/Makefile b/src/support/dictator2/src/Makefile
deleted file mode 100644
index c7c9137..0000000
--- a/src/support/dictator2/src/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all:
- cp dictator.h ../../../../include/support/
- make clean&&make -f Makefile_nodebug
- #make clean&&make -f Makefile_debug
-clean:
- rm -f D_internal/*.o
- rm *.o -f
diff --git a/src/support/dictator2/src/Makefile_debug b/src/support/dictator2/src/Makefile_debug
deleted file mode 100644
index e8d7fc6..0000000
--- a/src/support/dictator2/src/Makefile_debug
+++ /dev/null
@@ -1,43 +0,0 @@
-#################################################
-# #
-# dictator, version 0.01 #
-# #
-# Software Division, ICT, 2010.11 #
-# #
-#################################################
-
-#CC=gcc -g
-CC = g++
-
-INCLUDES =
-LIBS = -lpthread -ldl
-CFLAGS = -g -Wall -fPIC
-
-
-SOURCES = dictator.cpp
-OBJECTS = dictator.o dictator_debuger.o
-TARGET = EXEditctator
-TARGETLIB = libdictator.a
-
-.PHONY: all dep clean install
-
-.c.o:
- $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $< -DDICTATOR_DEBUG
-
-.cpp.o:
- $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $< -DDICTATOR_DEBUG
-all:$(OBJECTS)
- cd D_internal/ && $(MAKE) clean && $(MAKE)
- ar cqs $(TARGETLIB) *.o
- cp $(TARGETLIB) ../lib/
- cp $(TARGETLIB) ../../../lib/
-dictator.o: dictator.cpp dictator.h dictator_core.h
- $(CC) -c -o $@ $(CFLAGS) $< -DDICTATOR_DEBUG
-dictator_debuger.o: dictator_debuger.cpp dictator.h dictator_core.h
- $(CC) -c -o $@ $(CFLAGS) $< -DDICTATOR_DEBUG
-# $(CC) $(OBJECTS) -o $(TARGET) $(LIBS)
-# ld dictator.o $(LIBS)
-clean:
- rm -f *.o $(TARGETLIB)
- cd D_internal && $(MAKE) clean
-
diff --git a/src/support/dictator2/src/Makefile_nodebug b/src/support/dictator2/src/Makefile_nodebug
deleted file mode 100644
index 8884569..0000000
--- a/src/support/dictator2/src/Makefile_nodebug
+++ /dev/null
@@ -1,44 +0,0 @@
-#################################################
-# #
-# dictator, version 0.01 #
-# #
-# Software Division, ICT, 2010.11 #
-# #
-#################################################
-
-#CC=gcc -g
-CC = g++
-
-INCLUDES =
-LIBS = -lpthread -ldl
-CFLAGS = -g -Wall -fPIC
-
-
-
-SOURCES = dictator.cpp
-OBJECTS = dictator.o dictator_debuger.o
-TARGET = EXEditctator
-TARGETLIB = libdictator.a
-
-.PHONY: all dep clean install
-
-.c.o:
- $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-
-.cpp.o:
- $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-all:$(OBJECTS)
- cd D_internal/ && $(MAKE) clean && $(MAKE)
- ar cqs $(TARGETLIB) *.o
- cp $(TARGETLIB) ../lib/
- cp $(TARGETLIB) ../../../lib/
-dictator.o: dictator.cpp dictator.h dictator_core.h
- $(CC) -c -o $@ $(CFLAGS) $<
-dictator_debuger.o: dictator_debuger.cpp dictator.h dictator_core.h
- $(CC) -c -o $@ $(CFLAGS) $<
-# $(CC) $(OBJECTS) -o $(TARGET) $(LIBS)
-# ld dictator.o $(LIBS)
-clean:
- rm -f *.o $(TARGETLIB)
- cd D_internal && $(MAKE) clean
-
diff --git a/src/support/dictator2/src/dictator.cpp b/src/support/dictator2/src/dictator.cpp
deleted file mode 100644
index 2de2deb..0000000
--- a/src/support/dictator2/src/dictator.cpp
+++ /dev/null
@@ -1,866 +0,0 @@
-/*
- * Manage program memory,for high perfomance and exclusive application.
- * The dictator will hoard memory for program to reduce malloc time cost.
- * Version : 2014-12-15
- * Usage:LD_DICTATOR = -Wl,-wrap,malloc -Wl,-wrap,calloc -Wl,-wrap,free -Wl,-wrap,realloc,add LD_DICTATOR as ld parameter.
- * Zheng Chao, [email protected]
- *
- * History:
- * 2010-11-30 first build
- * 2010-12-14 to reduce memory waste,change block list from exponential(e.g.64,128,256,512...)to linearity (e.g. 64,128,192,256...)
- * 2010-12-16 to resolve productor and consumer problem, thread 1 free thread 2's mem block,add block to thread 2's tail,
- * use mutex to protect the block queues tail.
- * 2010-12-20 fix core_realloc memcpy read out line.
- * 2010-12-29 use gcc buildin atomic operation to proctec chain ele_cnt,use volatile to describe thread stat value
- * 2010-12-30 redesigned mem_info_t struct,reduce mem used from 40 to 8;not suport slice;
- * 2011-01-05 change block assigned strategy,POWER[].
- * 2011-01-28 use <alsa/iatomic.h> as atomic operation
- * 2011-02-14 check block's tid,if from unactivated thread
- * 2011-11-21 strict check block size ,whether it suit chain index in free with assert
- * 2013-12-26 DICTATOR2 first build.
- * 2014-01-17 DICTATOR2 v1.0 released.
- * 2014-06-18 fix realloc memcpy over read ptr bug.
- * 2014-12-02 use mesa_backtrace(student [email protected]) replace glibc backtrace or libunwind backtrace.
- * 2014-12-08 use array replace hash to implement tid2idx and tseq2idx.
- * Notes:
- *
- * block(dictator manged) < chunk (system mmap alloced)
- *
- */
-
-#include <stdio.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-#include <assert.h>
-#include <string.h>//using memset
-#include <malloc.h>
-#include <time.h>
-#include <new>
-#include <pthread.h>
-#include <sys/mman.h>
-//#define DPDK_HUGE_PAGE
-
-#ifdef DPDK_HUGE_PAGE
-#include <marsio.h>
-#endif
-
-#include "internal_mp.h"
-#include "dictator.h"
-#include "dictator_core.h"
-#include "dummy_hash.h"
-
-
-#ifdef DICTATOR_DEBUG
-const char* DICTATOR2_VERSION_20170910_DEBUG="DICTATOR2_VERSION_1_3_20170910_DEBUG";
-#else
-const char* DICTATOR2_VERSION_20170910="DICTATOR2_VERSION_1_3_20170910";
-#endif
-#define FREE_MEM_HEAD_LEN (sizeof(mem_info_t))
-struct dictator_space_t D_SPACE;
-#define D_THREAD_HASH_SIZE 4*1024
-int is_first=0;
-const unsigned int LINEAR_1_BOUNDARY=1024;
-const unsigned int LINEAR_2_FACTOR=8;
-
-char boundary_marker[D_MARKER_SIZE]={'d'};
-#define PAGE_SIZE 4096
-#define ELF_MIN_ALIGN PAGE_SIZE
-#define ELF_PAGEALIGN(_v) (((_v)+ELF_MIN_ALIGN-1)&~(ELF_MIN_ALIGN-1))
-
-static inline pid_t dictator_gettid(void){
- pid_t ret=(pid_t)pthread_self();
- return ret;
-}
-mem_info_t* fill_empty_block(mem_info_t* block,unsigned int blk_num,unsigned short D_id){
- block->blk_num=blk_num;
- block->D_id=D_id;
-#ifdef DICTATOR_DEBUG
- block->magic=DICTATOR_MAGIC;
- block->idx=NULL;
-#endif
- block->next=NULL;
- block->type=0;
- return block;
-}
-inline int D_hash_key_comp(uchar * key1, uint size1, uchar * key2, uint size2)
-{
- assert(size1==sizeof(int)&&size2==sizeof(int));
- if(*(int*)key1==*(int*)key2)
- {
- return 0;
- }
- else
- {
- return 1;
- }
-}
-inline unsigned int D_hash_key2index(MESA_hash_tab_v2_t * table, uchar *str, uint size)
-{
- assert(size==sizeof(int));
- return (*(unsigned int*)str % table->size);
-}
-inline static int tid2idx(pthread_t * array,int size,pthread_t tid)
-{
- int i=0;
- for(i=size-1;i>=0;i--)
- {
- if(array[i]==tid)
- {
- return i;
- }
- }
- return -1;
-}
-
-inline static thread_mem_pool_t* locate_mp_by_tseq(int t_seq)
-{
- long idx=0;
- int ret=0;
- pthread_t tid=0;
- thread_mem_pool_t* p_mempool=NULL;
- idx=D_SPACE.tseq2idx[t_seq];
- if(idx>=0)
- {
- p_mempool=D_SPACE.thread_mem_info[idx];
- }
- if(p_mempool==NULL)
- {
- tid=pthread_self();
- ret=dummy_htable_read(&(D_SPACE.tid2idx), (long)tid,&idx);
- if(ret==1)
- {
- p_mempool=D_SPACE.thread_mem_info[idx];
- }
- if(p_mempool==NULL)
- {
- atomic_inc(&(D_SPACE.used_mem_pool_counter));//here is not thread safe but __sync_add_and_fetch not support in all OS
- idx = atomic_read(&(D_SPACE.used_mem_pool_counter));
- p_mempool=create_mem_pool(idx);
- p_mempool->tid=tid;
-#ifdef DICTATOR_DEBUG
- init_debugger(&(p_mempool->debugger),p_mempool);
-#endif
- D_SPACE.thread_mem_info[idx]=p_mempool;
- dummy_htable_add(&(D_SPACE.tid2idx),tid,idx);
- D_SPACE.tseq2idx[t_seq]=idx;
- }
- p_mempool->t_seq=t_seq;
- }
-#ifdef DICTATOR_DEBUG
- tid=pthread_self();
- assert(p_mempool->t_seq==t_seq);
- assert(tid==p_mempool->tid);
-#endif
- return p_mempool;
-}
-inline static thread_mem_pool_t* locate_mp_by_tid(pthread_t tid)
-{
- thread_mem_pool_t* p_mempool=NULL;
- long idx=0;
- int ret=0;
- ret=dummy_htable_read(&(D_SPACE.tid2idx), tid, &idx);
- if(ret==1)
- {
- p_mempool=D_SPACE.thread_mem_info[idx];
- }
- if(p_mempool==NULL)
- {
- atomic_inc(&(D_SPACE.used_mem_pool_counter));
- idx = atomic_read(&(D_SPACE.used_mem_pool_counter));
- p_mempool=create_mem_pool(idx);
- p_mempool->tid=tid;
-#ifdef DICTATOR_DEBUG
- init_debugger(&(p_mempool->debugger),p_mempool);
-#endif
- D_SPACE.thread_mem_info[idx]=p_mempool;
- dummy_htable_add(&(D_SPACE.tid2idx), tid, idx);
- }
- return p_mempool;
-}
-thread_mem_pool_t* init_dictator(pthread_t tid)
-{
- unsigned int i=1;
- thread_mem_pool_t* p_mempool=NULL;
- is_first=1;
- D_SPACE.INIT_THREAD_BLOCK_NUM=0;
- assert(getpagesize()==PAGE_SIZE);
- D_SPACE.POWER[0]=1;
- for(i=1;i<MAX_CHAIN_NUM_SUPPORT;i++)
- {
- if((i+1)*DICTATOR_UNIT_SIZE<=LINEAR_1_BOUNDARY)
- {
- D_SPACE.POWER[i]=i+1;
- }
- else
- {
- D_SPACE.POWER[i]=D_SPACE.POWER[i-1]+LINEAR_2_FACTOR;
- }
- D_SPACE.INIT_THREAD_BLOCK_NUM+=D_SPACE.POWER[i];
- }
- D_SPACE.INIT_THREAD_BLOCK_NUM*=2;
-
- //biggest block num
- assert(D_SPACE.POWER[MAX_CHAIN_NUM_SUPPORT-1]<65535);
- memset((void*)D_SPACE.thread_mem_info,0,sizeof(D_SPACE.thread_mem_info));
- atomic_set(&(D_SPACE.used_mem_pool_counter),-1);
- for(i=0;i<MAX_TRHEAD_NUM_SUPPORT;i++)
- {
- D_SPACE.tseq2idx[i]=-1;
- }
- dummy_htable_init(&(D_SPACE.tid2idx));
- p_mempool=locate_mp_by_tid(tid);
-#ifdef DICTATOR_DEBUG
- pthread_t thread_desc;
- pthread_attr_t attr;
- memset(&thread_desc, 0, sizeof(thread_desc));
- memset(&attr, 0, sizeof(attr));
-
- if(0 != pthread_attr_init(&(attr))) {
- fprintf(stderr,"pthread_attr_init(): %d %s", errno, strerror(errno));
- return NULL;
- }
- if(0 != pthread_attr_setdetachstate(&(attr), PTHREAD_CREATE_DETACHED)) {
- fprintf(stderr,"pthread_attr_setdetachstate(): %d %s", errno, strerror(errno));
- return NULL;
- }
- if(0 != pthread_create(&(thread_desc), &(attr), (void *(*)(void *))(dictator_debug_thread), NULL)) {
- fprintf(stderr,"pthread_create(): %d %s", errno, strerror(errno));
- pthread_attr_destroy(&(attr));
- return NULL;
- }
- pthread_attr_destroy(&(attr));
- memset(boundary_marker,'d',D_MARKER_SIZE);
-#else
- ;//fprintf(stderr,"Using DICTATOR2 memory manager\n");
-#endif
- return p_mempool;
-}
-inline int select_chain(unsigned int block_num){
- assert(block_num<=D_SPACE.POWER[MAX_CHAIN_NUM_SUPPORT-1]);
- if(block_num*DICTATOR_UNIT_SIZE<=LINEAR_1_BOUNDARY)
- {
- return block_num-1;
- }
- else
- {
- if((block_num-LINEAR_1_BOUNDARY/DICTATOR_UNIT_SIZE)%LINEAR_2_FACTOR==0)
- return (block_num-LINEAR_1_BOUNDARY/DICTATOR_UNIT_SIZE)/LINEAR_2_FACTOR+LINEAR_1_BOUNDARY/DICTATOR_UNIT_SIZE-1;
- else
- return (block_num-LINEAR_1_BOUNDARY/DICTATOR_UNIT_SIZE)/LINEAR_2_FACTOR+LINEAR_1_BOUNDARY/DICTATOR_UNIT_SIZE;
- }
-
-}
-thread_mem_pool_t *create_mem_pool(unsigned short D_id)
-{
- unsigned int i=0,assigned_blk_num=0;
- mem_info_t *target_block=NULL;
- thread_mem_pool_t *p=(thread_mem_pool_t *)mmap_alloc(sizeof(thread_mem_pool_t));
- p->block_buffer_container.buffer=(char*)mmap_alloc(DICTATOR_UNIT_SIZE*D_SPACE.INIT_THREAD_BLOCK_NUM);
- if(NULL==p->block_buffer_container.buffer){
- fprintf(stderr,"malloc failed in dictator %s : %d\n",__FILE__,__LINE__);
- assert(0);
- }
- p->raw_mem_header[0]=p->block_buffer_container.buffer;
- p->rawmem_idx=1;
- p->block_buffer_container.available_size=DICTATOR_UNIT_SIZE*D_SPACE.INIT_THREAD_BLOCK_NUM;
- p->D_id=D_id;
- p->t_seq=-1;
- p->tid=0;
-
- //assigned a suitable block for each chain
- for(i=0;i<MAX_CHAIN_NUM_SUPPORT;i++)
- {
- //get a block
- assigned_blk_num=D_SPACE.POWER[i];
- target_block=(mem_info_t*)(p->block_buffer_container.buffer);
- fill_empty_block(target_block,assigned_blk_num ,D_id);
- p->block_buffer_container.buffer+=assigned_blk_num*DICTATOR_UNIT_SIZE;
- p->block_buffer_container.available_size-=assigned_blk_num*DICTATOR_UNIT_SIZE;
-
- //restore this block
- p->block_chain[i].head=target_block;
- p->block_chain[i].tail=p->block_chain[i].head;
- atomic_set(&(p->block_chain[i].ele_cnt),1);
- pthread_mutex_init(&(p->block_chain[i].mutex_tail_lock), NULL);
- }
- return p;
-
-}
-
-
-
-
-mem_info_t* get_chunk(unsigned short D_id,unsigned int blk_num){
- mem_info_t* block=NULL;
- size_t assigned_size=blk_num*DICTATOR_UNIT_SIZE;
- int is_dpdk_hugepage=0;
-#ifdef DPDK_HUGE_PAGE
- if(marsio_is_hugepage_available()==1)
- {
- block=(mem_info_t*)marsio_hugepage_malloc(assigned_size, D_SPACE.thread_mem_info[D_id]->t_seq);
- is_dpdk_hugepage=1;
- }
- else
- {
- block=(mem_info_t*)mmap(NULL,assigned_size,PROT_WRITE|PROT_READ,MAP_ANONYMOUS|MAP_PRIVATE,-1,0);
- }
-#else
- block=(mem_info_t*)mmap(NULL,assigned_size,PROT_WRITE|PROT_READ,MAP_ANONYMOUS|MAP_PRIVATE,-1,0);
-#endif
-
-
- if(-1==(long)block)
- {
- fprintf(stderr,"mmap/hugepage failed: %s ,at dictator %s : %d\n",strerror(errno),__FILE__,__LINE__);
- _exit(-1);
- }
- fill_empty_block(block,blk_num,D_id);
- block->type=is_dpdk_hugepage;
- if(block->type==0)
- {
- assert((unsigned long)block%PAGE_SIZE==0);
- }
- return block;
-}
-void* mmap_alloc(size_t size)
-{
- mem_info_t*p=NULL;
- unsigned int block_num=0;
- unsigned long assigned_size=0;
- block_num=calc_block_num(size+USED_MEM_HEAD_LEN);
- assigned_size=ELF_PAGEALIGN((unsigned long)block_num*(unsigned long)DICTATOR_UNIT_SIZE);
- block_num=assigned_size/DICTATOR_UNIT_SIZE;
- p=get_chunk(0, block_num);
- return D_MEM(p);
-}
-void mmap_free(void*p)
-{
- mem_info_t* block=D_HEADER(p);
- size_t len=block->blk_num*DICTATOR_UNIT_SIZE;
- int ret=0;
-#ifdef DPDK_HUGE_PAGE
- if(block->type==1)
- {
- marsio_hugepage_free(block);
- }
- else
- {
- ret=munmap(block,len);
- }
-#else
- ret=munmap(block,len);
-#endif
- if(ret!=0)
- {
- fprintf(stderr,"munmap failed: %s ,at dictator %s : %d\n",strerror(errno),__FILE__,__LINE__);
- }
- assert(ret==0);
- return;
-}
-void* block_alloc(size_t size,IMP_t *imp)
-{
- mem_info_t* p=NULL;
- thread_mem_pool_t *p_mempool=(thread_mem_pool_t *)imp;
- unsigned int block_num=calc_block_num(size+USED_MEM_HEAD_LEN);
- assert(!IS_CHUNK(block_num));
- p=get_block(p_mempool,block_num);
-#ifdef DICTATOR_DEBUG
- atomic_add(&(p_mempool->debugger.selfcost_mem),p->blk_num*DICTATOR_UNIT_SIZE);
- atomic_sub(&(p_mempool->debugger.cached_mem), p->blk_num*DICTATOR_UNIT_SIZE);
-#endif
- return D_MEM(p);
-}
-void block_free(void*p,IMP_t* imp)
-{
- mem_info_t *block=D_HEADER(p);
- thread_mem_pool_t *p_mempool=(thread_mem_pool_t *)imp;
-#ifdef DICTATOR_DEBUG
- atomic_sub(&(p_mempool->debugger.selfcost_mem),block->blk_num*DICTATOR_UNIT_SIZE);
- atomic_add(&(p_mempool->debugger.cached_mem), block->blk_num*DICTATOR_UNIT_SIZE);
-#endif
- restore_block(p_mempool, block);
- //restore_other_block(p_mempool, block);
-
- return;
-}
-
-// own block add to chain head
-inline void add_block_to_chain_head(thread_mem_pool_t* thread_info,int chain_idx,mem_info_t* block)
-{
- block->next=thread_info->block_chain[chain_idx].head;
- thread_info->block_chain[chain_idx].head=block;
- atomic_inc(&(thread_info->block_chain[chain_idx].ele_cnt));
-}
-inline void join_block_to_chain_tail(thread_mem_pool_t* thread_info,int chain_idx,mem_info_t* block)
-{
- thread_info->block_chain[chain_idx].tail->next=block;
- block->next=NULL;
- thread_info->block_chain[chain_idx].tail=block;
- atomic_inc(&(thread_info->block_chain[chain_idx].ele_cnt));
-}
-inline void restore_block(thread_mem_pool_t* thread_info,mem_info_t *block)
-{
- unsigned int chain_idx=0;
- chain_idx=select_chain(block->blk_num);
- assert(block->blk_num==D_SPACE.POWER[chain_idx]);
- add_block_to_chain_head(thread_info, chain_idx, block);
- return;
-}
-inline void restore_other_block(thread_mem_pool_t* thread_info,mem_info_t *block)
-{
- unsigned int chain_idx=0;
- chain_idx=select_chain(block->blk_num);
- assert(block->blk_num==D_SPACE.POWER[chain_idx]);
- pthread_mutex_lock(&(thread_info->block_chain[chain_idx].mutex_tail_lock));
- join_block_to_chain_tail(thread_info, chain_idx, block);
- pthread_mutex_unlock(&(thread_info->block_chain[chain_idx].mutex_tail_lock));
-
- return;
-}
-inline mem_info_t *get_block_from_chain(thread_mem_pool_t* thread_info,int chain_idx)
-{
- mem_info_t *target=NULL;
-#ifdef DICTATOR_DEBUG
- assert(thread_info->block_chain[chain_idx].head!=thread_info->block_chain[chain_idx].tail);
- assert(atomic_read(&(thread_info->block_chain[chain_idx].ele_cnt))>1);
-#endif
- target=thread_info->block_chain[chain_idx].head;
- thread_info->block_chain[chain_idx].head=target->next;
- atomic_dec(&(thread_info->block_chain[chain_idx].ele_cnt));
- return target;
-}
-inline mem_info_t *get_block(thread_mem_pool_t *thread_info,unsigned int block_num)
-{
-
- mem_info_t* target_block=NULL,*tmp;
- unsigned int assigned_chain=0;
- unsigned int assigned_size=0;
- assigned_chain=select_chain(block_num);
- assigned_size=D_SPACE.POWER[assigned_chain]*DICTATOR_UNIT_SIZE;
- int i=0;
- assert(assigned_size!=0);
- //block chain is available
- if(thread_info->block_chain[assigned_chain].head!=thread_info->block_chain[assigned_chain].tail&&
- atomic_read(&(thread_info->block_chain[assigned_chain].ele_cnt))>1)
- {
- target_block=get_block_from_chain(thread_info,assigned_chain);
- }
- else
- {
- //block buffer is not enough for this request
- if(thread_info->block_buffer_container.available_size<assigned_size)
- {
- //put left buffer into chain
- assert(thread_info->block_buffer_container.available_size%DICTATOR_UNIT_SIZE==0);
- if(thread_info->block_buffer_container.available_size>0)
- {
- for(i=0;thread_info->block_buffer_container.available_size>0;i++)
- {
- tmp=(mem_info_t *)(thread_info->block_buffer_container.buffer);
- thread_info->block_buffer_container.available_size-=DICTATOR_UNIT_SIZE;
- thread_info->block_buffer_container.buffer+=DICTATOR_UNIT_SIZE;
- fill_empty_block(tmp, 1, thread_info->D_id);
- restore_block(thread_info,tmp);
- }
- }
- //malloc a new buffer
- thread_info->block_buffer_container.buffer=(char *)mmap_alloc(D_SPACE.INIT_THREAD_BLOCK_NUM*DICTATOR_UNIT_SIZE);
- if(NULL==thread_info->block_buffer_container.buffer)
- {
- fprintf(stderr,"malloc failed in dictator %s : %d\n",__FILE__,__LINE__);
- return NULL;
- }
- thread_info->block_buffer_container.available_size=D_SPACE.INIT_THREAD_BLOCK_NUM*DICTATOR_UNIT_SIZE;
- thread_info->raw_mem_header[thread_info->rawmem_idx]=thread_info->block_buffer_container.buffer;
- thread_info->rawmem_idx++;
-#ifdef DICTATOR_DEBUG
- atomic_add(&(thread_info->debugger.cached_mem),D_SPACE.INIT_THREAD_BLOCK_NUM*DICTATOR_UNIT_SIZE);
-#endif
- }
- //cut a block from buffer
- target_block=(mem_info_t*)(thread_info->block_buffer_container.buffer);
- fill_empty_block(target_block, D_SPACE.POWER[assigned_chain],thread_info->D_id);
- thread_info->block_buffer_container.buffer+=assigned_size;
- thread_info->block_buffer_container.available_size-=assigned_size;
- }
- return target_block;
-
-
-}
-
-void *core_alloc(thread_mem_pool_t *p_mempool,size_t size)
-{
- unsigned int block_num=0;
- unsigned long assigned_size=0;
- mem_info_t *target_mem=NULL;
- if(0==size)
- {
- return NULL;
- }
- block_num=calc_block_num(size+USED_MEM_HEAD_LEN);
- if(block_num>D_SPACE.POWER[MAX_CHAIN_NUM_SUPPORT-1])
- {
- assigned_size=ELF_PAGEALIGN((unsigned long)block_num*(unsigned long)DICTATOR_UNIT_SIZE);
- block_num=assigned_size/DICTATOR_UNIT_SIZE;
- //malloc with mmap
- target_mem=get_chunk(p_mempool->D_id, block_num);
- }
- else
- {
- target_mem=get_block(p_mempool,block_num);
- }
-#ifdef DICTATOR_DEBUG
- backtrace_info_t *caller_bt;
- struct dbg_index_t* dbg_idx=NULL;
- assigned_size=target_mem->blk_num*DICTATOR_UNIT_SIZE;
- dbg_idx=get_dbg_index(&(p_mempool->debugger));
- target_mem->idx=dbg_idx;
- dbg_idx->mem_info=(void*)target_mem;
-
-
- //use by thread self and debug thread's threadsafe callback, no need to protect with mutex;
- caller_bt=backtrace_ref_inc(&((p_mempool->debugger.malloc_backtrace_hash)),size,p_mempool);
-
-
- target_mem->idx->p_backtrace=caller_bt;
- target_mem->idx->used_size=size;
- target_mem->idx->assigned_size=assigned_size;
-
- pthread_mutex_lock(&(p_mempool->debugger.mutex_malloced_in_reach_list));
- D_kernel_list_add_tail(&(p_mempool->debugger.malloced_in_reach_list),&(target_mem->idx->malloced_in_reach_hook));
- pthread_mutex_unlock(&(p_mempool->debugger.mutex_malloced_in_reach_list));
-
- int boundary_len=assigned_size-size-USED_MEM_HEAD_LEN;
- memset(D_MEM(target_mem)+target_mem->idx->used_size,'d',boundary_len);
- atomic_add(&(p_mempool->debugger.app_mem),size);
- atomic_add(&(p_mempool->debugger.assigned_mem),assigned_size);
- atomic_inc(&(p_mempool->debugger.inuse_num));
- atomic_inc(&(p_mempool->debugger.malloc_cnt));
- if(IS_CHUNK(target_mem->blk_num))
- {
- //no need do free_backtrace_hash ,index for double free check;
- }
- else
- {
- atomic_sub(&(p_mempool->debugger.cached_mem), target_mem->blk_num*DICTATOR_UNIT_SIZE);
- }
-#endif
- return D_MEM(target_mem);
-}
-void core_free(unsigned short caller_Did,void *p)
-{
- mem_info_t *block=D_HEADER(p);
- thread_mem_pool_t* p_mempool=D_SPACE.thread_mem_info[block->D_id];
-#ifdef DICTATOR_DEBUG
- thread_mem_pool_t* caller_mp=D_SPACE.thread_mem_info[caller_Did];
- backtrace_info_t *caller_bt;
- assert(block->magic==DICTATOR_MAGIC);
- const char* user_boundary=(char*)block+block->idx->used_size+USED_MEM_HEAD_LEN;
- int boundary_len=0;
- unsigned int assigned_size=block->blk_num*DICTATOR_UNIT_SIZE;
- assert(block->idx->assigned_size==assigned_size);
- if(!IS_CHUNK(block->blk_num))//not a chunk
- {
- atomic_add(&(p_mempool->debugger.cached_mem),assigned_size);
- }
- pthread_mutex_lock(&(p_mempool->debugger.mutex_malloced_in_reach_list));
- D_kernel_list_delete(&(p_mempool->debugger.malloced_in_reach_list),&(block->idx->malloced_in_reach_hook));
- pthread_mutex_unlock(&(p_mempool->debugger.mutex_malloced_in_reach_list));
-
- atomic_sub(&(p_mempool->debugger.app_mem),block->idx->used_size);
- atomic_sub(&(p_mempool->debugger.assigned_mem),assigned_size);
- atomic_dec(&(block->idx->p_backtrace->ref_cnt));
- atomic_sub(&(block->idx->p_backtrace->ref_bytes),block->idx->used_size);
- atomic_dec(&(p_mempool->debugger.inuse_num));
- atomic_inc(&(p_mempool->debugger.free_cnt));
- caller_bt=backtrace_ref_inc(&(caller_mp->debugger.free_backtrace_hash),assigned_size,caller_mp);
- block->idx->p_backtrace=caller_bt;
-
- boundary_len=MIN(assigned_size-block->idx->used_size-USED_MEM_HEAD_LEN,D_MARKER_SIZE);
- assert(0==memcmp(user_boundary,boundary_marker,boundary_len));
- restore_dbg_index(&(p_mempool->debugger), block->idx);
- block->idx=NULL;
-#endif
- if(IS_CHUNK(block->blk_num))
- {
- //a chunk
- mmap_free(D_MEM(block));
- }
- else
- {
- if(block->D_id==caller_Did)
- {
- restore_block(p_mempool, block);
-
- }
- else
- {
- restore_other_block(p_mempool, block);
- }
- }
-
-}
-void *core_realloc(unsigned short caller_Did,void *ptr, size_t size)
-{
- mem_info_t *block=D_HEADER(ptr);
- mem_info_t *new_block=NULL;
- void* new_mem=NULL;
- size_t old_size=0;
-#ifdef DICTATOR_DEBUG
- size_t new_size=0;
- thread_mem_pool_t* orginal_mempool=D_SPACE.thread_mem_info[block->D_id];
- struct dbg_index_t* tmp_idx=NULL;
- assert(block->magic==DICTATOR_MAGIC);
-#endif
- old_size=(block->blk_num*DICTATOR_UNIT_SIZE)-USED_MEM_HEAD_LEN;
-
- if(IS_CHUNK(block->blk_num))
- {
-#ifdef DICTATOR_DEBUG
- size_t orginal_size=0;
- orginal_size=block->blk_num*DICTATOR_UNIT_SIZE;
- atomic_sub(&(block->idx->p_backtrace->ref_bytes),block->idx->used_size);
- pthread_mutex_lock(&(orginal_mempool->debugger.mutex_malloced_in_reach_list));
- D_kernel_list_delete(&(orginal_mempool->debugger.malloced_in_reach_list),&(block->idx->malloced_in_reach_hook));
- pthread_mutex_unlock(&(orginal_mempool->debugger.mutex_malloced_in_reach_list));
- atomic_sub(&(orginal_mempool->debugger.app_mem),block->idx->used_size);
- atomic_sub(&(orginal_mempool->debugger.assigned_mem),orginal_size);
- tmp_idx=block->idx;
-#endif
- if(old_size>=size)
- {
- new_block=block;
- }
- else
- {
- new_block=D_HEADER(mmap_alloc(size));
- memcpy(D_MEM(new_block),D_MEM(block),old_size);
- mmap_free(D_MEM(block));
- }
- new_mem=D_MEM(new_block);
-#ifdef DICTATOR_DEBUG
- new_size=new_block->blk_num*DICTATOR_UNIT_SIZE;
- new_block->idx=tmp_idx;
- new_block->idx->used_size=size;
- new_block->idx->assigned_size=new_size;
- new_block->idx->mem_info=new_block;
- atomic_add(&(new_block->idx->p_backtrace->ref_bytes),size);
- if(atomic_read(&(new_block->idx->p_backtrace->maxsize))<(signed long)size)
- {
- atomic_set(&(new_block->idx->p_backtrace->maxsize),(signed long)size);
- }
- pthread_mutex_lock(&(orginal_mempool->debugger.mutex_malloced_in_reach_list));
- D_kernel_list_add_tail(&(orginal_mempool->debugger.malloced_in_reach_list),&(new_block->idx->malloced_in_reach_hook));
- pthread_mutex_unlock(&(orginal_mempool->debugger.mutex_malloced_in_reach_list));
-
- memset((char*)new_mem+size,'d',new_size-size-USED_MEM_HEAD_LEN);
- atomic_add(&(orginal_mempool->debugger.app_mem),size);
- atomic_add(&(orginal_mempool->debugger.assigned_mem),new_size);
-#endif
- block=NULL;
- }
- else
- {
- if(old_size>=size)
- {
- new_mem=ptr;
-#ifdef DICTATOR_DEBUG
- atomic_sub(&(orginal_mempool->debugger.app_mem),block->idx->used_size-size);
- atomic_sub(&(block->idx->p_backtrace->ref_bytes),block->idx->used_size-size);
- block->idx->used_size=size;
-#endif
- }
- else
- {
- new_mem=core_alloc(D_SPACE.thread_mem_info[caller_Did],size);
- new_block=D_HEADER(new_mem);
- memcpy((char*)new_mem,
- (char*)ptr,
- old_size);
- core_free(caller_Did,ptr);
- }
- }
- return new_mem;
-}
-
-void *__wrap_malloc(size_t size)
-{
- thread_mem_pool_t* p_mempool=NULL;
- pthread_t tid=pthread_self();
- if(is_first==0)
- {
- p_mempool=init_dictator(tid);
- }
- else
- {
- p_mempool=locate_mp_by_tid(tid);
- }
- return core_alloc(p_mempool,size);
-
-}
-
-//If ptr is NULL, no operation is performed.
-void __wrap_free(void *p)
-{
- thread_mem_pool_t* p_mempool=NULL;
- if(p==NULL)
- return;
- pthread_t tid=pthread_self();
- p_mempool=locate_mp_by_tid(tid);
- core_free(p_mempool->D_id,p);
- return;
-}
-
-#if 0// close by lijia
-void* operator new(size_t size)
-{
- if(size==0)
- {
- size=1;
- }
- return __wrap_malloc(size);
-}
-void* operator new(size_t size,const std::nothrow_t &nothrow_const)
-{
- if(size==0)
- {
- size=1;
- }
- return __wrap_malloc(size);
-}
-void operator delete(void*p)
-{
- __wrap_free(p);
-}
-#endif
-
-//The contents will be unchanged to the minimum of the old and new sizes;
-//If ptr is NULL, the call is equivalent to malloc(size); if size is equal to zero, the call is equivalent to free(ptr).
-//Unless ptr is NULL, it must have been returned by an earlier call to malloc(), calloc() or realloc().
-void *__wrap_realloc(void *ptr, size_t size)
-{
- pthread_t tid=pthread_self();
- thread_mem_pool_t* p_mempool=NULL;
- if(is_first==0)
- {
- p_mempool=init_dictator(tid);
- }
- else
- {
- p_mempool=locate_mp_by_tid(tid);
- }
- if(size==0&&ptr!=NULL)
- {
- core_free(p_mempool->D_id,ptr);
- return NULL;
- }
- if(ptr==NULL)
- {
- return core_alloc(p_mempool,size);
- }
- return core_realloc(p_mempool->D_id,ptr,size);
-}
-/* Maybe conflict with DPDK
-void *malloc(size_t size)
-{
- return __wrap_malloc(size);
-}
-void *realloc(void *ptr, size_t size)
-{
- return __wrap_realloc(ptr, size);
-}
-void *calloc(size_t nmemb, size_t size)
-{
- return __wrap_calloc(nmemb, size);
-}
-void free(void *p)
-{
- return __wrap_free(p);
-}*/
-void *__wrap_calloc(size_t nmemb, size_t size)
-{
- thread_mem_pool_t* p_mempool=NULL;
- void* p=NULL;
- pthread_t tid=pthread_self();
- if(is_first==0)
- {
- p_mempool=init_dictator(tid);
- }
- else
- {
- p_mempool=locate_mp_by_tid(tid);
- }
- p=core_alloc(p_mempool,nmemb*size);
- if(p!=NULL)
- {
- memset(p,0,nmemb*size);
- }
- return p;
-}
-void *__dictator_malloc(int t_seq,size_t size)
-{
- thread_mem_pool_t* p_mempool=NULL;
- pthread_t tid=0;
- if(is_first==0)
- {
- tid=pthread_self();
- p_mempool=init_dictator(tid);
- }
- else
- {
- p_mempool=locate_mp_by_tseq(t_seq);
- }
- return core_alloc(p_mempool,size);
-}
-void __dictator_free(int t_seq,void*p)
-{
- unsigned short this_D_id=0;
- if(p==NULL)
- {
- return;
- }
- thread_mem_pool_t* p_mempool=NULL;
- p_mempool=locate_mp_by_tseq(t_seq);
- this_D_id=p_mempool->D_id;
- core_free(this_D_id,p);
- return;
-}
-void *__dictator_realloc(int t_seq,void*ptr,size_t size)
-{
- thread_mem_pool_t* p_mempool=NULL;
- pthread_t tid=0;
- if(is_first==0)
- {
- tid=pthread_self();
- p_mempool=init_dictator(tid);
- }
- else
- {
- p_mempool=locate_mp_by_tseq(t_seq);
- }
- if(size==0&&ptr!=NULL){
- core_free(p_mempool->D_id,ptr);
- return NULL;
- }
- if(ptr==NULL)
- {
- return core_alloc(p_mempool,size);
- }
- return core_realloc(p_mempool->D_id,ptr,size);
-}
-void *__dictator_calloc(int t_seq,size_t nmemb, size_t size)
-{
- thread_mem_pool_t* p_mempool=NULL;
- pthread_t tid=0;
- if(is_first==0)
- {
- tid=pthread_self();
- p_mempool=init_dictator(tid);
- }
- else
- {
- p_mempool=locate_mp_by_tseq(t_seq);
- }
- return core_alloc(p_mempool,nmemb*size);
-}
-
diff --git a/src/support/dictator2/src/dictator.h b/src/support/dictator2/src/dictator.h
deleted file mode 100644
index 5a95132..0000000
--- a/src/support/dictator2/src/dictator.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* DICATATOR Memory Manager
-* Version 20141115
-*/
-#ifndef _DICTATOR2_H_
-#define _DICTATOR2_H_
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-void *__wrap_malloc(size_t size);
-void __wrap_free(void *p);
-void *__wrap_realloc(void *ptr, size_t size);
-void *__wrap_calloc(size_t nmemb, size_t size);
-
-void *__dictator_malloc(int t_seq,size_t size);
-void __dictator_free(int t_seq,void*p);
-void *__dictator_realloc(int t_seq,void *ptr, size_t size);
-void *__dictator_calloc(int t_seq,size_t nmemb, size_t size);
-
-void *malloc(size_t size);
-void *calloc(size_t nmemb, size_t size);
-void free(void *p);
-
-#ifdef __cplusplus
-}
-#endif// end extern "C"
-
-#endif
diff --git a/src/support/dictator2/src/dictator_core.h b/src/support/dictator2/src/dictator_core.h
deleted file mode 100644
index be11cdc..0000000
--- a/src/support/dictator2/src/dictator_core.h
+++ /dev/null
@@ -1,191 +0,0 @@
-#ifndef _DICTATOR2_CORE_H_
-#define _DICTATOR2_CORE_H_
-
-#include <pthread.h>
-#include "internal_mp.h"
-#include "dummy_hash.h"
-
-#define DICTATOR2_VERSION "v1.3"
-#if(__GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCHLEVEL__ >= 410)
-#define atomic_inc(x) __sync_add_and_fetch((x),1)
-#define atomic_dec(x) __sync_sub_and_fetch((x),1)
-#define atomic_add(x,y) __sync_add_and_fetch((x),(y))
-#define atomic_sub(x,y) __sync_sub_and_fetch((x),(y))
-typedef long atomic_t;
-#define ATOMIC_INIT(i) { (i) }
-#define atomic_read(x) __sync_add_and_fetch((x),0)
-#define atomic_set(x,y) __sync_lock_test_and_set((x),y)
-#else
-typedef long atomic_t;
-#define atomic_inc(x) ((*(x))++)
-#define atomic_dec(x) ((*(x))--)
-#define atomic_add(x,y) ((*(x))+=(y))
-#define atomic_sub(x,y) ((*(x))-=(y))
-#define ATOMIC_INIT(i) { (i) }
-#define atomic_read(x) (*(x))
-#define atomic_set(x,y) ((*(x))=(y))
-#endif
-#include "D_internal/D_kernel_list.h"
-#include "D_internal/MESA_hash_v2.h"
-
-const unsigned int MAX_CHAIN_NUM_SUPPORT=128*3;
-const unsigned int MAX_TRHEAD_NUM_SUPPORT=1024;
-const unsigned int MAX_THREAD_RAWMEM_CNT=1024*4;
-const unsigned int DICTATOR_UNIT_SIZE=32;
-const unsigned int BATCH_DBG_IDX_NUM=MAX_CHAIN_NUM_SUPPORT*256;
-
-
-#ifndef MAX
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef MIN
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
-
-const unsigned int DICTATOR_MAGIC=0x5210;
-#define MAX_BACKTRACE_DEPTH 32
-#define MALLOC_SELF_DEPTH 3
-#define FREE_SEFL_DEPTH 3
-
-#define D_MARKER_SIZE 1024
-enum CHUNK_STATE
-{
- CHUNK_STATE_MALLOC=0,
- CHUNK_STATE_FREE,
- CHUNK_STATE_VIGRIN,
- CHUNK_STATE_REALLOC
-};
-struct backtrace_info_t
-{
- atomic_t ref_cnt;
- atomic_t ref_bytes;
- atomic_t maxsize;
- void** bt_array;
- size_t array_size;
- IMP_t* p_mempool;
-};
-struct dbg_index_t
-{
- unsigned int used_size;
- unsigned int assigned_size;
- struct D_kernel_list_head malloced_in_reach_hook;
- struct backtrace_info_t* p_backtrace;
- void* mem_info;
-};
-typedef struct mem_info{
-
-#ifdef DICTATOR_DEBUG
- unsigned short magic;
- unsigned short D_id;
- unsigned int blk_num:31;
- unsigned short type:1; // 0:mmap, 1:DPDK_HUGEPAGE
- struct dbg_index_t* idx;
-#else
- unsigned int blk_num;
- unsigned short D_id;
- unsigned short type; // 0:mmap, 1:DPDK_HUGEPAGE
-#endif
-
- struct mem_info *next;//used only if free
-} mem_info_t;
-//__attribute__((packed))
-typedef struct buffer_container{
- size_t available_size;
- char *buffer;
-}buffer_container_t;
-
-typedef struct mem_queue{
- mem_info_t * head;
- mem_info_t * tail;
- atomic_t ele_cnt;
- pthread_mutex_t mutex_tail_lock;
-}mem_queue_t;
-
-typedef struct _thread_mem_debugger
-{
- atomic_t cached_mem;//dictator managed mem,less than total mem
- atomic_t app_mem; //application applied mem size,inlucding not managed mem,less than total_mem
- atomic_t assigned_mem;//dictator assigned to application
- atomic_t inuse_num;
- atomic_t malloc_cnt;
- atomic_t free_cnt;
- atomic_t selfcost_mem;//used by dictator itself
- MESA_hash_tab_v2_t malloc_backtrace_hash;
- MESA_hash_tab_v2_t free_backtrace_hash;
- pthread_mutex_t mutex_malloced_in_reach_list;
- struct D_kernel_list_head malloced_in_reach_list;
-
- atomic_t pool_unit_cnt;
- struct D_kernel_list_head index_pool;
- pthread_mutex_t mutex_pool_tail;
- unsigned int rawmem_idx;
- void* raw_mem_header[MAX_THREAD_RAWMEM_CNT];
-}thread_mem_debugger_t;
-
-typedef struct thread_mem_pool{
- unsigned short D_id;
- pthread_t tid;
- int t_seq;
- int rawmem_idx;
- mem_queue_t block_chain[MAX_CHAIN_NUM_SUPPORT];
- buffer_container_t block_buffer_container;
- void* raw_mem_header[MAX_THREAD_RAWMEM_CNT];
-#ifdef DICTATOR_DEBUG
- thread_mem_debugger_t debugger;
-#endif
-}thread_mem_pool_t;
-
-struct dictator_space_t
-{
- unsigned int POWER[MAX_CHAIN_NUM_SUPPORT];
- unsigned int INIT_THREAD_BLOCK_NUM;
-
- struct dummy_htable_t tid2idx;
- int tseq2idx[MAX_TRHEAD_NUM_SUPPORT];
-
- thread_mem_pool_t *thread_mem_info[MAX_TRHEAD_NUM_SUPPORT];
- atomic_t used_mem_pool_counter;
- int page_size;
-};
-
-inline mem_info_t *get_block(thread_mem_pool_t *thread_info,unsigned int block_num);
-inline void restore_block(thread_mem_pool_t* thread_info,mem_info_t *block);
-
-unsigned int calc_block_num(size_t alloc_size);
-inline mem_info_t* fill_empty_block(mem_info_t* block,unsigned int blk_num,unsigned short D_id);
-
-thread_mem_pool_t *create_mem_pool(unsigned short D_id);
-backtrace_info_t* create_bt_info(void** bt_array,int size);
-backtrace_info_t* backtrace_ref_inc(MESA_hash_tab_v2_t* hash,size_t inc_size,thread_mem_pool_t *p_mempool);
-struct dbg_index_t* get_dbg_index(thread_mem_debugger_t* debugger);
-void restore_dbg_index(thread_mem_debugger_t* debugger,struct dbg_index_t*idx);
-thread_mem_pool_t *create_mem_pool(unsigned short D_id);
-void init_debugger(thread_mem_debugger_t* debugger,thread_mem_pool_t* p_mp);
-
-void * dictator_debug_thread(void* param);
-void D_check_mem(int sd,int is_scheduled);
-#define USED_MEM_HEAD_LEN (sizeof(mem_info_t)-sizeof(struct mem_info *))
-#define D_HEADER(ptr) ((mem_info_t *)((char*)(ptr)-USED_MEM_HEAD_LEN))
-#define D_MEM(ptr) ((char*)(ptr)+USED_MEM_HEAD_LEN)
-#define IS_CHUNK(x) ((x)>(D_SPACE.POWER[MAX_CHAIN_NUM_SUPPORT-1]))
-
-inline unsigned int calc_block_num(size_t alloc_size){
- unsigned int block_num=0;
- if(alloc_size%DICTATOR_UNIT_SIZE==0)
- {
- block_num = alloc_size/DICTATOR_UNIT_SIZE;
-#ifdef DICTATOR_DEBUG
- block_num++;
-#endif
- }
- else
- {
- block_num = (alloc_size/DICTATOR_UNIT_SIZE)+1;
- }
- return block_num;
-}
-
-
-#endif
-
diff --git a/src/support/dictator2/src/dictator_debuger.cpp b/src/support/dictator2/src/dictator_debuger.cpp
deleted file mode 100644
index db8b621..0000000
--- a/src/support/dictator2/src/dictator_debuger.cpp
+++ /dev/null
@@ -1,816 +0,0 @@
-#include <stdio.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-#include <assert.h>
-#include <string.h>//using memset
-#include <time.h>
-#include <errno.h>
-#include <stdio.h>
-//#include <execinfo.h>//backtrace
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <sys/un.h>
-//#include <libunwind.h>
-
-#include "dictator.h"
-#include "dictator_core.h"
-#ifdef DICTATOR_DEBUG
-extern struct dictator_space_t D_SPACE;
-thread_mem_pool_t* DEBUGGER_MP=NULL;
-extern char boundary_marker[D_MARKER_SIZE];
-
-#define D_CMD_HELP 0
-#define D_CMD_STAT 1
-#define D_CMD_LIST_MALLOC 2
-#define D_CMD_CHECK 3
-#define D_CMD_LIST_LARGE_M 4
-const char* support_cmd_full[]={"help","stat memory","list malloc","check memory","list large","\0"};
-const char support_cmd_short[]={'h','s','l','c','m','\0'};
-const char* cmd_introduce[]={"Print this text",
- "Statistic memory usage",
- "List 'max_num' and 'minmum_bytes' malloc backtrace,list all as default",
- "Check 'times' and 'interval us' to find if any memroy corrupt,check 1 time and 100*1000 us as default",
- "List 'max_num' and 'minmum_bytes' of SINGLE malloc backtrace which size is larger than 'minmum_bytes',list 65535(64KB) as default",
- "\0"};
-
-backtrace_info_t* create_bt_info(void** bt_array,int size,thread_mem_pool_t *p_mempool)
-{
- backtrace_info_t*caller_bt=NULL;
- unsigned int memsize=sizeof(backtrace_info_t)+sizeof(void**)*size;
- caller_bt=(backtrace_info_t*)block_alloc(memsize,(IMP_t*)p_mempool);
- atomic_set(&(caller_bt->ref_cnt),0);
- atomic_set(&(caller_bt->ref_bytes),0);
- atomic_set(&(caller_bt->maxsize),0);
- caller_bt->bt_array=(void**)((char*)caller_bt+sizeof(backtrace_info_t));
- memcpy(caller_bt->bt_array,bt_array,sizeof(void**)*size);
- caller_bt->array_size=size;
- caller_bt->p_mempool=(IMP_t*)p_mempool;
- return caller_bt;
-}
-void destroy_bt_info(void* bt_info)
-{
- backtrace_info_t*caller_bt=(backtrace_info_t*)bt_info;
- block_free(caller_bt,caller_bt->p_mempool);
- return;
-}
-void init_debugger(thread_mem_debugger_t* debugger,thread_mem_pool_t* p_mp)
-{
- unsigned int i=0;
- int ret=0;
- struct dbg_index_t* idx_pool_buff=NULL;
-
- D_kernel_list_init(&(debugger->malloced_in_reach_list));
- pthread_mutex_init(&(debugger->mutex_malloced_in_reach_list),NULL);
- pthread_mutex_init(&(debugger->mutex_pool_tail),NULL);
- atomic_set(&(debugger->app_mem),0);
- atomic_set(&(debugger->assigned_mem),0);
- atomic_set(&(debugger->inuse_num),0);
- atomic_set(&(debugger->malloc_cnt),0);
- atomic_set(&(debugger->free_cnt),0);
- atomic_set(&(debugger->selfcost_mem),sizeof(thread_mem_pool_t));
- debugger->cached_mem=DICTATOR_UNIT_SIZE*D_SPACE.INIT_THREAD_BLOCK_NUM;
-
-
- idx_pool_buff=(struct dbg_index_t*)mmap_alloc(D_SPACE.INIT_THREAD_BLOCK_NUM*sizeof(struct dbg_index_t));
- atomic_add(&(debugger->selfcost_mem),D_SPACE.INIT_THREAD_BLOCK_NUM*sizeof(struct dbg_index_t));
-
- debugger->raw_mem_header[0]=idx_pool_buff;
- debugger->rawmem_idx=1;
- D_kernel_list_init(&(debugger->index_pool));
- for(i=0;i<D_SPACE.INIT_THREAD_BLOCK_NUM;i++)
- {
- D_kernel_list_add_tail(&(debugger->index_pool), &(idx_pool_buff[i].malloced_in_reach_hook));
- }
- atomic_set(&(debugger->pool_unit_cnt),D_SPACE.INIT_THREAD_BLOCK_NUM);
- ret=D_INTERNAL_MESA_hash_create_v2(&(debugger->malloc_backtrace_hash),
- 1,//thread safe
- 1024*32,
- 0,//unlimited max element num
- NULL,
- NULL,
- destroy_bt_info,
- NULL,
- 0,
- 0,//never expire
- (IMP_t*)p_mp);
- assert(ret==0);
- ret=D_INTERNAL_MESA_hash_create_v2(&(debugger->free_backtrace_hash),
- 1,//thread safe
- 1024*32,
- 0,//unlimited max element num
- NULL,
- NULL,
- destroy_bt_info,
- NULL,
- 0,
- 0,//never expire
- (IMP_t*)p_mp);
- assert(ret==0);
- return;
-}
-void destroy_thread_mem_debugger(thread_mem_debugger_t* debugger)
-{
- unsigned int i=0;
- D_INTERNAL_MESA_hash_destroy_v2(&(debugger->malloc_backtrace_hash),NULL);
- D_INTERNAL_MESA_hash_destroy_v2(&(debugger->free_backtrace_hash),NULL);
- for(i=0;i<debugger->rawmem_idx;i++)
- {
- mmap_free(debugger->raw_mem_header[i]);
- debugger->raw_mem_header[i]=NULL;
- }
- pthread_mutex_destroy(&(debugger->mutex_malloced_in_reach_list));
- pthread_mutex_destroy(&(debugger->mutex_pool_tail));
- return;
-}
-struct dbg_index_t* get_dbg_index(thread_mem_debugger_t* debugger)
-{
- struct dbg_index_t* p;
- struct D_kernel_list_head* elem=NULL;
- struct dbg_index_t* idx_pool_buff=NULL;
- unsigned int i=0;
- if(atomic_read(&(debugger->pool_unit_cnt))<2)
- {
- idx_pool_buff=(struct dbg_index_t*)mmap_alloc(BATCH_DBG_IDX_NUM*sizeof(struct dbg_index_t));
- atomic_add(&(debugger->selfcost_mem),BATCH_DBG_IDX_NUM*sizeof(struct dbg_index_t));
- assert(debugger->rawmem_idx<MAX_THREAD_RAWMEM_CNT);
- debugger->raw_mem_header[debugger->rawmem_idx]=idx_pool_buff;
- debugger->rawmem_idx++;
- for(i=0;i<BATCH_DBG_IDX_NUM;i++)
- {
- D_kernel_list_add_head(&(debugger->index_pool), &(idx_pool_buff[i].malloced_in_reach_hook));
- }
- atomic_add(&(debugger->pool_unit_cnt),BATCH_DBG_IDX_NUM);
- }
- elem=D_kernel_list_get_head(&(debugger->index_pool));
- p=container_of(elem,struct dbg_index_t,malloced_in_reach_hook);
- atomic_dec(&(debugger->pool_unit_cnt));
- p->used_size=0;
- p->p_backtrace=NULL;
- p->mem_info=0;
- return p;
-}
-void restore_dbg_index(thread_mem_debugger_t* debugger,struct dbg_index_t*idx)
-{
- pthread_mutex_lock(&(debugger->mutex_pool_tail));
- D_kernel_list_add_tail(&(debugger->index_pool),&(idx->malloced_in_reach_hook));
- atomic_inc(&(debugger->pool_unit_cnt));
- pthread_mutex_unlock(&(debugger->mutex_pool_tail));
- return;
-}
-struct sort_data_t
-{
- long val;
- void* data;
-};
-static int sort_data_pos=0;
-
-void quick_sort(struct sort_data_t *a,int i,int j)
-{
-
- int m,n;
- struct sort_data_t temp;
- int k;
- m=i;
- n=j;
- k=a[(i+j)/2].val; /*ѡȡ�IJ���*/
- do {
- while(a[m].val<k&&m<j)
- m++; /* �������ұ�k���Ԫ��*/
- while(a[n].val>k&&n>i)
- n--; /* ���ҵ����ұ�kС��Ԫ��*/
- if(m<=n)
- { /*���ҵ��������������򽻻�*/
- temp=a[m];
- a[m]=a[n];
- a[n]=temp;
- m++;
- n--;
- }
-
- }while(m<=n);
-
- if(m<j)
- quick_sort(a,m,j); /*���õݹ�*/
- if(n>i)
- quick_sort(a,i,n);
-
-}
-void show_help(int sd)
-{
- int i=0;
- char buff[4096]={0};
- unsigned int printed=0;
- printed+=snprintf(buff,sizeof(buff)-printed,"Command Usage:\n");
- while(strlen(support_cmd_full[i])>1&&printed<sizeof(buff))
- {
- printed+=snprintf(buff+printed,sizeof(buff)-printed,"\t%s(or '%c'):\t\t\t%s\n",support_cmd_full[i],
- support_cmd_short[i],
- cmd_introduce[i]);
- i++;
- }
- write(sd,buff,printed);
-}
-void stat_memory(int sd)
-{
- int i=0;
- char buff[4096]={0};
- unsigned int printed=0;
- unsigned long long app_mem=0,assigned_mem=0,cached_mem=0;
- unsigned long long inuse_num=0,malloc_cnt=0,free_cnt=0;
- unsigned long long num_malloced_places=0,num_freed_places=0;
- unsigned long long selfcost_mem=0;
- for(i=0;i<=atomic_read(&(D_SPACE.used_mem_pool_counter));i++)
- {
- if(D_SPACE.thread_mem_info[i]==NULL)
- {
- continue;
- }
- app_mem+=atomic_read(&(D_SPACE.thread_mem_info[i]->debugger.app_mem));
- cached_mem+=atomic_read(&(D_SPACE.thread_mem_info[i]->debugger.cached_mem));
- assigned_mem+=atomic_read(&(D_SPACE.thread_mem_info[i]->debugger.assigned_mem));
- num_malloced_places+=D_SPACE.thread_mem_info[i]->debugger.malloc_backtrace_hash.elem_count;
- num_freed_places+=D_SPACE.thread_mem_info[i]->debugger.free_backtrace_hash.elem_count;
- inuse_num+=atomic_read(&(D_SPACE.thread_mem_info[i]->debugger.inuse_num));
- malloc_cnt+=atomic_read(&(D_SPACE.thread_mem_info[i]->debugger.malloc_cnt));
- free_cnt+=atomic_read(&(D_SPACE.thread_mem_info[i]->debugger.free_cnt));
- selfcost_mem+=atomic_read(&(D_SPACE.thread_mem_info[i]->debugger.selfcost_mem));
- }
- printed+=snprintf(buff+printed,sizeof(buff)-printed,"pool num:%d inuse %llu block\n",i,inuse_num);
- printed+=snprintf(buff+printed,sizeof(buff)-printed,"malloced %llu times in %llu context(s)\n",malloc_cnt,num_malloced_places);
- printed+=snprintf(buff+printed,sizeof(buff)-printed,"freed %llu times in %llu context(s)\n",free_cnt,num_freed_places);
- printed+=snprintf(buff+printed,sizeof(buff)-printed,"app used:%llu bytes/%lluMB\n",app_mem,app_mem/(1024*1024));
- printed+=snprintf(buff+printed,sizeof(buff)-printed,"assigned:%llu bytes/%lluMB\n",assigned_mem,assigned_mem/(1024*1024));
- printed+=snprintf(buff+printed,sizeof(buff)-printed,"cached :%llu bytes/%lluMB\n",cached_mem,cached_mem/(1024*1024));
- printed+=snprintf(buff+printed,sizeof(buff)-printed,"selfcost:%llu bytes/%lluMB\n",selfcost_mem,selfcost_mem/(1024*1024));
- write(sd,buff,printed);
-}
-
-/*
-int unw_backtrace(void **bt_array,int number)
-{
- unw_cursor_t cursor;
- unw_context_t uc;
- unw_word_t ip;
-
- unw_getcontext(&uc);
- unw_init_local(&cursor, &uc);
- int ret_cnt=0;
- while (unw_step(&cursor) > 0) {
- unw_get_reg(&cursor, UNW_REG_IP, &ip);
- if(ret_cnt<number)
- {
- bt_array[ret_cnt]=(void*)ip;
- ret_cnt++;
- }
- else
- {
- break;
- }
- }
- if(ret_cnt>0)//make exception for unw_backtrace
- {
- return ret_cnt-1;
- }
- else
- {
- return 0;
- }
-}
-*/
-#define STACKCALL __attribute__((regparm(1),noinline))
-void ** STACKCALL getEBP(void){
- void **ebp=NULL;
- __asm__ __volatile__("mov %%rbp, %0;\n\t"
- :"=m"(ebp) /* ��� */
- : /* ���� */
- :"memory"); /* ����Ӱ��ļĴ��� */
- return (void **)(*ebp);
-}
-int mesa_backtrace(void **buffer,int size){
-
- int frame=0;
- void ** ebp;
- void **ret=NULL;
- unsigned long long func_frame_distance=0;
- if(buffer!=NULL && size >0)
- {
- ebp=getEBP();
- func_frame_distance=(unsigned long long)(*ebp) - (unsigned long long)ebp;
- while(ebp&& frame<size
- &&(func_frame_distance< (1ULL<<24))//assume function ebp more than 16M
- &&(func_frame_distance>0))
- {
- ret=ebp+1;
- buffer[frame++]=*ret;
- ebp=(void**)(*ebp);
- func_frame_distance=(unsigned long long)(*ebp) - (unsigned long long)ebp;
- }
- }
- return frame;
-}
-
-
-backtrace_info_t* backtrace_ref_inc(MESA_hash_tab_v2_t* hash,size_t inc_size,thread_mem_pool_t *p_mempool)
-{
- void *bt_array[MAX_BACKTRACE_DEPTH];
- void** except_self_bt_array;
- size_t bt_depth,except_self_bt_depths;
- bt_depth = mesa_backtrace(bt_array, MAX_BACKTRACE_DEPTH);
-// bt_depth = backtrace(bt_array, MAX_BACKTRACE_DEPTH);
-// bt_depth = unw_backtrace(bt_array, MAX_BACKTRACE_DEPTH);
- backtrace_info_t *caller_bt;
- if(bt_depth<=MALLOC_SELF_DEPTH)
- {
- bt_depth=MALLOC_SELF_DEPTH+1;
- memset(bt_array,0,sizeof(bt_array));
- }
- except_self_bt_array=bt_array+MALLOC_SELF_DEPTH;
- except_self_bt_depths=bt_depth-MALLOC_SELF_DEPTH;
- caller_bt=(backtrace_info_t *)D_INTERNAL_MESA_hash_sel_v2(hash,
- (uchar*)(except_self_bt_array),
- sizeof(void*)*(except_self_bt_depths));
- if(caller_bt==NULL)
- {
- caller_bt=create_bt_info(except_self_bt_array, except_self_bt_depths,p_mempool);
- D_INTERNAL_MESA_hash_add_v2(hash,
- (uchar*)except_self_bt_array,
- sizeof(void*)*except_self_bt_depths,
- caller_bt);
- }
- atomic_inc(&(caller_bt->ref_cnt));
- atomic_add(&(caller_bt->ref_bytes),inc_size);
- if(atomic_read(&(caller_bt->maxsize))<(signed long)inc_size)
- {
- atomic_set(&(caller_bt->maxsize),(signed long)inc_size);
- }
- return caller_bt;
-}
-void merge_mp_hash(uchar * key, uint size, void * data, void * u)
-{
- MESA_hash_tab_v2_t* target_hash=(MESA_hash_tab_v2_t*)u;
- backtrace_info_t* tmp_bt_info=(backtrace_info_t*)data;
- if(0==atomic_read(&(tmp_bt_info->ref_bytes)))
- {
- return;
- }
- backtrace_info_t* target_bt_info=(backtrace_info_t *)D_INTERNAL_MESA_hash_sel_v2(target_hash,
- (uchar*)key,
- size);
- if(target_bt_info==NULL)
- {
- target_bt_info=create_bt_info(tmp_bt_info->bt_array, tmp_bt_info->array_size,DEBUGGER_MP);
-
- D_INTERNAL_MESA_hash_add_v2(target_hash,
- key,
- size,
- target_bt_info);
- }
- atomic_add(&(target_bt_info->ref_bytes),atomic_read(&(tmp_bt_info->ref_bytes)));
- atomic_add(&(target_bt_info->ref_cnt),atomic_read(&(tmp_bt_info->ref_cnt)));
- if(atomic_read(&(target_bt_info->maxsize))<atomic_read(&(tmp_bt_info->maxsize)))
- {
- atomic_set(&(target_bt_info->maxsize),atomic_read(&(tmp_bt_info->maxsize)));
- }
- return;
-}
-void dump2array_by_refbytes(uchar * key, uint size, void * data, void * u)
-{
-
- backtrace_info_t* bt_info=(backtrace_info_t*)data;
- struct sort_data_t* sort_array=(struct sort_data_t*)u;
- sort_array[sort_data_pos].val=atomic_read(&(bt_info->ref_bytes));
- sort_array[sort_data_pos].data=data;
- sort_data_pos++;
- return;
-}
-void dump2array_by_maxsize(uchar * key, uint size, void * data, void * u)
-{
-
- backtrace_info_t* bt_info=(backtrace_info_t*)data;
- struct sort_data_t* sort_array=(struct sort_data_t*)u;
- sort_array[sort_data_pos].val=atomic_read(&(bt_info->maxsize));
- sort_array[sort_data_pos].data=data;
- sort_data_pos++;
- return;
-}
-int exec_shell(const char*cmd ,char* buff,int buff_size)
-{
- FILE* fp = popen(cmd, "r");
- if(fp==NULL)
- {
- return -1;
- }
- memset(buff,0,buff_size);
- fgets(buff,buff_size,fp);
- pclose(fp);
- return strlen(buff);
-}
-int get_backtrace_string(void* bt,char* buff,int buff_size)
-{
- char cmd[128] = {0};
- char property[256]={0};
- char not_care1[128]={0},not_care2[128]={0},not_care3[128]={0};
- char library_path[256]={0};
- char exe_path[256]={0},function_name[256]={0};
- char maps_line[1024]={0};
- void* offset_start,*offset_end;
- int maps_column_num=0;
- FILE* fd_maps=NULL;
- fd_maps=fopen("/proc/self/maps","r");
- unsigned long exe_symbol_offset=0;
- const char* unknow_position="??:0\n";
- if(fd_maps==NULL)
- {
- return -1;
- }
- while(NULL!=fgets(maps_line,sizeof(maps_line),fd_maps))
- {
- maps_column_num=sscanf(maps_line,"%p-%p\t%s\t%s\t%s\t%s\t%s"
- ,&offset_start
- ,&offset_end
- ,property
- ,not_care1
- ,not_care2
- ,not_care3
- ,library_path);
- if(maps_column_num==7&&bt>=offset_start&&bt<=offset_end)
- {
- break;
- }
-
- }
- fclose(fd_maps);
- memset(exe_path,0,sizeof(exe_path));
- readlink("/proc/self/exe", exe_path, sizeof(exe_path));
- if(exe_path[strlen(exe_path)-1]=='\n')
- {
- exe_path[strlen(exe_path)-1]='\0';
- }
- if(0==strcmp(exe_path,library_path))
- {
- exe_symbol_offset=(unsigned long)bt;
- }
- else
- {
- exe_symbol_offset=(char*)bt-(char*)offset_start;
- }
- snprintf(cmd,sizeof(cmd),"addr2line -C -e %s 0x%lx",library_path,exe_symbol_offset);
- exec_shell(cmd, buff, buff_size);
- if(0==strcmp(buff,unknow_position))
- {
- snprintf(cmd,sizeof(cmd),"addr2line -Cif -e %s 0x%lx",library_path,exe_symbol_offset);
- exec_shell(cmd, function_name, sizeof(function_name));
- function_name[strlen(function_name)-1]='\0';
- snprintf(buff,buff_size,"%s(%s+0x%lx)\n",library_path,function_name,exe_symbol_offset);
- }
- return 0;
-}
-
-int merge_malloc_bt(MESA_hash_tab_v2_t *merged_hash)
-{
- int ret=0,i=0;
- MESA_hash_tab_v2_t* mp_malloc_hash;
- int to_sort_size=0;
- ret=D_INTERNAL_MESA_hash_create_v2(merged_hash,
- 1,//thread safe
- 1024*32,
- 0,//unlimited max element num
- NULL,
- NULL,
- destroy_bt_info,
- NULL,
- 0,
- 0,//never expire
- (IMP_t*)DEBUGGER_MP);
- assert(ret==0);
- for(i=0;i<=atomic_read(&(D_SPACE.used_mem_pool_counter));i++)
- {
- if(D_SPACE.thread_mem_info[i]==NULL)
- {
- continue;
- }
- mp_malloc_hash=&(D_SPACE.thread_mem_info[i]->debugger.malloc_backtrace_hash);
- D_INTERNAL_MESA_hash_iterate_v2_2(mp_malloc_hash, merge_mp_hash,merged_hash);
- }
-
- to_sort_size=merged_hash->elem_count;
- return to_sort_size;
-}
-
-
-void list_malloc_bt(int sd,const char*args,int CMD)
-{
- int i=0,printed=0,list_cnt=0;
- unsigned int j=0;
- backtrace_info_t* bt_info=NULL;
- long ref_bytes=0,ref_cnt=0;
- struct sort_data_t* sort_array=NULL;
- int to_sort_size=0;
- char buff[4096]={0},bt_string[1024]={0};
- pid_t pid=getpid();
- int max_list_num=-1,min_list_size=-1;
- MESA_hash_tab_v2_t merged_hash;
- sscanf(args,"%d %d",&max_list_num,&min_list_size);
- if(CMD!=D_CMD_LIST_LARGE_M&&CMD!=D_CMD_LIST_MALLOC)
- {
- assert(0);
- }
- to_sort_size=merge_malloc_bt(&merged_hash);
- sort_array=(struct sort_data_t*)mmap_alloc(to_sort_size*sizeof(struct sort_data_t));
-
- if(CMD==D_CMD_LIST_LARGE_M)
- {
- D_INTERNAL_MESA_hash_iterate_v2_2(&merged_hash, dump2array_by_maxsize,sort_array);
-
- }
- else if(CMD==D_CMD_LIST_MALLOC)
- {
- D_INTERNAL_MESA_hash_iterate_v2_2(&merged_hash, dump2array_by_refbytes,sort_array);
- }
- sort_data_pos=0;
- quick_sort(sort_array, 0,to_sort_size-1);
- for(i=to_sort_size-1;i>=0;i--)
- {
- printed=0;
- memset(buff,0,sizeof(buff));
- bt_info=(backtrace_info_t*)(sort_array[i].data);
- if(list_cnt>=max_list_num&&max_list_num>0)
- {
- break;
- }
- if(CMD==D_CMD_LIST_LARGE_M)
- {
- if(atomic_read(&(bt_info->maxsize))<min_list_size&&min_list_size>0)
- {
- break;
- }
- }
- else if(CMD==D_CMD_LIST_MALLOC)
- {
- if(atomic_read(&(bt_info->ref_bytes))<min_list_size&&min_list_size>0)
- {
- break;
- }
- }
-
- ref_bytes=atomic_read(&(bt_info->ref_bytes));
- ref_cnt=atomic_read(&(bt_info->ref_cnt));
- printed+=snprintf(buff+printed,sizeof(buff)-printed,
- "=%u=\t malloc %ld bytes(%ldMB) and %ld times in contexts (MAX %ld bytes,AVG %ld bytes)\n",
- pid,
- ref_bytes,
- ref_bytes/(1024*1024),
- ref_cnt,
- atomic_read(&(bt_info->maxsize)),
- ref_bytes/ref_cnt);
- for(j=0;j<bt_info->array_size;j++)
- {
- memset(bt_string,0,sizeof(bt_string));
- get_backtrace_string(bt_info->bt_array[j],bt_string,sizeof(bt_string));
- printed+=snprintf(buff+printed,sizeof(buff)-printed,"=%u=\tby %s",pid,bt_string);
- }
- printed+=snprintf(buff+printed,sizeof(buff)-printed,"\n");
- write(sd,buff,printed);
- list_cnt++;
- }
- D_INTERNAL_MESA_hash_destroy_v2(&merged_hash,NULL);
- mmap_free(sort_array);
-}
-int d_chk_one_mem(struct dbg_index_t* idx,char* err_string,int size)
-{
- int printed=0,invalid_write_size=0,i=0;
- unsigned int assigned_size=0;
- const char* user_boundary=NULL;
- mem_info_t* block=(mem_info_t*)(idx->mem_info);
- int boundary_len=0,is_corrupt=0;
- if(block->magic!=DICTATOR_MAGIC)
- {
- printed+=snprintf(err_string+printed,size-printed,"Magic Error|");
- is_corrupt=1;
- }
- assigned_size=block->blk_num*DICTATOR_UNIT_SIZE;
- if(assigned_size<idx->used_size+USED_MEM_HEAD_LEN)
- {
- printed+=snprintf(err_string+printed,size-printed,"Corrupt mem head usd(%lu)>assigned(%u)|"
- ,idx->used_size+USED_MEM_HEAD_LEN
- ,assigned_size);
- is_corrupt=1;
- }
- user_boundary=(char*)block+USED_MEM_HEAD_LEN+idx->used_size;
- boundary_len=MIN(assigned_size-idx->used_size-USED_MEM_HEAD_LEN,D_MARKER_SIZE);
- if(0!=memcmp(user_boundary,boundary_marker,boundary_len))
- {
- for(i=0;i<boundary_len;i++)
- {
- if(user_boundary[i]!='d')
- {
- invalid_write_size++;
- }
- }
- printed+=snprintf(err_string+printed,size-printed,"Invaid write %d bytes after %p|",invalid_write_size,user_boundary);
- if(invalid_write_size==boundary_len)
- {
- printed+=snprintf(err_string+printed,size-printed,"May stack overflow|");
-
- }
- is_corrupt=1;
- }
- return is_corrupt;
-}
-void D_check_mem(int sd,int is_scheduled)
-{
- int i=0;
- unsigned int j=0;
- int is_corrupt=0,printed=0;
- unsigned long chked_blk_sum=0,chked_bytes_sum=0,corrupt_sum=0;
- struct D_kernel_list_head* to_check_list=NULL,*to_check_elem=NULL;
- struct dbg_index_t* to_chk_idx=NULL;
- mem_info_t* block=NULL;
- char err_string[256]={0},bt_string[1024]={0};;
- char buff[4096]={0};
- pid_t pid=getpid();
- for(i=0;i<=atomic_read(&(D_SPACE.used_mem_pool_counter));i++)
- {
- if(D_SPACE.thread_mem_info[i]==NULL)
- {
- continue;
- }
- pthread_mutex_lock(&(D_SPACE.thread_mem_info[i]->debugger.mutex_malloced_in_reach_list));
- to_check_list=&(D_SPACE.thread_mem_info[i]->debugger.malloced_in_reach_list);
- to_check_elem=to_check_list->next;
- while(to_check_elem!=to_check_list)
- {
- printed=0;
- to_chk_idx=container_of(to_check_elem,struct dbg_index_t, malloced_in_reach_hook);
- chked_blk_sum++;
- chked_bytes_sum+=to_chk_idx->used_size;
- is_corrupt=d_chk_one_mem(to_chk_idx, err_string,sizeof(err_string));
- if(is_corrupt==1)
- {
- block=(mem_info_t*)to_chk_idx->mem_info;
- corrupt_sum++;
- printed=snprintf(buff+printed,sizeof(buff)-printed,"Mem %p size %d(%s) D_id %u %s in context\n",
- (char*)block+USED_MEM_HEAD_LEN,
- to_chk_idx->used_size,
- block->blk_num?"block":"chunk",
- block->D_id,
- err_string);
-
- for(j=0;j<to_chk_idx->p_backtrace->array_size;j++)
- {
- memset(bt_string,0,sizeof(bt_string));
- get_backtrace_string(to_chk_idx->p_backtrace->bt_array[j],bt_string,sizeof(bt_string));
- printed+=snprintf(buff+printed,sizeof(buff)-printed,"=%u=\tby %s",pid,bt_string);
- }
-
- write(sd,buff,printed);
- }
- to_check_elem=to_check_elem->next;
- }
- pthread_mutex_unlock(&(D_SPACE.thread_mem_info[i]->debugger.mutex_malloced_in_reach_list));
-
- }
- printed=0;
- printed+=snprintf(buff+printed,sizeof(buff)-printed,"Corrutp Sumary:\n\tChecked %d threads.\n\tChecked %lu block,%lu bytes(%luMB).\n\t%lu block(s) Corrupt.\n",
- i,
- chked_blk_sum,
- chked_bytes_sum,
- chked_bytes_sum/(1024*1024),
- corrupt_sum);
- if(!is_scheduled)
- {
- write(sd,buff,printed);
- }
- return;
-
-}
-int dictator_parse_cmd(const char* cmd,const char**args)
-{
- int i=0,ret=0;
- while(strlen(support_cmd_full[i])>1)
- {
- ret=strncasecmp(cmd,support_cmd_full[i],strlen(support_cmd_full[i]));
- if(ret==0)
- {
- *args=cmd+strlen(support_cmd_full[i])+1;
- break;
- }
- else if((cmd[0]==support_cmd_short[i])&&(cmd[1]=='\n'||cmd[1]==' '))
- {
- *args=cmd+2;
- break;
- }
- i++;
- }
- return i;
-}
-void * dictator_debug_thread(void* param)
-{
- pid_t app_pid=0;
- char listen_path[64];
- char cmd_buff[1024],debug_cmd[1024];
- app_pid=getpid();
- char banner[1024]={0};
- const char* unknown_cmd="UNKNOWN CMD.\n";
- const char* shell="dictator2>";
- const char* schedule_checking="Schedule Checking";
- snprintf(listen_path,sizeof(listen_path),"/tmp/dictator_%u",app_pid);
- snprintf(banner,sizeof(banner),"WELCOME TO DICTATOR2(%s) DEBUG CONSOLE.\n",
- DICTATOR2_VERSION);
- DEBUGGER_MP=create_mem_pool(-1);
- struct sockaddr_un address;
- int sock, conn,cmd_id=0;
- int check_times=-1,check_interval_us=1000*100;
- int i=0,ret=-1;
- size_t addrLength;
- const char *args=NULL;
-
- if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
- {
- fprintf(stderr,"DICTATOR2 INIT FAILED!\n");
- }
-
- unlink(listen_path);
-
- address.sun_family = AF_UNIX;
- strcpy(address.sun_path,listen_path);
-
- addrLength = sizeof(address.sun_family) + strlen(address.sun_path);
-
- if (bind(sock, (struct sockaddr *) &address, addrLength))
- {
- fprintf(stderr,"DICTATOR2 bind %s FAILED!\n",listen_path);
- }
- if (listen(sock, 1))
- {
- fprintf(stderr,"DICTATOR2 listen %s FAILED!\n",listen_path);
- }
- fprintf(stderr,"Using DICTATOR2 memory debugger (%s)\n",listen_path);
- while ((conn = accept(sock, (struct sockaddr *) &address,(socklen_t*)&addrLength)) >= 0)
- {
- write(conn,banner,strlen(banner));
- memset(debug_cmd,0,sizeof(debug_cmd));
- write(conn,shell,strlen(shell));
- while(read(conn,cmd_buff,sizeof(cmd_buff))>0)
- {
- if(cmd_buff[0]!='\n')
- {
- memcpy(debug_cmd,cmd_buff,sizeof(debug_cmd));
- cmd_id=dictator_parse_cmd(debug_cmd,&args);
- }
- check_times=-1;
- check_interval_us=1000*100;
- switch(cmd_id)
- {
- case D_CMD_HELP:
- show_help(conn);
- break;
- case D_CMD_STAT:
- stat_memory(conn);
- break;
- case D_CMD_LIST_MALLOC:
- case D_CMD_LIST_LARGE_M:
- list_malloc_bt(conn,args,cmd_id);
- break;
- case D_CMD_CHECK:
- sscanf(args,"%d %d",&check_times,&check_interval_us);
- if(check_times>0)
- {
- write(conn,schedule_checking,strlen(schedule_checking));
- for(i=0;i<check_times;i++)
- {
- D_check_mem(conn,1);
- ret=write(conn,".",1);
- if(ret<=0)
- {
- break;
- }
- usleep(check_interval_us);
- }
- write(conn,"\n",1);
- }
- else
- {
- D_check_mem(conn,0);
- }
- break;
- default:
- write(conn,unknown_cmd,strlen(unknown_cmd));
- break;
- }
- memset(cmd_buff,0,sizeof(cmd_buff));
- write(conn,shell,strlen(shell));
- }
- close(conn);
- }
- return NULL;
-}
-#endif //end of DICTATOR_DEBUG
-
diff --git a/src/support/dictator2/src/dummy_hash.h b/src/support/dictator2/src/dummy_hash.h
deleted file mode 100644
index 02dd580..0000000
--- a/src/support/dictator2/src/dummy_hash.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef _DUMMY_HTABLE_H_
-#define _DUMMY_HTABLE_H_
-#include <string.h>//using memset
-#define DUMMY_HASH_SIZE 2048
-#define DUMMY_COLLISION_SIZE 2048
-struct dummy_pair_t
-{
- long key;
- long value;
-};
-struct dummy_htable_t
-{
- struct dummy_pair_t array[DUMMY_HASH_SIZE+DUMMY_COLLISION_SIZE];
- long collision_cnt;
-};
-inline void dummy_htable_init(struct dummy_htable_t* table)
-{
- memset(table,0,sizeof(struct dummy_htable_t));
- return;
-}
-inline long dummy_htable_read(struct dummy_htable_t* table,long key,long *value)
-{
- int i=0;
- int idx=key%DUMMY_HASH_SIZE;
- if(table->array[idx].key==key)
- {
- *value=table->array[idx].value;
- return 1;
- }
- else if(table->array[idx].key==0)
- {
- return 0;
- }
- else
- {
- for(i=DUMMY_HASH_SIZE;i<DUMMY_HASH_SIZE+table->collision_cnt;i++)
- {
- if(table->array[i].key==key)
- {
- *value=table->array[i].value;
- return 1;
- }
- }
- return 0;
- }
-}
-inline int dummy_htable_add(struct dummy_htable_t* table,long key,long value)
-{
- int idx=key%DUMMY_HASH_SIZE;
- long previous_key=0,previous_value=0;
- assert(key!=0);
- previous_key=__sync_lock_test_and_set(&(table->array[idx].key),key);
- if(previous_key==0)
- {
- return 0;
- }
- previous_value=table->array[idx].value;
- table->array[idx].value=value;
-
- assert(table->collision_cnt<DUMMY_COLLISION_SIZE);
- idx=DUMMY_HASH_SIZE+__sync_fetch_and_add(&(table->collision_cnt),1);
- previous_key=__sync_fetch_and_add(&(table->array[idx].key),previous_key);
- table->array[idx].value=previous_value;
- assert(previous_key==0);
- return idx;
-}
-#endif
diff --git a/src/support/dictator2/src/internal_mp.h b/src/support/dictator2/src/internal_mp.h
deleted file mode 100644
index 40796cd..0000000
--- a/src/support/dictator2/src/internal_mp.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __INTERNAL_MEM_POOL_H_INCLUDE_
-#define __INTERNAL_MEM_POOL_H_INCLUDE_
-typedef struct
-{
-}IMP_t;
-void* mmap_alloc(size_t size);
-void mmap_free(void*p);
-void* block_alloc(size_t size,IMP_t *imp);
-void block_free(void*p,IMP_t* imp);
-#endif //end of __INTERNAL_MEM_POOL_H_INCLUDE_
-
diff --git a/src/support/dictator2/src/mr_hugepage.h b/src/support/dictator2/src/mr_hugepage.h
deleted file mode 100644
index d853e86..0000000
--- a/src/support/dictator2/src/mr_hugepage.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* 申请大页内存函数
- * @note: 不要在数据面频繁使用!!
- */
-int marsio_is_hugepage_available(void);
-void * marsio_hugepage_malloc(size_t size, int seq);
-void * marsio_hugepage_calloc(size_t num, size_t size, int seq);
-void * marsio_hugepage_realloc(void * ptr, size_t size);
-
-/* 释放大页内存函数 */
-void marsio_hugepage_free(void * mem);
-
-#ifdef __cplusplus
-}
-#endif \ No newline at end of file
diff --git a/src/support/dictator2/test/Makefile b/src/support/dictator2/test/Makefile
deleted file mode 100644
index 682b906..0000000
--- a/src/support/dictator2/test/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-all:
- g++ -o test -g -Wall test.cpp ../lib/libdictator_debug.a -lpthread
-clean:
- rm test -f
diff --git a/src/support/dictator2/test/test.cpp b/src/support/dictator2/test/test.cpp
deleted file mode 100644
index 504dcb0..0000000
--- a/src/support/dictator2/test/test.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <pthread.h>
-#if 0 // for EAL check, Delete code temporary
-#define TEST_CNT (8)
-#define TEST_THREAD (4)
-struct test_case_t
-{
- void *mem;
- unsigned int size;
-};
-unsigned int g_used_mem_size=0;
-
-void mem_test(void*)
-{
- struct test_case_t test_array[TEST_CNT];
- int i=0;
- for(i=1;i<TEST_CNT;i++)
- {
- test_array[i].size=i*64;
- test_array[i].mem=malloc(test_array[i].size);
- g_used_mem_size+=test_array[i].size;
- }
- sleep(10);
- for(i=1;i<TEST_CNT;i++)
- {
- switch(i%10)
- {
- case 5:
- g_used_mem_size-=test_array[i].size;
- test_array[i].size+=1500;
- test_array[i].mem=realloc(test_array[i].mem,test_array[i].size);
- g_used_mem_size+=test_array[i].size;
- break;
- case 2:
- free(test_array[i].mem);
- g_used_mem_size-=test_array[i].size;
- test_array[i].size=0;
- test_array[i].mem=NULL;
- break;
- default:
- break;
- }
- }
-
- for(i=1;i<TEST_CNT;i++){
- free(test_array[i].mem);
- }
-}
-int main(int argc,char* argv[])
-{
- pthread_t thread_desc[TEST_THREAD];
- pthread_attr_t attr;
- int i=0;
- memset(&thread_desc, 0, sizeof(thread_desc));
- memset(&attr, 0, sizeof(attr));
-
- if(0 != pthread_attr_init(&(attr)))
- {
- fprintf(stderr,"pthread_attr_init(): %d %s", errno, strerror(errno));
- return -1;
- }
- if(0 != pthread_attr_setdetachstate(&(attr), PTHREAD_CREATE_DETACHED))
- {
- fprintf(stderr,"pthread_attr_setdetachstate(): %d %s", errno, strerror(errno));
- return -1 ;
- }
- for(i=0;i<TEST_THREAD;i++)
- {
- if(0 != pthread_create(&(thread_desc[i]), &(attr), (void *(*)(void *))(mem_test), NULL))
- {
- fprintf(stderr,"pthread_create(): %d %s", errno, strerror(errno));
- pthread_attr_destroy(&(attr));
- return -1;
- }
- }
- sleep(5);
- return 0;
-}
-#else
-int main(int argc,char* argv[])
-{
- return 0;
-}
-
-#endif
-
diff --git a/src/support/md5/Makefile b/src/support/md5/Makefile
deleted file mode 100644
index 6dac19a..0000000
--- a/src/support/md5/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-all:libmd5.a
-CFLAGS = -D__FAVOR_BSD=1 -D__USE_BSD=1 -D_GNU_SOURCE=1 -fPIC
-
-libmd5.a:md5.o
- ar -cr $@ $^
- cp $@ ../../lib
-
-md5.o:md5.c
- gcc -c -o $@ $(CFLAGS) $^
-
-clean:
- rm -f *.o libmd5.a
-
diff --git a/src/support/symbol_check/Makefile b/src/support/symbol_check/Makefile
deleted file mode 100644
index 57a5540..0000000
--- a/src/support/symbol_check/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-all:libsymbol_check.a
-
-INC=-I./
-INC+=-I/opt/MESA/include
-INC+=-I/opt/MESA/include/MESA
-INC+=-I../../../include/
-INC+=-I../../../include/public
-INC+=-I../../../include/private
-INC+=-I../../../include/support
-LIBS = -L/opt/MESA/lib
-CFLAGS = -D__FAVOR_BSD=1 -D__USE_BSD=1 -D_GNU_SOURCE=1 -fPIC
-
-test_symbol_check:test_symbol_check.c libsymbol_check.a
- gcc -o $@ $(INC) $^ -g -D_GNU_SOURCE=1 -ldl -lpthread -lMESA_htable
-
-libsymbol_check.a:libsymbol_check.o
- ar -cr $@ $^
- cp $@ ../../lib/
-
-libsymbol_check.o:libsymbol_check.cpp
- g++ -c $^ $(INC) $(CFLAGS) -ldl -g
-
-clean:
- rm -f test_symbol_check *.o *.a
diff --git a/src/support/timestamp_record/Makefile b/src/support/timestamp_record/Makefile
deleted file mode 100644
index 1e80c4d..0000000
--- a/src/support/timestamp_record/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-all:libtimestamp_record.a
-
-INC = -I../../../include
-INC += -I../../../include/public
-INC += -I../../../include/private
-INC += -I../../../include/support
-INC += -I/opt/MESA/include
-INC += -I/opt/MESA/include/MESA
-
-libtimestamp_record.a:timestamp_record.o
- ar -cr $@ $^
- cp $@ ../../lib
-
-timestamp_record.o:timestamp_record.cpp
- g++ -c $(CFLAGS) -fPIC $(INC) -o $@ $^
-
-clean:
- rm -f *.o libtimestamp_record.a
-
diff --git a/src/support/tomlc99_wrap/Makefile b/src/support/tomlc99_wrap/Makefile
deleted file mode 100644
index f754bb4..0000000
--- a/src/support/tomlc99_wrap/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-CC = gcc
-CCC = g++
-CFILES = toml.c
-
-CFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE -std=c99 -Wall -Wextra -fPIC
-# to compile for debug: make DEBUG=1
-# to compile for no debug: make
-CFLAGS += -O0 -g
-
-EXEC = test_toml
-
-LIB = libtoml.a libtomlc99_wrap.so libtomlc99_wrap.a
-LIB_PATH = -L/opt/MESA/lib
-
-#all: $(LIB) $(EXEC)
-all: $(LIB)
-
-libtoml.a: toml.o
- ar -rcs $@ $^;
-
-toml_json: toml_json.c $(LIB)
-
-toml_cat: toml_cat.c $(LIB)
-
-test_toml: test_toml.c
- gcc -o $@ $(LIB_PATH) -ltomlc99_wrap $^
-
-libtomlc99_wrap.so:tomlc99_wrap.o toml.o
- gcc -o $@ -shared -fPIC $^; cp tomlc99_wrap.h ../../../include/support/;
-
-libtomlc99_wrap.a:tomlc99_wrap.o toml.o
- ar -rcs $@ $^; cp tomlc99_wrap.h ../../../include/support/; cp $@ ../../lib/
-
-.c.o:
- $(CC) -c $(CFLAGS) -I. $<
-
-.cpp.o:
- $(CCC) -c $(CFLAGS) -I. $<
-
-
-prefix ?= /usr/local
-
-install: all
- install -d ${prefix}/include ${prefix}/lib
- install toml.h ${prefix}/include
- install libtoml.a ${prefix}/lib
-
-clean:
- rm -f *.o $(EXEC) $(LIB)
diff --git a/src/timer/Makefile b/src/timer/Makefile
deleted file mode 100644
index 5dbcf1c..0000000
--- a/src/timer/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-#opt: OPTFLAGS = -O2
-#export OPTFLAGS
-
-CC = g++
-CCC = g++
-CFLAGS += -Wall
-CFLAGS += -fPIC -shared -D_DEFAULT_SOURCE -D_DEFAULT_SOURCE -D__DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H
-CFLAGS += $(OPTFLAGS)
-CFLAGS += $(PACKET_TAG_863)
-CFLAGS += -DPLATFORM_NSDPF_PAPP=1
-
-LIBPATH = ../lib
-
-H_DIR += $(INC)
-H_DIR += -I../../include
-H_DIR += -I../../include/private
-H_DIR += -I../../include/public
-H_DIR += -I../../include/support
-
-H_DIR += -I/opt/MESA/include
-H_DIR += -I/opt/MESA/include/MESA
-
-TARGET = libtimer.a
-
-OBJS= sapp_timer.o
-
-ifeq ($(IIEFD_DUAL_STACK), $(YES))
-CFLAGS += -g -DIIEFD_DUAL_STACK=1
-endif
-
-ifeq ($(USE_MEM_POOL), 1)
-CFLAGS += -DUSE_MEMPOOL=1
-endif
-
-
-all: $(TARGET)
-
-$(TARGET): $(OBJS)
- rm -f $@ ;ar -r $@ $^;
- cp $(TARGET) $(LIBPATH)
-
-.c.o:
- $(CC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-.cpp.o:
- $(CCC) -c $(CFLAGS) -I. $(H_DIR) $<
-
-clean:
- rm -f *.o $(TARGET) *~
-
-opt:
- $(MAKE) all
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index d76c1d8..812d7db 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -21,7 +21,7 @@ LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/test)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/sapp_devel.cpp "")
set(LIBS sapp_dev dealpkt packet_io packet_io_pcap packet_io_marsio common
- config inline_keepalive gdev_assistant sapp_assistant plugctrl project timer dictator2
+ config inline_keepalive gdev_assistant sapp_assistant sapp_metrics plugctrl project timer
md5 symbol_check tomlc99_wrap MESA_socket_wrap timestamp_record
MESA_sleep dpdk_ip_hash cpu_limit timeout libdabloom-static )
diff --git a/test/MESA_path_trace/Makefile b/test/MESA_path_trace/Makefile
deleted file mode 100644
index caf968f..0000000
--- a/test/MESA_path_trace/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-CC = gcc
-CFLAGS = -g -Wall -fPIC
-CFLAGS += -D__FAVOR_BSD=1 -D__USE_MISC=1 -D_GNU_SOURCE=1
-CFLAGS += $(OPTFLAGS)
-OBJECTS = MESA_path_trace.o
-MODULES =
-TARGET = MESA_path_trace.so
-
-INCS = -I ../../include
-INCS += -I ../../include/net
-INCS += -I ../../dealpkt
-INCS += -I /usr/include/MESA
-INCS += -I../../include/stream_inc
-
-
-.PHONY: all clean
-all: $(TARGET)
-$(TARGET):$(OBJECTS)
- $(CC) -o $(TARGET) -shared -fPIC $(CFLAGS) $(OBJECTS) $(MODULES)
- cp $@ ../../plug/business/MESA_path_trace/
- cp MESA_path_trace.inf ../../plug/business/MESA_path_trace/
-
-MESA_path_trace.o:MESA_path_trace.c
- $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-
-clean:
- rm -f $(TARGET) $(OBJECTS)
-
diff --git a/test/Makefile b/test/Makefile
deleted file mode 100644
index 4166e8f..0000000
--- a/test/Makefile
+++ /dev/null
@@ -1,75 +0,0 @@
-CC = gcc
-CCC = g++
-CFLAGS = -g -fPIC
-CFLAGS += -D__USE_BSD=1 -D__FAVOR_BSD=1 -D__USE_MISC=1 -D_GNU_SOURCE=1
-CFLAGS += $(OPTFLAGS)
-OBJECTS = test_app_sapp.o trace_delay.o terminal_tag.o g_device_plug.o
-MODULES =
-
-BIN_PATH = ../bin/
-
-TARGET = test_app_sapp.so
-TARGET += inline_device_measurement.so
-TARGET += test_sendpacket_performance.so
-#TARGET += test_anti_flood_hijack
-#TARGET += sapp_so_run
-
-TARGET += test_sapp_dev_static test_sapp_dev_dynamic
-
-INCS =
-
-INCS += -I ../include
-INCS += -I../include/private
-INCS += -I../include/public
-INCS += -I../include/public/stream_inc/
-INCS += -I../include/support/
-INCS += -I/opt/MESA/include
-INCS += -I/opt/MESA/include/MESA
-
-
-.PHONY: all
-all: $(TARGET)
-
-test_app_sapp.so: test_app_sapp.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
-
-test_sendpacket_performance.so: test_sendpacket_performance.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
-
-trace_delay.so: trace_delay.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
-
-terminal_tag.so: terminal_tag.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
-
-g_device_plug.so: g_device_plug.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
-
-test_http.so:test_http.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
-
-test_anti_flood_hijack:test_anti_flood_hijack.c ../lib/libavltree.a
- g++ -o $@ $(CFLAGS) $^ -I../inner_plug -I../support/avl_tree -lpcap -lpthread -lanti_flood_hijack -lMESA_htable -lMESA_handle_logger
-
-inline_device_measurement.so:inline_device_measurement.c
- $(CC) -o $@ -shared -fPIC $(INCS) $(CFLAGS) -DIOMODE_MARSIO=1 $^ $(MODULES)
-
-
-sapp_so_run:test_sapp_so.o
- $(CC) -o $@ -g $(INCS) $(CFLAGS) $^ -lpcap -ldl
-
-test_sapp_dev_static:test_sapp_dev.c
- gcc -o $@ $^ ../build/src/sapp_dev/libsapp_dev.a -I/opt/MESA/include/MESA -I/opt/MESA/include/MESA/stream_inc -L/opt/MESA/lib -lpcap -lpthread -ldl -lMESA_htable -lMESA_prof_load -lMESA_handle_logger -lMESA_field_stat2
-
-test_sapp_dev_dynamic:test_sapp_dev.c
- gcc -o $@ $^ -lsapp_devel -I/opt/MESA/include/MESA -I/opt/MESA/include/MESA/stream_inc -L/opt/MESA/lib -lpcap -lpthread -ldl -lMESA_htable -lMESA_prof_load -lMESA_handle_logger -lMESA_field_stat2 -lsystemd -lMESA_jump_layer -lbreakpad_mini
-
-.c.o:
- $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-
-.cpp.o:
- $(CCC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-
-clean:
- rm -f $(TARGET) $(OBJECTS)
-
diff --git a/test/Makefile_kill b/test/Makefile_kill
deleted file mode 100644
index cec4fa3..0000000
--- a/test/Makefile_kill
+++ /dev/null
@@ -1,24 +0,0 @@
-CC = gcc
-CFLAGS = -g -Wall -fPIC
-CFLAGS += $(OPTFLAGS)
-OBJECTS = test_kill.o
-MODULES =
-TARGET = test_kill.so
-
-INCS = -I ../../include
-
-
-.c.o:
- $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-
-.PHONY: all clean
-all: $(TARGET)
-$(TARGET):$(OBJECTS)
- $(CC) -o $(TARGET) -shared -fPIC $(CFLAGS) $(OBJECTS) $(MODULES)
- cp $@ ../plug/general
-
-test_app.o: test_kill.c
-
-clean:
- rm -f $(TARGET) $(OBJECTS)
-
diff --git a/test/Makefile_proxy b/test/Makefile_proxy
deleted file mode 100644
index 18ec183..0000000
--- a/test/Makefile_proxy
+++ /dev/null
@@ -1,25 +0,0 @@
-CC = gcc
-CFLAGS = -g -Wall -fPIC
-CFLAGS += $(OPTFLAGS)
-OBJECTS = test_connect.o
-MODULES =
-TARGET = test_app.so
-
-INCS = -I ../../include
-INCS += -I../../include/stream_inc/
-
-
-.c.o:
- $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-
-.PHONY: all clean
-all: $(TARGET)
-$(TARGET):$(OBJECTS)
- $(CC) -o $(TARGET) -shared -fPIC $(CFLAGS) $(OBJECTS) $(MODULES)
- cp $@ ../plug/business/test_app/
-
-test_connect.o: test_connect.c
-
-clean:
- rm -f $(TARGET) $(OBJECTS)
-
diff --git a/test/dpdk_ip_hash/Makefile b/test/dpdk_ip_hash/Makefile
deleted file mode 100644
index 26d266f..0000000
--- a/test/dpdk_ip_hash/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all:test_dpdk_hash.so
-
-test_dpdk_hash.o:test_dpdk_hash.c
- gcc -c -o $@ -fPIC $^ -I./include -I/opt/MESA/include/MESA
-
-test_dpdk_hash.so:test_dpdk_hash.o
- gcc -o $@ -fPIC -shared $^
diff --git a/test/terminal_tag.c b/test/terminal_tag.c
deleted file mode 100644
index 1e89eb7..0000000
--- a/test/terminal_tag.c
+++ /dev/null
@@ -1,398 +0,0 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __FAVOR_BSD
-#define __FAVOR_BSD 1
-#endif
-
-#include "stream_base.h"
-#include "stream_internal.h"
-#include "stream_manage.h"
-#include "mesa_net.h"
-#include "project_requirement.h"
-#include "terminal_tag.h"
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-
-#define TERMINAL_TAG_SIZE_MAX (48)
-extern int project_req_terminal_tag_id;
-unsigned char terminal_tag_checksum_hash(unsigned char rand_num,
- unsigned int ip_addr, unsigned short dev_id)
-{
- unsigned char checksum_key = 0x5A;
- unsigned char *p;
-
- checksum_key += rand_num;
- p = (unsigned char *)&ip_addr;
- checksum_key += p[0];
- checksum_key += p[1];
- checksum_key += p[2];
- checksum_key += p[3];
- p = (unsigned char *)&dev_id;
- checksum_key += p[0];
- checksum_key += p[1];
-
- return checksum_key;
-}
-
-unsigned char terminal_tag_checksum(struct terminal_tag_t *terminal_tag,
- unsigned char checksum_key)
-{
- unsigned char checksum = 0x77;
- unsigned char *p = (unsigned char *)terminal_tag;
-
- terminal_tag->check_sum = 0;
-
- checksum += p[0];
- checksum += p[1];
- checksum += p[2];
- checksum += p[3];
- checksum += p[4];
- checksum += p[5];
- checksum += p[6];
- checksum += p[7];
- checksum += p[8];
- checksum += p[9];
- checksum += checksum_key;
-
- return checksum;
-}
-
-unsigned char terminal_tag_encrypt_hash(unsigned char rand_num, unsigned int ip_addr)
-{
- unsigned char encrypt_key = 0xA5;
- unsigned char *p;
-
- encrypt_key ^= rand_num;
- p = (unsigned char *)&ip_addr;
- encrypt_key ^= p[0];
- encrypt_key ^= p[1];
- encrypt_key ^= p[2];
- encrypt_key ^= p[3];
-
- return encrypt_key;
-}
-
-static void *terminal_tag_create_struct(int thread_num)
-{
- void *info = dictator_malloc(thread_num, TERMINAL_TAG_SIZE_MAX);
- memset(info, 0, TERMINAL_TAG_SIZE_MAX);
-
- return info;
-}
-
-static void terminal_tag_transform(struct terminal_tag_t *terminal_tag,
- struct streaminfo *stream, unsigned char *stack_tag_string)
-{
- char ip_str[16];
- unsigned char *mac;
- struct stream_tuple4_v4 *st4;
- int sip_addr;
- void *stream_tag_value;
-
- if(ADDR_TYPE_IPV4 == stream->addr.addrtype){
- st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- sip_addr = st4->saddr;
- }else{
- return; /* ��֧��ipv6 */
- }
-
- switch(terminal_tag->type)
- {
- case TERMINAL_ADDR_TYPE_MAC:
- mac = (unsigned char *)terminal_tag->local_addr.local_mac;
- snprintf((char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX, "%s:%05u:%02x%02x-%02x%02x-%02x%02x",
- "M",ntohs(terminal_tag->dev_id), mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);
- break;
-
- case TERMINAL_ADDR_TYPE_IP:
- inet_ntop(AF_INET, &terminal_tag->local_addr.local_ip.ipaddr, ip_str, 16);
- snprintf((char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX, "%s:%05u:%s",
- "I", ntohs(terminal_tag->dev_id), ip_str);
- break;
-
- case TERMINAL_ADDR_TYPE_TRACE:
- // to do!
- break;
-
- case TERMINAL_ADDR_TYPE_GLOBAL_SIP:
- break;
-
- default:
- inet_ntop(AF_INET, &sip_addr, ip_str, 16);
- snprintf((char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX, "%s:%s", "G:00000", ip_str);
- break;
- }
-
-#if 0
- if(terminal_tag->type < 2)
- {
- printf("Tagv4 is: %s\n", stream->terminal_tag);
- }
- //mac = (unsigned char *)terminal_tag;
- //printf("Clear-bin is: %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n",
- //mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[6],mac[7],mac[8],mac[9]);
-#endif
-
- stream_tag_value = terminal_tag_create_struct(stream->threadnum);
- strncpy((char *)stream_tag_value, (const char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX);
- project_req_add_struct(stream, project_req_terminal_tag_id, stream_tag_value);
-
- return;
-}
-
-static int terminal_tag_checksum_check(struct terminal_tag_t *terminal_tag_clear,
- struct streaminfo *stream, unsigned char *stack_tag_string)
-{
- unsigned char checksum_key;
- unsigned char raw_checksum, new_checksum;
- struct stream_tuple4_v4 *st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- int dip_addr;
-
- if(ADDR_TYPE_IPV4 == stream->addr.addrtype){
- st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- dip_addr = st4->daddr;
- }else{
- return -1; /* ��֧��ipv6 */
- }
-
- checksum_key = terminal_tag_checksum_hash(terminal_tag_clear->random,
- dip_addr,
- ntohs(terminal_tag_clear->dev_id));
-
- raw_checksum = terminal_tag_clear->check_sum;
-
- new_checksum = terminal_tag_checksum(terminal_tag_clear, checksum_key);
-
- if(raw_checksum != new_checksum)
- {
- //printf("Checksum error!\n");
- goto err; /* У��Ͳ��ԣ����ܴ�����󡢻򱻴۸ġ������α��� */
- }
-
- switch(terminal_tag_clear->type)
- {
- case TERMINAL_ADDR_TYPE_MAC:
- break;
-
- case TERMINAL_ADDR_TYPE_IP: /* IP����,���������ֽ�����������У�� */
- if(IP_STRUCT_MAGIC != terminal_tag_clear->local_addr.local_ip.ip_magic_num)
- {
- goto err;
- }
- break;
-
- default: /* �û���ǩ�豸���ӵı�־ֻ����MAC��IP */
- return -1;
- break;
- }
-
- terminal_tag_transform(terminal_tag_clear, stream, stack_tag_string);
- return 0;
-
-err:
- return -1;
-}
-
-/* �û���ǩ���� */
-static int terminal_tag_decrypt(struct terminal_tag_t *terminal_tag_enc,
- struct streaminfo *stream, unsigned char *stack_tag_string)
-{
- struct terminal_tag_t terminal_tag;
- unsigned char rand_num, encrypt_key;
- unsigned char *clear, *encrypt;
- struct stream_tuple4_v4 *st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- int dip_addr;
-
- if(ADDR_TYPE_IPV4 == stream->addr.addrtype){
- st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- dip_addr = st4->daddr;
- }else{
- return -1; /* ��֧��ipv6 */
- }
-
- /* copy��һ����ʱ�ռ䣬���޸�ԭʼ���ݰ� */
- memcpy(&terminal_tag, terminal_tag_enc, sizeof(struct terminal_tag_t));
-
-#if 0
- unsigned char * mac = (unsigned char *)&terminal_tag;
- printf("Encrypt-bin is: %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n",
- mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[6],mac[7],mac[8],mac[9]);
-#endif
-
- clear = (unsigned char *)&terminal_tag;
- encrypt = (unsigned char *)terminal_tag_enc;
-
- clear[0] = ror(encrypt[0], 4);
- rand_num = terminal_tag.random;
-
- encrypt_key = terminal_tag_encrypt_hash(rand_num, dip_addr);
-
- /* ������һ���ֽڣ�type��random�ֶβ�����˷�ʽ���� */
-
- clear[1] = encrypt[1] ^ encrypt_key;
- clear[2] = encrypt[2] ^ encrypt_key;
- clear[3] = encrypt[3] ^ encrypt_key;
- clear[4] = encrypt[4] ^ encrypt_key;
- clear[5] = encrypt[5] ^ encrypt_key;
- clear[6] = encrypt[6] ^ encrypt_key;
- clear[7] = encrypt[7] ^ encrypt_key;
- clear[8] = encrypt[8] ^ encrypt_key;
- clear[9] = encrypt[9] ^ encrypt_key;
-
- return terminal_tag_checksum_check(&terminal_tag, stream, stack_tag_string);
-}
-
-
-static int terminal_tag_trace(struct streaminfo *stream, unsigned char *stack_tag_string)
-{
- struct terminal_tag_t terminal_tag;
- /* ��Դϵͳ��ѯ */
- /* to do:
- terminal_tag_trace();
- if(err)
- {
- goto def_tag;
- }
- terminal_tag_clear->type = TERMINAL_ADDR_TYPE_TRACE;
- */
- terminal_tag.type = TERMINAL_ADDR_TYPE_GLOBAL_SIP;
- terminal_tag_transform(&terminal_tag, stream, stack_tag_string);
- return 0;
-}
-
-
-
-
-static int terminal_tag_set_ipv6(struct streaminfo *stream, unsigned char *stack_tag_string, const void *rawippkt)
-{
- void *stream_tag_value;
- const struct mesa_ip6_hdr *ip6h = (struct mesa_ip6_hdr *)rawippkt;
-
- /* ��ʱʹ��IPv6��Դ��ַ��Ϊv6_tag */
- if(NULL == inet_ntop(AF_INET6, &ip6h->ip6_src, (char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX))
- {
- return -1;
- }
-
- stream_tag_value = terminal_tag_create_struct(stream->threadnum);
- strncpy((char *)stream_tag_value, (const char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX);
- project_req_add_struct(stream, project_req_terminal_tag_id, stream_tag_value);
-
- return 0;
-}
-
-
-/* �豸��ȡ�û�TAG, �ж��Ƿ���ȷ�����ܺ����stream�ṹ�� */
-static int terminal_tag_probe(struct streaminfo *stream, struct tcphdr *api_tcp_hdr,
- const void *rawippkt)
-{
- struct mesa_tcp_hdr *this_tcphdr;
- unsigned char *stream_tag_string = NULL;
- unsigned char stack_tag_string[TERMINAL_TAG_SIZE_MAX];
- u_int8_t *option;
- int tcp_hdr_len;
- u_int16_t option_len;
- int ret = 0;
-
- if(likely(-1 == project_req_terminal_tag_id)){
- return -1;
- }
-
- this_tcphdr = (struct mesa_tcp_hdr *)api_tcp_hdr;
- option = (u_int8_t *)this_tcphdr + 20; /* TCP��׼ͷ������=20 */
- tcp_hdr_len = 4 * this_tcphdr->th_off;
-
- stream_tag_string = (unsigned char *)project_req_get_struct(stream, project_req_terminal_tag_id);
- if((NULL != stream_tag_string) && (stream_tag_string[0] != '\0')){ /* �Ѿ���ȡ����ǩ */
- return 0;
- }
-
- if(ADDR_TYPE_IPV6 == stream->addr.addrtype)
- {
- return terminal_tag_set_ipv6(stream, stack_tag_string, rawippkt);
- }else if(ADDR_TYPE_IPV4 != stream->addr.addrtype){
- return -1;
- }
-
- if(this_tcphdr->th_flags != TH_SYN)
- {
- ret = -2;
- goto trace_tag;
- }
- tcp_hdr_len -= 20;
- if(tcp_hdr_len < TCP_SYN_TAG_LEN)
- {
- ret = -3;
- goto trace_tag;
- }
-
- while(tcp_hdr_len > 0)
- {
- switch(*option)
- {
- case 0: /* type=0ԭ����ѡ���������׷������ѡ�����Ҫ���������� */
- case 1:
- option_len = 1;
- break;
-
- case TCP_SYN_TAG_TYPE:
- option_len = *(option+1);
- if(TCP_SYN_TAG_LEN == option_len)
- {
- ret = terminal_tag_decrypt((struct terminal_tag_t *)(option+2), stream, stack_tag_string);
- if(0 == ret)
- {
- return 0;
- }
- }
- break;
-
- default:
- option_len = *(option+1);
- }
- if(0 == option_len)
- {
- goto trace_tag;
- }
- if(option_len > tcp_hdr_len)
- {
- goto trace_tag;
- }
- option += option_len;
- tcp_hdr_len -= option_len;
- }
-
-trace_tag:
- return terminal_tag_trace(stream, stack_tag_string);
- //return -1;
-}
-
-
-char terminal_tag_tcp_all_entry(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a_packet)
-{
- const struct mesa_ip4_hdr *ip4h = (const struct mesa_ip4_hdr *)a_packet;
-
- if(OP_STATE_PENDING == a_tcp->pktstate){
- terminal_tag_probe(a_tcp, (struct tcphdr *)((char *)a_packet + ip4h->ip_hl*4), a_packet);
- }
-
- return APP_STATE_DROPME;
-}
-
-int terminal_tag_init(void)
-{
- return 0;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
diff --git a/test/terminal_tag.h b/test/terminal_tag.h
deleted file mode 100644
index 335ce39..0000000
--- a/test/terminal_tag.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef _TERMINAL_TAG_H_
-#define _TERMINAL_TAG_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "mesa_net.h"
-#include <stdio.h>
-#include <sys/types.h>
-
-#define TERMINAL_MODULE_NAME "terminal_tag"
-
-#define TCP_SYN_TAG_TYPE (0xF1)
-#define TCP_SYN_TAG_LEN (12) /* 6BMAC+2B�豸ID+1B����+1BУ���+1B����+1B���� */
-#define TCP_HDR_MAX_LEN (60) /* TCPͷ����󳤶� */
-
-#define rol(x,n) (((x)<<(n)) | ((x)>>(8*sizeof(x)-(n))))
-#define ror(x,n) (((x)>>(n)) | ((x)<<(8*sizeof(x)-(n))))
-
-
-#define IP_STRUCT_MAGIC (0x8633)
-struct local_ip_t{
- unsigned int ipaddr; /* �ն��豸����IP, ������ */
- unsigned short ip_magic_num; /* ħ��,�洢IPʱ����������ֽ�,��������֤ */
-}BYTE_ALIGNED(1); //sizeof(this)=6B
-
-union local_addr_t{
- unsigned char local_mac[6]; /* �ն��豸MAC��ַ */
- struct local_ip_t local_ip; /* �ն��豸����IP�ṹ */
-}BYTE_ALIGNED(1); //sizeof(this)=6B
-
-#define TERMINAL_ADDR_TYPE_MAC (0)
-#define TERMINAL_ADDR_TYPE_IP (1)
-#define TERMINAL_ADDR_TYPE_TRACE (2)
-#define TERMINAL_ADDR_TYPE_GLOBAL_SIP (3)
-struct terminal_tag_t{
-#if __BYTE_ORDER == __BIG_ENDIAN
- unsigned char type:2; /* ����������ȡ��ʽ, 1:MAC; 2:IP */
- unsigned char random:6; /* �����,���ڼ��� */
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned char random:6; /* �����,���ڼ��� */
- unsigned char type:2; /* ����������ȡ��ʽ, 1:MAC; 2:IP */
-#endif
-
- unsigned char check_sum; /* У��ͣ�������������֤����α�� */
- unsigned short dev_id; /* �豸ID (����ID���������� */
- union local_addr_t local_addr; /* �豸������ַ�ṹ */
-}BYTE_ALIGNED(1); //sizeof(this)=10B
-
-extern unsigned char terminal_tag_encrypt_hash(unsigned char rand_num, unsigned int ip_addr);
-extern unsigned char terminal_tag_checksum_hash(unsigned char rand_num, unsigned int ip_addr, unsigned short dev_id);
-extern unsigned char terminal_tag_checksum(struct terminal_tag_t *terminal_tag,unsigned char checksum_key);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
diff --git a/tools/tun_transparent/Makefile b/tools/tun_transparent/Makefile
deleted file mode 100644
index a4a393b..0000000
--- a/tools/tun_transparent/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-obj-m := sapp_tun_bridge_kmodule.o
-
-modules-objs:= sapp_tun_bridge_kmodule.o
-
-KDIR := /lib/modules/`uname -r`/build
-
-PWD := $(shell pwd)
-
-default:
- make -C $(KDIR) M=$(PWD) modules
-
-clean:
- rm -rf *.o *.ko *.mod.c .tmp_versions \ No newline at end of file
diff --git a/tools/tun_transparent/Makefile.user b/tools/tun_transparent/Makefile.user
deleted file mode 100644
index 6263278..0000000
--- a/tools/tun_transparent/Makefile.user
+++ /dev/null
@@ -1,39 +0,0 @@
-CC = gcc
-CCC = g++
-CFLAGS = -g -fPIC
-CFLAGS += -D__USE_BSD=1 -D__FAVOR_BSD=1 -D__USE_MISC=1 -D_GNU_SOURCE=1
-CFLAGS += $(OPTFLAGS)
-OBJECTS = test_app_sapp.o trace_delay.o terminal_tag.o g_device_plug.o
-MODULES =
-
-BIN_PATH = ../bin/
-
-TARGET = sapp_tun_bridge_user
-
-INCS =
-INCS += -I ../include
-INCS += -I../include/private
-INCS += -I../include/public
-INCS += -I../include/public/stream_inc/
-INCS += -I../include/support/
-INCS += -I/opt/MESA/include
-INCS += -I/opt/MESA/include/MESA
-
-
-.PHONY: all
-all: $(TARGET)
-
-
-sapp_tun_bridge_user:sapp_tun_bridge_user.c
- #gcc -o $@ $^ -g -O0 $(CFLAGS) -lpthread -lpcap -lnetfilter_queue -lnfnetlink
- gcc -o $@ $^ -g -O0 $(CFLAGS) -lpthread -lpcap
-
-.c.o:
- $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-
-.cpp.o:
- $(CCC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-
-clean:
- rm -f $(TARGET) $(OBJECTS)
-