summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijia <[email protected]>2020-06-02 21:05:34 +0800
committerlijia <[email protected]>2020-06-02 21:05:34 +0800
commit01ffdcbe04db4cb0ad1e873bfeea389bd28490d4 (patch)
tree5e1a1c4da6021becf3bc4eeb1bfc746730a0ea87
parent8909c32e3697411a32778fc8384ca082de4b94e4 (diff)
parent382f6f5569834c3d1115722c160e126afd071841 (diff)
Merge branch 'fix-udp-drop-stream' into sapp_v4.0_develop
-rw-r--r--CMakeLists.txt5
-rw-r--r--bin/conf.bak/inline_device_measure/to_11.141.conf (renamed from bin/conf.bak/wangyan_gdev_measure/to_11.141.conf)4
-rw-r--r--bin/conf.bak/inline_device_measure/to_MESA_dev.conf (renamed from bin/conf.bak/wangyan_gdev_measure/to_MESA_dev.conf)4
-rw-r--r--bin/etc/sapp.toml4
-rw-r--r--include/private/packet_io.h2
-rw-r--r--include/private/packet_io_internal.h2
-rw-r--r--include/private/sapp_declaration.h1
-rw-r--r--include/private/sapp_global_val.h7
-rw-r--r--include/private/stream_internal.h5
-rw-r--r--include/public/stream_inc/stream_inject.h17
-rw-r--r--src/config/config_parse.cpp12
-rw-r--r--src/dealpkt/callapp.c13
-rw-r--r--src/dealpkt/deal_tcp.c2
-rw-r--r--src/dealpkt/deal_udp.c7
-rw-r--r--src/dealpkt/plug_support.c20
-rw-r--r--src/entry/sapp_init.c6
-rw-r--r--src/inner_plug/CMakeLists.txt4
-rw-r--r--src/inner_plug/Makefile9
-rw-r--r--src/inner_plug/g_device_plug.c2
-rw-r--r--src/inner_plug/sapp_assistant.cpp17
-rw-r--r--src/inner_plug/wangyan_keepalive_plug.c.bak966
-rw-r--r--src/inner_plug/wy_keepalive.conf (renamed from src/inner_plug/wangyan_keepalive.conf)0
-rw-r--r--src/inner_plug/wy_keepalive_plug.c (renamed from src/inner_plug/wangyan_keepalive_plug.c)286
-rw-r--r--src/inner_plug/wy_keepalive_plug_with_libping.c (renamed from src/inner_plug/wangyan_keepalive_plug_with_libping.c)158
-rw-r--r--src/packet_io/CMakeLists.txt2
-rw-r--r--src/packet_io/Makefile2
-rw-r--r--src/packet_io/packet_io.c10
-rw-r--r--src/packet_io/packet_io_lib_load.c3
-rw-r--r--src/packet_io/packet_io_marsio.c10
-rw-r--r--src/packet_io/sapp_compat_old_papp_api.c (renamed from src/packet_io/sapp_compat_wangyan_api.c)32
-rw-r--r--src/packet_io/sendpacket.c108
-rw-r--r--src/plugin/src/plugin.c4
-rw-r--r--test/CMakeLists.txt10
-rw-r--r--test/Makefile14
-rw-r--r--test/inline_device_measurement.c (renamed from test/wangyan_gdev_measurement.c)111
-rw-r--r--test/test_app_sapp.c106
-rw-r--r--test/test_sendpacket_performance.c111
-rw-r--r--test/test_wy.c (renamed from test/test_wangyan.c)28
-rw-r--r--test/wy_demo.c (renamed from test/wangyan_demo.c)2
39 files changed, 727 insertions, 1379 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c191b08..cbca796 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,8 +19,8 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG")
endif()
-set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Werror -DHIGH_PERF=1")
-set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Werror -DHIGH_PERF=1")
+set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Werror -O2 -DNDEBUG -DHIGH_PERF=1")
+set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Werror -O2 -DNDEBUG -DHIGH_PERF=1")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG -DHIGH_PERF=0")
@@ -134,7 +134,6 @@ add_definitions(${CAPTURE_DEFINITIONS} ${MEM_POOL_DEFINITIONS} -D__FAVOR_BSD=1
set(SAPP_DEPEND_DYN_LIB MESA_handle_logger MESA_htable pthread MESA_field_stat2 cjson)
-set(CMAKE_C_FLAGS_RELEASE "-Werror")
file(MD5 ${PROJECT_SOURCE_DIR}/include/public/stream_inc/stream_base.h MD5_STREAM_BASE)
file(MD5 ${PROJECT_SOURCE_DIR}/include/public/stream_inc/stream_control.h MD5_STREAM_CONTROL)
diff --git a/bin/conf.bak/wangyan_gdev_measure/to_11.141.conf b/bin/conf.bak/inline_device_measure/to_11.141.conf
index 4b4bb40..fab025a 100644
--- a/bin/conf.bak/wangyan_gdev_measure/to_11.141.conf
+++ b/bin/conf.bak/inline_device_measure/to_11.141.conf
@@ -20,7 +20,7 @@ SRC_IN_MAC:00:0C:29:86:83:29
DST_IN_MAC:e8:61:1f:13:70:7a
-#wangyan dev measure plug config
+#inline device measure plug config
#send packet transport type only support tcp or udp
[plug]
transport_type=tcp
@@ -37,5 +37,5 @@ inner_dip=192.168.11.200
inner_sport=53
inner_dport=8888
-payload=wangyan_test_plug_1
+payload=test123
diff --git a/bin/conf.bak/wangyan_gdev_measure/to_MESA_dev.conf b/bin/conf.bak/inline_device_measure/to_MESA_dev.conf
index 839b4ac..293c4c8 100644
--- a/bin/conf.bak/wangyan_gdev_measure/to_MESA_dev.conf
+++ b/bin/conf.bak/inline_device_measure/to_MESA_dev.conf
@@ -20,7 +20,7 @@ SRC_IN_MAC:00:50:b6:5e:9d:a8
DST_IN_MAC:e8:61:1f:13:70:7a
-#wangyan dev measure plug config
+#inline device measure plug config
#send packet transport type only support tcp or udp
[plug]
transport_type=tcp
@@ -37,5 +37,5 @@ inner_sip=192.168.11.141
inner_sport=9999
inner_dport=80
-payload=wangyan_test_plug_MESA_dev
+payload=testtesttest
diff --git a/bin/etc/sapp.toml b/bin/etc/sapp.toml
index a599265..6f9eb9c 100644
--- a/bin/etc/sapp.toml
+++ b/bin/etc/sapp.toml
@@ -10,9 +10,13 @@ instance_name = "sapp_v4.0"
[CPU]
worker_threads=1
+send_only_threads_max=16
### note, bind_mask, if you do not want to bind thread to special CPU core, keep it empty as []
bind_mask=[]
+[MEM]
+dictator_enable=1
+
[PACKET_IO]
[packet_io.feature]
### note, used to represent inbound or outbound direction value,
diff --git a/include/private/packet_io.h b/include/private/packet_io.h
index 4caaa5e..64d9b9c 100644
--- a/include/private/packet_io.h
+++ b/include/private/packet_io.h
@@ -116,6 +116,7 @@ typedef struct{
int (*dl_io_register_exit_cb)(PACKET_IO_EXIT_CB_T exit_fun);
int (*dl_io_get_version)(void);
void * (*dl_io_device_alias)(unsigned int target_id, char *device_args);
+ int (*dl_io_send_only_thread_init)(void); /* 2020-06-01 lijia add, ������д����Ķ��������߳�, ��Ҫ���ô˽ӿڰ󶨵��ض�CPU������ */
}dl_io_fun_list_t;
/* ���º����������, ������ȷ���������������� */
@@ -146,6 +147,7 @@ unsigned char *packet_io_get_sendbuf(int type, int thread_num);
void packet_io_free_sendbuf(int type, int thread_num);
int packet_io_set_send_dev(const char *send_dev);
int packet_io_set_gateway_mac(const char *gateway_mac);
+int packet_io_send_only_thread_init(void);
extern void MESA_runtime_log(int level, char * module, char * fmt, ...);
diff --git a/include/private/packet_io_internal.h b/include/private/packet_io_internal.h
index 4321a82..ad2875a 100644
--- a/include/private/packet_io_internal.h
+++ b/include/private/packet_io_internal.h
@@ -295,7 +295,7 @@ extern int marsio_dl_io_register_cb(PACKET_IO_CB_T fun);
extern int marsio_dl_io_register_exit_cb(PACKET_IO_EXIT_CB_T exit_fun);
extern int marsio_dl_io_get_version(void);
extern void * marsio_dl_io_device_alias(unsigned int target_id, char *device_args);
-
+extern int marsio_dl_io_send_only_thread_init(void);
/********************** marsio funcitons for dynamic link *********************/
/********************** tun funcitons for dynamic link ***********************/
diff --git a/include/private/sapp_declaration.h b/include/private/sapp_declaration.h
index 5bb924b..a53f1fe 100644
--- a/include/private/sapp_declaration.h
+++ b/include/private/sapp_declaration.h
@@ -59,6 +59,7 @@ 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 812cadd..e1e6d01 100644
--- a/include/private/sapp_global_val.h
+++ b/include/private/sapp_global_val.h
@@ -7,12 +7,18 @@
typedef struct{
int worker_threads;
+ int send_only_threads_max_num; /* �������߳��������, �Dz����̬������, sapp�����޷�Ԥ֪, ֻ��������ֵ */
int bind_mask_array_num;
long bind_mask_array[SAPP_MAX_THREADS];
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];
}sapp_config_system_t;
@@ -182,6 +188,7 @@ 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/stream_internal.h b/include/private/stream_internal.h
index b9c2c4f..4f358cc 100644
--- a/include/private/stream_internal.h
+++ b/include/private/stream_internal.h
@@ -20,14 +20,14 @@
#define USE_RBTREE_INSTEAD_LIST (0) /* ��HASH��ͻʱ, ʹ�ú������������, ������������±��� */
#define USE_LINUX_KERNEL_HASH_ALGO (1) /* ʹ��LINUX�ں�HASH�㷨 */
-#define SAPP_INSECTICIDE (0) /* ɱ��(DEBUG)��ʱ����, ������Ī�������BUGʱ��ʱ����, ���緢������, �����糬�� */
+#define SAPP_INSECTICIDE (1) /* ɱ��(DEBUG)��ʱ����, ������Ī�������BUGʱ��ʱ����, ���緢������, �����糬�� */
//#define CYCLE_PKT_DUMP (1 && DEBUG) /* 2015-04-16 lijia add, ������������޹�coredump, ���Ҳ���ԭ�� */
#define CYCLE_PKT_DUMP (1) /* 2015-04-16 lijia add, ������������޹�coredump, ���Ҳ���ԭ�� */
#define PCAP_CAP_FROM_IP (0) /* Ϊ��ģ��pag�����߻���, ��pcapҲģ���IPv4ͷ����ʼ��ȡ */
-#define NON_PKT_THREAD_SEND_QUEUE (64) /* �ǰ������߳�����Ͷ������� */
+//#define NON_PKT_THREAD_SEND_QUEUE (64) /* �����������߳�����Ͷ������� */
#define IKNOW_ENABLE (0)
@@ -226,6 +226,7 @@ struct udpdetail_private
struct udpdetail udpdetail_public;
void *apme; //Ӧ�ò�������
struct udp_flow_stat *flow_stat; /* 2015-12-28 lijia add, udpdetail�е���ϸ����(64bit), ʵ���ڴ������ͷ���projectģ�����, ����ΪNULL */
+ UCHAR drop_stream_flag; //2020-06-02 lijia add, ����ͬDROPPKT, ֻ����������������stream
};
/* 2015-02-26 lijia add, for stream-addr-list ntop, pton */
diff --git a/include/public/stream_inc/stream_inject.h b/include/public/stream_inc/stream_inject.h
index c386cb6..1dc0e46 100644
--- a/include/public/stream_inc/stream_inject.h
+++ b/include/public/stream_inc/stream_inject.h
@@ -101,6 +101,23 @@ int MESA_kill_connection_feedback(struct streaminfo *stream, const void *raw_pkt
*/
unsigned char MESA_dir_reverse(unsigned char raw_route_dir);
+/***************************************************************************************
+ NOTE:
+ �ڱ���ģʽ��, ����������route_dir�ľ���ֵ, ֻ��Ҫ����ͬ��ͷ��򼴿�,
+ ��������������Ҫ��ȷ����route_dir��0����1, �������������ģʽ��ͬ, ������ʱ��仯,
+ �������ô˽ӿ�, ���ֻ�贫����������ķ���, ���ص�ǰ��·��link route dir,
+ ע��etc/sapp.toml inbound_route_dirҪ������ȷ.
+
+ args: ��ʾ����Ŀ������ڵ�ǰ�豸���ڵĵ���λ��,
+ 'E' or 'e': ��ʾ���������Ǵ�Internal to External.
+ 'I' or 'i': ��ʾ���������Ǵ�External to Internal.
+
+ return value:
+ 0 or 1: success.
+ -1 : error.
+****************************************************************************************/
+int MESA_dir_human_to_link(int human_dir);
+
/*
ARG:
stream: ���ṹ��ָ��;
diff --git a/src/config/config_parse.cpp b/src/config/config_parse.cpp
index 0ac9b28..5ef8b0a 100644
--- a/src/config/config_parse.cpp
+++ b/src/config/config_parse.cpp
@@ -453,9 +453,10 @@ static int config_sanity_check(void)
sleep(1);
}
- if((pconfig->cpu.bind_mask_array_num > 0) &&(pconfig->cpu.worker_threads != pconfig->cpu.bind_mask_array_num)){
- printf("\033[41m[Error]etc/sapp.toml->CPU->bind_mask value is not match etc/sapp.toml->CPU->worker_threads!\033[0m\n");
- printf("\033[41m for example, worker_threads=8, bind_mask shoule be [1,2,3,4,5,6,7,8] etc.\033[0m\n");
+ if((pconfig->cpu.bind_mask_array_num > 0)
+ &&(pconfig->cpu.worker_threads + pconfig->cpu.send_only_threads_max_num != pconfig->cpu.bind_mask_array_num)){
+ printf("\033[41m[Error]etc/sapp.toml->CPU->bind_mask value is not match etc/sapp.toml->CPU->worker_threads + CPU->send_only_threads_max!\033[0m\n");
+ printf("\033[41m for example, worker_threads=4, send_only_threads_max=4, bind_mask should be [1,2,3,4,5,6,7,8].\033[0m\n");
return -1;
}
@@ -574,9 +575,14 @@ int sapp_parse_config(void)
/******************************* CPU *********************************/
tomlc99_wrap_load_int_def(default_config_file, (char *)"CPU", (char *)"worker_threads", (int *)&pconfig->cpu.worker_threads, 1);
+ tomlc99_wrap_load_int_def(default_config_file, (char *)"CPU", (char *)"send_only_threads_max", (int *)&pconfig->cpu.send_only_threads_max_num, 0);
+
pconfig->cpu.bind_mask_array_num = SAPP_MAX_THREADS;
tomlc99_wrap_load_long_array(default_config_file, (char *)"CPU", (char *)"bind_mask", pconfig->cpu.bind_mask_array, &pconfig->cpu.bind_mask_array_num);
+ /******************************* MEM *********************************/
+ tomlc99_wrap_load_int_def(default_config_file, (char *)"MEM", (char *)"dictator_enable", (int *)&pconfig->mem.dictator_enable, 1);
+
/******************************* PACKET_IO ******************************/
/******************************* packet_io.feature ******************************/
tomlc99_wrap_load_string_def(default_config_file, (char *)"packet_io.feature", (char *)"BSD_packet_filter", str_tmp, NAME_MAX, "");
diff --git a/src/dealpkt/callapp.c b/src/dealpkt/callapp.c
index bff17fc..cfee3a4 100644
--- a/src/dealpkt/callapp.c
+++ b/src/dealpkt/callapp.c
@@ -266,10 +266,12 @@ char plugin_call_streamentry(int type,StreamFunInfo *pFunInfo,struct streaminfo
}
#endif
+#if 0
if(g_business_plug_info!=NULL)
{
plug_record_start_time(g_business_plug_info->plugid, thread_seq);
}
+#endif
if(type==CALL_FUN_TYPE_RAW)
{
rec=((SAPP_STREAM_FUN_T)pFunInfo->pfun)(a_stream,transport_hdr,a_packet,&(pFunInfo->pAppInfo));
@@ -278,11 +280,13 @@ char plugin_call_streamentry(int type,StreamFunInfo *pFunInfo,struct streaminfo
{
rec=((STREAM_CB_FUN_T)pFunInfo->pfun)(a_stream,&(pFunInfo->pAppInfo),thread_seq, a_packet);
}
-
+
+#if 0
if(g_business_plug_info!=NULL)
{
plug_record_end_time(g_business_plug_info->plugid, thread_seq);
}
+#endif
#if SAPP_INSECTICIDE
if(a_packet != NULL){
@@ -304,11 +308,13 @@ char plugin_call_ipentry(int type,IPv4_CB_FUN_T stream_fun,SAPP_PKT_CB_FUN_T sap
int thread_num,unsigned char routedir, const raw_pkt_t *raw_pkt)
{
char rec;
-
+
+#if 0
if(g_business_plug_info!=NULL)
{
plug_record_start_time(g_business_plug_info->plugid, thread_num);
}
+#endif
if(type==CALL_FUN_TYPE_RAW)
{
rec=stream_fun(pfstream,routedir,thread_num,this_layer_hdr);
@@ -317,12 +323,13 @@ char plugin_call_ipentry(int type,IPv4_CB_FUN_T stream_fun,SAPP_PKT_CB_FUN_T sap
{
rec=sapp_fun(pfstream,this_layer_hdr,raw_pkt);
}
-
+#if 0
if(g_business_plug_info!=NULL)
{
plug_record_end_time(g_business_plug_info->plugid, thread_num);
}
+#endif
/* if(g_business_plug_type==PLUGTYPE_JC)
{
rec=rec|APP_STATE_DROPPKT;
diff --git a/src/dealpkt/deal_tcp.c b/src/dealpkt/deal_tcp.c
index eb93696..94a3dfe 100644
--- a/src/dealpkt/deal_tcp.c
+++ b/src/dealpkt/deal_tcp.c
@@ -1170,7 +1170,7 @@ static void tcp_change_stream_tonouse(struct streamindex *pindex)
//void tcp_free_stream(struct streamindex *pindex)
//add raw_pkt by lqy 2015-01-07
-/* 2017-07-14 lijia add return value, for wangyan master and slave mode, last packet also need assign forward action */
+/* 2017-07-14 lijia add return value, for WY master and slave mode, last packet also need assign forward action */
int tcp_free_stream(struct streamindex *pindex, const void *this_ip_hdr, const void *transport_hdr, const raw_pkt_t *raw_pkt)
{
struct stream_list *plist=NULL;
diff --git a/src/dealpkt/deal_udp.c b/src/dealpkt/deal_udp.c
index d8398ef..8bf5fde 100644
--- a/src/dealpkt/deal_udp.c
+++ b/src/dealpkt/deal_udp.c
@@ -538,6 +538,11 @@ static int dealipv4udppkt(struct streamindex *pindex, const struct mesa_ip4_hdr
pstream_pr=&(a_index->stream);
pstream=&(pstream_pr->stream_public);
//pstream->addr.pktipfragtype = pstream->stream_public.addr.pktipfragtype; /* 2015-11-04 lijia add, IP��Ƭ���͸��� */
+ pdetail_pr=(struct udpdetail_private *)(pstream->pdetail);
+
+ if(unlikely(pdetail_pr->drop_stream_flag != 0)){ /* 2020-06-02 lijia add */
+ return DROP;
+ }
update_polling_inject_context(pstream_pr, raw_pkt);
@@ -550,7 +555,7 @@ static int dealipv4udppkt(struct streamindex *pindex, const struct mesa_ip4_hdr
#endif
pstream_pr->offset_to_ip_hdr = (char *)udph - (char *)this_iphdr;
pstream_pr->raw_pkt = raw_pkt; /* 2014-12-30 lijia add */
- pdetail_pr=(struct udpdetail_private *)(pstream->pdetail);
+
ret=stream_process_udp(pstream,(const void *)this_iphdr, (const void *)udph, raw_pkt,&(pdetail_pr->apme),&(pstream->opstate));
udp_cleardata(pstream);
}
diff --git a/src/dealpkt/plug_support.c b/src/dealpkt/plug_support.c
index e366925..172a93c 100644
--- a/src/dealpkt/plug_support.c
+++ b/src/dealpkt/plug_support.c
@@ -9,7 +9,7 @@
extern "C" {
#endif
-int G_DICTATOR_SW = 1;
+//int G_DICTATOR_SW = 1;
//extern int g_packet_io_thread_num;
extern const raw_ipfrag_list_t *get_raw_frag_list(const struct streaminfo *stream);
@@ -630,9 +630,18 @@ int MESA_set_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o
case MSO_DROP_STREAM:
{
int drop_flag = *((int *)opt_val);
- struct tcpdetail_private *pdetail_pr=(struct tcpdetail_private*)(pstream->pdetail);
- pdetail_pr->drop_stream_flag = (drop_flag != 0 ? 1:0);
- ret = 0;
+ if(STREAM_TYPE_TCP == pstream->type){
+ struct tcpdetail_private *tcp_pdetail_pr=(struct tcpdetail_private*)(pstream->pdetail);
+ tcp_pdetail_pr->drop_stream_flag = (drop_flag != 0 ? 1:0);
+ ret = 0;
+ }else if(STREAM_TYPE_UDP == pstream->type){
+ struct udpdetail_private *udp_pdetail_pr=(struct udpdetail_private*)(pstream->pdetail);
+ udp_pdetail_pr->drop_stream_flag = (drop_flag != 0 ? 1:0);
+ ret = 0;
+ }else{
+ sapp_runtime_log(RLOG_LV_FATAL, "MESA_set_stream_opt() MSO_DROP_STREAM error: stream type is not tcp or udp!\n");
+ ret = -1;
+ }
}
break;
@@ -1182,6 +1191,9 @@ void dictator_free(int thread_seq,void *pbuf)
{
free(pbuf);
}
+#if SAPP_INSECTICIDE
+ *((char *)pbuf) = 0xFE;
+#endif
}
void *dictator_realloc(int thread_seq, void *ptr, size_t size)
diff --git a/src/entry/sapp_init.c b/src/entry/sapp_init.c
index ccb4e69..2d60388 100644
--- a/src/entry/sapp_init.c
+++ b/src/entry/sapp_init.c
@@ -23,7 +23,7 @@ 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 int G_DICTATOR_SW;
extern struct global_stream **G_MESA_GLOBAL_STREAM;
//static int __times = 0;
//int g_timestamp_record_sw = 0;
@@ -35,7 +35,7 @@ int g_reverse_ethernet_addr_sw;
//extern int g_kill_tcp_remedy_sw;
extern int g_encapsulate_with_ddp;
extern int g_encapsulate_with_L2E; /* ʹ��DDPЭ���װ��x27ԭʼIP�� */
-extern int G_DICTATOR_SW;
+
extern int g_PollingFunNum;
extern int packet_io_set_ipv6_raw_socket_enable(int op_switch);
extern const char *stream_addr_list_ntop_outward(const struct streaminfo *pstream);
@@ -104,7 +104,7 @@ int MESA_platform_init(int argc, char *argv[])
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);
+ //MESA_load_profile_int_def("conf/main.conf","Module", "dictator_switch", &G_DICTATOR_SW, 1);
sapp_dictator_init();
//MESA_load_profile_int_def((char *)"conf/main.conf", (char *)"ShowStatInfo", (char *)"platform_log_level", &g_sapp_log_level, 10);
diff --git a/src/inner_plug/CMakeLists.txt b/src/inner_plug/CMakeLists.txt
index ebc7b34..d1648d6 100644
--- a/src/inner_plug/CMakeLists.txt
+++ b/src/inner_plug/CMakeLists.txt
@@ -24,8 +24,8 @@ set_target_properties(pptp_protocol_plug PROPERTIES PREFIX "")
add_library(isakmp_protocol_plug SHARED isakmp_protocol_plug_add_nat.c)
set_target_properties(isakmp_protocol_plug PROPERTIES PREFIX "")
-#add_library(wangyan_keepalive_plug SHARED wangyan_keepalive_plug.c)
-#set_target_properties(wangyan_keepalive_plug PROPERTIES PREFIX "")
+#add_library(wy_keepalive_plug SHARED wy_keepalive_plug.c)
+#set_target_properties(wy_keepalive_plug PROPERTIES PREFIX "")
add_library(g_device_plug SHARED g_device_plug.c)
set_target_properties(g_device_plug PROPERTIES PREFIX "")
diff --git a/src/inner_plug/Makefile b/src/inner_plug/Makefile
index c301717..0dbf10f 100644
--- a/src/inner_plug/Makefile
+++ b/src/inner_plug/Makefile
@@ -27,7 +27,7 @@ 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 += wangyan_keepalive_plug.so
+TARGET += wy_keepalive_plug.so
OBJS=
@@ -126,17 +126,16 @@ g_device_plug.so: g_device_plug.o
mkdir -p $(RELEASE_PLT_PATH)/g_device_plug;
cp $@ $(RELEASE_PLT_PATH)/g_device_plug/
-wangyan_keepalive_plug.so:wangyan_keepalive_plug.c
+wy_keepalive_plug.so:wy_keepalive_plug.c
$(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES) $(H_DIR) $(LIB);
- mkdir -p $(RELEASE_PLT_PATH)/wangyan_keepalive_plug;
- cp $@ $(RELEASE_PLT_PATH)/wangyan_keepalive_plug/;
+ 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;
- cp $@ /opt/MESA/lib/;
+
libanti_flood_hijack.so:anti_flood_plug.o anti_flood_hijack.o
$(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES);
diff --git a/src/inner_plug/g_device_plug.c b/src/inner_plug/g_device_plug.c
index b80b668..d29f4fa 100644
--- a/src/inner_plug/g_device_plug.c
+++ b/src/inner_plug/g_device_plug.c
@@ -2,7 +2,7 @@
extern "C" {
#endif
/*
- ��wangyanƽ̨��������, �Ƿ���GDEV�����Ǹ��ݲ��������״̬��̬����, �������ٹ̶�һֱ����,
+ ��WY��Ŀ��������, �Ƿ���GDEV�����Ǹ��ݲ��������״̬��̬����, �������ٹ̶�һֱ����,
���Խ�GDEV-KEEPALIVE���ܴ�ƽ̨�а���,
���ص�IP��UDP�������ԭ�б����.
diff --git a/src/inner_plug/sapp_assistant.cpp b/src/inner_plug/sapp_assistant.cpp
index b51493e..033e292 100644
--- a/src/inner_plug/sapp_assistant.cpp
+++ b/src/inner_plug/sapp_assistant.cpp
@@ -21,7 +21,7 @@ extern char g_app_instance_name[64];
//extern int g_timestamp_record_sw;
static pthread_mutex_t g_plug_Independent_thread_mutex;
-static pthread_t g_plug_Independent_thread_pid[NON_PKT_THREAD_SEND_QUEUE];
+static pthread_t *g_plug_Independent_thread_pid;
static const unsigned char G_BROADCAST_ADDR[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
@@ -353,7 +353,7 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va
pthread_mutex_lock(&g_plug_Independent_thread_mutex);
/* Ϊ����һ���̶߳�ε��ô˽ӿ�, �Ȳ���֮ǰ�Ƿ񱣴�� */
- for(i = 0; i < NON_PKT_THREAD_SEND_QUEUE; i++){
+ for(i = 0; i < sapp_global_val->config.cpu.send_only_threads_max_num; i++){
if(g_plug_Independent_thread_pid[i] == this_pid){
id_index = i;
break;
@@ -361,15 +361,15 @@ int sapp_get_platform_opt(enum sapp_platform_opt opt, void *opt_val, int *opt_va
}
if(-1 == id_index){ /* ��ǰ�̵߳�һ�δ���, û�ҵ� */
- for(i = 0; i < NON_PKT_THREAD_SEND_QUEUE; i++){
+ for(i = 0; i < sapp_global_val->config.cpu.send_only_threads_max_num; i++){
if(0 == g_plug_Independent_thread_pid[i]){
g_plug_Independent_thread_pid[i] = this_pid;
break;
}
}
- if((i+ g_packet_io_thread_num >= NON_PKT_THREAD_SEND_QUEUE ) /* �����߳����64�� */
- || (i >= NON_PKT_THREAD_SEND_QUEUE)){
- sapp_runtime_log(RLOG_LV_FATAL, "Independent_thread num over limit, only support max %d!\n", NON_PKT_THREAD_SEND_QUEUE);
+ if(i >= sapp_global_val->config.cpu.send_only_threads_max_num ){ /* ���������߳�������� */
+ sapp_runtime_log(RLOG_LV_FATAL, "Independent_thread num more than CPU->send_only_threads_max:%d!\n",
+ sapp_global_val->config.cpu.send_only_threads_max_num);
*opt_int = -1;
ret = -1;
}else{
@@ -582,6 +582,11 @@ int sapp_assistant_init(void)
//sapp_line_protocol_init();
sapp_identify_broad_multicast_init();
pthread_mutex_init(&g_plug_Independent_thread_mutex, NULL);
+
+ if(sapp_global_val->config.cpu.send_only_threads_max_num > 0){
+ g_plug_Independent_thread_pid = (pthread_t *)calloc(1, sizeof(pthread_t));
+ }
+
return 1;
}
diff --git a/src/inner_plug/wangyan_keepalive_plug.c.bak b/src/inner_plug/wangyan_keepalive_plug.c.bak
deleted file mode 100644
index e8b6e98..0000000
--- a/src/inner_plug/wangyan_keepalive_plug.c.bak
+++ /dev/null
@@ -1,966 +0,0 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <arpa/inet.h>
-#include <netinet/udp.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <assert.h>
-#include <link.h>
-#include <dlfcn.h>
-#include "gdev_keepalive.h"
-#include "MESA_prof_load.h"
-#include "MESA_handle_logger.h"
-#include "plugin_serial.h"
-#include "stream_base.h"
-
-int wangyan_keepalive_plug_version_VERSION_20180305;
-
-#define WANGYAN_PLUG_NUM_MAX (64)
-
-#define SELF_DEBUG (0) /* ���ܿص��������Բ��� */
-
-#if SELF_DEBUG
-stPlugRuntimeInfo plugctrl_runtime_info;
-int wy_steward_plugin_id_get(void)
-{
- return 0;
-}
-stPlugBaseInfo wkp_g_plug_base_info[WANGYAN_PLUG_NUM_MAX];
-#else
-/* ��������������ı���, ��master��ʹ��, slave����, ��slave���޷��ҵ���ط�����, Ҳ������������汾, ��̬��ȡ */
-extern stPlugRuntimeInfo plugctrl_runtime_info; /* ƽ̨����, ���ڼ�������͵���������ʱ, ֱ������ */
-extern int wy_steward_plugin_id_get(void); /* �ܿط��ز��id���� */
-static stPlugBaseInfo *wkp_g_plug_base_info;
-#endif
-
-
-
-/*
- ʹ�÷��������ķ�ʽ, dl_iterate_phdr(dl_iterate_callback, &ret);
- ��̬��ȡ����ָ��, ����Ǵ�Ӧ���򲻵���gdev_set_opt.
-*/
-static int (* wkp_gdev_keepalive_set_opt)(const SAPP_TLV_T *tlv_value);
-
-
-/*
-[main]
-mode=master
-begin_listen_port=60000 //��ʼ�˿�Ϊ60000, ���ذ�Դ�˿�Ϊ60000, ���2�Ų��, ��Է����ն˿�Ϊ60002.
-slave_plug_id_list=1,2,23,34,45
-*/
-
-#define WANGYAN_KEEPALIVE_MODE_MASTER 1
-#define WANGYAN_KEEPALIVE_MODE_SLAVE 2
-
-#define WANGYAN_KEEPALIVE_MAGIC (0x474E4157) /* "WANG"�ַ�����16���� */
-
-
-#ifndef WKP_MAX
-#define WKPMAX(a, b) (((a) > (b)) ? (a) : (b))
-#endif
-
-enum plug_abnormal_t{
- PLUG_ABNORMAL_DEADLOCK = 1,
- PLUG_ABNORMAL_TIMEDELAY,
- PLUG_ABNORMAL_IOBUF_FULL,
-};
-
-typedef struct{
- unsigned int magic;
- unsigned char local_id; /* ���ڱ�ʶ���˵�id, ����WANGYAN��Ŀ��˵, �����id */
- unsigned char msg_type; /* 0:reply; 8:echo, ����ICMPЭ���ֶκ� */
- unsigned char version; /* ĿǰΪ1 */
- unsigned char seq_num; /* ��0��ʼ, �ۼ� */
-}wangyan_keepalive_comm_t; /* ����ͨ�Žӿ� */
-
-typedef struct{
- int plug_id;
- int plug_keepalive_state; /* 1:��������; 0:�쳣״̬ */
- struct sockaddr_in sock_addr;
- unsigned long long last_rcv_reply_timestamp;
- time_t last_recv_time_sec;
- unsigned long long total_snd_keepalive_pkt_num;
- unsigned long long total_rcv_keepalive_pkt_num;
- time_t last_log_time; /* ��һ�μ�¼��־��ʱ��, ����ˢӲ�� */
- volatile int plug_exclusivity; /* �����ռ�Կ���, ����˲��������, �������ٺ�gdev����, �ᶯ̬���� */
- unsigned char seq_num;
- char __pad[59];
-}wangyan_keepalive_state_t; /* ����״̬��¼ */
-
-static unsigned short g_begin_listen_port = 60000; /* ������, host order, ���ڸ��ݲ��ID������Χ */
-
-static int g_wangyan_keepalive_mode = WANGYAN_KEEPALIVE_MODE_SLAVE; /* Ĭ�ϴ�ģʽ, ��ֹû�������ļ���������ģʽ����, ����������̽��� */
-
-static unsigned long long g_wkp_time_increase = 1; /* ����������ʱ���, ����̽�Ᵽ�ʱ, ��1��ʼ���ÿ��50ms����1 */
-static time_t g_wkp_cur_time; /* ��ǰ����ʱ�������, master��slave�ڲ�ͬ���̸��Ը��� */
-
-static wangyan_keepalive_state_t g_wangyan_keepalive_state[WANGYAN_PLUG_NUM_MAX]; /* ��Ӧ�ò����ַ�� */
-
-static int g_wkp_sock_fd = -1; /* ֻ��һ��fd����, master����������slave���ͺͽ��� */
-
-static volatile int g_wkp_slave_abnormal_flag = 0;
-
-static int g_wkp_slave_local_plug_id = -1; /* ��Ӧ�����еIJ��ID */
-
-static void *g_wkp_log_handle;
-
-extern time_t g_CurrentTime;
-extern int get_thread_count(void);
-
-static char *wkp_timet_to_str(time_t timet, char *time_str, int time_str_len)
-{
- struct tm *now;
-
- if(NULL == time_str || time_str_len <= (int)strlen("YY-MM-DD HH:MM:SS"))
- {
- return (char *)"1970-01-01 error"; /* error! */
- }
-
- now = localtime(&timet);
- strftime(time_str, time_str_len, "%Y-%m-%d %H:%M:%S", now);
-
- return time_str;
-}
-
-
-static int wkp_slave_check_plug_deadlock(void)
-{
- int i, tot_thread_count;
- int call_times[MAX_THREAD_NUM];
- static int last_check_flag = 0; /* ������¼��ǰ��callentryֵ, ˫���ü�¼ֵ�͵�ǰֵ�Ƚ� */
- static int last_check_time;
- static int record_deadlock_flag = 0;
-
- /* NOTE: �ⲿ�̻߳���ʵʱ����ʱ���, �����ڱ�������ʹ��sleep()����, ����ʹ�ñ�־λ��¼+�첽��� */
-
- tot_thread_count = get_thread_count();
-
- if(0 == last_check_flag){
- for(i = 0; i < tot_thread_count; i++){
- call_times[i] = plugctrl_runtime_info.callentry_num[i];
- }
- last_check_flag = 1;
- last_check_time = g_wkp_time_increase;
- }else{
- if(g_wkp_time_increase - last_check_time > 20){/* ���1������, �ٴμ��֮ǰ�����ֵ��plugctrl_runtime_infoʵʱֵ�Ƿ�һ�� */
- for(i = 0; i < tot_thread_count; i++){
- if((call_times[i] == plugctrl_runtime_info.callentry_num[i])
- && (plugctrl_runtime_info.callentry_num[i] & 1)){ /* callentry�ǵ���, ˵�����ڲ������ջ��, ��ʱ�䲻�伴������ */
- last_check_flag = 0;
- record_deadlock_flag = 1;
- return record_deadlock_flag;
- }
- }
- record_deadlock_flag = 0; /* �ָ�����ֵ */
- last_check_flag = 0;
- }
- }
-
- return record_deadlock_flag;
-}
-
-static int wkp_slave_check_plug_timedelay(void)
-{
- int i, tot_thread_count;
- tot_thread_count = get_thread_count();
-
- for(i = 0; i < tot_thread_count; i++){
- if(plugctrl_runtime_info.interval_num[i] > 30){ /* ���������¼���60�γ���1ms�ĵ��ü�¼ */
- return 1;
- }
- }
-
- return 0;
-}
-
-static int wkp_slave_check_plug_iobuf(void)
-{
-#if IOMODE_MARSIO
- /* TODO */
-#endif
-
- return 0;
-}
-
-
-static const char *wkp_abnormal_state_to_string(int type)
-{
- const char *res = "";
-
- switch(type){
- case PLUG_ABNORMAL_DEADLOCK:
- res = "deadlock";
- break;
-
- case PLUG_ABNORMAL_TIMEDELAY:
- res = "pkt process too slow";
- break;
-
- case PLUG_ABNORMAL_IOBUF_FULL:
- res = "I/O buf full";
- break;
-
- default:
- break;
- }
-
- return res;
-}
-
-
-/* ���ڼ�鵱ǰ�����Ƿ�����, ��������ʱ̫��, IO���������쳣��� */
-static void *wkp_slave_check_plug_state_thread(void *arg)
-{
- int res = 0;
- int res_type;
- static int log_last_slave_state = 0;
-
- while(1){
- res = 0;
- g_wkp_cur_time = time(NULL);
-
- res = wkp_slave_check_plug_deadlock();
- res_type = PLUG_ABNORMAL_DEADLOCK;
- if(res != 0){
- goto do_log; /* һƱ�����, ֻҪ��һ�������, �Ϳ���д��־��, �������������� */
- }
-
- res = wkp_slave_check_plug_timedelay();
- res_type = PLUG_ABNORMAL_TIMEDELAY;
- if(res != 0){
- goto do_log; /* һƱ�����, ֻҪ��һ�������, �Ϳ���д��־��, �������������� */
- }
-
- res = wkp_slave_check_plug_iobuf();
- res_type = PLUG_ABNORMAL_IOBUF_FULL;
-
-do_log:
- if(res != 0){
- g_wkp_slave_abnormal_flag = 1;
- if(log_last_slave_state != g_wkp_slave_abnormal_flag){/* ��״̬�л�ʱ��д��־, �����д������������־ */
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "plug_id %d, because %s into abnormal status!",
- g_wkp_slave_local_plug_id,
- wkp_abnormal_state_to_string(res_type));
- }
- }else{
- g_wkp_slave_abnormal_flag = 0;
- if(log_last_slave_state != g_wkp_slave_abnormal_flag){/* ��״̬�л�ʱ��д��־, �����д������������־ */
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "plug_id %d, into normal status!",
- g_wkp_slave_local_plug_id);
- }
- }
-
- log_last_slave_state = g_wkp_slave_abnormal_flag;
-
- usleep(1000 * 50);
- g_wkp_time_increase++;
- }
-
- return NULL;
-}
-
-static void *wkp_slave_recv_thread(void *arg)
-{
- int ret;
- wangyan_keepalive_comm_t wkp_comm_data;
- struct sockaddr_in sock_addr;
- socklen_t sock_len;
-
- while(1){
- sock_len = sizeof(sock_addr);
- ret = recvfrom(g_wkp_sock_fd, (void *)&wkp_comm_data, sizeof(wkp_comm_data), 0,
- (struct sockaddr *)&sock_addr, &sock_len);
- if(ret != sizeof(wkp_comm_data)){
- continue;
- }
-
- if(wkp_comm_data.magic != WANGYAN_KEEPALIVE_MAGIC){
- continue;
- }
- if(wkp_comm_data.msg_type != 8){ /* not request */
- continue;
- }
- if(wkp_comm_data.local_id != 0){ /* not master request */
- continue;
- }
-
- wkp_comm_data.msg_type = 0;
- wkp_comm_data.local_id = (unsigned char)g_wkp_slave_local_plug_id;
-
- /* ֻ����wkp_slave_check_plug_state_thread�̼߳�����а������̶߳�����ʱ, �ٻظ����� */
- if(0 == g_wkp_slave_abnormal_flag){
-retry:
- ret = sendto(g_wkp_sock_fd, (void *)&wkp_comm_data, sizeof(wkp_comm_data), 0,
- (struct sockaddr *)&sock_addr, sock_len);
- if((ret < 0) && (EINTR == errno)){
- goto retry;
- }
- }
- }
-
- return NULL;
-}
-
-
-/* �����������ռ�����Կ��ܻ���ʱ�仯, ��Ҫʵʱ��ȡ�ܿصı������� */
-static void wkp_master_get_plug_exclusivity_stat(void)
-{
- int i;
-
- for(i = 0; i < WANGYAN_PLUG_NUM_MAX; i++){
- g_wangyan_keepalive_state[i].plug_exclusivity = wkp_g_plug_base_info[g_wangyan_keepalive_state[i].plug_id].keepalive_flag;
- }
-}
-
-/* ��֮�ܿ�, ÿ����Ӧ�õı���״̬ */
-static int wkp_master_update_plug_state(int plug_id, int keepalive_state)
-{
- assert(plug_id < WY_MAX_PLUG_NUM);
-
- wkp_g_plug_base_info[plug_id].keepalive_state = keepalive_state; /* �����ܿز����״̬ */
- g_wangyan_keepalive_state[plug_id].plug_keepalive_state = keepalive_state; /* ���±�ģ���ڲ��״̬ */
-
- return g_wangyan_keepalive_state[plug_id].plug_keepalive_state;
-}
-
-
-static void wkp_master_keepalive_status_log(void)
-{
- static time_t last_log_time = 0;
- int i, tot_alive_slave_num = 0;
- FILE *fp;
- char tmp_time_str[64];
-
- if(last_log_time < g_wkp_cur_time){
- fp = fopen("./log/wangyan_keepalive_status.log", "w+");
- if(NULL == fp){
- return;
- }
-
- fprintf(fp, "%8s %12s %10s %10s %6s %24s\n", "plug-id", "exclusivity", "tot-snd", "tot-rcv", "alive", "last_pkt_time");
- for(i = 0; i < WANGYAN_PLUG_NUM_MAX; i++){
- if(0 == g_wangyan_keepalive_state[i].plug_id){ /* 0 is master */
- continue;
- }
- if(0 == g_wangyan_keepalive_state[i].plug_keepalive_state){
- continue; /* ��Ӧ��̫��, �������ʧ������ʾ */
- }
- wkp_timet_to_str(g_wangyan_keepalive_state[i].last_recv_time_sec, tmp_time_str, 64);
- fprintf(fp,
- "%8d %12d %10lld %10lld %6d %24s\n",
- g_wangyan_keepalive_state[i].plug_id,
- g_wangyan_keepalive_state[i].plug_exclusivity,
- g_wangyan_keepalive_state[i].total_snd_keepalive_pkt_num,
- g_wangyan_keepalive_state[i].total_rcv_keepalive_pkt_num,
- g_wangyan_keepalive_state[i].plug_keepalive_state,
- tmp_time_str);
- tot_alive_slave_num++;
- }
-
- if(0 == tot_alive_slave_num){
- fprintf(fp, "All slave plug are not alive!\n");
- }
- fclose(fp);
- last_log_time = g_wkp_cur_time;
- }
-}
-
-
-static void wkp_master_update_gdev_keepalive_flag(void)
-{
- int plug_id;
- int gdev_global_switch = 1; /* ��ʼΪ1, �����fd����, ����ȫ����ż���GDEV����; �����fd����, ������һ���������, ������GDEV���� */
- SAPP_TLV_T keepalive_opt;
- int alive_plug_num = 0;
- static time_t last_log_time = 0;
-
- for(plug_id = 1; plug_id < WANGYAN_PLUG_NUM_MAX; plug_id++){
- if((1 == g_wangyan_keepalive_state[plug_id].plug_exclusivity)
- && (0 == g_wangyan_keepalive_state[plug_id].plug_keepalive_state)){
- gdev_global_switch = 0; /* һƱ��� */
- if(g_wangyan_keepalive_state[plug_id].last_log_time < g_CurrentTime){
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "plug id=%d is not alive, is exclusive, so disable gdev global keepalive!", plug_id);
- g_wangyan_keepalive_state[plug_id].last_log_time = g_CurrentTime;
- }
- break;
- }
- if(1 == g_wangyan_keepalive_state[plug_id].plug_keepalive_state){
- alive_plug_num++;
- }
- }
-
- if(0 == alive_plug_num){
- gdev_global_switch = 0;
- if(last_log_time + 5 < g_CurrentTime){
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "All plug is not alive, disable gdev global keepalive!");
- last_log_time = g_CurrentTime;
- }
- }
-
- keepalive_opt.type = GDEV_KEEPALIVE_OPT_GLOBAL_SWITCH;
- keepalive_opt.length = sizeof(int);
- keepalive_opt.int_value = gdev_global_switch;
- if(wkp_gdev_keepalive_set_opt){
- wkp_gdev_keepalive_set_opt(&keepalive_opt);
- }
-
- return;
-}
-
-
-static void *wkp_master_check_keepalive_state_thread(void *arg)
-{
- int i;
- int plug_state_sum = 0;
-
- while(1){
- plug_state_sum = 0;
- for(i = 0; i < WANGYAN_PLUG_NUM_MAX; i++){
- if(g_wangyan_keepalive_state[i].plug_id == 0){
- continue;
- }
- /* ��һ���յ��������ʱ���ټ���3����������, �ȵ�ǰʱ�����С, ˵���ܳ�ʱ��û�յ������� */
- if(g_wangyan_keepalive_state[i].last_rcv_reply_timestamp + 3 < g_wkp_time_increase){
- g_wangyan_keepalive_state[i].plug_keepalive_state = 0;
- }else{
- g_wangyan_keepalive_state[i].plug_keepalive_state = 1;
- }
-
- /* ���ݱ��ر���״̬, �����ܿز���ڲ���״̬ */
- plug_state_sum += wkp_master_update_plug_state(g_wangyan_keepalive_state[i].plug_id, g_wangyan_keepalive_state[i].plug_keepalive_state);
- }
-
- wkp_master_update_gdev_keepalive_flag();
-
- wkp_master_get_plug_exclusivity_stat();
-
- wkp_master_keepalive_status_log();
-
- usleep(1000 * 100);
- }
-
- return NULL;
-}
-
-static void wkp_master_pkt_process(const wangyan_keepalive_comm_t *wkp_msg, const struct sockaddr_in *netaddr)
-{
- int i;
-
- if(WANGYAN_KEEPALIVE_MAGIC != wkp_msg->magic){
- return; /* not keepalive pkt */
- }
-
- if(wkp_msg->msg_type != 0){ /* not reply */
- return;
- }
-
- for(i = 0; i < WANGYAN_PLUG_NUM_MAX; i++){
- if(g_wangyan_keepalive_state[i].plug_id == 0){
- continue;
- }
- if(wkp_msg->local_id == g_wangyan_keepalive_state[i].plug_id){
- if((g_wangyan_keepalive_state[i].sock_addr.sin_addr.s_addr != netaddr->sin_addr.s_addr)
- || (g_wangyan_keepalive_state[i].sock_addr.sin_port != netaddr->sin_port)){
- /* �����Ǵ�Ӧ��������, ���°��˶˿�, ��ʱ��Ҫ���ô�Ӧ�õ�ַ */
- g_wangyan_keepalive_state[i].sock_addr.sin_addr.s_addr = netaddr->sin_addr.s_addr;
- g_wangyan_keepalive_state[i].sock_addr.sin_port = netaddr->sin_port;
-
- char last_ip_str[16], new_ip_str[16];
- inet_ntop(AF_INET, &g_wangyan_keepalive_state[i].sock_addr.sin_addr.s_addr, last_ip_str, 16);
- inet_ntop(AF_INET, &netaddr->sin_addr.s_addr, new_ip_str, 16);
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "Plug:%u last addr is:%s:%u, new addr is:%s:%u!",
- wkp_msg->local_id, last_ip_str, ntohs(g_wangyan_keepalive_state[i].sock_addr.sin_port),
- new_ip_str, ntohs(netaddr->sin_port));
- }
- g_wangyan_keepalive_state[i].plug_keepalive_state = 1; /* ÿ�յ�һ�λظ�����Ϊ����, ��ֹ�Է��������ָֻ��޷���⵽������ */
- g_wangyan_keepalive_state[i].last_rcv_reply_timestamp = g_wkp_time_increase;
- g_wangyan_keepalive_state[i].last_recv_time_sec = g_wkp_cur_time;
- g_wangyan_keepalive_state[i].total_rcv_keepalive_pkt_num++;
- break;
- }
- }
-
- return;
-}
-
-static void *wkp_master_recv_thread(void *arg)
-{
- int ret;
- struct sockaddr_in saddr;
- char rcv_buf[1500];
- socklen_t saddr_len;
-
- while(1){
- saddr_len = sizeof(struct sockaddr);
- ret = recvfrom(g_wkp_sock_fd, rcv_buf, 1500, 0, (struct sockaddr *)&saddr, &saddr_len);
- if(ret > 0){
- wkp_master_pkt_process((const wangyan_keepalive_comm_t *)rcv_buf, &saddr);
- }
- }
-
- return NULL;
-}
-
-static void *wkp_master_send_thread(void *arg)
-{
- int ret, i;
- wangyan_keepalive_comm_t wkp_comm_data;
-
- wkp_comm_data.magic = WANGYAN_KEEPALIVE_MAGIC;
- wkp_comm_data.version = 1;
- wkp_comm_data.msg_type = 8;
- wkp_comm_data.local_id = 0; /* master id is 0 */
- wkp_comm_data.seq_num = 0;
-
- while(1){
- g_wkp_cur_time = time(NULL);
- for(i = 0; i < WANGYAN_PLUG_NUM_MAX; i++){
- if(g_wangyan_keepalive_state[i].plug_id == 0){
- continue;
- }
-retry:
- ret = sendto(g_wkp_sock_fd, &wkp_comm_data, sizeof(wangyan_keepalive_comm_t), MSG_DONTWAIT,
- (const struct sockaddr *)&g_wangyan_keepalive_state[i].sock_addr,
- sizeof(g_wangyan_keepalive_state[i].sock_addr));
- if(ret < 0){
- if(EINTR == errno){
- goto retry;
- }
- printf("[wangyan_keepalive] sendto error, %s\n", strerror(errno));
- }else{
- g_wangyan_keepalive_state[i].total_snd_keepalive_pkt_num++;
- }
- }
-
- usleep(1000 * 50);
- g_wkp_time_increase++; /* ��sleep������, ���շ�����ڴ�ʱ�����û�յ�Ӧ��, ����Ϊ�Է�����ʧ�� */
- }
-
- return NULL;
-}
-
-
-struct wkp_check_dl{
- int exist_flag;
- const char *dl_name;
-};
-#if (0 == SELF_DEBUG)
-static int wkp_dl_iterate_callback(struct dl_phdr_info *info, size_t size, void *cb_arg)
-{
- int len1, len2;
- struct wkp_check_dl *user_arg = (struct wkp_check_dl *)cb_arg;
-
- if((NULL == info->dlpi_name) || ('\0' == info->dlpi_name[0])){
- return 0;
- }
-
- len1 = strlen(basename(info->dlpi_name)); /* һ�㶼��·��, Ҫ��basename() */
- len2 = strlen(user_arg->dl_name);
- if(strncasecmp(basename(info->dlpi_name), user_arg->dl_name, WKPMAX(len1, len2)) == 0){
- user_arg->exist_flag++; /* ��ѭ��cb��ջ��, ���ۼ�ֵ��ʾ���� */
- return 1;
- }
-
- return 0;
-}
-
-
-static int wkp_search_dl(const char *name)
-{
- struct wkp_check_dl user_arg;
-
- user_arg.dl_name = name;
- user_arg.exist_flag = 0;
-
- dl_iterate_phdr(wkp_dl_iterate_callback, &user_arg);
-
- return user_arg.exist_flag;
-}
-#endif
-
-/* �����������.so�����ȹ��� */
-static int wkp_plug_master_check_depend_plug(void)
-{
-#if (0 == SELF_DEBUG)
- if(wkp_search_dl("g_device_plug.so") <= 0){
- printf("\033[41m[wangyan_keepalive] error, in master mode, but no '%s' plug load!\033[0m\n", "g_device_plug.so");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "error, in master mode, but no '%s' plug load!", "g_device_plug.so");
- return -1;
- }
-
- if(wkp_search_dl("steward_wy.so") <= 0){
- printf("\033[41m[wangyan_keepalive] error, in master mode, but no '%s' plug load!\033[0m\n", "steward_wy.so");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "error, in master mode, but no '%s' plug load!", "steward_wy.so");
- return -1;
- }
-#endif
-
- wy_steward_plugin_id_get();
-
- return 0;
-}
-
-
-static int wkp_plug_master_get_depend_plug_symbol(void)
-{
-#if (0 == SELF_DEBUG)
- void *dl_handle_gdev;
- void *dl_handle_wy_master;
-
- dl_handle_gdev = dlopen("./plug/platform/g_device_plug/g_device_plug.so", RTLD_NOW);
- if(NULL == dl_handle_gdev){
- printf("\033[41m[wangyan_keepalive] dlopen '%s' error!\033[0m\n", "./plug/platform/g_device_plug/g_device_plug.so");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "dlopen '%s' error!", "./plug/platform/g_device_plug/g_device_plug.so");
- return -1;
- }
-
- wkp_gdev_keepalive_set_opt = (int (* )(const SAPP_TLV_T *))dlsym(dl_handle_gdev, "gdev_keepalive_set_opt");
- if(NULL == wkp_gdev_keepalive_set_opt){
- printf("\033[41m[wangyan_keepalive] dlsym '%s' error!\033[0m\n", "gdev_keepalive_set_opt");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "dlsym '%s' error!", "gdev_keepalive_set_opt");
- return -1;
- }
-
- dl_handle_wy_master = dlopen("./plug/platform/steward_wy/steward_wy.so", RTLD_NOW);
- if(NULL == dl_handle_wy_master){
- printf("\033[41m[wangyan_keepalive] dlopen '%s' error!\033[0m\n", "./plug/platform/steward_wy/steward_wy.so");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "dlopen '%s' error!", "./plug/platform/steward_wy/steward_wy.so");
- return -1;
- }
-
- wkp_g_plug_base_info = (stPlugBaseInfo *)dlsym(dl_handle_wy_master, "g_plug_base_info");
- if(NULL == wkp_g_plug_base_info){
- printf("\033[41m[wangyan_keepalive] dlsym '%s' error!\033[0m\n", "g_plug_base_info");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "dlsym '%s' error!", "g_plug_base_info");
- return -1;
- }
-#endif
-
- return 0;
-}
-
-static int wangyan_keepalive_plug_master_init(void)
-{
- //char __id_list_string_buf[1024];
- //const char *delim = ", ";
- //char *save_ptr;
- //char *single_plug_id_str, *tmp_id_list_string = __id_list_string_buf;
- int tmp_plug_id;
- struct sockaddr_in sockadd;
- //int plug_cfg_num = 0;
-
- if(wkp_plug_master_check_depend_plug() < 0){
- return -1;
- }
-
- if(wkp_plug_master_get_depend_plug_symbol() < 0){
- return -1;
- }
-
-#if 0 /* 2017-11-27 lijia modify, ���ٿ������ļ��ֹ�ָ����Ӧ��id, Ĭ�����в��ȫ���� */
- MESA_load_profile_string_def((char *)"./conf/wangyan_keepalive.conf", (char *)"master", (char *)"slave_plug_id_list", tmp_id_list_string, 1024, "");
- if('\0' == __id_list_string_buf[0]){
- printf("\033[41m[wangyan_keepalive] error, read conf 'slave_plug_id_list' error!\033[0m\n");
- return -1;
- }
-
- while((single_plug_id_str = strtok_r(tmp_id_list_string, delim, &save_ptr)) != NULL){
- tmp_plug_id = atoi(single_plug_id_str);
- assert(tmp_plug_id > 0 );
- assert(tmp_plug_id < WANGYAN_PLUG_NUM_MAX);
-
- g_wangyan_keepalive_state[tmp_plug_id].plug_id = tmp_plug_id;
- g_wangyan_keepalive_state[tmp_plug_id].plug_keepalive_state = 1; /* Ĭ������ */
- g_wangyan_keepalive_state[tmp_plug_id].sock_addr.sin_family = AF_INET;
- g_wangyan_keepalive_state[tmp_plug_id].sock_addr.sin_addr.s_addr = htonl(0x7f000001);
- g_wangyan_keepalive_state[tmp_plug_id].sock_addr.sin_port = ntohs(g_begin_listen_port + tmp_plug_id);
- g_wangyan_keepalive_state[tmp_plug_id].last_rcv_reply_timestamp = 0;
- g_wangyan_keepalive_state[tmp_plug_id].last_recv_time_sec = 0;
- g_wangyan_keepalive_state[tmp_plug_id].total_snd_keepalive_pkt_num = 0;
- g_wangyan_keepalive_state[tmp_plug_id].total_rcv_keepalive_pkt_num = 0;
- g_wangyan_keepalive_state[tmp_plug_id].seq_num = 0;
- g_wangyan_keepalive_state[tmp_plug_id].plug_exclusivity = 0;
- plug_cfg_num++;
- tmp_id_list_string = NULL;
- }
-
- if(0 == plug_cfg_num){
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "not found any valid plug!");
- }
-#else
-
- for(tmp_plug_id = 0; tmp_plug_id < WANGYAN_PLUG_NUM_MAX; tmp_plug_id++){
- g_wangyan_keepalive_state[tmp_plug_id].plug_id = tmp_plug_id;
- g_wangyan_keepalive_state[tmp_plug_id].plug_keepalive_state = 1; /* Ĭ������ */
- g_wangyan_keepalive_state[tmp_plug_id].sock_addr.sin_family = AF_INET;
- g_wangyan_keepalive_state[tmp_plug_id].sock_addr.sin_addr.s_addr = htonl(0x7f000001);
- g_wangyan_keepalive_state[tmp_plug_id].sock_addr.sin_port = ntohs(g_begin_listen_port + tmp_plug_id);
- g_wangyan_keepalive_state[tmp_plug_id].last_rcv_reply_timestamp = 0;
- g_wangyan_keepalive_state[tmp_plug_id].last_recv_time_sec = 0;
- g_wangyan_keepalive_state[tmp_plug_id].total_snd_keepalive_pkt_num = 0;
- g_wangyan_keepalive_state[tmp_plug_id].total_rcv_keepalive_pkt_num = 0;
- g_wangyan_keepalive_state[tmp_plug_id].seq_num = 0;
- g_wangyan_keepalive_state[tmp_plug_id].plug_exclusivity = 0;
- }
-#endif
-
- g_wkp_sock_fd = socket(AF_INET,SOCK_DGRAM,0);
- if(g_wkp_sock_fd < 0){
- printf("\033[41m[wangyan_keepalive] socket error!\033[0m\n");
- return -1;
- }
-
-#if 0 /* UDP���ܿ���SO_REUSEADDRѡ��, ��������ͬ�����ܼ���ͬһ�����ض˿� */
- int opt = 1;
- setsockopt(g_wkp_sock_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
-#endif
-
- bzero(&sockadd, sizeof(sockadd));
- sockadd.sin_family = AF_INET;
- sockadd.sin_addr.s_addr = htonl(INADDR_ANY);
- sockadd.sin_port = htons(g_begin_listen_port);
-
- if(bind(g_wkp_sock_fd, (struct sockaddr *) &sockadd, sizeof(sockadd)) < 0){
- printf("\033[41m[wangyan_keepalive]master bind port %u error, %s!\033[0m\n", g_begin_listen_port, strerror(errno));
- return -1;
- }
-
- MESA_handle_runtime_log(g_wkp_log_handle, 10, "wangyan_keepalive", "master init SUCC");
-
- return 0;
-}
-
-static int wangyan_keepalive_plug_slave_init(void)
-{
- //char plug_id_str[128];
- int tmp_plug_id;
- struct sockaddr_in sockadd;
-
-#if 0
- MESA_load_profile_string_def((char *)"./conf/wangyan_keepalive.conf", (char *)"slave", (char *)"local_plug_id", plug_id_str, 128, "");
- if('\0' == plug_id_str[0]){
- printf("\033[41m[wangyan_keepalive] error, read conf 'local_plug_id' error!\033[0m\n");
- return -1;
- }
- tmp_plug_id = atoi(plug_id_str);
- if((tmp_plug_id < 1) || (tmp_plug_id > 64)){
- printf("\033[41m[wangyan_keepalive] error, 'local_plug_id' invalid!\033[0m\n");
- return -1;
- }
- g_wkp_slave_local_plug_id = tmp_plug_id;
-#else
- /* ����ÿ����Ӧ�ö����ø��Ե�ID, �ܿ��Ѿ�֪����ǰ���id, ֱ�ӵ��ü���, ���������ļ����� */
- tmp_plug_id = wy_steward_plugin_id_get();
- g_wkp_slave_local_plug_id = tmp_plug_id;
-#endif
-
- g_wkp_sock_fd = socket(AF_INET,SOCK_DGRAM,0);
- if(g_wkp_sock_fd < 0){
- printf("\033[41m[wangyan_keepalive] socket error!\033[0m\n");
- return -1;
- }
-
-#if 0 /* UDP���ܿ���SO_REUSEADDRѡ��, ��������ͬ�����ܼ���ͬһ�����ض˿� */
- int opt = 1;
- setsockopt(g_wkp_sock_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int));
-#endif
-
- bzero(&sockadd, sizeof(sockadd));
- sockadd.sin_family = AF_INET;
- sockadd.sin_addr.s_addr = htonl(INADDR_ANY);
- sockadd.sin_port = htons(g_begin_listen_port + tmp_plug_id);
-
- /* NOTE:
- ��Ӧ�õĶ˿ڿ��ܱ���������ռ��, �Զ�����Կ��ö˿�.
- */
- while(1){
- if(bind(g_wkp_sock_fd, (struct sockaddr *) &sockadd, sizeof(sockadd)) < 0){
- printf("\033[41m[wangyan_keepalive]plug_id:%u bind port %u error, %s!\033[0m\n",
- g_wkp_slave_local_plug_id, g_begin_listen_port+tmp_plug_id, strerror(errno));
- tmp_plug_id++;
- sockadd.sin_port = htons(g_begin_listen_port + tmp_plug_id);
- continue;
- }else{
- MESA_handle_runtime_log(g_wkp_log_handle, 20, "wangyan_keepalive", "plug_id:%d bind port %d SUCC!\n",
- g_wkp_slave_local_plug_id, g_begin_listen_port + tmp_plug_id);
- break;
- }
- }
-
- MESA_handle_runtime_log(g_wkp_log_handle, 10, "wangyan_keepalive", "slave init SUCC");
-
- return 0;
-}
-
-
-#if (0 == SELF_DEBUG)
-static void wangyan_gdev_keepalive_depend_service_set(int service_num)
-{
- SAPP_TLV_T keepalive_opt;
-
- keepalive_opt.type = GDEV_KEEPALIVE_OPT_GLOBAL_SWITCH;
- keepalive_opt.length = sizeof(int);
- keepalive_opt.int_value = 0;
- wkp_gdev_keepalive_set_opt(&keepalive_opt);
-
- struct gdev_keepalive_service_ctrl service_opt;
- service_opt.keepalive_switch = 1;
- service_opt.service_num = service_num;
- keepalive_opt.type = GDEV_KEEPALIVE_OPT_SERVICE_CTRL;
- keepalive_opt.length = sizeof(service_opt);
- keepalive_opt.ptr_value = &service_opt;
- wkp_gdev_keepalive_set_opt(&keepalive_opt);
-
- MESA_handle_runtime_log(g_wkp_log_handle, 10, "wangyan_keepalive", "set gdev keepalive service num: %d", service_num);
-
- return;
-}
-#endif
-
-/*
- ͬʱ֧�ֶ��ŷָ��Ķ��ҵ���.
-*/
-#if (0 == SELF_DEBUG)
-static int wangyan_gdev_keepalive_init(char *servie_num_list)
-{
- const char *delim = "\t ,";
- char *saveptr = NULL;
- char *section;
- int tmp_int_num;
- char *parse_config_str = servie_num_list;
-
- while((section = strtok_r(parse_config_str, delim, &saveptr))){
- tmp_int_num = atoi(section);
- if((tmp_int_num > 0) && (tmp_int_num < 255)){
- wangyan_gdev_keepalive_depend_service_set(tmp_int_num);
- }
- parse_config_str = NULL;
- }
-
- return 0;
-}
-#endif
-
-/* ����dpdk�����鿴��ǰ���̵�������Ϣ, ������Ӧ����,
- ��Ϊ�ȵ���plug_proc(), �����ʼ��ʱ, packet_io��δ��ʼ��, ����ʹ�ú����ӿ�����,
- packet_io_marsio.soĬ�ϴ�main.conf->sapp_instance_name��ȡ,
- ��ģ��ֱ���޸�main.conf->sapp_instance_name.
-*/
-static void wangyan_set_sapp_instance_name(void)
-{
- char tmp_cmd_buf[256];
-
- /* ���ý����� */
- if(0 == g_wkp_slave_local_plug_id){
- snprintf(tmp_cmd_buf, 256, "sed -r -i 's/app_instance_name=.*/app_instance_name=sapp_master/g' conf/main.conf ");
- }else{
- snprintf(tmp_cmd_buf, 256, "sed -r -i 's/app_instance_name=.*/app_instance_name=slave%d/g' conf/main.conf", g_wkp_slave_local_plug_id);
- }
- system(tmp_cmd_buf);
-
-#if IOMODE_MARSIO
- /* �������� */
- if(0 == g_wkp_slave_local_plug_id){
- snprintf(tmp_cmd_buf, 256, "sed -r -i 's/pcapdevice=.*/pcapdevice=vxlan_user/g' conf/main.conf");
- }else{
- snprintf(tmp_cmd_buf, 256, "sed -r -i 's/pcapdevice=.*/pcapdevice=loop%d/g' conf/main.conf", g_wkp_slave_local_plug_id);
- }
-
- system(tmp_cmd_buf);
-#endif
-
-}
-
-int wangyan_keepalive_plug_init(void)
-{
- int tmp_int, ret;
- pthread_t t_pid1,t_pid2,t_pid3;
- char tmp_str[128];
-
-#if SELF_DEBUG
- printf("\033[1;31;40m[wangyan_keepalive_plug] This is a debug version!\033[0m\n");
- sleep(3);
-#endif
-
- /* read conf, get master, or slave */
-
- assert(sizeof(wangyan_keepalive_state_t) % 64 == 0);
-
- g_wkp_cur_time = time(NULL);
-
- g_wkp_log_handle = MESA_create_runtime_log_handle("./log/wangyan_keepalive.log", 0);
-
-#if 0 /* 2017-11-27 lijia modify, ���ٿ������ļ��ֹ�ָ��ģʽ, ͨ���ܿغ������ز��id����, 0����master */
- MESA_load_profile_string_def((char *)"./conf/wangyan_keepalive.conf", (char *)"main", (char *)"mode", tmp_str, 128, "");
- if(strncasecmp("master", tmp_str, strlen("master")) == 0){
- g_wangyan_keepalive_mode = WANGYAN_KEEPALIVE_MODE_MASTER;
- }else if(strncasecmp("slave", tmp_str, strlen("slave")) == 0){
- g_wangyan_keepalive_mode = WANGYAN_KEEPALIVE_MODE_SLAVE;
- }else{
- printf("\033[41m[[wangyan_keepalive] error, read conf 'mode' error!\033[0m[\n");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "read conf 'mode' error!");
- return -1;
- }
-#else
- g_wkp_slave_local_plug_id = wy_steward_plugin_id_get();
- if(0 == g_wkp_slave_local_plug_id){
- g_wangyan_keepalive_mode = WANGYAN_KEEPALIVE_MODE_MASTER;
- }else{
- g_wangyan_keepalive_mode = WANGYAN_KEEPALIVE_MODE_SLAVE;
- }
-#endif
-
- MESA_load_profile_int_def((char *)"./conf/wangyan_keepalive.conf", (char *)"main", (char *)"begin_listen_port", &tmp_int, 0);
- if((0 >= tmp_int) || (tmp_int > 65535)){
- printf("\033[41m[[wangyan_keepalive] error, read conf 'begin_listen_port' error!\033[0m[\n");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "read conf 'begin_listen_port' error!");
- return -1;
- }
- g_begin_listen_port = (unsigned short)tmp_int;
-
- if(WANGYAN_KEEPALIVE_MODE_MASTER == g_wangyan_keepalive_mode){
- ret = wangyan_keepalive_plug_master_init();
- if(ret < 0){
- return -1;
- }
- pthread_create(&t_pid1, NULL, wkp_master_send_thread, NULL);
- pthread_create(&t_pid2, NULL, wkp_master_recv_thread, NULL);
- pthread_create(&t_pid3, NULL, wkp_master_check_keepalive_state_thread, NULL);
- }else{
- ret = wangyan_keepalive_plug_slave_init();
- if(ret < 0){
- return -1;
- }
- pthread_create(&t_pid1, NULL, wkp_slave_recv_thread, NULL);
- pthread_create(&t_pid2, NULL, wkp_slave_check_plug_state_thread, NULL);
- }
-
- /* ֻ����Ӧ�ò�����G������ز���, ��Ӧ��������� */
- if(WANGYAN_KEEPALIVE_MODE_MASTER == g_wangyan_keepalive_mode){
- /* wangyanĬ��ҵ���: 12, ֧�ֶ��ҵ�񶺺ŷָ�ģʽ */
- MESA_load_profile_string_def((char *)"./conf/wangyan_keepalive.conf", (char *)"gdev_service", (char *)"keepalive_service", tmp_str, 128, "12");
-
- /* NOTE: �˺���������wangyan_keepalive_plug_master_init֮��, ��Ϊ�漰����ȡg_keepalive_plug.so�еķ����� */
-#if (0 == SELF_DEBUG)
- wangyan_gdev_keepalive_init(tmp_str);
-#endif
- }
-
- wangyan_set_sapp_instance_name();
-
- return ret;
-}
-
-
-#ifdef __cplusplus
-}
-#endif
-
diff --git a/src/inner_plug/wangyan_keepalive.conf b/src/inner_plug/wy_keepalive.conf
index 88da537..88da537 100644
--- a/src/inner_plug/wangyan_keepalive.conf
+++ b/src/inner_plug/wy_keepalive.conf
diff --git a/src/inner_plug/wangyan_keepalive_plug.c b/src/inner_plug/wy_keepalive_plug.c
index 4bece8f..e2ca562 100644
--- a/src/inner_plug/wangyan_keepalive_plug.c
+++ b/src/inner_plug/wy_keepalive_plug.c
@@ -5,9 +5,9 @@ extern "C" {
#include "sapp_api.h"
#include "sapp_private_api.h"
-int wangyan_keepalive_plug_version_VERSION_20180305;
+int wy_keepalive_plug_version_VERSION_20180305;
-#define WANGYAN_PLUG_NUM_MAX (64)
+#define WY_PLUG_NUM_MAX (64)
#define SELF_DEBUG (0) /* ���ܿص��������Բ��� */
@@ -17,7 +17,7 @@ int wy_steward_plugin_id_get(void)
{
return 0;
}
-stPlugBaseInfo wkp_g_plug_base_info[WANGYAN_PLUG_NUM_MAX];
+stPlugBaseInfo wkp_g_plug_base_info[WY_PLUG_NUM_MAX];
#else
/* ��������������ı���, ��master��ʹ��, slave����, ��slave���޷��ҵ���ط�����, Ҳ������������汾, ��̬��ȡ */
extern stPlugRuntimeInfo plugctrl_runtime_info; /* ƽ̨����, ���ڼ�������͵���������ʱ, ֱ������ */
@@ -41,10 +41,10 @@ begin_listen_port=60000 //��ʼ�˿�Ϊ60000, ���ذ�Դ�˿�Ϊ60000, ���2�Ų
slave_plug_id_list=1,2,23,34,45
*/
-#define WANGYAN_KEEPALIVE_MODE_MASTER 1
-#define WANGYAN_KEEPALIVE_MODE_SLAVE 2
+#define WY_KEEPALIVE_MODE_MASTER 1
+#define WY_KEEPALIVE_MODE_SLAVE 2
-#define WANGYAN_KEEPALIVE_MAGIC (0x474E4157) /* "WANG"�ַ�����16���� */
+#define WY_KEEPALIVE_MAGIC (0x474E4157)
#ifndef WKP_MAX
@@ -59,11 +59,11 @@ enum plug_abnormal_t{
typedef struct{
unsigned int magic;
- unsigned char local_id; /* ���ڱ�ʶ���˵�id, ����WANGYAN��Ŀ��˵, �����id */
+ unsigned char local_id; /* ���ڱ�ʶ���˵�id, ����WY��Ŀ��˵, �����id */
unsigned char msg_type; /* 0:reply; 8:echo, ����ICMPЭ���ֶκ� */
unsigned char version; /* ĿǰΪ1 */
unsigned char seq_num; /* ��0��ʼ, �ۼ� */
-}wangyan_keepalive_comm_t; /* ����ͨ�Žӿ� */
+}wy_keepalive_comm_t; /* ����ͨ�Žӿ� */
typedef struct{
int plug_id;
@@ -77,16 +77,16 @@ typedef struct{
volatile int plug_exclusivity; /* �����ռ�Կ���, ����˲��������, �������ٺ�gdev����, �ᶯ̬���� */
unsigned char seq_num;
char __pad[59];
-}wangyan_keepalive_state_t; /* ����״̬��¼ */
+}wy_keepalive_state_t; /* ����״̬��¼ */
static unsigned short g_begin_listen_port = 60000; /* ������, host order, ���ڸ��ݲ��ID������Χ */
-static int g_wangyan_keepalive_mode = WANGYAN_KEEPALIVE_MODE_SLAVE; /* Ĭ�ϴ�ģʽ, ��ֹû�������ļ���������ģʽ����, ����������̽��� */
+static int g_wy_keepalive_mode = WY_KEEPALIVE_MODE_SLAVE; /* Ĭ�ϴ�ģʽ, ��ֹû�������ļ���������ģʽ����, ����������̽��� */
static unsigned long long g_wkp_time_increase = 1; /* ����������ʱ���, ����̽�Ᵽ�ʱ, ��1��ʼ���ÿ��50ms����1 */
static time_t g_wkp_cur_time; /* ��ǰ����ʱ�������, master��slave�ڲ�ͬ���̸��Ը��� */
-static wangyan_keepalive_state_t g_wangyan_keepalive_state[WANGYAN_PLUG_NUM_MAX]; /* ��Ӧ�ò����ַ�� */
+static wy_keepalive_state_t g_wy_keepalive_state[WY_PLUG_NUM_MAX]; /* ��Ӧ�ò����ַ�� */
static int g_wkp_sock_fd = -1; /* ֻ��һ��fd����, master����������slave���ͺͽ��� */
@@ -229,14 +229,14 @@ do_log:
if(res != 0){
g_wkp_slave_abnormal_flag = 1;
if(log_last_slave_state != g_wkp_slave_abnormal_flag){/* ��״̬�л�ʱ��д��־, �����д������������־ */
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "plug_id %d, because %s into abnormal status!",
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "plug_id %d, because %s into abnormal status!",
g_wkp_slave_local_plug_id,
wkp_abnormal_state_to_string(res_type));
}
}else{
g_wkp_slave_abnormal_flag = 0;
if(log_last_slave_state != g_wkp_slave_abnormal_flag){/* ��״̬�л�ʱ��д��־, �����д������������־ */
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "plug_id %d, into normal status!",
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "plug_id %d, into normal status!",
g_wkp_slave_local_plug_id);
}
}
@@ -253,7 +253,7 @@ do_log:
static void *wkp_slave_recv_thread(void *arg)
{
int ret;
- wangyan_keepalive_comm_t wkp_comm_data;
+ wy_keepalive_comm_t wkp_comm_data;
struct sockaddr_in sock_addr;
socklen_t sock_len;
@@ -265,7 +265,7 @@ static void *wkp_slave_recv_thread(void *arg)
continue;
}
- if(wkp_comm_data.magic != WANGYAN_KEEPALIVE_MAGIC){
+ if(wkp_comm_data.magic != WY_KEEPALIVE_MAGIC){
continue;
}
if(wkp_comm_data.msg_type != 8){ /* not request */
@@ -298,8 +298,8 @@ static void wkp_master_get_plug_exclusivity_stat(void)
{
int i;
- for(i = 0; i < WANGYAN_PLUG_NUM_MAX; i++){
- g_wangyan_keepalive_state[i].plug_exclusivity = wkp_g_plug_base_info[g_wangyan_keepalive_state[i].plug_id].keepalive_flag;
+ for(i = 0; i < WY_PLUG_NUM_MAX; i++){
+ g_wy_keepalive_state[i].plug_exclusivity = wkp_g_plug_base_info[g_wy_keepalive_state[i].plug_id].keepalive_flag;
}
}
@@ -309,9 +309,9 @@ static int wkp_master_update_plug_state(int plug_id, int keepalive_state)
assert(plug_id < WY_MAX_PLUG_NUM);
wkp_g_plug_base_info[plug_id].keepalive_state = keepalive_state; /* �����ܿز����״̬ */
- g_wangyan_keepalive_state[plug_id].plug_keepalive_state = keepalive_state; /* ���±�ģ���ڲ��״̬ */
+ g_wy_keepalive_state[plug_id].plug_keepalive_state = keepalive_state; /* ���±�ģ���ڲ��״̬ */
- return g_wangyan_keepalive_state[plug_id].plug_keepalive_state;
+ return g_wy_keepalive_state[plug_id].plug_keepalive_state;
}
@@ -323,27 +323,27 @@ static void wkp_master_keepalive_status_log(void)
char tmp_time_str[64];
if(last_log_time < g_wkp_cur_time){
- fp = fopen("./log/wangyan_keepalive_status.log", "w+");
+ fp = fopen("./log/wy_keepalive_status.log", "w+");
if(NULL == fp){
return;
}
fprintf(fp, "%8s %12s %10s %10s %6s %24s\n", "plug-id", "exclusivity", "tot-snd", "tot-rcv", "alive", "last_pkt_time");
- for(i = 0; i < WANGYAN_PLUG_NUM_MAX; i++){
- if(0 == g_wangyan_keepalive_state[i].plug_id){ /* 0 is master */
+ for(i = 0; i < WY_PLUG_NUM_MAX; i++){
+ if(0 == g_wy_keepalive_state[i].plug_id){ /* 0 is master */
continue;
}
- if(0 == g_wangyan_keepalive_state[i].plug_keepalive_state){
+ if(0 == g_wy_keepalive_state[i].plug_keepalive_state){
continue; /* ��Ӧ��̫��, �������ʧ������ʾ */
}
- wkp_timet_to_str(g_wangyan_keepalive_state[i].last_recv_time_sec, tmp_time_str, 64);
+ wkp_timet_to_str(g_wy_keepalive_state[i].last_recv_time_sec, tmp_time_str, 64);
fprintf(fp,
"%8d %12d %10lld %10lld %6d %24s\n",
- g_wangyan_keepalive_state[i].plug_id,
- g_wangyan_keepalive_state[i].plug_exclusivity,
- g_wangyan_keepalive_state[i].total_snd_keepalive_pkt_num,
- g_wangyan_keepalive_state[i].total_rcv_keepalive_pkt_num,
- g_wangyan_keepalive_state[i].plug_keepalive_state,
+ g_wy_keepalive_state[i].plug_id,
+ g_wy_keepalive_state[i].plug_exclusivity,
+ g_wy_keepalive_state[i].total_snd_keepalive_pkt_num,
+ g_wy_keepalive_state[i].total_rcv_keepalive_pkt_num,
+ g_wy_keepalive_state[i].plug_keepalive_state,
tmp_time_str);
tot_alive_slave_num++;
}
@@ -365,17 +365,17 @@ static void wkp_master_update_gdev_keepalive_flag(void)
int alive_plug_num = 0;
static time_t last_log_time = 0;
- for(plug_id = 1; plug_id < WANGYAN_PLUG_NUM_MAX; plug_id++){
- if((1 == g_wangyan_keepalive_state[plug_id].plug_exclusivity)
- && (0 == g_wangyan_keepalive_state[plug_id].plug_keepalive_state)){
+ for(plug_id = 1; plug_id < WY_PLUG_NUM_MAX; plug_id++){
+ if((1 == g_wy_keepalive_state[plug_id].plug_exclusivity)
+ && (0 == g_wy_keepalive_state[plug_id].plug_keepalive_state)){
gdev_global_switch = 0; /* һƱ��� */
- if(g_wangyan_keepalive_state[plug_id].last_log_time < g_CurrentTime){
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "plug id=%d is not alive, is exclusive, so disable gdev global keepalive!", plug_id);
- g_wangyan_keepalive_state[plug_id].last_log_time = g_CurrentTime;
+ if(g_wy_keepalive_state[plug_id].last_log_time < g_CurrentTime){
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "plug id=%d is not alive, is exclusive, so disable gdev global keepalive!", plug_id);
+ g_wy_keepalive_state[plug_id].last_log_time = g_CurrentTime;
}
break;
}
- if(1 == g_wangyan_keepalive_state[plug_id].plug_keepalive_state){
+ if(1 == g_wy_keepalive_state[plug_id].plug_keepalive_state){
alive_plug_num++;
}
}
@@ -383,7 +383,7 @@ static void wkp_master_update_gdev_keepalive_flag(void)
if(0 == alive_plug_num){
gdev_global_switch = 0;
if(last_log_time + 5 < g_CurrentTime){
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "All plug is not alive, disable gdev global keepalive!");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "All plug is not alive, disable gdev global keepalive!");
last_log_time = g_CurrentTime;
}
}
@@ -406,19 +406,19 @@ static void *wkp_master_check_keepalive_state_thread(void *arg)
while(1){
plug_state_sum = 0;
- for(i = 0; i < WANGYAN_PLUG_NUM_MAX; i++){
- if(g_wangyan_keepalive_state[i].plug_id == 0){
+ for(i = 0; i < WY_PLUG_NUM_MAX; i++){
+ if(g_wy_keepalive_state[i].plug_id == 0){
continue;
}
/* ��һ���յ��������ʱ���ټ���3����������, �ȵ�ǰʱ�����С, ˵���ܳ�ʱ��û�յ������� */
- if(g_wangyan_keepalive_state[i].last_rcv_reply_timestamp + 3 < g_wkp_time_increase){
- g_wangyan_keepalive_state[i].plug_keepalive_state = 0;
+ if(g_wy_keepalive_state[i].last_rcv_reply_timestamp + 3 < g_wkp_time_increase){
+ g_wy_keepalive_state[i].plug_keepalive_state = 0;
}else{
- g_wangyan_keepalive_state[i].plug_keepalive_state = 1;
+ g_wy_keepalive_state[i].plug_keepalive_state = 1;
}
/* ���ݱ��ر���״̬, �����ܿز���ڲ���״̬ */
- plug_state_sum += wkp_master_update_plug_state(g_wangyan_keepalive_state[i].plug_id, g_wangyan_keepalive_state[i].plug_keepalive_state);
+ plug_state_sum += wkp_master_update_plug_state(g_wy_keepalive_state[i].plug_id, g_wy_keepalive_state[i].plug_keepalive_state);
}
wkp_master_update_gdev_keepalive_flag();
@@ -433,11 +433,11 @@ static void *wkp_master_check_keepalive_state_thread(void *arg)
return NULL;
}
-static void wkp_master_pkt_process(const wangyan_keepalive_comm_t *wkp_msg, const struct sockaddr_in *netaddr)
+static void wkp_master_pkt_process(const wy_keepalive_comm_t *wkp_msg, const struct sockaddr_in *netaddr)
{
int i;
- if(WANGYAN_KEEPALIVE_MAGIC != wkp_msg->magic){
+ if(WY_KEEPALIVE_MAGIC != wkp_msg->magic){
return; /* not keepalive pkt */
}
@@ -445,28 +445,28 @@ static void wkp_master_pkt_process(const wangyan_keepalive_comm_t *wkp_msg, cons
return;
}
- for(i = 0; i < WANGYAN_PLUG_NUM_MAX; i++){
- if(g_wangyan_keepalive_state[i].plug_id == 0){
+ for(i = 0; i < WY_PLUG_NUM_MAX; i++){
+ if(g_wy_keepalive_state[i].plug_id == 0){
continue;
}
- if(wkp_msg->local_id == g_wangyan_keepalive_state[i].plug_id){
- if((g_wangyan_keepalive_state[i].sock_addr.sin_addr.s_addr != netaddr->sin_addr.s_addr)
- || (g_wangyan_keepalive_state[i].sock_addr.sin_port != netaddr->sin_port)){
+ if(wkp_msg->local_id == g_wy_keepalive_state[i].plug_id){
+ if((g_wy_keepalive_state[i].sock_addr.sin_addr.s_addr != netaddr->sin_addr.s_addr)
+ || (g_wy_keepalive_state[i].sock_addr.sin_port != netaddr->sin_port)){
/* �����Ǵ�Ӧ��������, ���°��˶˿�, ��ʱ��Ҫ���ô�Ӧ�õ�ַ */
- g_wangyan_keepalive_state[i].sock_addr.sin_addr.s_addr = netaddr->sin_addr.s_addr;
- g_wangyan_keepalive_state[i].sock_addr.sin_port = netaddr->sin_port;
+ g_wy_keepalive_state[i].sock_addr.sin_addr.s_addr = netaddr->sin_addr.s_addr;
+ g_wy_keepalive_state[i].sock_addr.sin_port = netaddr->sin_port;
char last_ip_str[16], new_ip_str[16];
- inet_ntop(AF_INET, &g_wangyan_keepalive_state[i].sock_addr.sin_addr.s_addr, last_ip_str, 16);
+ inet_ntop(AF_INET, &g_wy_keepalive_state[i].sock_addr.sin_addr.s_addr, last_ip_str, 16);
inet_ntop(AF_INET, &netaddr->sin_addr.s_addr, new_ip_str, 16);
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "Plug:%u last addr is:%s:%u, new addr is:%s:%u!",
- wkp_msg->local_id, last_ip_str, ntohs(g_wangyan_keepalive_state[i].sock_addr.sin_port),
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "Plug:%u last addr is:%s:%u, new addr is:%s:%u!",
+ wkp_msg->local_id, last_ip_str, ntohs(g_wy_keepalive_state[i].sock_addr.sin_port),
new_ip_str, ntohs(netaddr->sin_port));
}
- g_wangyan_keepalive_state[i].plug_keepalive_state = 1; /* ÿ�յ�һ�λظ�����Ϊ����, ��ֹ�Է��������ָֻ��޷���⵽������ */
- g_wangyan_keepalive_state[i].last_rcv_reply_timestamp = g_wkp_time_increase;
- g_wangyan_keepalive_state[i].last_recv_time_sec = g_wkp_cur_time;
- g_wangyan_keepalive_state[i].total_rcv_keepalive_pkt_num++;
+ g_wy_keepalive_state[i].plug_keepalive_state = 1; /* ÿ�յ�һ�λظ�����Ϊ����, ��ֹ�Է��������ָֻ��޷���⵽������ */
+ g_wy_keepalive_state[i].last_rcv_reply_timestamp = g_wkp_time_increase;
+ g_wy_keepalive_state[i].last_recv_time_sec = g_wkp_cur_time;
+ g_wy_keepalive_state[i].total_rcv_keepalive_pkt_num++;
break;
}
}
@@ -485,7 +485,7 @@ static void *wkp_master_recv_thread(void *arg)
saddr_len = sizeof(struct sockaddr);
ret = recvfrom(g_wkp_sock_fd, rcv_buf, 1500, 0, (struct sockaddr *)&saddr, &saddr_len);
if(ret > 0){
- wkp_master_pkt_process((const wangyan_keepalive_comm_t *)rcv_buf, &saddr);
+ wkp_master_pkt_process((const wy_keepalive_comm_t *)rcv_buf, &saddr);
}
}
@@ -495,9 +495,9 @@ static void *wkp_master_recv_thread(void *arg)
static void *wkp_master_send_thread(void *arg)
{
int ret, i;
- wangyan_keepalive_comm_t wkp_comm_data;
+ wy_keepalive_comm_t wkp_comm_data;
- wkp_comm_data.magic = WANGYAN_KEEPALIVE_MAGIC;
+ wkp_comm_data.magic = WY_KEEPALIVE_MAGIC;
wkp_comm_data.version = 1;
wkp_comm_data.msg_type = 8;
wkp_comm_data.local_id = 0; /* master id is 0 */
@@ -505,21 +505,21 @@ static void *wkp_master_send_thread(void *arg)
while(1){
g_wkp_cur_time = time(NULL);
- for(i = 0; i < WANGYAN_PLUG_NUM_MAX; i++){
- if(g_wangyan_keepalive_state[i].plug_id == 0){
+ for(i = 0; i < WY_PLUG_NUM_MAX; i++){
+ if(g_wy_keepalive_state[i].plug_id == 0){
continue;
}
retry:
- ret = sendto(g_wkp_sock_fd, &wkp_comm_data, sizeof(wangyan_keepalive_comm_t), MSG_DONTWAIT,
- (const struct sockaddr *)&g_wangyan_keepalive_state[i].sock_addr,
- sizeof(g_wangyan_keepalive_state[i].sock_addr));
+ ret = sendto(g_wkp_sock_fd, &wkp_comm_data, sizeof(wy_keepalive_comm_t), MSG_DONTWAIT,
+ (const struct sockaddr *)&g_wy_keepalive_state[i].sock_addr,
+ sizeof(g_wy_keepalive_state[i].sock_addr));
if(ret < 0){
if(EINTR == errno){
goto retry;
}
- printf("[wangyan_keepalive] sendto error, %s\n", strerror(errno));
+ printf("[wy_keepalive] sendto error, %s\n", strerror(errno));
}else{
- g_wangyan_keepalive_state[i].total_snd_keepalive_pkt_num++;
+ g_wy_keepalive_state[i].total_snd_keepalive_pkt_num++;
}
}
@@ -574,14 +574,14 @@ static int wkp_plug_master_check_depend_plug(void)
{
#if (0 == SELF_DEBUG)
if(wkp_search_dl("g_device_plug.so") <= 0){
- printf("\033[41m[wangyan_keepalive] error, in master mode, but no '%s' plug load!\033[0m\n", "g_device_plug.so");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "error, in master mode, but no '%s' plug load!", "g_device_plug.so");
+ printf("\033[41m[wy_keepalive] error, in master mode, but no '%s' plug load!\033[0m\n", "g_device_plug.so");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "error, in master mode, but no '%s' plug load!", "g_device_plug.so");
return -1;
}
if(wkp_search_dl("steward_wy.so") <= 0){
- printf("\033[41m[wangyan_keepalive] error, in master mode, but no '%s' plug load!\033[0m\n", "steward_wy.so");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "error, in master mode, but no '%s' plug load!", "steward_wy.so");
+ printf("\033[41m[wy_keepalive] error, in master mode, but no '%s' plug load!\033[0m\n", "steward_wy.so");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "error, in master mode, but no '%s' plug load!", "steward_wy.so");
return -1;
}
#endif
@@ -600,29 +600,29 @@ static int wkp_plug_master_get_depend_plug_symbol(void)
dl_handle_gdev = dlopen("./plug/platform/g_device_plug/g_device_plug.so", RTLD_NOW);
if(NULL == dl_handle_gdev){
- printf("\033[41m[wangyan_keepalive] dlopen '%s' error!\033[0m\n", "./plug/platform/g_device_plug/g_device_plug.so");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "dlopen '%s' error!", "./plug/platform/g_device_plug/g_device_plug.so");
+ printf("\033[41m[wy_keepalive] dlopen '%s' error!\033[0m\n", "./plug/platform/g_device_plug/g_device_plug.so");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "dlopen '%s' error!", "./plug/platform/g_device_plug/g_device_plug.so");
return -1;
}
wkp_gdev_keepalive_set_opt = (int (* )(const SAPP_TLV_T *))dlsym(dl_handle_gdev, "gdev_keepalive_set_opt");
if(NULL == wkp_gdev_keepalive_set_opt){
- printf("\033[41m[wangyan_keepalive] dlsym '%s' error!\033[0m\n", "gdev_keepalive_set_opt");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "dlsym '%s' error!", "gdev_keepalive_set_opt");
+ printf("\033[41m[wy_keepalive] dlsym '%s' error!\033[0m\n", "gdev_keepalive_set_opt");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "dlsym '%s' error!", "gdev_keepalive_set_opt");
return -1;
}
dl_handle_wy_master = dlopen("./plug/platform/steward_wy/steward_wy.so", RTLD_NOW);
if(NULL == dl_handle_wy_master){
- printf("\033[41m[wangyan_keepalive] dlopen '%s' error!\033[0m\n", "./plug/platform/steward_wy/steward_wy.so");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "dlopen '%s' error!", "./plug/platform/steward_wy/steward_wy.so");
+ printf("\033[41m[wy_keepalive] dlopen '%s' error!\033[0m\n", "./plug/platform/steward_wy/steward_wy.so");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "dlopen '%s' error!", "./plug/platform/steward_wy/steward_wy.so");
return -1;
}
wkp_g_plug_base_info = (stPlugBaseInfo *)dlsym(dl_handle_wy_master, "g_plug_base_info");
if(NULL == wkp_g_plug_base_info){
- printf("\033[41m[wangyan_keepalive] dlsym '%s' error!\033[0m\n", "g_plug_base_info");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "dlsym '%s' error!", "g_plug_base_info");
+ printf("\033[41m[wy_keepalive] dlsym '%s' error!\033[0m\n", "g_plug_base_info");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "dlsym '%s' error!", "g_plug_base_info");
return -1;
}
#endif
@@ -630,7 +630,7 @@ static int wkp_plug_master_get_depend_plug_symbol(void)
return 0;
}
-static int wangyan_keepalive_plug_master_init(void)
+static int wy_keepalive_plug_master_init(void)
{
//char __id_list_string_buf[1024];
//const char *delim = ", ";
@@ -658,46 +658,46 @@ static int wangyan_keepalive_plug_master_init(void)
while((single_plug_id_str = strtok_r(tmp_id_list_string, delim, &save_ptr)) != NULL){
tmp_plug_id = atoi(single_plug_id_str);
assert(tmp_plug_id > 0 );
- assert(tmp_plug_id < WANGYAN_PLUG_NUM_MAX);
-
- g_wangyan_keepalive_state[tmp_plug_id].plug_id = tmp_plug_id;
- g_wangyan_keepalive_state[tmp_plug_id].plug_keepalive_state = 1; /* Ĭ������ */
- g_wangyan_keepalive_state[tmp_plug_id].sock_addr.sin_family = AF_INET;
- g_wangyan_keepalive_state[tmp_plug_id].sock_addr.sin_addr.s_addr = htonl(0x7f000001);
- g_wangyan_keepalive_state[tmp_plug_id].sock_addr.sin_port = ntohs(g_begin_listen_port + tmp_plug_id);
- g_wangyan_keepalive_state[tmp_plug_id].last_rcv_reply_timestamp = 0;
- g_wangyan_keepalive_state[tmp_plug_id].last_recv_time_sec = 0;
- g_wangyan_keepalive_state[tmp_plug_id].total_snd_keepalive_pkt_num = 0;
- g_wangyan_keepalive_state[tmp_plug_id].total_rcv_keepalive_pkt_num = 0;
- g_wangyan_keepalive_state[tmp_plug_id].seq_num = 0;
- g_wangyan_keepalive_state[tmp_plug_id].plug_exclusivity = 0;
+ assert(tmp_plug_id < WY_PLUG_NUM_MAX);
+
+ g_wy_keepalive_state[tmp_plug_id].plug_id = tmp_plug_id;
+ g_wy_keepalive_state[tmp_plug_id].plug_keepalive_state = 1; /* Ĭ������ */
+ g_wy_keepalive_state[tmp_plug_id].sock_addr.sin_family = AF_INET;
+ g_wy_keepalive_state[tmp_plug_id].sock_addr.sin_addr.s_addr = htonl(0x7f000001);
+ g_wy_keepalive_state[tmp_plug_id].sock_addr.sin_port = ntohs(g_begin_listen_port + tmp_plug_id);
+ g_wy_keepalive_state[tmp_plug_id].last_rcv_reply_timestamp = 0;
+ g_wy_keepalive_state[tmp_plug_id].last_recv_time_sec = 0;
+ g_wy_keepalive_state[tmp_plug_id].total_snd_keepalive_pkt_num = 0;
+ g_wy_keepalive_state[tmp_plug_id].total_rcv_keepalive_pkt_num = 0;
+ g_wy_keepalive_state[tmp_plug_id].seq_num = 0;
+ g_wy_keepalive_state[tmp_plug_id].plug_exclusivity = 0;
plug_cfg_num++;
tmp_id_list_string = NULL;
}
if(0 == plug_cfg_num){
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "not found any valid plug!");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "not found any valid plug!");
}
#else
- for(tmp_plug_id = 0; tmp_plug_id < WANGYAN_PLUG_NUM_MAX; tmp_plug_id++){
- g_wangyan_keepalive_state[tmp_plug_id].plug_id = tmp_plug_id;
- g_wangyan_keepalive_state[tmp_plug_id].plug_keepalive_state = 1; /* Ĭ������ */
- g_wangyan_keepalive_state[tmp_plug_id].sock_addr.sin_family = AF_INET;
- g_wangyan_keepalive_state[tmp_plug_id].sock_addr.sin_addr.s_addr = htonl(0x7f000001);
- g_wangyan_keepalive_state[tmp_plug_id].sock_addr.sin_port = ntohs(g_begin_listen_port + tmp_plug_id);
- g_wangyan_keepalive_state[tmp_plug_id].last_rcv_reply_timestamp = 0;
- g_wangyan_keepalive_state[tmp_plug_id].last_recv_time_sec = 0;
- g_wangyan_keepalive_state[tmp_plug_id].total_snd_keepalive_pkt_num = 0;
- g_wangyan_keepalive_state[tmp_plug_id].total_rcv_keepalive_pkt_num = 0;
- g_wangyan_keepalive_state[tmp_plug_id].seq_num = 0;
- g_wangyan_keepalive_state[tmp_plug_id].plug_exclusivity = 0;
+ for(tmp_plug_id = 0; tmp_plug_id < WY_PLUG_NUM_MAX; tmp_plug_id++){
+ g_wy_keepalive_state[tmp_plug_id].plug_id = tmp_plug_id;
+ g_wy_keepalive_state[tmp_plug_id].plug_keepalive_state = 1; /* Ĭ������ */
+ g_wy_keepalive_state[tmp_plug_id].sock_addr.sin_family = AF_INET;
+ g_wy_keepalive_state[tmp_plug_id].sock_addr.sin_addr.s_addr = htonl(0x7f000001);
+ g_wy_keepalive_state[tmp_plug_id].sock_addr.sin_port = ntohs(g_begin_listen_port + tmp_plug_id);
+ g_wy_keepalive_state[tmp_plug_id].last_rcv_reply_timestamp = 0;
+ g_wy_keepalive_state[tmp_plug_id].last_recv_time_sec = 0;
+ g_wy_keepalive_state[tmp_plug_id].total_snd_keepalive_pkt_num = 0;
+ g_wy_keepalive_state[tmp_plug_id].total_rcv_keepalive_pkt_num = 0;
+ g_wy_keepalive_state[tmp_plug_id].seq_num = 0;
+ g_wy_keepalive_state[tmp_plug_id].plug_exclusivity = 0;
}
#endif
g_wkp_sock_fd = socket(AF_INET,SOCK_DGRAM,0);
if(g_wkp_sock_fd < 0){
- printf("\033[41m[wangyan_keepalive] socket error!\033[0m\n");
+ printf("\033[41m[wy_keepalive] socket error!\033[0m\n");
return -1;
}
@@ -712,16 +712,16 @@ static int wangyan_keepalive_plug_master_init(void)
sockadd.sin_port = htons(g_begin_listen_port);
if(bind(g_wkp_sock_fd, (struct sockaddr *) &sockadd, sizeof(sockadd)) < 0){
- printf("\033[41m[wangyan_keepalive]master bind port %u error, %s!\033[0m\n", g_begin_listen_port, strerror(errno));
+ printf("\033[41m[wy_keepalive]master bind port %u error, %s!\033[0m\n", g_begin_listen_port, strerror(errno));
return -1;
}
- MESA_handle_runtime_log(g_wkp_log_handle, 10, "wangyan_keepalive", "master init SUCC");
+ MESA_handle_runtime_log(g_wkp_log_handle, 10, "wy_keepalive", "master init SUCC");
return 0;
}
-static int wangyan_keepalive_plug_slave_init(void)
+static int wy_keepalive_plug_slave_init(void)
{
//char plug_id_str[128];
int tmp_plug_id;
@@ -730,12 +730,12 @@ static int wangyan_keepalive_plug_slave_init(void)
#if 0
MESA_load_profile_string_def((char *)"./conf/wangyan_keepalive.conf", (char *)"slave", (char *)"local_plug_id", plug_id_str, 128, "");
if('\0' == plug_id_str[0]){
- printf("\033[41m[wangyan_keepalive] error, read conf 'local_plug_id' error!\033[0m\n");
+ printf("\033[41m[wy_keepalive] error, read conf 'local_plug_id' error!\033[0m\n");
return -1;
}
tmp_plug_id = atoi(plug_id_str);
if((tmp_plug_id < 1) || (tmp_plug_id > 64)){
- printf("\033[41m[wangyan_keepalive] error, 'local_plug_id' invalid!\033[0m\n");
+ printf("\033[41m[wy_keepalive] error, 'local_plug_id' invalid!\033[0m\n");
return -1;
}
g_wkp_slave_local_plug_id = tmp_plug_id;
@@ -747,7 +747,7 @@ static int wangyan_keepalive_plug_slave_init(void)
g_wkp_sock_fd = socket(AF_INET,SOCK_DGRAM,0);
if(g_wkp_sock_fd < 0){
- printf("\033[41m[wangyan_keepalive] socket error!\033[0m\n");
+ printf("\033[41m[wy_keepalive] socket error!\033[0m\n");
return -1;
}
@@ -766,26 +766,26 @@ static int wangyan_keepalive_plug_slave_init(void)
*/
while(1){
if(bind(g_wkp_sock_fd, (struct sockaddr *) &sockadd, sizeof(sockadd)) < 0){
- printf("\033[41m[wangyan_keepalive]plug_id:%u bind port %u error, %s!\033[0m\n",
+ printf("\033[41m[wy_keepalive]plug_id:%u bind port %u error, %s!\033[0m\n",
g_wkp_slave_local_plug_id, g_begin_listen_port+tmp_plug_id, strerror(errno));
tmp_plug_id++;
sockadd.sin_port = htons(g_begin_listen_port + tmp_plug_id);
continue;
}else{
- MESA_handle_runtime_log(g_wkp_log_handle, 20, "wangyan_keepalive", "plug_id:%d bind port %d SUCC!\n",
+ MESA_handle_runtime_log(g_wkp_log_handle, 20, "wy_keepalive", "plug_id:%d bind port %d SUCC!\n",
g_wkp_slave_local_plug_id, g_begin_listen_port + tmp_plug_id);
break;
}
}
- MESA_handle_runtime_log(g_wkp_log_handle, 10, "wangyan_keepalive", "slave init SUCC");
+ MESA_handle_runtime_log(g_wkp_log_handle, 10, "wy_keepalive", "slave init SUCC");
return 0;
}
#if (0 == SELF_DEBUG)
-static void wangyan_gdev_keepalive_depend_service_set(int service_num)
+static void wy_gdev_keepalive_depend_service_set(int service_num)
{
SAPP_TLV_T keepalive_opt;
@@ -802,7 +802,7 @@ static void wangyan_gdev_keepalive_depend_service_set(int service_num)
keepalive_opt.ptr_value = &service_opt;
wkp_gdev_keepalive_set_opt(&keepalive_opt);
- MESA_handle_runtime_log(g_wkp_log_handle, 10, "wangyan_keepalive", "set gdev keepalive service num: %d", service_num);
+ MESA_handle_runtime_log(g_wkp_log_handle, 10, "wy_keepalive", "set gdev keepalive service num: %d", service_num);
return;
}
@@ -812,7 +812,7 @@ static void wangyan_gdev_keepalive_depend_service_set(int service_num)
ͬʱ֧�ֶ��ŷָ��Ķ��ҵ���.
*/
#if (0 == SELF_DEBUG)
-static int wangyan_gdev_keepalive_init(char *servie_num_list)
+static int wy_gdev_keepalive_init(char *servie_num_list)
{
const char *delim = "\t ,";
char *saveptr = NULL;
@@ -823,7 +823,7 @@ static int wangyan_gdev_keepalive_init(char *servie_num_list)
while((section = strtok_r(parse_config_str, delim, &saveptr))){
tmp_int_num = atoi(section);
if((tmp_int_num > 0) && (tmp_int_num < 255)){
- wangyan_gdev_keepalive_depend_service_set(tmp_int_num);
+ wy_gdev_keepalive_depend_service_set(tmp_int_num);
}
parse_config_str = NULL;
}
@@ -837,7 +837,7 @@ static int wangyan_gdev_keepalive_init(char *servie_num_list)
packet_io_marsio.soĬ�ϴ�main.conf->sapp_instance_name��ȡ,
��ģ��ֱ���޸�main.conf->sapp_instance_name.
*/
-static void wangyan_set_sapp_instance_name(void)
+static void wy_set_sapp_instance_name(void)
{
char tmp_cmd_buf[256];
@@ -862,55 +862,55 @@ static void wangyan_set_sapp_instance_name(void)
}
-int wangyan_keepalive_plug_init(void)
+int wy_keepalive_plug_init(void)
{
int tmp_int, ret;
pthread_t t_pid1,t_pid2,t_pid3;
char tmp_str[128];
#if SELF_DEBUG
- printf("\033[1;31;40m[wangyan_keepalive_plug] This is a debug version!\033[0m\n");
+ printf("\033[1;31;40m[wy_keepalive_plug] This is a debug version!\033[0m\n");
sleep(3);
#endif
/* read conf, get master, or slave */
- assert(sizeof(wangyan_keepalive_state_t) % 64 == 0);
+ assert(sizeof(wy_keepalive_state_t) % 64 == 0);
g_wkp_cur_time = time(NULL);
- g_wkp_log_handle = MESA_create_runtime_log_handle("./log/wangyan_keepalive.log", 0);
+ g_wkp_log_handle = MESA_create_runtime_log_handle("./log/wy_keepalive.log", 0);
#if 0 /* 2017-11-27 lijia modify, ���ٿ������ļ��ֹ�ָ��ģʽ, ͨ���ܿغ������ز��id����, 0����master */
MESA_load_profile_string_def((char *)"./conf/wangyan_keepalive.conf", (char *)"main", (char *)"mode", tmp_str, 128, "");
if(strncasecmp("master", tmp_str, strlen("master")) == 0){
- g_wangyan_keepalive_mode = WANGYAN_KEEPALIVE_MODE_MASTER;
+ g_wy_keepalive_mode = WY_KEEPALIVE_MODE_MASTER;
}else if(strncasecmp("slave", tmp_str, strlen("slave")) == 0){
- g_wangyan_keepalive_mode = WANGYAN_KEEPALIVE_MODE_SLAVE;
+ g_wy_keepalive_mode = WY_KEEPALIVE_MODE_SLAVE;
}else{
- printf("\033[41m[[wangyan_keepalive] error, read conf 'mode' error!\033[0m[\n");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "read conf 'mode' error!");
+ printf("\033[41m[[wy_keepalive] error, read conf 'mode' error!\033[0m[\n");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "read conf 'mode' error!");
return -1;
}
#else
g_wkp_slave_local_plug_id = wy_steward_plugin_id_get();
if(0 == g_wkp_slave_local_plug_id){
- g_wangyan_keepalive_mode = WANGYAN_KEEPALIVE_MODE_MASTER;
+ g_wy_keepalive_mode = WY_KEEPALIVE_MODE_MASTER;
}else{
- g_wangyan_keepalive_mode = WANGYAN_KEEPALIVE_MODE_SLAVE;
+ g_wy_keepalive_mode = WY_KEEPALIVE_MODE_SLAVE;
}
#endif
MESA_load_profile_int_def((char *)"./conf/wangyan_keepalive.conf", (char *)"main", (char *)"begin_listen_port", &tmp_int, 0);
if((0 >= tmp_int) || (tmp_int > 65535)){
- printf("\033[41m[[wangyan_keepalive] error, read conf 'begin_listen_port' error!\033[0m[\n");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "read conf 'begin_listen_port' error!");
+ printf("\033[41m[[wy_keepalive] error, read conf 'begin_listen_port' error!\033[0m[\n");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "read conf 'begin_listen_port' error!");
return -1;
}
g_begin_listen_port = (unsigned short)tmp_int;
- if(WANGYAN_KEEPALIVE_MODE_MASTER == g_wangyan_keepalive_mode){
- ret = wangyan_keepalive_plug_master_init();
+ if(WY_KEEPALIVE_MODE_MASTER == g_wy_keepalive_mode){
+ ret = wy_keepalive_plug_master_init();
if(ret < 0){
return -1;
}
@@ -918,7 +918,7 @@ int wangyan_keepalive_plug_init(void)
pthread_create(&t_pid2, NULL, wkp_master_recv_thread, NULL);
pthread_create(&t_pid3, NULL, wkp_master_check_keepalive_state_thread, NULL);
}else{
- ret = wangyan_keepalive_plug_slave_init();
+ ret = wy_keepalive_plug_slave_init();
if(ret < 0){
return -1;
}
@@ -927,17 +927,17 @@ int wangyan_keepalive_plug_init(void)
}
/* ֻ����Ӧ�ò�����G������ز���, ��Ӧ��������� */
- if(WANGYAN_KEEPALIVE_MODE_MASTER == g_wangyan_keepalive_mode){
- /* wangyanĬ��ҵ���: 12, ֧�ֶ��ҵ�񶺺ŷָ�ģʽ */
+ if(WY_KEEPALIVE_MODE_MASTER == g_wy_keepalive_mode){
+ /* wyĬ��ҵ���: 12, ֧�ֶ��ҵ�񶺺ŷָ�ģʽ */
MESA_load_profile_string_def((char *)"./conf/wangyan_keepalive.conf", (char *)"gdev_service", (char *)"keepalive_service", tmp_str, 128, "12");
- /* NOTE: �˺���������wangyan_keepalive_plug_master_init֮��, ��Ϊ�漰����ȡg_keepalive_plug.so�еķ����� */
+ /* NOTE: �˺���������wy_keepalive_plug_master_init֮��, ��Ϊ�漰����ȡg_keepalive_plug.so�еķ����� */
#if (0 == SELF_DEBUG)
- wangyan_gdev_keepalive_init(tmp_str);
+ wy_gdev_keepalive_init(tmp_str);
#endif
}
- wangyan_set_sapp_instance_name();
+ wy_set_sapp_instance_name();
return ret;
}
diff --git a/src/inner_plug/wangyan_keepalive_plug_with_libping.c b/src/inner_plug/wy_keepalive_plug_with_libping.c
index c5a0cbe..b68a09f 100644
--- a/src/inner_plug/wangyan_keepalive_plug_with_libping.c
+++ b/src/inner_plug/wy_keepalive_plug_with_libping.c
@@ -7,9 +7,9 @@ extern "C" {
#include "libping.h"
-int wangyan_keepalive_plug_version_VERSION_20180428;
+int wy_keepalive_plug_version_VERSION_20180428;
-#define WANGYAN_PLUG_NUM_MAX (64)
+#define WY_PLUG_NUM_MAX (64)
#define SELF_DEBUG (0) /* ���ܿص��������Բ��� */
@@ -19,7 +19,7 @@ int wy_steward_plugin_id_get(void)
{
return 0;
}
-stPlugBaseInfo wkp_g_plug_base_info[WANGYAN_PLUG_NUM_MAX];
+stPlugBaseInfo wkp_g_plug_base_info[WY_PLUG_NUM_MAX];
#else
/* ��������������ı���, ��master��ʹ��, slave����, ��slave���޷��ҵ���ط�����, Ҳ������������汾, ��̬��ȡ */
extern stPlugRuntimeInfo plugctrl_runtime_info; /* ƽ̨����, ���ڼ�������͵���������ʱ, ֱ������ */
@@ -44,10 +44,10 @@ begin_listen_port=60000 //��ʼ�˿�Ϊ60000, ���ذ�Դ�˿�Ϊ60000, ���2�Ų
slave_plug_id_list=1,2,23,34,45
*/
-#define WANGYAN_KEEPALIVE_MODE_MASTER 1
-#define WANGYAN_KEEPALIVE_MODE_SLAVE 2
+#define WY_KEEPALIVE_MODE_MASTER 1
+#define WY_KEEPALIVE_MODE_SLAVE 2
-#define WANGYAN_KEEPALIVE_MAGIC (0x474E4157) /* "WANG"�ַ�����16���� */
+#define WY_KEEPALIVE_MAGIC (0x474E4157) /* "WANG"�ַ�����16���� */
#ifndef WKP_MAX
@@ -62,11 +62,11 @@ enum plug_abnormal_t{
typedef struct{
unsigned int magic;
- unsigned char local_id; /* ���ڱ�ʶ���˵�id, ����WANGYAN��Ŀ��˵, �����id */
+ unsigned char local_id; /* ���ڱ�ʶ���˵�id, ����WY��Ŀ��˵, �����id */
unsigned char msg_type; /* 0:reply; 8:echo, ����ICMPЭ���ֶκ� */
unsigned char version; /* ĿǰΪ1 */
unsigned char seq_num; /* ��0��ʼ, �ۼ� */
-}wangyan_keepalive_comm_t; /* ����ͨ�Žӿ� */
+}wy_keepalive_comm_t; /* ����ͨ�Žӿ� */
typedef struct{
int plug_id;
@@ -80,16 +80,16 @@ typedef struct{
volatile int plug_exclusivity; /* �����ռ�Կ���, ����˲��������, �������ٺ�gdev����, �ᶯ̬���� */
//unsigned char seq_num;
//char __pad[59];
-}wangyan_keepalive_state_t; /* ����״̬��¼ */
+}wy_keepalive_state_t; /* ����״̬��¼ */
static unsigned short g_begin_listen_port = 60000; /* ������, host order, ���ڸ��ݲ��ID������Χ */
-static int g_wangyan_keepalive_mode = WANGYAN_KEEPALIVE_MODE_SLAVE; /* Ĭ�ϴ�ģʽ, ��ֹû�������ļ���������ģʽ����, ����������̽��� */
+static int g_wy_keepalive_mode = WY_KEEPALIVE_MODE_SLAVE; /* Ĭ�ϴ�ģʽ, ��ֹû�������ļ���������ģʽ����, ����������̽��� */
static unsigned long long g_wkp_time_increase = 1; /* ����������ʱ���, ����̽�Ᵽ�ʱ, ��1��ʼ���ÿ��50ms����1 */
static time_t g_wkp_cur_time; /* ��ǰ����ʱ�������, master��slave�ڲ�ͬ���̸��Ը��� */
-static wangyan_keepalive_state_t g_wangyan_keepalive_state[WANGYAN_PLUG_NUM_MAX]; /* ��Ӧ�ò����ַ�� */
+static wy_keepalive_state_t g_wy_keepalive_state[WY_PLUG_NUM_MAX]; /* ��Ӧ�ò����ַ�� */
static volatile int g_wkp_slave_abnormal_flag = 0; /* ��Ӧ���쳣���, ��������, ����������ʱ������ */
@@ -231,14 +231,14 @@ do_log:
if(res != 0){
g_wkp_slave_abnormal_flag = 1;
if(log_last_slave_state != g_wkp_slave_abnormal_flag){/* ��״̬�л�ʱ��д��־, �����д������������־ */
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "plug_id %d, because %s into abnormal status!",
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "plug_id %d, because %s into abnormal status!",
g_wkp_slave_local_plug_id,
wkp_abnormal_state_to_string(res_type));
}
}else{
g_wkp_slave_abnormal_flag = 0;
if(log_last_slave_state != g_wkp_slave_abnormal_flag){/* ��״̬�л�ʱ��д��־, �����д������������־ */
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "plug_id %d, into normal status!",
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "plug_id %d, into normal status!",
g_wkp_slave_local_plug_id);
}
}
@@ -259,8 +259,8 @@ static void wkp_master_get_plug_exclusivity_stat(void)
{
int i;
- for(i = 0; i < WANGYAN_PLUG_NUM_MAX; i++){
- g_wangyan_keepalive_state[i].plug_exclusivity = wkp_g_plug_base_info[g_wangyan_keepalive_state[i].plug_id].keepalive_flag;
+ for(i = 0; i < WY_PLUG_NUM_MAX; i++){
+ g_wy_keepalive_state[i].plug_exclusivity = wkp_g_plug_base_info[g_wy_keepalive_state[i].plug_id].keepalive_flag;
}
}
@@ -270,9 +270,9 @@ static int wkp_master_update_plug_state(int plug_id, int keepalive_state)
assert(plug_id < WY_MAX_PLUG_NUM);
wkp_g_plug_base_info[plug_id].keepalive_state = keepalive_state; /* �����ܿز����״̬ */
- g_wangyan_keepalive_state[plug_id].plug_keepalive_state = keepalive_state; /* ���±�ģ���ڲ��״̬ */
+ g_wy_keepalive_state[plug_id].plug_keepalive_state = keepalive_state; /* ���±�ģ���ڲ��״̬ */
- return g_wangyan_keepalive_state[plug_id].plug_keepalive_state;
+ return g_wy_keepalive_state[plug_id].plug_keepalive_state;
}
@@ -286,19 +286,19 @@ static void wkp_master_keepalive_status_log(void)
int node_stat_len = sizeof(node_stat);
if(last_log_time < g_wkp_cur_time){
- fp = fopen("./log/wangyan_keepalive_status.log", "w+");
+ fp = fopen("./log/wy_keepalive_status.log", "w+");
if(NULL == fp){
return;
}
fprintf(fp, "%8s %12s %10s %10s %6s %24s\n", "plug-id", "exclusivity", "tot-snd", "tot-rcv", "alive", "last_pkt_time");
- for(i = 0; i < WANGYAN_PLUG_NUM_MAX; i++){
- if(0 == g_wangyan_keepalive_state[i].plug_id){ /* 0 is master */
+ for(i = 0; i < WY_PLUG_NUM_MAX; i++){
+ if(0 == g_wy_keepalive_state[i].plug_id){ /* 0 is master */
continue;
}
wkp_timet_to_str(time(NULL), tmp_time_str, 64);
- node_stat.slave_id = g_wangyan_keepalive_state[i].plug_id;
+ node_stat.slave_id = g_wy_keepalive_state[i].plug_id;
ret = libping_get_opt(g_wkp_ping_handle, PO_NODE_STATUS, &node_stat, &node_stat_len);
if((ret < 0) || (LIBPING_STATE_KEEPALIVE_SUCC != node_stat.state)){
continue;
@@ -306,11 +306,11 @@ static void wkp_master_keepalive_status_log(void)
fprintf(fp,
"%8d %12d %10u %10u %6d %24s\n",
- g_wangyan_keepalive_state[i].plug_id,
- g_wangyan_keepalive_state[i].plug_exclusivity,
+ g_wy_keepalive_state[i].plug_id,
+ g_wy_keepalive_state[i].plug_exclusivity,
node_stat.send_req_pkt,
node_stat.send_req_pkt,
- g_wangyan_keepalive_state[i].plug_keepalive_state,
+ g_wy_keepalive_state[i].plug_keepalive_state,
tmp_time_str);
tot_alive_slave_num++;
}
@@ -332,17 +332,17 @@ static void wkp_master_update_gdev_keepalive_flag(void)
int alive_plug_num = 0;
static time_t last_log_time = 0;
- for(plug_id = 1; plug_id < WANGYAN_PLUG_NUM_MAX; plug_id++){
- if((1 == g_wangyan_keepalive_state[plug_id].plug_exclusivity)
- && (0 == g_wangyan_keepalive_state[plug_id].plug_keepalive_state)){
+ for(plug_id = 1; plug_id < WY_PLUG_NUM_MAX; plug_id++){
+ if((1 == g_wy_keepalive_state[plug_id].plug_exclusivity)
+ && (0 == g_wy_keepalive_state[plug_id].plug_keepalive_state)){
gdev_global_switch = 0; /* һƱ��� */
- if(g_wangyan_keepalive_state[plug_id].last_log_time < g_CurrentTime){
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "plug id=%d is not alive, is exclusive, so disable gdev global keepalive!", plug_id);
- g_wangyan_keepalive_state[plug_id].last_log_time = g_CurrentTime;
+ if(g_wy_keepalive_state[plug_id].last_log_time < g_CurrentTime){
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "plug id=%d is not alive, is exclusive, so disable gdev global keepalive!", plug_id);
+ g_wy_keepalive_state[plug_id].last_log_time = g_CurrentTime;
}
break;
}
- if(1 == g_wangyan_keepalive_state[plug_id].plug_keepalive_state){
+ if(1 == g_wy_keepalive_state[plug_id].plug_keepalive_state){
alive_plug_num++;
}
}
@@ -350,7 +350,7 @@ static void wkp_master_update_gdev_keepalive_flag(void)
if(0 == alive_plug_num){
gdev_global_switch = 0;
if(last_log_time + 5 < g_CurrentTime){
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "All plug is not alive, disable gdev global keepalive!");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "All plug is not alive, disable gdev global keepalive!");
last_log_time = g_CurrentTime;
}
}
@@ -375,21 +375,21 @@ static void *wkp_master_check_keepalive_state_thread(void *arg)
while(1){
plug_state_sum = 0;
- for(i = 0; i < WANGYAN_PLUG_NUM_MAX; i++){
- if(g_wangyan_keepalive_state[i].plug_id == 0){
+ for(i = 0; i < WY_PLUG_NUM_MAX; i++){
+ if(g_wy_keepalive_state[i].plug_id == 0){
continue;
}
- node_stat.slave_id = g_wangyan_keepalive_state[i].plug_id;
+ node_stat.slave_id = g_wy_keepalive_state[i].plug_id;
ret = libping_get_opt(g_wkp_ping_handle, PO_NODE_STATUS, &node_stat, &node_stat_len);
if((ret >= 0) && (LIBPING_STATE_KEEPALIVE_SUCC == node_stat.state)){
- g_wangyan_keepalive_state[i].plug_keepalive_state = 1;
+ g_wy_keepalive_state[i].plug_keepalive_state = 1;
}else{
- g_wangyan_keepalive_state[i].plug_keepalive_state = 0;
+ g_wy_keepalive_state[i].plug_keepalive_state = 0;
}
/* ���ݱ��ر���״̬, �����ܿز���ڲ���״̬ */
- plug_state_sum += wkp_master_update_plug_state(g_wangyan_keepalive_state[i].plug_id, g_wangyan_keepalive_state[i].plug_keepalive_state);
+ plug_state_sum += wkp_master_update_plug_state(g_wy_keepalive_state[i].plug_id, g_wy_keepalive_state[i].plug_keepalive_state);
}
wkp_master_update_gdev_keepalive_flag();
@@ -449,14 +449,14 @@ static int wkp_plug_master_check_depend_plug(void)
{
#if (0 == SELF_DEBUG)
if(wkp_search_dl("g_device_plug.so") <= 0){
- printf("\033[41m[wangyan_keepalive] error, in master mode, but no '%s' plug load!\033[0m\n", "g_device_plug.so");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "error, in master mode, but no '%s' plug load!", "g_device_plug.so");
+ printf("\033[41m[wy_keepalive] error, in master mode, but no '%s' plug load!\033[0m\n", "g_device_plug.so");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "error, in master mode, but no '%s' plug load!", "g_device_plug.so");
return -1;
}
if(wkp_search_dl("steward_wy.so") <= 0){
- printf("\033[41m[wangyan_keepalive] error, in master mode, but no '%s' plug load!\033[0m\n", "steward_wy.so");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "error, in master mode, but no '%s' plug load!", "steward_wy.so");
+ printf("\033[41m[wy_keepalive] error, in master mode, but no '%s' plug load!\033[0m\n", "steward_wy.so");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "error, in master mode, but no '%s' plug load!", "steward_wy.so");
return -1;
}
#endif
@@ -475,29 +475,29 @@ static int wkp_plug_master_get_depend_plug_symbol(void)
dl_handle_gdev = dlopen("./plug/platform/g_device_plug/g_device_plug.so", RTLD_NOW);
if(NULL == dl_handle_gdev){
- printf("\033[41m[wangyan_keepalive] dlopen '%s' error!\033[0m\n", "./plug/platform/g_device_plug/g_device_plug.so");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "dlopen '%s' error!", "./plug/platform/g_device_plug/g_device_plug.so");
+ printf("\033[41m[wy_keepalive] dlopen '%s' error!\033[0m\n", "./plug/platform/g_device_plug/g_device_plug.so");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "dlopen '%s' error!", "./plug/platform/g_device_plug/g_device_plug.so");
return -1;
}
wkp_gdev_keepalive_set_opt = (int (* )(const SAPP_TLV_T *))dlsym(dl_handle_gdev, "gdev_keepalive_set_opt");
if(NULL == wkp_gdev_keepalive_set_opt){
- printf("\033[41m[wangyan_keepalive] dlsym '%s' error!\033[0m\n", "gdev_keepalive_set_opt");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "dlsym '%s' error!", "gdev_keepalive_set_opt");
+ printf("\033[41m[wy_keepalive] dlsym '%s' error!\033[0m\n", "gdev_keepalive_set_opt");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "dlsym '%s' error!", "gdev_keepalive_set_opt");
return -1;
}
dl_handle_wy_master = dlopen("./plug/platform/steward_wy/steward_wy.so", RTLD_NOW);
if(NULL == dl_handle_wy_master){
- printf("\033[41m[wangyan_keepalive] dlopen '%s' error!\033[0m\n", "./plug/platform/steward_wy/steward_wy.so");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "dlopen '%s' error!", "./plug/platform/steward_wy/steward_wy.so");
+ printf("\033[41m[wy_keepalive] dlopen '%s' error!\033[0m\n", "./plug/platform/steward_wy/steward_wy.so");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "dlopen '%s' error!", "./plug/platform/steward_wy/steward_wy.so");
return -1;
}
wkp_g_plug_base_info = (stPlugBaseInfo *)dlsym(dl_handle_wy_master, "g_plug_base_info");
if(NULL == wkp_g_plug_base_info){
- printf("\033[41m[wangyan_keepalive] dlsym '%s' error!\033[0m\n", "g_plug_base_info");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "dlsym '%s' error!", "g_plug_base_info");
+ printf("\033[41m[wy_keepalive] dlsym '%s' error!\033[0m\n", "g_plug_base_info");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "dlsym '%s' error!", "g_plug_base_info");
return -1;
}
#endif
@@ -505,7 +505,7 @@ static int wkp_plug_master_get_depend_plug_symbol(void)
return 0;
}
-static int wangyan_keepalive_plug_master_init(void)
+static int wy_keepalive_plug_master_init(void)
{
int tmp_plug_id;
short opt_short;
@@ -518,10 +518,10 @@ static int wangyan_keepalive_plug_master_init(void)
if(wkp_plug_master_get_depend_plug_symbol() < 0){
return -1;
}
- for(tmp_plug_id = 0; tmp_plug_id < WANGYAN_PLUG_NUM_MAX; tmp_plug_id++){
- g_wangyan_keepalive_state[tmp_plug_id].plug_id = tmp_plug_id;
- g_wangyan_keepalive_state[tmp_plug_id].plug_keepalive_state = 0; /* ��ʼ״̬������ */
- g_wangyan_keepalive_state[tmp_plug_id].plug_exclusivity = 0;
+ for(tmp_plug_id = 0; tmp_plug_id < WY_PLUG_NUM_MAX; tmp_plug_id++){
+ g_wy_keepalive_state[tmp_plug_id].plug_id = tmp_plug_id;
+ g_wy_keepalive_state[tmp_plug_id].plug_keepalive_state = 0; /* ��ʼ״̬������ */
+ g_wy_keepalive_state[tmp_plug_id].plug_exclusivity = 0;
}
g_wkp_ping_handle = libping_create();
@@ -537,12 +537,12 @@ static int wangyan_keepalive_plug_master_init(void)
libping_run(g_wkp_ping_handle);
- MESA_handle_runtime_log(g_wkp_log_handle, 10, "wangyan_keepalive", "master init SUCC");
+ MESA_handle_runtime_log(g_wkp_log_handle, 10, "wy_keepalive", "master init SUCC");
return 0;
}
-static int wangyan_keepalive_slave_replay_cb_fun(ping_handle ph, unsigned int pair_tag, unsigned int slave_id)
+static int wy_keepalive_slave_replay_cb_fun(ping_handle ph, unsigned int pair_tag, unsigned int slave_id)
{
if(0 == g_wkp_slave_abnormal_flag){
return 1;
@@ -551,7 +551,7 @@ static int wangyan_keepalive_slave_replay_cb_fun(ping_handle ph, unsigned int pa
return 0;
}
-static int wangyan_keepalive_plug_slave_init(void)
+static int wy_keepalive_plug_slave_init(void)
{
int master_ip_net = 0x0100007f;
short opt_short;
@@ -567,7 +567,7 @@ static int wangyan_keepalive_plug_slave_init(void)
libping_set_opt(g_wkp_ping_handle, PO_WORK_MODE, (void *)&opt_short, sizeof(short));
libping_set_opt(g_wkp_ping_handle, PO_SLAVE_ID, (void *)&g_wkp_slave_local_plug_id, sizeof(int));
- libping_set_opt(g_wkp_ping_handle, PO_SLAVE_PRE_REPLAY_CB, (void *)&wangyan_keepalive_slave_replay_cb_fun, sizeof(void *));
+ libping_set_opt(g_wkp_ping_handle, PO_SLAVE_PRE_REPLAY_CB, (void *)&wy_keepalive_slave_replay_cb_fun, sizeof(void *));
libping_set_opt(g_wkp_ping_handle, PO_MASTER_IP_NET_ORDER, (void *)&master_ip_net, sizeof(int));
g_begin_listen_port = htons(g_begin_listen_port);
@@ -575,14 +575,14 @@ static int wangyan_keepalive_plug_slave_init(void)
libping_run(g_wkp_ping_handle);
- MESA_handle_runtime_log(g_wkp_log_handle, 10, "wangyan_keepalive", "slave init SUCC");
+ MESA_handle_runtime_log(g_wkp_log_handle, 10, "wy_keepalive", "slave init SUCC");
return 0;
}
#if (0 == SELF_DEBUG)
-static void wangyan_gdev_keepalive_depend_service_set(int service_num)
+static void wy_gdev_keepalive_depend_service_set(int service_num)
{
SAPP_TLV_T keepalive_opt;
@@ -599,7 +599,7 @@ static void wangyan_gdev_keepalive_depend_service_set(int service_num)
keepalive_opt.ptr_value = &service_opt;
wkp_gdev_keepalive_set_opt(&keepalive_opt);
- MESA_handle_runtime_log(g_wkp_log_handle, 10, "wangyan_keepalive", "set gdev keepalive service num: %d", service_num);
+ MESA_handle_runtime_log(g_wkp_log_handle, 10, "wy_keepalive", "set gdev keepalive service num: %d", service_num);
return;
}
@@ -609,7 +609,7 @@ static void wangyan_gdev_keepalive_depend_service_set(int service_num)
ͬʱ֧�ֶ��ŷָ��Ķ��ҵ���.
*/
#if (0 == SELF_DEBUG)
-static int wangyan_gdev_keepalive_init(char *servie_num_list)
+static int wy_gdev_keepalive_init(char *servie_num_list)
{
const char *delim = "\t ,";
char *saveptr = NULL;
@@ -620,7 +620,7 @@ static int wangyan_gdev_keepalive_init(char *servie_num_list)
while((section = strtok_r(parse_config_str, delim, &saveptr))){
tmp_int_num = atoi(section);
if((tmp_int_num > 0) && (tmp_int_num < 255)){
- wangyan_gdev_keepalive_depend_service_set(tmp_int_num);
+ wy_gdev_keepalive_depend_service_set(tmp_int_num);
}
parse_config_str = NULL;
}
@@ -634,7 +634,7 @@ static int wangyan_gdev_keepalive_init(char *servie_num_list)
packet_io_marsio.soĬ�ϴ�main.conf->sapp_instance_name��ȡ,
��ģ��ֱ���޸�main.conf->sapp_instance_name.
*/
-static void wangyan_set_sapp_instance_name(void)
+static void wy_set_sapp_instance_name(void)
{
char tmp_cmd_buf[256];
@@ -659,14 +659,14 @@ static void wangyan_set_sapp_instance_name(void)
}
-int wangyan_keepalive_plug_init(void)
+int wy_keepalive_plug_init(void)
{
int tmp_int, ret;
pthread_t t_pid;
char tmp_str[128];
#if SELF_DEBUG
- printf("\033[1;31;40m[wangyan_keepalive_plug] This is a debug version!\033[0m\n");
+ printf("\033[1;31;40m[wy_keepalive_plug] This is a debug version!\033[0m\n");
sleep(3);
#endif
@@ -674,31 +674,31 @@ int wangyan_keepalive_plug_init(void)
g_wkp_cur_time = time(NULL);
- g_wkp_log_handle = MESA_create_runtime_log_handle("./log/wangyan_keepalive.log", 0);
+ g_wkp_log_handle = MESA_create_runtime_log_handle("./log/y_keepalive.log", 0);
g_wkp_slave_local_plug_id = wy_steward_plugin_id_get();
if(0 == g_wkp_slave_local_plug_id){ /* Լ��: id=0��ʾmaster, ����slave��1��ʼ��� */
- g_wangyan_keepalive_mode = WANGYAN_KEEPALIVE_MODE_MASTER;
+ g_wy_keepalive_mode = WY_KEEPALIVE_MODE_MASTER;
}else{
- g_wangyan_keepalive_mode = WANGYAN_KEEPALIVE_MODE_SLAVE;
+ g_wy_keepalive_mode = WY_KEEPALIVE_MODE_SLAVE;
}
MESA_load_profile_int_def((char *)"./conf/wangyan_keepalive.conf", (char *)"main", (char *)"begin_listen_port", &tmp_int, 0);
if((0 >= tmp_int) || (tmp_int > 65535)){
- printf("\033[41m[[wangyan_keepalive] error, read conf 'begin_listen_port' error!\033[0m[\n");
- MESA_handle_runtime_log(g_wkp_log_handle, 30, "wangyan_keepalive", "read conf 'begin_listen_port' error!");
+ printf("\033[41m[[wy_keepalive] error, read conf 'begin_listen_port' error!\033[0m[\n");
+ MESA_handle_runtime_log(g_wkp_log_handle, 30, "wy_keepalive", "read conf 'begin_listen_port' error!");
return -1;
}
g_begin_listen_port = (unsigned short)tmp_int;
- if(WANGYAN_KEEPALIVE_MODE_MASTER == g_wangyan_keepalive_mode){
- ret = wangyan_keepalive_plug_master_init();
+ if(WY_KEEPALIVE_MODE_MASTER == g_wy_keepalive_mode){
+ ret = wy_keepalive_plug_master_init();
if(ret < 0){
return -1;
}
pthread_create(&t_pid, NULL, wkp_master_check_keepalive_state_thread, NULL);
}else{
- ret = wangyan_keepalive_plug_slave_init();
+ ret = wy_keepalive_plug_slave_init();
if(ret < 0){
return -1;
}
@@ -706,17 +706,17 @@ int wangyan_keepalive_plug_init(void)
}
/* ֻ����Ӧ�ò�����G������ز���, ��Ӧ��������� */
- if(WANGYAN_KEEPALIVE_MODE_MASTER == g_wangyan_keepalive_mode){
+ if(WY_KEEPALIVE_MODE_MASTER == g_wy_keepalive_mode){
/* wangyanĬ��ҵ���: 12, ֧�ֶ��ҵ�񶺺ŷָ�ģʽ */
MESA_load_profile_string_def((char *)"./conf/wangyan_keepalive.conf", (char *)"gdev_service", (char *)"keepalive_service", tmp_str, 128, "12");
- /* NOTE: �˺���������wangyan_keepalive_plug_master_init֮��, ��Ϊ�漰����ȡg_keepalive_plug.so�еķ����� */
+ /* NOTE: �˺���������keepalive_plug_master_init֮��, ��Ϊ�漰����ȡg_keepalive_plug.so�еķ����� */
#if (0 == SELF_DEBUG)
- wangyan_gdev_keepalive_init(tmp_str);
+ wy_gdev_keepalive_init(tmp_str);
#endif
}
- wangyan_set_sapp_instance_name();
+ wy_set_sapp_instance_name();
return ret;
}
diff --git a/src/packet_io/CMakeLists.txt b/src/packet_io/CMakeLists.txt
index acd1e25..a554168 100644
--- a/src/packet_io/CMakeLists.txt
+++ b/src/packet_io/CMakeLists.txt
@@ -69,7 +69,7 @@ set(PACKET_IO_STATIC_SOURCE cycle_pkt_dump_through_write_offset.c packet_io_lib
iknow_info.c packet_io_log.c sendpacket.c
packet_io.c
packet_io_status.cpp packet_io_status_new.c
-packet_io_device.c sapp_compat_wangyan_api.c
+packet_io_device.c sapp_compat_old_papp_api.c
sapp_inject.c)
add_library(packet_io STATIC ${PACKET_IO_STATIC_SOURCE})
diff --git a/src/packet_io/Makefile b/src/packet_io/Makefile
index d25051a..66f3847 100644
--- a/src/packet_io/Makefile
+++ b/src/packet_io/Makefile
@@ -34,7 +34,7 @@ OBJS+=packet_io_status_new.o
#OBJS += cycle_pkt_dump_unix.o
OBJS += cycle_pkt_dump_through_write_offset.o
OBJS += packet_io_device.o
-OBJS += sapp_compat_wangyan_api.o
+OBJS += sapp_compat_old_papp_api.o
OBJS += sapp_inject.o
diff --git a/src/packet_io/packet_io.c b/src/packet_io/packet_io.c
index 44c9f0b..667d58a 100644
--- a/src/packet_io/packet_io.c
+++ b/src/packet_io/packet_io.c
@@ -352,6 +352,16 @@ int packet_io_set_cap_buf_queue(int queue_num_max)
return ret;
}
+int packet_io_send_only_thread_init(void)
+{
+ int ret = 0;
+ if(dl_io_fun_list.dl_io_send_only_thread_init != NULL){
+ ret = dl_io_fun_list.dl_io_send_only_thread_init();
+ }
+
+ return ret;
+}
+
static int packet_io_process_ddp_pkt(const MESA_feedback_raw_pkt_t *ddp_fix_hdr,
int ddp_payload_len, raw_pkt_t *p_raw_pkt, unsigned char dir, int thread_num)
{
diff --git a/src/packet_io/packet_io_lib_load.c b/src/packet_io/packet_io_lib_load.c
index a82937d..cb4ca1c 100644
--- a/src/packet_io/packet_io_lib_load.c
+++ b/src/packet_io/packet_io_lib_load.c
@@ -123,6 +123,7 @@ static int packet_io_lib_load_by_mode(int cap_mode, const char *no_use)
dl_io_fun_list_static_link[CAP_MODEL_PCAP_ONLINE].dl_io_register_exit_cb = (int (*)(PACKET_IO_EXIT_CB_T exit_fun))pcap_dl_io_register_exit_cb;
dl_io_fun_list_static_link[CAP_MODEL_PCAP_ONLINE].dl_io_get_version = (int (*)(void))pcap_dl_io_get_version;
dl_io_fun_list_static_link[CAP_MODEL_PCAP_ONLINE].dl_io_device_alias = (void * (*)(unsigned int , char *))pcap_dl_io_device_alias;
+ dl_io_fun_list_static_link[CAP_MODEL_PCAP_ONLINE].dl_io_send_only_thread_init = NULL;
memcpy(&dl_io_fun_list_static_link[CAP_MODEL_PCAP_DUMPFILE], &dl_io_fun_list_static_link[CAP_MODEL_PCAP_ONLINE], sizeof(dl_io_fun_list_t));
}
@@ -151,6 +152,7 @@ static int packet_io_lib_load_by_mode(int cap_mode, const char *no_use)
//dl_io_fun_list_static_link[CAP_MODEL_MARSIOV4].dl_io_register_exit_cb = (int (*)(PACKET_IO_EXIT_CB_T exit_fun))marsio_dl_io_register_exit_cb;
dl_io_fun_list_static_link[CAP_MODEL_MARSIOV4].dl_io_get_version = (int (*)(void))marsio_dl_io_get_version;
dl_io_fun_list_static_link[CAP_MODEL_MARSIOV4].dl_io_device_alias = (void * (*)(unsigned int , char *))marsio_dl_io_device_alias;
+ dl_io_fun_list_static_link[CAP_MODEL_PCAP_ONLINE].dl_io_send_only_thread_init = (int (*)(void))marsio_dl_io_send_only_thread_init;
}
#endif
@@ -181,7 +183,6 @@ static int packet_io_lib_load_by_mode(int cap_mode, const char *no_use)
#endif
#ifdef IOMODE_TUN
-
dl_io_fun_list_static_link[CAP_MODEL_TUN].dl_io_set_cap_level = (int (*)(int cap_level))tun_dl_io_set_cap_level;
dl_io_fun_list_static_link[CAP_MODEL_TUN].dl_io_set_cap_mode = (int (*)(int cap_mode))tun_dl_io_set_cap_mode;
dl_io_fun_list_static_link[CAP_MODEL_TUN].dl_io_set_topology_mode = (int (*)(int topology_mode))tun_dl_io_set_topology_mode;
diff --git a/src/packet_io/packet_io_marsio.c b/src/packet_io/packet_io_marsio.c
index a09aca1..05f0d3f 100644
--- a/src/packet_io/packet_io_marsio.c
+++ b/src/packet_io/packet_io_marsio.c
@@ -46,7 +46,7 @@ static marsio4_io_handle *g_mario4_io_handle;
#define MARSIO_BURST_PKT_MAX (256)
static int marsio4_burst_process_pkt_num = 32; /* ������������, ��pag.conf�л�ȡ */
//static long marsio4_thread_bind_mask = 0;
-#define TIME_DELAY_MONITOR (1) /* ����������ʱ��� */
+#define TIME_DELAY_MONITOR (0) /* ����������ʱ��� */
extern void timestamp_region_update_driver(int tid, long long cpu_cycle);
extern int stream_process_polling(int thread_seq);
@@ -308,6 +308,14 @@ int marsio_dl_io_register_cb(PACKET_IO_CB_T fun)
return 0;
}
+int marsio_dl_io_send_only_thread_init(void)
+{
+ if(sapp_global_val->config.cpu.bind_mask_array_num > 0){
+ marsio_thread_init(sapp_marsio4_instance);
+ }
+
+ return 0;
+}
#ifndef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
diff --git a/src/packet_io/sapp_compat_wangyan_api.c b/src/packet_io/sapp_compat_old_papp_api.c
index 001ab7f..a436425 100644
--- a/src/packet_io/sapp_compat_wangyan_api.c
+++ b/src/packet_io/sapp_compat_old_papp_api.c
@@ -1,3 +1,9 @@
+/**************************************************************
+ pappƽ̨����WY��Ŀ��������, �����½ӿ�,
+ sapp��ƽ̨Ϊ�˱���������, �������½ӿ�.
+***************************************************************/
+
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -35,10 +41,7 @@ extern int MESA_fakepacket_send_ipv6_udp_options(const struct streaminfo *stream
extern int MESA_sendpacket_iplayer_options(int thread_index,const char *data, int data_len, u_int8_t dir, SAPP_TLV_T *options, int opt_num);
#endif
-/*
- pappƽ̨����wangyan��������, �����½ӿ�,
- sapp��ƽ̨Ϊ�˱���������, �������½ӿ�.
-*/
+
int Gserial_sendpacket_iplayer(int plug_id, struct streaminfo *stream,const char *buf, int buf_len, u_char dir)
{
@@ -412,6 +415,7 @@ int Gserial_sendpacket_ipv6_udp_detail(int plug_id,struct streaminfo *stream, st
��ע�İ�����tcpdump_mesa����, ֱ���������ײ㲶�񼴿�.
*/
extern void cycle_pkt_dump(int thread_seq, const raw_pkt_t *p_raw_pkt);
+extern int G_PKT_DUMP_SW;
int marsio_send_burst_with_options_for_tcpdumpmesa(struct mr_sendpath * sendpath, queue_id_t sid, marsio_buff_t * mbufs[],
int nr_mbufs, uint16_t options)
{
@@ -419,17 +423,19 @@ int marsio_send_burst_with_options_for_tcpdumpmesa(struct mr_sendpath * sendpath
char *rawpkt_data;
uint32_t rawpkt_len;
- rawpkt_data = marsio_buff_mtod(mbufs[0]);
- rawpkt_len = marsio_buff_buflen(mbufs[0]);
+ if(G_PKT_DUMP_SW != 0){
+ rawpkt_data = marsio_buff_mtod(mbufs[0]);
+ rawpkt_len = marsio_buff_buflen(mbufs[0]);
- rawpkt.magic_num = RAW_PKT_MAGIC_NUM;
- rawpkt.low_layer_type = ADDR_TYPE_MAC;
- rawpkt.raw_pkt_data = rawpkt_data;
- rawpkt.raw_pkt_len = rawpkt_len;
- rawpkt.__lib_raw_pkt_data = rawpkt_data;
- rawpkt.__lib_raw_pkt_len = rawpkt_len;
+ rawpkt.magic_num = RAW_PKT_MAGIC_NUM;
+ rawpkt.low_layer_type = ADDR_TYPE_MAC;
+ rawpkt.raw_pkt_data = rawpkt_data;
+ rawpkt.raw_pkt_len = rawpkt_len;
+ rawpkt.__lib_raw_pkt_data = rawpkt_data;
+ rawpkt.__lib_raw_pkt_len = rawpkt_len;
- cycle_pkt_dump(sid, &rawpkt);
+ cycle_pkt_dump(sid, &rawpkt);
+ }
return marsio_send_burst_with_options(sendpath, sid, mbufs, nr_mbufs, options);
}
diff --git a/src/packet_io/sendpacket.c b/src/packet_io/sendpacket.c
index 3166d94..fe38d98 100644
--- a/src/packet_io/sendpacket.c
+++ b/src/packet_io/sendpacket.c
@@ -102,7 +102,9 @@ void random_seed(int pkt_len, UINT64 *pkt_rand)
UINT64 MESA_rand(void)
{
- return g_rand_seed ^ (UINT64)random();
+ struct timespec curtime;
+ clock_gettime (CLOCK_THREAD_CPUTIME_ID, &curtime);
+ return g_rand_seed ^ (UINT64)curtime.tv_nsec;
}
/* return value: [start, end] */
@@ -367,10 +369,7 @@ int MESA_mac_pton(const char *str, int delim, char *mac)
}
-
-
-int
-sendpacket_in_cksum(u_int16_t *addr, int len)
+int sendpacket_in_cksum(u_int16_t *addr, int len)
{
int sum;
int nleft;
@@ -514,9 +513,13 @@ int sendpacket_build_ipv4(u_int16_t carry_layer_len, u_int8_t tos, u_int16_t id,
{
struct mesa_ip4_hdr *ip_hdr;
+#if 0
if (!buf){
return (-1);
}
+#else
+ assert(buf);
+#endif
ip_hdr = (struct mesa_ip4_hdr *)buf;
@@ -616,10 +619,13 @@ int sendpacket_build_tcp(u_int16_t sp, u_int16_t dp, u_int32_t seq, u_int32_t ac
{
struct mesa_tcp_hdr *tcp_hdr;
+#if 0
if (!buf){
return (-1);
}
-
+#else
+ assert(buf);
+#endif
tcp_hdr = (struct mesa_tcp_hdr *)buf;
tcp_hdr->th_sport = htons(sp); /* source port */
@@ -650,25 +656,27 @@ int sendpacket_build_tcp_with_option(u_int16_t sp, u_int16_t dp, u_int32_t seq,
const char *option, int option_len, const char *payload, int payload_s,
unsigned char *buf)
{
- struct mesa_tcp_hdr tcp_hdr;
+ struct mesa_tcp_hdr *tcp_hdr;
if (!buf){
return (-1);
}
+
if((option_len % 4) != 0){
return (-2);
}
+ tcp_hdr = (struct mesa_tcp_hdr *)buf;
- tcp_hdr.th_sport = htons(sp); /* source port */
- tcp_hdr.th_dport = htons(dp); /* destination port */
- tcp_hdr.th_seq = htonl(seq); /* sequence number */
- tcp_hdr.th_ack = htonl(ack); /* acknowledgement number */
- tcp_hdr.th_flags = control; /* control flags */
- tcp_hdr.th_x2 = 0; /* UNUSED */
- tcp_hdr.th_off = 5 + option_len/4; /* 20 byte header + option_len */
- tcp_hdr.th_win = htons(win); /* window size */
- tcp_hdr.th_sum = 0; /* checksum done in userland */
- tcp_hdr.th_urp = urg; /* urgent pointer */
+ tcp_hdr->th_sport = htons(sp); /* source port */
+ tcp_hdr->th_dport = htons(dp); /* destination port */
+ tcp_hdr->th_seq = htonl(seq); /* sequence number */
+ tcp_hdr->th_ack = htonl(ack); /* acknowledgement number */
+ tcp_hdr->th_flags = control; /* control flags */
+ tcp_hdr->th_x2 = 0; /* UNUSED */
+ tcp_hdr->th_off = 5 + option_len/4; /* 20 byte header + option_len */
+ tcp_hdr->th_win = htons(win); /* window size */
+ tcp_hdr->th_sum = 0; /* checksum done in userland */
+ tcp_hdr->th_urp = urg; /* urgent pointer */
if(option && option_len){
memcpy(buf + SENDPACKET_TCP_H, option, option_len);
@@ -681,24 +689,29 @@ int sendpacket_build_tcp_with_option(u_int16_t sp, u_int16_t dp, u_int32_t seq,
*/
memcpy(buf + SENDPACKET_TCP_H + option_len, payload, payload_s);
}
- memcpy((char *)buf, (char *)&tcp_hdr, sizeof(struct mesa_tcp_hdr));
+ //memcpy((char *)buf, (char *)&tcp_hdr, sizeof(struct mesa_tcp_hdr));
return (0);
}
int sendpacket_build_udp(u_int16_t sp, u_int16_t dp, const char *payload, int payload_s,
unsigned char *buf)
{
- struct mesa_udp_hdr udp_hdr;
+ struct mesa_udp_hdr *udp_hdr;
+#if 0
if (!buf)
{
return (-1);
}
+#else
+ assert(buf);
+#endif
+ udp_hdr = (struct mesa_udp_hdr *)buf;
- udp_hdr.uh_sport = htons(sp); /* source port */
- udp_hdr.uh_dport = htons(dp); /* destination port */
- udp_hdr.uh_ulen = htons(SENDPACKET_UDP_H + payload_s); /* total length */
- udp_hdr.uh_sum = 0; /* checksum */
+ udp_hdr->uh_sport = htons(sp); /* source port */
+ udp_hdr->uh_dport = htons(dp); /* destination port */
+ udp_hdr->uh_ulen = htons(SENDPACKET_UDP_H + payload_s); /* total length */
+ udp_hdr->uh_sum = 0; /* checksum */
if (payload && payload_s)
{
@@ -708,7 +721,7 @@ int sendpacket_build_udp(u_int16_t sp, u_int16_t dp, const char *payload, int pa
*/
memcpy(buf + SENDPACKET_UDP_H, payload, payload_s);
}
- memcpy(buf, &udp_hdr, sizeof(udp_hdr));
+
return (1);
}
@@ -3226,6 +3239,47 @@ unsigned char MESA_dir_reverse(unsigned char raw_dir)
return raw_dir;
}
+
+/***************************************************************************************
+ NOTE:
+ �ڱ���ģʽ��, ����������route_dir�ľ���ֵ, ֻ��Ҫ����ͬ��ͷ��򼴿�,
+ ��������������Ҫ��ȷ����route_dir��0����1, �������������ģʽ��ͬ, ������ʱ��仯,
+ �������ô˽ӿ�, ���ֻ�贫����������ķ���, ���ص�ǰ��·��link route dir,
+ ע��etc/sapp.toml inbound_route_dirҪ������ȷ.
+
+ args: ��ʾ����Ŀ������ڵ�ǰ�豸���ڵĵ���λ��,
+ 'E' or 'e': ��ʾ���������Ǵ�Internal to External.
+ 'I' or 'i': ��ʾ���������Ǵ�External to Internal.
+
+ return value:
+ 0 or 1: success.
+ -1 : error.
+****************************************************************************************/
+int MESA_dir_human_to_link(int human_dir)
+{
+ int link_route_dir;
+
+ switch(human_dir){
+ case 'E':
+ case 'e':
+ link_route_dir = sapp_global_val->config.packet_io.inbound_route_dir ^ 1;
+ break;
+
+ case 'I':
+ case 'i':
+ link_route_dir = sapp_global_val->config.packet_io.inbound_route_dir;
+ break;
+
+ default:
+ link_route_dir = -1;
+ break;
+ }
+
+ return link_route_dir;
+}
+
+
+
static inline int dir_check(unsigned char raw_dir)
{
if(raw_dir & DIR_BIT_UNUSE_MASK){ /* ����ֻʹ������ߺ����λbit, �����������ֵ,˵�������ת��dirʱ���˴��� */
@@ -3758,6 +3812,7 @@ static int __MESA_sendpacket_iplayer_options(int thread_index,const char *data,
inner_ret = marsio_buff_malloc_global(dl_io_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_index);
if(inner_ret < 0){
+ sapp_runtime_log(30, "call marsio_buff_malloc_global() failed!\n");
return -1;
}
//g_SysInputInfo[thread_index][PKT_MARSIO_MALLOC]++;
@@ -3849,6 +3904,7 @@ int MESA_fakepacket_send_ipv4_options(const struct streaminfo *stream, uint8_t p
inner_ret = marsio_buff_malloc_global(dl_io_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_index);
if(inner_ret < 0){
+ sapp_runtime_log(30, "call marsio_buff_malloc_global() failed!\n");
return -1;
}
//g_SysInputInfo[thread_index][PKT_MARSIO_MALLOC]++;
@@ -3993,6 +4049,7 @@ int MESA_fakepacket_send_tcp_options(const struct streaminfo *stream,
inner_ret = marsio_buff_malloc_global(dl_io_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_index);
if(inner_ret < 0){
+ sapp_runtime_log(30, "call marsio_buff_malloc_global() failed!\n");
return -1;
}
//g_SysInputInfo[thread_index][PKT_MARSIO_MALLOC]++;
@@ -4074,6 +4131,7 @@ int MESA_fakepacket_send_ipv6_tcp_options(const struct streaminfo *stream,
inner_ret = marsio_buff_malloc_global(dl_io_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_index);
if(inner_ret < 0){
+ sapp_runtime_log(30, "call marsio_buff_malloc_global() failed!\n");
return -1;
}
//g_SysInputInfo[thread_index][PKT_MARSIO_MALLOC]++;
@@ -4147,6 +4205,7 @@ int MESA_fakepacket_send_udp_options(const struct streaminfo *stream,
inner_ret = marsio_buff_malloc_global(dl_io_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_index);
if(inner_ret < 0){
+ sapp_runtime_log(30, "call marsio_buff_malloc_global() failed!\n");
return -1;
}
//g_SysInputInfo[thread_index][PKT_MARSIO_MALLOC]++;
@@ -4223,6 +4282,7 @@ int MESA_fakepacket_send_ipv6_udp_options(const struct streaminfo *stream,
inner_ret = marsio_buff_malloc_global(dl_io_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, thread_index);
if(inner_ret < 0){
+ sapp_runtime_log(30, "call marsio_buff_malloc_global() failed!\n");
return -1;
}
//g_SysInputInfo[thread_index][PKT_MARSIO_MALLOC]++;
diff --git a/src/plugin/src/plugin.c b/src/plugin/src/plugin.c
index cd7a4a9..46ec9ad 100644
--- a/src/plugin/src/plugin.c
+++ b/src/plugin/src/plugin.c
@@ -1461,11 +1461,11 @@ char plugin_call_appentry(stSessionFunInfo* funelem_session,stSessionInfo* sessi
return rec;
}
- plug_record_start_time(g_business_plug_info->plugid, thread_seq);
+ //plug_record_start_time(g_business_plug_info->plugid, thread_seq);
rec=funelem_session->appentry(session_info,&(funelem_session->pme),thread_seq,a_stream,a_packet);
- plug_record_end_time(g_business_plug_info->plugid, thread_seq);
+ //plug_record_end_time(g_business_plug_info->plugid, thread_seq);
/*
if(g_business_plug_type==PLUGTYPE_JC)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 0e39d95..ec02fce 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -17,11 +17,13 @@ add_definitions(-D_BSD_SOURCE -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_
add_definitions(-fPIC)
add_library(test_app_sapp SHARED test_app_sapp.c)
+add_library(test_sendpacket_performance SHARED test_sendpacket_performance.c)
set_target_properties(test_app_sapp PROPERTIES PREFIX "")
+set_target_properties(test_sendpacket_performance PROPERTIES PREFIX "")
-#add_library(wangyan_demo SHARED wangyan_demo.c)
-#set_target_properties(wangyan_demo PROPERTIES PREFIX "")
+#add_library(wy_demo SHARED wy_demo.c)
+#set_target_properties(wy_demo PROPERTIES PREFIX "")
-#add_library(test_wangyan SHARED test_wangyan.c)
-#set_target_properties(test_wangyan PROPERTIES PREFIX "")
+#add_library(test_wy SHARED test_wy.c)
+#set_target_properties(test_wy PROPERTIES PREFIX "")
diff --git a/test/Makefile b/test/Makefile
index dff6d4e..ee2720a 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -9,7 +9,8 @@ MODULES =
BIN_PATH = ../bin/
TARGET = test_app_sapp.so
-TARGET += wangyan_gdev_measurement.so
+TARGET += inline_device_measurement.so
+TARGET += test_sendpacket_performance.so
#TARGET += test_anti_flood_hijack
#TARGET += sapp_so_run
@@ -29,34 +30,31 @@ all: $(TARGET)
test_app_sapp.so: test_app_sapp.o
$(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
- cp $@ $(BIN_PATH)/plug/business/test_app/
+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)
- cp $@ $(BIN_PATH)/plug/business/test_app/
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)
- cp $@ $(BIN_PATH)/plug/business/g_device_plug/
test_http.so:test_http.o
$(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
- cp $@ $(BIN_PATH)/plug/business/test_http/
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
-wangyan_gdev_measurement.so:wangyan_gdev_measurement.c
+inline_device_measurement.so:inline_device_measurement.c
$(CC) -o $@ -shared -fPIC $(INCS) $(CFLAGS) -DIOMODE_MARSIO=1 $^ $(MODULES)
- #cp $@ ../bin/plug/business/wangyan_gdev_measurement/$@
sapp_so_run:test_sapp_so.o
$(CC) -o $@ -g $(INCS) $(CFLAGS) $^ -lpcap -ldl
- cp $@ ../bin;
.c.o:
$(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
diff --git a/test/wangyan_gdev_measurement.c b/test/inline_device_measurement.c
index 2a0b5b7..c642aa5 100644
--- a/test/wangyan_gdev_measurement.c
+++ b/test/inline_device_measurement.c
@@ -5,9 +5,9 @@
extern "C" {
#endif
-int wangyan_gdev_measure_version_20190527;
+int version_20190527;
-#define GDEV_MEASURE_CONF_DIR "conf/wangyan_gdev_measure/"
+#define GDEV_MEASURE_CONF_DIR "conf/inline_device_measure"
#define GDEV_MEASURE_MAX_NUM (32) /* ���ͬʱ֧�ֶ��ٸ�����ʵ�� */
#define GDEV_MEASURE_SEND_MSS (1400)
@@ -45,11 +45,11 @@ typedef struct{
send_pkt_para_t send_pkt_para;
int send_pkt_num;
time_t last_send_time;
-}wangyan_gdev_measure_instance_t;
+}inline_device_measure_instance_t;
-static wangyan_gdev_measure_instance_t wangyan_gdev_measure_instance_set[GDEV_MEASURE_MAX_NUM];
-static int wangyan_gdev_measure_instance_num = 0;
+static inline_device_measure_instance_t inline_device_measure_instance_set[GDEV_MEASURE_MAX_NUM];
+static int inline_device_measure_instance_num = 0;
typedef struct{
int last_record_time;
@@ -57,60 +57,11 @@ typedef struct{
char __pad[58];
}send_pkt_realtime_t;
-static send_pkt_realtime_t g_wangyan_send_fake_pkt_rt_stat[MAX_THREAD_NUM];
+static send_pkt_realtime_t g_send_fake_pkt_rt_stat[MAX_THREAD_NUM];
static void *gdev_measure_logh;
extern int get_thread_count(void);
-#if 0
-
-typedef struct {
- int use_which_config; /* 'M', 'N' */
- char para_name[32];
- char para_delime; /* �����ļ��ָ��� */
- char MESA_para_name[32];
- char ONLINE_para_name[32];
- char user_arg[32];
- int (*config_convert)(const char *conf_str, send_pkt_para_t *send_para_bin);
-}send_pkt_conf_parse_t;
-
-
-static send_pkt_conf_parse_t g_send_pkt_conf_engine[] =
-{
- {'M',"conf_file_name", '=', "./conf/wangyan_send_fake_pkt.conf", "/home/ningsi/new_machine.conf", ""},
- {'N', "vxlan_smac ", ':', "vxlan_smac", "SRC_OUT_MAC", "-"},
- {'N', "vxlan_dmac ", ':', "vxlan_dmac", "DST_OUT_MAC", ":"},
- {'N', "vxlan_sip ", ':', "vxlan_sip", "115_IP", ""},
- {'N', "vxlan_dip ", ':', "vxlan_dip", "GIP", ""},
- {'M',"vxlan_sport ", '=', "vxlan_sport", "", ""},
- {'M',"vxlan_dport ", '=', "vxlan_dport", "", ""},
- {'N', "vxlan_link_id ", ':', "vxlan_link_id", "LINK_ID_VALUE", ""},
- {'N', "vxlan_vlxn_num", ':', "vxlan_vlxn_num", "no", ""},
- {'N', "vxlan_inner_layer2_type" ,':', "vxlan_inner_layer2_type", "LINK_TYPE", ""},
- {'M',"vxlan_trans_dir", '=', "vxlan_trans_dir", "C_DIR", "CorI"},
- {'N', "vxlan_inner_smac", ':', "vxlan_inner_smac", "SRC_IN_MAC", ":"},
- {'N', "vxlan_inner_dmac", ':', "vxlan_inner_dmac", "DST_IN_MAC", ":"}
-}
-
-/*
- #use_which PARA_NAME DELIM MESA_NAME ONLINE_NAME USER_ARG
- #ʹ����Դ
- M conf_file_name = ./conf/wangyan_send_pkt.conf /home/ningsi/new_machine.conf
- N vxlan_smac : vxlan_smac SRC_OUT_MAC -
- N vxlan_dmac : vxlan_dmac DST_OUT_MAC :
- N vxlan_sip : vxlan_sip 115_IP
- N vxlan_dip : vxlan_dip GIP
- M vxlan_sport = vxlan_sport --no
- M vxlan_dport = vxlan_dport --no
- N vxlan_link_id : vxlan_link_id LINK_ID_VALUE
- N vxlan_vlxn_num : vxlan_vlxn_num no
- N vxlan_inner_layer2_type : vxlan_inner_layer2_type LINK_TYPE
- M vxlan_trans_dir = vxlan_trans_dir C_DIR CorI
- N vxlan_inner_smac : vxlan_inner_smac SRC_IN_MAC :
- N vxlan_inner_dmac : vxlan_inner_dmac DST_IN_MAC :
-
-*/
-#endif
static inline time_t get_tmie_from_sapp(void)
{
@@ -173,7 +124,7 @@ static int __load_profile_string_no_section(const char *filename, const char *ke
return -1;
}
-static int wangyan_gdev_measure_parse_config(const char *config_file, wangyan_gdev_measure_instance_t *tmp_ins)
+static int idev_measure_parse_config(const char *config_file, inline_device_measure_instance_t *tmp_ins)
{
char tmp_str[256];
int tmp_int;
@@ -462,7 +413,7 @@ static int wangyan_gdev_measure_parse_config(const char *config_file, wangyan_gd
if ningsi.conf->CorI is I, means sample packet from outside to inside, vxlan dir flag is 1;
*/
-char wangyan_polling_cb_send_fake_pkt_udp(int thread_seq, wangyan_gdev_measure_instance_t *instance)
+char polling_cb_send_fake_pkt_udp(int thread_seq, inline_device_measure_instance_t *instance)
{
struct streaminfo phony_stream;
@@ -557,12 +508,12 @@ char wangyan_polling_cb_send_fake_pkt_udp(int thread_seq, wangyan_gdev_measure_i
option,
option_num);
- g_wangyan_send_fake_pkt_rt_stat[thread_seq].realtime_pkt_num++;
+ g_send_fake_pkt_rt_stat[thread_seq].realtime_pkt_num++;
return APP_STATE_GIVEME;
}
-char wangyan_polling_cb_send_fake_pkt_tcp(int thread_seq, wangyan_gdev_measure_instance_t *instance)
+char polling_cb_send_fake_pkt_tcp(int thread_seq, inline_device_measure_instance_t *instance)
{
struct streaminfo phony_stream;
SAPP_TLV_T option[32];
@@ -662,13 +613,13 @@ char wangyan_polling_cb_send_fake_pkt_tcp(int thread_seq, wangyan_gdev_measure_i
option,
option_num);
- g_wangyan_send_fake_pkt_rt_stat[thread_seq].realtime_pkt_num++;
+ g_send_fake_pkt_rt_stat[thread_seq].realtime_pkt_num++;
return APP_STATE_GIVEME;
}
#if 0
-char wangyan_polling_cb_send_fake_pkt_iplayer(struct streaminfo *__stream, void **__pme, int thread_seq,const void *__raw_pkt)
+char polling_cb_send_fake_pkt_iplayer(struct streaminfo *__stream, void **__pme, int thread_seq,const void *__raw_pkt)
{
char snd_pkt_payload[] =
{
@@ -773,7 +724,7 @@ char wangyan_polling_cb_send_fake_pkt_iplayer(struct streaminfo *__stream, void
option,
option_num);
- g_wangyan_send_fake_pkt_rt_stat[thread_seq].realtime_pkt_num++;
+ g_send_fake_pkt_rt_stat[thread_seq].realtime_pkt_num++;
return APP_STATE_GIVEME;
}
@@ -803,7 +754,7 @@ static void *test_gdev_get_opt(void *arg)
#endif
-static void wangyan_gdev_measure_send_pkt(int thread_seq, wangyan_gdev_measure_instance_t *instance)
+static void idev_measure_send_pkt(int thread_seq, inline_device_measure_instance_t *instance)
{
if(instance->last_send_time == get_tmie_from_sapp()){
if(instance->send_pkt_num >= instance->send_pkt_para.send_pps){
@@ -815,16 +766,16 @@ static void wangyan_gdev_measure_send_pkt(int thread_seq, wangyan_gdev_measure_i
}
if(IPPROTO_TCP == instance->send_pkt_para.transport_layer_type){
- wangyan_polling_cb_send_fake_pkt_tcp(thread_seq, instance);
+ polling_cb_send_fake_pkt_tcp(thread_seq, instance);
}else{
- wangyan_polling_cb_send_fake_pkt_udp(thread_seq, instance);
+ polling_cb_send_fake_pkt_udp(thread_seq, instance);
}
instance->send_pkt_num++;
}
-char wangyan_gdev_measure_polling_cb(struct streaminfo *__stream, void **__pme, int thread_seq, const void *__raw_pkt)
+char idev_measure_polling_cb(struct streaminfo *__stream, void **__pme, int thread_seq, const void *__raw_pkt)
{
int i;
@@ -833,24 +784,24 @@ char wangyan_gdev_measure_polling_cb(struct streaminfo *__stream, void **__pme,
return APP_STATE_GIVEME;
}
- for(i = 0; i < wangyan_gdev_measure_instance_num; i++){
- wangyan_gdev_measure_send_pkt(thread_seq, &wangyan_gdev_measure_instance_set[i]);
+ for(i = 0; i < inline_device_measure_instance_num; i++){
+ idev_measure_send_pkt(thread_seq, &inline_device_measure_instance_set[i]);
}
return APP_STATE_GIVEME;
}
-static int wangyan_gdev_measure_add_new_instance(wangyan_gdev_measure_instance_t *tmp_ins)
+static int idev_measure_add_new_instance(inline_device_measure_instance_t *tmp_ins)
{
- if(wangyan_gdev_measure_instance_num >= GDEV_MEASURE_MAX_NUM){
+ if(inline_device_measure_instance_num >= GDEV_MEASURE_MAX_NUM){
printf("\033[1;31;40m[Error]instance number is over limit %d![0m\n", GDEV_MEASURE_MAX_NUM);
MESA_handle_runtime_log(gdev_measure_logh, 30, "gdev", "instance number is over limit %d!", GDEV_MEASURE_MAX_NUM);
return -1;
}
- memcpy(&wangyan_gdev_measure_instance_set[wangyan_gdev_measure_instance_num], tmp_ins, sizeof(wangyan_gdev_measure_instance_t));
- wangyan_gdev_measure_instance_num++;
+ memcpy(&inline_device_measure_instance_set[inline_device_measure_instance_num], tmp_ins, sizeof(inline_device_measure_instance_t));
+ inline_device_measure_instance_num++;
return 0;
}
@@ -863,7 +814,7 @@ static int iterate_readdir(const char *conf_dir)
DIR *dir_h;
struct dirent *file_h;
int ret;
- wangyan_gdev_measure_instance_t tmp_ins;
+ inline_device_measure_instance_t tmp_ins;
stat(conf_dir, &fstat);
@@ -896,35 +847,35 @@ static int iterate_readdir(const char *conf_dir)
continue; /* ����ͨ�ļ� */
}else{
memset(&tmp_ins, 0, sizeof(tmp_ins));
- ret = wangyan_gdev_measure_parse_config(tmp_file_name, &tmp_ins);
+ ret = idev_measure_parse_config(tmp_file_name, &tmp_ins);
if(ret >= 0){
- wangyan_gdev_measure_add_new_instance(&tmp_ins);
+ idev_measure_add_new_instance(&tmp_ins);
}
}
}
closedir(dir_h);
- MESA_handle_runtime_log(gdev_measure_logh, 10, "gdev", "parse conf succ, total valid config num:%d\n", wangyan_gdev_measure_instance_num);
+ MESA_handle_runtime_log(gdev_measure_logh, 10, "gdev", "parse conf succ, total valid config num:%d\n", inline_device_measure_instance_num);
return 0;
}
-int wangyan_gdev_measure_init(void)
+int inline_device_measure_init(void)
{
int ret;
- gdev_measure_logh = MESA_create_runtime_log_handle("./log/gdev_measure.log", 10);
+ gdev_measure_logh = MESA_create_runtime_log_handle("./log/inline_device_measure.log", 10);
if(get_thread_count() != 1){
- printf("\033[1;31;40m[Error]wangyan_gdev_measure plug not support multithread!\033[0m\n");
+ printf("\033[1;31;40m[Error]inline_device_measure plug not support multithread!\033[0m\n");
}
iterate_readdir(GDEV_MEASURE_CONF_DIR);
- if(wangyan_gdev_measure_instance_num <= 0){
+ if(inline_device_measure_instance_num <= 0){
printf("\033[1;31;40m[Error]No valid config in %s!\033[0m\n", GDEV_MEASURE_CONF_DIR);
MESA_handle_runtime_log(gdev_measure_logh, 30, "gdev", "No valid config in %s!", GDEV_MEASURE_CONF_DIR);
return -1;
diff --git a/test/test_app_sapp.c b/test/test_app_sapp.c
index c5d1a6d..1e29e32 100644
--- a/test/test_app_sapp.c
+++ b/test/test_app_sapp.c
@@ -747,6 +747,112 @@ test_set_stream_timeout(pstream, pme, thread_seq, a_packet);
return APP_STATE_GIVEME;
}
+
+/* 关于网络相关字段, 均为网络序, network order */
+struct __inline_vxlan_hdr{
+ unsigned char flags;
+
+ /*------------byte delim -------*/
+#if 0
+ unsigned char reserved[3];
+#else
+ unsigned char nat_type; /* 复用一个保留字段, 表示NAT类型 */
+ unsigned char reserved[2];
+#endif
+ /*--------int delim -------*/
+ unsigned char vlan_id_half_high;
+ unsigned char link_layer_type : 4; /* 二层报文封装格式 */
+ unsigned char vlan_id_half_low : 4;
+ unsigned int dir : 1;
+ unsigned int link_id : 6;
+ unsigned int online_test : 1;
+
+ unsigned int r7 : 1;
+ unsigned int r6 : 1;
+ unsigned int r5 : 1;
+ unsigned int r4 : 1;
+ unsigned int vni_flag : 1;
+ unsigned int r2 : 1;
+ unsigned int r1 : 1;
+ unsigned int r0 : 1;
+}__attribute__((packed));
+typedef struct __inline_vxlan_hdr test_inline_vxlan_hdr_t;
+
+
+char tcpentry_vlink_info(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet)
+{
+#if IOMODE_MARSIO
+ int ret;
+ char link_dir;
+ long long vlink_id;
+ const struct ip *ihdr;
+ char srcstr[INET6_ADDRSTRLEN], dststr[INET6_ADDRSTRLEN];
+ const struct mesa_ethernet_hdr *ehdr;
+ unsigned char inline_dev_mac[6], local_dev_mac[6];
+ unsigned int inline_dev_ip, local_dev_ip;
+
+ if(pstream->opstate== OP_STATE_PENDING)
+ {
+ if(ADDR_TYPE_IPV4 != pstream->addr.addrtype){
+ return APP_STATE_DROPME;
+ }
+ ret = get_rawpkt_opt_from_streaminfo(pstream, RAW_PKT_GET_VXLAN_LINK_DIR, &link_dir);
+ if(ret < 0){
+ printf("tcpentry_vlink_info(): get_rawpkt_opt_from_streaminfo of RAW_PKT_GET_VXLAN_LINK_DIR error!\n");
+ return APP_STATE_DROPME;
+ }
+ ret = get_rawpkt_opt_from_streaminfo(pstream, RAW_PKT_GET_VIRTUAL_LINK_ID, &vlink_id);
+ if(ret < 0){
+ printf("tcpentry_vlink_info(): get_rawpkt_opt_from_streaminfo of RAW_PKT_GET_VIRTUAL_LINK_ID error!\n");
+ return APP_STATE_DROPME;
+ }
+
+ ret = get_rawpkt_opt_from_streaminfo(pstream, RAW_PKT_GET_VXLAN_OUTER_GDEV_MAC, inline_dev_mac);
+ if(ret < 0){
+ printf("tcpentry_vlink_info(): get_rawpkt_opt_from_streaminfo of RAW_PKT_GET_VXLAN_OUTER_GDEV_MAC error!\n");
+ return APP_STATE_DROPME;
+ }
+
+ ret = get_rawpkt_opt_from_streaminfo(pstream, RAW_PKT_GET_VXLAN_OUTER_LOCAL_MAC, local_dev_mac);
+ if(ret < 0){
+ printf("tcpentry_vlink_info(): get_rawpkt_opt_from_streaminfo of RAW_PKT_GET_VXLAN_OUTER_LOCAL_MAC error!\n");
+ return APP_STATE_DROPME;
+ }
+
+ ret = get_rawpkt_opt_from_streaminfo(pstream, RAW_PKT_GET_VXLAN_OUTER_LOCAL_MAC, local_dev_mac);
+ if(ret < 0){
+ printf("tcpentry_vlink_info(): get_rawpkt_opt_from_streaminfo of RAW_PKT_GET_VXLAN_OUTER_LOCAL_MAC error!\n");
+ return APP_STATE_DROPME;
+ }
+
+
+ ihdr = (struct ip *)a_packet;
+ inet_ntop(AF_INET, &ihdr->ip_src.s_addr, srcstr, sizeof(srcstr));
+ inet_ntop(AF_INET, &ihdr->ip_dst.s_addr, dststr, sizeof(dststr));
+
+ ehdr = (struct mesa_ethernet_hdr *)((char *)a_packet - 14);
+
+ printf("--------------------------------------------link info-----------------------------------------\n");
+ printf("outer mac:%02x-%02x-%02x-%02x-%02x-%02x -> %02x-%02x-%02x-%02x-%02x-%02x\n",
+ inline_dev_mac[0], inline_dev_mac[1],inline_dev_mac[2],inline_dev_mac[3],inline_dev_mac[4],inline_dev_mac[5],
+ local_dev_mac[0],local_dev_mac[1],local_dev_mac[2],local_dev_mac[3],local_dev_mac[4],local_dev_mac[5]);
+
+ printf("inner mac:%02x-%02x-%02x-%02x-%02x-%02x -> %02x-%02x-%02x-%02x-%02x-%02x\n",
+ ehdr->ether_shost[0], ehdr->ether_shost[1], ehdr->ether_shost[2], ehdr->ether_shost[3], ehdr->ether_shost[4], ehdr->ether_shost[5],
+ ehdr->ether_dhost[0],ehdr->ether_dhost[1],ehdr->ether_dhost[2],ehdr->ether_dhost[3],ehdr->ether_dhost[4],ehdr->ether_dhost[5]);
+ printf("inner ip: %s->%s\n", srcstr, dststr);
+ printf("link_dir:%d, mrzcpd_vlink_id:%lld\n", link_dir, vlink_id);
+
+ printf("--------------------------------------------------------------------------------------------\n");
+
+ }
+#else
+ printf("tcpentry_vlink_info(): not compile in marsio mode, do nothing!\n");
+#endif
+ return APP_STATE_DROPME;
+}
+
+
static int test_tcpall_flow_id = -1;
char testtcpApp_allpkt(struct streaminfo *pstream,void **pme, int thread_seq,void *a_packet)
diff --git a/test/test_sendpacket_performance.c b/test/test_sendpacket_performance.c
new file mode 100644
index 0000000..deb9a35
--- /dev/null
+++ b/test/test_sendpacket_performance.c
@@ -0,0 +1,111 @@
+#include "sapp_api.h"
+#include "sapp_private_api.h"
+
+#include <pthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static int MAX_SEND_THREAD = 1;
+static int send_payload_len = 22;
+
+#if IOMODE_MARSIO
+
+static void test_send_udp_by_vlink(int thread_seq)
+{
+ SAPP_TLV_T option[32];
+ int opt_num = 0, ret;
+ struct streaminfo tmp_streaminfo;
+ const char *udp_payload = "test MESA_fakepacket_send_udp_options by vlink id()";
+ char udp_paylaod_long[1450]; //负载22字节整体包长是64, 1472整体包长是1514.
+
+ tmp_streaminfo.threadnum = thread_seq;
+
+ option[0].type = SAPP_SEND_OPT_VIRTUAL_LINK_ID;
+ option[0].length = sizeof(long long);
+ option[0].long_value = 1;
+ opt_num++;
+
+#if 0
+ ret = MESA_fakepacket_send_udp_options(&tmp_streaminfo, 0xC0A83294, 0xC0A86405, 0x1111, 0x5555,
+ udp_payload, strlen(udp_payload), 0,
+ option, opt_num);
+#else
+ret = MESA_fakepacket_send_udp_options(&tmp_streaminfo, 0xC0A83294, 0xC0A86405, 0x1111, 0x5555,
+ udp_paylaod_long, send_payload_len, 0,
+ option, opt_num);
+
+#endif
+ if(ret < 0){
+ printf("MESA_fakepacket_send_udp_options error!\n");
+ }
+}
+
+static void *sendpacket_perf_thread(void *arg)
+{
+ int tid, ret, opt_len;
+
+ opt_len = sizeof(int);
+ ret = sapp_get_platform_opt(SPO_INDEPENDENT_THREAD_ID, &tid, &opt_len);
+ if(ret < 0){
+ printf("houyi_plug: get SPO_INDEPENDENT_THREAD_ID error!\n");
+ return NULL;
+ }
+
+#if 0 //加上修改线程名之后, marsio会发包错误, 原因不明
+ char thread_name[32];
+ snprintf(thread_name, sizeof(thread_name), "%s_%d", "sapp_snd", tid);
+ pthread_setname_np(pthread_self(), thread_name);
+#endif
+
+ packet_io_send_only_thread_init();
+
+ while(1){
+ test_send_udp_by_vlink(tid);
+ }
+
+ return NULL;
+}
+
+
+int CHAR_INIT()
+{
+ pthread_t pid[256];
+ int i;
+
+ int ret = MESA_load_profile_int_def((char *)"etc/test_sendpacket_perf.conf", (char *)"main", (char *)"thread_num", &MAX_SEND_THREAD, 1);
+ if(ret < 0){
+ printf("can't get thread_num from: %s\n", "etc/test_sendpacket_perf.conf");
+ return -1;
+ }
+ ret = MESA_load_profile_int_def((char *)"etc/test_sendpacket_perf.conf", (char *)"main", (char *)"send_payload_len", &send_payload_len, 22);
+ if(ret < 0){
+ printf("can't get send_payload_len from: %s\n", "etc/test_sendpacket_perf.conf");
+ return -1;
+ }
+ for(i = 0; i < MAX_SEND_THREAD; i++){
+ pthread_create(&pid[i], NULL, sendpacket_perf_thread, NULL);
+ }
+
+ return 1;
+}
+
+void CHAR_DESTROY(void)
+{
+
+}
+#else
+int CHAR_INIT()
+{
+ printf("##### error! test_sendpacket_performance plug must compile and run in marsio mode!\n");
+ return -1;
+}
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
diff --git a/test/test_wangyan.c b/test/test_wy.c
index 699d870..7524f25 100644
--- a/test/test_wangyan.c
+++ b/test/test_wy.c
@@ -98,14 +98,14 @@ char send_ipv4_pkt_options_demo(struct streaminfo *stream,void **pme, int thread
-char test_wangyan_send_tcp_pkt_detail(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
+char test_wy_send_tcp_pkt_detail(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
{
Gserial_sendpacket_tcp_detail(TEST_PLUG_ID, stream, 0x0A0A066C, 0x0A00063B, 0x1234, 55, 0x1111,0x2222,
0x12345678, 0x87654321, 0x10, 9999, "TCP payload test", strlen("TCP payload test"), 0);
return APP_STATE_GIVEME;
}
-char test_wangyan_send_tcp_pkt_options(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
+char test_wy_send_tcp_pkt_options(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
{
if(NULL == raw_pkt){
return APP_STATE_GIVEME;
@@ -156,21 +156,21 @@ char test_wangyan_send_tcp_pkt_options(struct streaminfo *stream,void **pme, int
#endif
return APP_STATE_GIVEME;
}
-char test_wangyan_send_udp_pkt(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
+char test_wy_send_udp_pkt(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
{
Gserial_sendpacket_udp(TEST_PLUG_ID, stream, 0x0A0A066C, 0x0A00063B, 0x1111,0x2222,
"UDP payload test", strlen("UDP payload test"), 0);
return APP_STATE_GIVEME;
}
-char test_wangyan_send_udp_pkt_detail(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
+char test_wy_send_udp_pkt_detail(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
{
Gserial_sendpacket_udp_detail(TEST_PLUG_ID, stream, 0x0A0A066C, 0x0A00063B, 0x1234, 55, 0x1111,0x2222,
"UDP payload test", strlen("UDP payload test"), 0);
return APP_STATE_GIVEME;
}
-char test_wangyan_send_udp_pkt_options(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
+char test_wy_send_udp_pkt_options(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
{
if(NULL == raw_pkt){
return APP_STATE_DROPME;
@@ -217,7 +217,7 @@ char test_wangyan_send_udp_pkt_options(struct streaminfo *stream,void **pme, int
return APP_STATE_GIVEME;
}
-char test_wangyan_forward_pkt(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
+char test_wy_forward_pkt(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
{
sapp_forward_current_pkt(stream, 1);
sapp_forward_current_pkt(stream, 2);
@@ -247,7 +247,7 @@ char test_gdev_keepalive_ctrl(struct streaminfo *stream,void **pme, int thread_s
return APP_STATE_GIVEME;
}
-char test_wangyan_send_ipv4_pkt(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
+char test_wy_send_ipv4_pkt(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
{
int test_ip;
@@ -268,7 +268,7 @@ char test_wangyan_send_ipv4_pkt(struct streaminfo *stream,void **pme, int thread
return APP_STATE_GIVEME;
}
-char test_wangyan_send_ipv6_pkt(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
+char test_wy_send_ipv6_pkt(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
{
struct in6_addr sip, dip;
char payload[] = {
@@ -290,7 +290,7 @@ char test_wangyan_send_ipv6_pkt(struct streaminfo *stream,void **pme, int thread
}
-char test_wangyan_send_ipv6_tcp_pkt(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
+char test_wy_send_ipv6_tcp_pkt(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
{
struct in6_addr sip, dip;
char payload[] = {
@@ -310,7 +310,7 @@ char test_wangyan_send_ipv6_tcp_pkt(struct streaminfo *stream,void **pme, int th
return APP_STATE_GIVEME;
}
-char test_wangyan_send_ipv6_udp_pkt(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
+char test_wy_send_ipv6_udp_pkt(struct streaminfo *stream,void **pme, int thread_seq,const void *raw_pkt)
{
struct in6_addr sip, dip;
char payload[] = {
@@ -371,14 +371,10 @@ static void *plug_thread_send(void *arg)
sleep(5); /* �ȴ�packet_io��ʼ���ɹ� */
while(1){
-#if 0
- wangyan_polling_cb_send_fake_pkt_tcp(NULL, NULL, send_tid, NULL);
-#else
struct streaminfo phony_stream;
phony_stream.threadnum = send_tid;
// Gserial_sendpacket_ipv4(1, &phony_stream, 32, 17, 0x01010101, 0x02020202, snd_ip_pkt_payload, sizeof(snd_ip_pkt_payload), 0);
- MESA_sendpacket_ethlayer(send_tid, snd_eth_pkt_data, sizeof(snd_eth_pkt_data), 0);
-#endif
+ MESA_sendpacket_ethlayer(send_tid, snd_eth_pkt_data, sizeof(snd_eth_pkt_data), 0);
sleep(1);
}
@@ -399,7 +395,7 @@ char test_pkt_action(int net_conn_mode, char plug_action)
}
-int test_wangyan_init(void)
+int test_wy_init(void)
{
pthread_t tid;
diff --git a/test/wangyan_demo.c b/test/wy_demo.c
index 2e040ac..a8d1dc9 100644
--- a/test/wangyan_demo.c
+++ b/test/wy_demo.c
@@ -221,7 +221,7 @@ char sendpacket_udp_detail_demo(struct streaminfo *stream,void **pme, int thread
-int test_wangyan_init(void)
+int test_wy_init(void)
{
return PLUG_DEMO_ID;
}