diff options
| author | 杨威 <[email protected]> | 2023-01-10 23:53:24 +0800 |
|---|---|---|
| committer | 杨威 <[email protected]> | 2023-01-11 11:50:53 +0800 |
| commit | 8393d32ba6aeec6ff5a1a3143cb3fde2b88a10a4 (patch) | |
| tree | 8931d569aeb8099c356c56a03010e33c5234de90 /src | |
| parent | 351930141a08886cbd31d1968cfe66de2fbcc3dd (diff) | |
🌈 style(linter check): reduce lint check warning
Diffstat (limited to 'src')
54 files changed, 383 insertions, 331 deletions
diff --git a/src/common/linux_kernel_jhash.c b/src/common/linux_kernel_jhash.c index 2abf635..39c0500 100644 --- a/src/common/linux_kernel_jhash.c +++ b/src/common/linux_kernel_jhash.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
diff --git a/src/common/net_common.c b/src/common/net_common.c index 22f6306..1079722 100644 --- a/src/common/net_common.c +++ b/src/common/net_common.c @@ -1,5 +1,6 @@ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #ifdef __cplusplus @@ -1499,6 +1500,7 @@ char *sapp_memmove_for_blank_table(char *data, int max_len) while(('\t' == data[0]) || (' ' ==data[0])){ memmove(data, data+1, max_len-1); } + return data; } /* @@ -1600,13 +1602,12 @@ const char *sapp_raw_ipv6_ntop(const struct mesa_ip6_hdr *ip6_hdr, char *out_buf const char *sapp_rawpkt_ntop(const raw_pkt_t *raw_pkt, int greedy_inner_layer, char *out_buf, int buf_len) { - const struct mesa_ethernet_hdr *ehdr; const struct mesa_ip4_hdr *ip4hdr; const struct mesa_ip6_hdr *ip6hdr; const struct mesa_tcp_hdr *thdr; const struct mesa_udp_hdr *uhdr; char ipsrc_str[64], ipdst_str[64]; - unsigned short sport, dport, ipid, transport_checksum; + unsigned short sport, dport, ipid=0, transport_checksum; unsigned char ip_pro; if(greedy_inner_layer){ diff --git a/src/common/sapp_log.c b/src/common/sapp_log.c index 4d4b26a..f3d8ba4 100644 --- a/src/common/sapp_log.c +++ b/src/common/sapp_log.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #include "support/tomlc99_wrap.h" diff --git a/src/common/sapp_mem.c b/src/common/sapp_mem.c index 0f93a74..7634d1a 100644 --- a/src/common/sapp_mem.c +++ b/src/common/sapp_mem.c @@ -1,5 +1,6 @@ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #ifdef __cplusplus extern "C" { diff --git a/src/common/stream_addr_inet.c b/src/common/stream_addr_inet.c index be9a632..cf92436 100644 --- a/src/common/stream_addr_inet.c +++ b/src/common/stream_addr_inet.c @@ -8,6 +8,7 @@ */ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #ifdef __cplusplus extern "C" { diff --git a/src/config/cmd_args.c b/src/config/cmd_args.c index a956469..ede0122 100644 --- a/src/config/cmd_args.c +++ b/src/config/cmd_args.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #ifdef GIT_VERSION __attribute__((__used__)) const char *sapp_git_ver = GIT_VERSION; #endif diff --git a/src/config/config_parse.cpp b/src/config/config_parse.cpp index a93af63..90a2e94 100644 --- a/src/config/config_parse.cpp +++ b/src/config/config_parse.cpp @@ -8,6 +8,7 @@ extern "C" { #include "sapp_private_api.h" #include "support/tomlc99_wrap.h" #include "field_stat2.h" +#include "sapp_declaration.h" extern int g_overlay_layer_set[__ADDR_TYPE_MAX][SAPP_SUPPORT_LAYER_NUM_MAX]; @@ -151,7 +152,7 @@ static int cfg_value_check_bind_mask(const sapp_config_check_t *sapp_cfg_check_a } const char *raw_cfg_send_only_threads_value = sapp_cfg_get_value_from_attr_by_section_key(sapp_cfg_check_attr, "CPU", "send_only_threads_max"); - if(NULL == raw_cfg_worker_threads_value){ + if(NULL == raw_cfg_send_only_threads_value){ return -1; } @@ -171,7 +172,7 @@ static int cfg_value_check_stream_id_base_time(const sapp_config_check_t *sapp_c { struct tm local_tm; - if(NULL == raw_cfg_value || strlen(raw_cfg_value) <= 0){ + if(NULL == raw_cfg_value || strlen(raw_cfg_value) == 0){ return 0; /* ����ΪNULL,������� */ } @@ -292,8 +293,8 @@ static const sapp_config_check_t g_sapp_cfg_check_attr[] = {6301,1,RLOG_LV_FATAL,"profiling.log", "level", NULL,NULL, NULL, NULL, 0}, {6302,0,RLOG_LV_INFO,"profiling.log", "interval", NULL,NULL, NULL, NULL, 0}, - {6401,0,RLOG_LV_INFO,"profiling.log.local", "enabled", NULL, NULL, NULL, 0}, - {6402,0,RLOG_LV_INFO,"profiling.log.local", "file_truncate_enabled", NULL, NULL, NULL, 0}, + {6401,0,RLOG_LV_INFO,"profiling.log.local", "enabled", NULL, NULL, NULL, 0, 0}, + {6402,0,RLOG_LV_INFO,"profiling.log.local", "file_truncate_enabled", NULL, NULL, NULL, 0, 0}, {6501,0,RLOG_LV_INFO,"profiling.log.remote", "enabled", NULL,NULL, NULL, NULL, 0}, {6502,6501,RLOG_LV_INFO,"profiling.log.remote", "server_ip", "1",NULL, NULL, NULL, 0}, @@ -381,7 +382,6 @@ static const sapp_config_check_t g_sapp_cfg_check_attr[] = {-1,-1,RLOG_LV_DEBUG,NULL,NULL,NULL, NULL, NULL,NULL, 0} }; -static const int g_sapp_cfg_check_attr_num = sizeof(g_sapp_cfg_check_attr)/sizeof(sapp_config_check_t) - 1; /* ����и�������, ȫ��NULL */ static int cfg_get_index_by_cfg_id(int expect_cfg_id) @@ -510,7 +510,7 @@ static void special_usage(void) static inline int is_file_exist(const char *filename) { struct stat fstat; - int fres, ret; + int fres, ret=0; fres = stat(filename, &fstat); if(fres < 0){ @@ -639,7 +639,7 @@ static int parse_vlan_flipping_map_config(void) c_router_vlan_id = 4097; i_router_vlan_id = 4097; mac_flip_enable = 0; - ret = sscanf(line_cont, "%u %u %u", &c_router_vlan_id, &i_router_vlan_id, &mac_flip_enable); + ret = sscanf(line_cont, "%llu %llu %llu", &c_router_vlan_id, &i_router_vlan_id, &mac_flip_enable); if(ret != 3){ sapp_log(RLOG_LV_FATAL,1,1,"parse vlan_flipping_cfg_file:%s, line:%s error!", ABBR_VLAN_FLIPPING_CONF_FILE, line_cont); fclose(fp); @@ -682,7 +682,7 @@ static int parse_vlan_flipping_map_config(void) static int embed_layer_t_pton(char *config_val, embed_layer_t *result) { enum addr_type_t addrtype; - int j, ret, layer_index; + int j, layer_index; const char *delim = "[] "; char *save_ptr; const char *layer_type_string; @@ -770,8 +770,6 @@ static int update_asymmetric_layer_info(embed_layer_t *global_array, embed_layer static int update_asymmetric_presence_layer(enum addr_type_t addrtype, embed_layer_t *under_layer, embed_layer_t *upper_layer) { - int i; - g_asymmetric_presence_layer_set[addrtype].is_asymmetric_layer = 1; update_asymmetric_layer_info(&g_asymmetric_presence_layer_set[addrtype].under_layer, under_layer); @@ -1449,7 +1447,7 @@ static int config_sanity_check(void) int tot_cpu_core_num = get_nprocs(); for(i = 0; i < pconfig->cpu.bind_mask_array_num; i++){ if(pconfig->cpu.bind_mask_array[i] > tot_cpu_core_num-1){ - printf("\033[41mbind_mask[%d]=%d, bigger than total cpu core number:%d!\033[0m\n", i, pconfig->cpu.bind_mask_array[i], tot_cpu_core_num); + printf("\033[41mbind_mask[%d]=%ld, bigger than total cpu core number:%d!\033[0m\n", i, pconfig->cpu.bind_mask_array[i], tot_cpu_core_num); return -1; } } @@ -1481,16 +1479,16 @@ static int config_sanity_check(void) if(strncasecmp(tmp_str, "transparent", strlen("transparent")) == 0){ if((pconfig->packet_io.internal.interface.name[0] == '\0') - || (strlen(pconfig->packet_io.internal.interface.name) <= 0) + || (strlen(pconfig->packet_io.internal.interface.name) == 0) ||(pconfig->packet_io.internal.interface.type_str[0] == '\0') - || (strlen(pconfig->packet_io.internal.interface.type_str) <= 0)){ + || (strlen(pconfig->packet_io.internal.interface.type_str) == 0)){ sapp_log(RLOG_LV_FATAL, ~0, ~0, "depolyment_mode is transparent, must set internal interface parameters!"); return -1; } if((pconfig->packet_io.external.interface.name[0] == '\0') - || (strlen(pconfig->packet_io.external.interface.name) <= 0) + || (strlen(pconfig->packet_io.external.interface.name) == 0) ||(pconfig->packet_io.external.interface.type_str[0] == '\0') - || (strlen(pconfig->packet_io.external.interface.type_str) <= 0)){ + || (strlen(pconfig->packet_io.external.interface.type_str) == 0)){ sapp_log(RLOG_LV_FATAL, ~0, ~0, "depolyment_mode is transparent, must set external interface parameters!"); return -1; } @@ -2276,7 +2274,7 @@ int sapp_config_check(void) sapp_config_check_t *local_cfg_check_attr = (sapp_config_check_t *)sapp_mem_calloc(SAPP_MEM_FIX_GLOBAL_VAL, MEM_STAT_GLOBAL_THREAD_ID,sizeof(g_sapp_cfg_check_attr)); memcpy(local_cfg_check_attr, g_sapp_cfg_check_attr, sizeof(g_sapp_cfg_check_attr)); - for(i = 0; i < sizeof(g_interger_range_array)/sizeof(int); i++){ + for(i = 0; i < (int)(sizeof(g_interger_range_array)/sizeof(int)); i++){ g_interger_range_array[i] = i; } diff --git a/src/dealpkt/callapp.c b/src/dealpkt/callapp.c index a9aec00..b113634 100644 --- a/src/dealpkt/callapp.c +++ b/src/dealpkt/callapp.c @@ -1,5 +1,6 @@ #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
#include "stream_register.h"
@@ -274,7 +275,7 @@ int stream_register_overlay_udp(STREAM_CB_FUN_T x) return stream_register_funtoArray(FUN_TYPE_UDP,(char (*)())x,g_OverlayUdpFun,&g_OverlayUdpFunNum, 0);
}
-
+extern const char *sapp_rawpkt_ntop(const raw_pkt_t *raw_pkt, int greedy_inner_layer, char *out_buf, int buf_len);
/*
lijia 2015-01-12 add this_iphdr,
�����IP��Ƭ����İ�, ������ʽ�Ĵ���IP��ͷ, ����ֻ��raw_hdr, ����ȡ������IP��ͷ.
@@ -772,7 +773,7 @@ int stream_process_udp_single(struct streaminfo *a_udp,const void * a_packet,voi //add by lqy 20141230
//ע�����µ�ֻ����stream_raw���͵ĺ������������ò�һ��
//if(funtype>FUN_TYPE_IPV6_RAW)
- if(is_raw_cb(funtype)){
+ if(is_raw_cb((enum fun_type_t)funtype)){
appState=g_StreamUdpFun[i].sapp_stream_fun(a_udp,a_packet,a_packet,&(pAppInfo));
}else{
appState=g_StreamUdpFun[i].stream_fun(a_udp,&(pAppInfo),a_udp->threadnum,a_packet);
@@ -1216,50 +1217,6 @@ static inline int is_raw_cb(enum fun_type_t cb_type) }
-#ifdef IIEFD_DUAL_STACK
-/* 2015-09-02 lijia add, for iieqd_dual_stack */
-static int judge_pure_ipv4_stack(const struct streaminfo *pstream, const void *a_packet)
-{
- int ret = 0;
- const mesa_ip4_hdr *ip4_hdr = (const mesa_ip4_hdr *)a_packet;
-
- switch(pstream->addr.addrtype){
- case __ADDR_TYPE_IP_PAIR_V4:
- if((IPPROTO_TCP != ip4_hdr->ip_p) && (IPPROTO_UDP != ip4_hdr->ip_p)){
- ret = 0;
- break;
- }
- if((NULL == pstream->pfather)
- ||((NULL != pstream->pfather) && (ADDR_TYPE_MAC == pstream->pfather->addr.addrtype))){
- ret = 1;
- }else{
- ret = 0;
- }
- break;
-
- case ADDR_TYPE_IPV4:
- if(__ADDR_TYPE_IP_PAIR_V4 != pstream->pfather->addr.addrtype){
- ret = 0;
- break;
- }
-
- if((pstream->pfather->pfather != NULL) && (ADDR_TYPE_MAC != pstream->pfather->pfather->addr.addrtype)){
- ret = 0;
- break;
- }
-
- ret = 1;
- break;
-
- default:
- ret = 0;
- break;
- }
-
- return ret;
-}
-#endif
-
int app_function_rationality_check(void)
{
/* 2015-01-12 lijia add, for error message */
diff --git a/src/dealpkt/deal_arp.c b/src/dealpkt/deal_arp.c index f7e5836..bf126ff 100644 --- a/src/dealpkt/deal_arp.c +++ b/src/dealpkt/deal_arp.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
int arp_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_hdr,
int thread_num, unsigned char dir, const raw_pkt_t *raw_pkt, int offset_to_raw_pkt_hdr)
diff --git a/src/dealpkt/deal_ethernet.c b/src/dealpkt/deal_ethernet.c index 9623b18..3861d9b 100644 --- a/src/dealpkt/deal_ethernet.c +++ b/src/dealpkt/deal_ethernet.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
extern int g_overlay_layer_set[__ADDR_TYPE_MAX][SAPP_SUPPORT_LAYER_NUM_MAX];
extern int g_skip_ethernet_layer_sw;
@@ -41,6 +42,8 @@ static inline int should_create_empty_mpls_layer_for_symmetric(const struct stre return 0;
}
+extern int sapp_is_overlay_layer(const struct streaminfo_private *stream_pr, const raw_pkt_t *rawpkt);
+
int eth_entry(struct streaminfo_private *fstream_pr, const void *this_layer_hdr,int thread_num,
unsigned char dir, const raw_pkt_t *raw_pkt, int offset_to_raw_pkt_hdr)
{
diff --git a/src/dealpkt/deal_gprs_tunnel.c b/src/dealpkt/deal_gprs_tunnel.c index 77e4e0f..062425c 100644 --- a/src/dealpkt/deal_gprs_tunnel.c +++ b/src/dealpkt/deal_gprs_tunnel.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" /* �����: diff --git a/src/dealpkt/deal_gre.c b/src/dealpkt/deal_gre.c index f5da2a7..d2f6149 100644 --- a/src/dealpkt/deal_gre.c +++ b/src/dealpkt/deal_gre.c @@ -5,6 +5,7 @@ extern "C" { #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
#define GRE_DEBUG (0)
diff --git a/src/dealpkt/deal_ipv4.c b/src/dealpkt/deal_ipv4.c index 2fcf084..7a23991 100644 --- a/src/dealpkt/deal_ipv4.c +++ b/src/dealpkt/deal_ipv4.c @@ -22,6 +22,7 @@ #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
#ifdef __cplusplus
extern "C" {
@@ -435,86 +436,93 @@ found: }
/*Is this a continuous piece?*/
- if(0 > i && 0 > j)
- {
- /*creat a new fragment piece*/
- tfp = frags_create(ip4_frag_handle, offset, end);
- tfp->prev = prev;
- tfp->next = next;
- if(prev)
- prev->next = tfp;
- else
- ipv4_qp->fragments = tfp;
-
- if(next)
- next->prev = tfp;
- else
- ipv4_qp->fragments_tail = tfp; /* 2013-06-06 lijia add */
- }
- else if(i >= 0 && j >= 0)
- {
- for (tmp2=next,tmp=next; NULL!=tmp; tmp=tmp->next)
- {
- if (end < tmp->offset)
- {
- break;
- tmp2 = tmp;
- }
- }
- prev->end = end;
- for(next=next; NULL!=next && next!=tmp; next=next->next)
- {
- if(end <= next->end)
- {
- prev->end = next->end;
- end -= (end - next->offset);
- frags_kill(ip4_frag_handle, ipv4_qp, next);
- break;
- }
- ipv4_qp->meat -= (next->end - next->offset);
- frags_kill(ip4_frag_handle, ipv4_qp, next);
- }
- }
- else if(i >= 0)
- {
- if(end > prev->end)
- {
- prev->end = end;
- }
- else
- {
- end = offset;
- }
- }
- else if (j >= 0)
- {
- for (prev=next,tmp=next; NULL!=tmp; tmp=tmp->next) {
- if (end < tmp->offset) {
- break;
- prev = tmp;
- }
- }
-
- if (next != tmp) {
- next->offset = offset;
- next->end = end;
- for (tmp2=next->next; NULL!=tmp2 && tmp2!=tmp; tmp2=tmp2->next) {
- if (end <= tmp2->end) {
- next->end = tmp2->end;
- end -= (end - tmp2->offset);
- frags_kill(ip4_frag_handle, ipv4_qp, tmp2);
- break;
- }
- ipv4_qp->meat -= (tmp2->end - tmp2->offset);
- frags_kill(ip4_frag_handle, ipv4_qp, tmp2);
- }
- } else {
- end -= j;
- next->offset = offset;
- }
- }
-
- ipv4_qp->meat += (end - offset);
+ if (0 > i && 0 > j)
+ {
+ /*creat a new fragment piece*/
+ tfp = frags_create(ip4_frag_handle, offset, end);
+ tfp->prev = prev;
+ tfp->next = next;
+ if (prev)
+ prev->next = tfp;
+ else
+ ipv4_qp->fragments = tfp;
+
+ if (next)
+ next->prev = tfp;
+ else
+ ipv4_qp->fragments_tail = tfp; /* 2013-06-06 lijia add */
+ }
+ else if (i >= 0 && j >= 0)
+ {
+ for (tmp2 = next, tmp = next; NULL != tmp; tmp = tmp->next)
+ {
+ if (end < tmp->offset)
+ {
+ break;
+ // tmp2 = tmp;
+ }
+ }
+ prev->end = end;
+ for (; NULL != next && next != tmp; next = next->next)
+ {
+ if (end <= next->end)
+ {
+ prev->end = next->end;
+ end -= (end - next->offset);
+ frags_kill(ip4_frag_handle, ipv4_qp, next);
+ break;
+ }
+ ipv4_qp->meat -= (next->end - next->offset);
+ frags_kill(ip4_frag_handle, ipv4_qp, next);
+ }
+ }
+ else if (i >= 0)
+ {
+ if (end > prev->end)
+ {
+ prev->end = end;
+ }
+ else
+ {
+ end = offset;
+ }
+ }
+ else if (j >= 0)
+ {
+ for (prev = next, tmp = next; NULL != tmp; tmp = tmp->next)
+ {
+ if (end < tmp->offset)
+ {
+ break;
+ // prev = tmp;
+ }
+ }
+
+ if (next != tmp)
+ {
+ next->offset = offset;
+ next->end = end;
+ for (tmp2 = next->next; NULL != tmp2 && tmp2 != tmp; tmp2 = tmp2->next)
+ {
+ if (end <= tmp2->end)
+ {
+ next->end = tmp2->end;
+ end -= (end - tmp2->offset);
+ frags_kill(ip4_frag_handle, ipv4_qp, tmp2);
+ break;
+ }
+ ipv4_qp->meat -= (tmp2->end - tmp2->offset);
+ frags_kill(ip4_frag_handle, ipv4_qp, tmp2);
+ }
+ }
+ else
+ {
+ end -= j;
+ next->offset = offset;
+ }
+ }
+
+ ipv4_qp->meat += (end - offset);
/*If ipq buff is not enough to store current fragment piece, get a bigger one*/
if (end + private_info->raw_ip_hdr_len > ipv4_qp->buf_size)
{
@@ -579,6 +587,9 @@ static inline void set_ipv4_addr(struct stream_tuple4_v4 *addr, struct mesa_ip4_ addr->dest = 0;/* �˿���Ϣ��tcp/udp������ */
}
+extern int sapp_is_overlay_layer(const struct streaminfo_private *stream_pr, const raw_pkt_t *rawpkt);
+extern int stream_process_overlay_ipv4(struct streaminfo *pfstream, const struct ip* this_layer_hdr,
+ int thread_num,unsigned char routedir, const raw_pkt_t *raw_pkt);
/* IPv4���ݰ���ں���, ������Ƭ�� */
int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_data, int thread_num,
@@ -731,7 +742,8 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da local_sys_stat->count[SAPP_STAT_RCV_IPV4_FRAG]++;
local_sys_stat->length[SAPP_STAT_RCV_IPV4_FRAG] += this_layer_len;
}else{
- if(0 == this_layer_is_overlay){ /* ��overlay����ۼ���ز���� */
+ //if(0 == this_layer_is_overlay)
+ { /* ��overlay����ۼ���ز���� */
local_sys_stat->count[SAPP_STAT_RCV_IPV4]++;
local_sys_stat->length[SAPP_STAT_RCV_IPV4] += this_layer_len;
if (routedir == sapp_global_val->config.packet_io.inbound_route_dir)
diff --git a/src/dealpkt/deal_ipv6.c b/src/dealpkt/deal_ipv6.c index 5e5a3be..efa5cfe 100644 --- a/src/dealpkt/deal_ipv6.c +++ b/src/dealpkt/deal_ipv6.c @@ -9,6 +9,7 @@ #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
#ifdef __cplusplus
extern "C" {
diff --git a/src/dealpkt/deal_l2tp.c b/src/dealpkt/deal_l2tp.c index 8aa48f8..188f8a8 100644 --- a/src/dealpkt/deal_l2tp.c +++ b/src/dealpkt/deal_l2tp.c @@ -33,6 +33,7 @@ extern "C" { */
#include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
#define L2TP_DEBUG (0)
#if L2TP_DEBUG
diff --git a/src/dealpkt/deal_mac_in_mac.c b/src/dealpkt/deal_mac_in_mac.c index 53ef6b9..5163d6f 100644 --- a/src/dealpkt/deal_mac_in_mac.c +++ b/src/dealpkt/deal_mac_in_mac.c @@ -5,6 +5,7 @@ extern "C" { #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
extern int g_skip_ethernet_layer_sw;
diff --git a/src/dealpkt/deal_mpls.c b/src/dealpkt/deal_mpls.c index 1a6a93c..ad46995 100644 --- a/src/dealpkt/deal_mpls.c +++ b/src/dealpkt/deal_mpls.c @@ -5,6 +5,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" extern int ipv4_entry(struct streaminfo_private *pfstream, const void *this_layer_data, int thread_num, unsigned char routedir, const raw_pkt_t *raw_pkt, int); diff --git a/src/dealpkt/deal_pppoe.c b/src/dealpkt/deal_pppoe.c index c46b836..e4d4cb3 100644 --- a/src/dealpkt/deal_pppoe.c +++ b/src/dealpkt/deal_pppoe.c @@ -4,7 +4,7 @@ extern "C" { #include "sapp_api.h"
#include "sapp_private_api.h"
-
+#include "sapp_declaration.h"
static inline void set_pppoe_addr(struct layer_addr_pppoe_session *tuple_pppoe,
struct mesa_pppoe_session_hdr *pppoe_hdr)
diff --git a/src/dealpkt/deal_pptp.c b/src/dealpkt/deal_pptp.c index 0746dd3..5e452bc 100644 --- a/src/dealpkt/deal_pptp.c +++ b/src/dealpkt/deal_pptp.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" unsigned short g_pptp_plugid = 0; MESA_htable_handle *g_pptp_htable_array; /* �ڴ������HASH������Э���������ڳ�ʼ������� */ diff --git a/src/dealpkt/deal_tcp.c b/src/dealpkt/deal_tcp.c index 5dd68c7..05d7187 100644 --- a/src/dealpkt/deal_tcp.c +++ b/src/dealpkt/deal_tcp.c @@ -36,6 +36,7 @@ */ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #ifdef __cplusplus extern "C" { diff --git a/src/dealpkt/deal_teredo.c b/src/dealpkt/deal_teredo.c index 2c3c043..49fed77 100644 --- a/src/dealpkt/deal_teredo.c +++ b/src/dealpkt/deal_teredo.c @@ -5,6 +5,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" extern int ipv4_entry(struct streaminfo_private *pfstream, const void *this_layer_data, int thread_num, unsigned char routedir, const raw_pkt_t *raw_pkt, int); diff --git a/src/dealpkt/deal_udp.c b/src/dealpkt/deal_udp.c index 6a05ac8..eb47d5e 100644 --- a/src/dealpkt/deal_udp.c +++ b/src/dealpkt/deal_udp.c @@ -5,6 +5,7 @@ */ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #ifdef __cplusplus extern "C" { diff --git a/src/dealpkt/deal_vlan.c b/src/dealpkt/deal_vlan.c index 39f0ce4..bb05ffa 100644 --- a/src/dealpkt/deal_vlan.c +++ b/src/dealpkt/deal_vlan.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
extern int vlan_addr_net_to_mem(const struct mesa_vlan_detail_hdr *net_vlan_hdr, struct single_layer_vlan_addr *mem_vlan_hdr);
diff --git a/src/dealpkt/deal_vxlan.c b/src/dealpkt/deal_vxlan.c index 20230a7..4fe7fcc 100644 --- a/src/dealpkt/deal_vxlan.c +++ b/src/dealpkt/deal_vxlan.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" int set_vxlan_addr(const void *this_layer_hdr, struct layer_addr_vxlan_private *addr_pr) { diff --git a/src/dealpkt/duplicate_pkt_distinguish.c b/src/dealpkt/duplicate_pkt_distinguish.c index 8c9c058..200604f 100644 --- a/src/dealpkt/duplicate_pkt_distinguish.c +++ b/src/dealpkt/duplicate_pkt_distinguish.c @@ -3,6 +3,7 @@ extern "C" { #endif #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #include "dablooms.h" diff --git a/src/dealpkt/g_device.c b/src/dealpkt/g_device.c index 6feecf5..bdd3862 100644 --- a/src/dealpkt/g_device.c +++ b/src/dealpkt/g_device.c @@ -9,6 +9,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" char pcap_gdev_card[128]; /* 2012-08-14 LiJia add, �����豸ģʽ�£������������ƣ�ͨ����sendto_gdev_cardһ�� */ diff --git a/src/dealpkt/ip_reassembly.c b/src/dealpkt/ip_reassembly.c index b6d66c1..ce9def3 100644 --- a/src/dealpkt/ip_reassembly.c +++ b/src/dealpkt/ip_reassembly.c @@ -9,6 +9,7 @@ */
#include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
#ifdef __cplusplus
extern "C" {
diff --git a/src/dealpkt/plug_support.c b/src/dealpkt/plug_support.c index 6b00bd9..03a2ab8 100644 --- a/src/dealpkt/plug_support.c +++ b/src/dealpkt/plug_support.c @@ -4,6 +4,7 @@ */ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #include "stream_inc/stream_base.h" #ifdef __cplusplus diff --git a/src/dealpkt/stream_manage.c b/src/dealpkt/stream_manage.c index f4ac2c2..34fda10 100644 --- a/src/dealpkt/stream_manage.c +++ b/src/dealpkt/stream_manage.c @@ -25,6 +25,8 @@ */ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" +#include "stream_inc/stream_base.h" #include "timeout.h" #ifdef __cplusplus @@ -184,7 +186,6 @@ static inline UINT64 stream_get_detail_last_mtime(const struct streamindex *pind static void stream_timeout_shift_lrulist(struct streamindex *pindex, unsigned short new_timeout) { unsigned short global_default_timeout; - struct streamindex *tmp_index; struct stream_list *lru_list_root; const struct streaminfo *pstream = &pindex->stream.stream_public; @@ -426,6 +427,7 @@ void free_streamindex(int threadnum,struct streamindex *pindex) } +extern int call_streamentry(struct streaminfo *a_stream, const void *this_iphdr, const void *transport_hdr, const void *raw_pkt, StreamFunInfo *pFunInfo); //add by lqy 20141203 //�������β�������һ�������Ƿ�ʱ�������ʱ����̭֮ @@ -457,29 +459,31 @@ int del_stream_by_time(struct stream_list *plist, const struct streamindex *curr struct streaminfo_private *pstream_pr = &(pindex->stream); struct streaminfo *pstream = &(pstream_pr->stream_public); - if (pindex == current_drive_index) - { /* ��ǰ�����ڵ�����ʱ, ˵��֮ǰ�ܳ�ʱ��û�а�����, ��ʱ����free, ���Ƿ���1, �ٵ���reset */ - if (STREAM_TYPE_TCP == pstream->type) - { - /* 2016-12-15 lijia add, ��ʱreset֮ǰ, ��Ҫ����link_state */ - ((struct tcpdetail_private *)(pstream->pdetail))->link_state = STREAM_LINK_TIMEOUT; - } - ret = 1; - } - if (STREAM_TYPE_TCP == pstream->type) - { - ((struct tcpdetail_private *)(pstream->pdetail))->link_state = STREAM_LINK_TIMEOUT; - tcp_free_stream(pindex, NULL, NULL, NULL); - ret = 2; - - } - else - { - pstream_pr->stream_close_reason = STREAM_CLOSE_REASON_TIMEOUT; - udp_free_stream(pindex); - ret = 2; - } - } + if (pindex == current_drive_index) + { /* ��ǰ�����ڵ�����ʱ, ˵��֮ǰ�ܳ�ʱ��û�а�����, ��ʱ����free, ���Ƿ���1, �ٵ���reset */ + if (STREAM_TYPE_TCP == pstream->type) + { + /* 2016-12-15 lijia add, ��ʱreset֮ǰ, ��Ҫ����link_state */ + ((struct tcpdetail_private *)(pstream->pdetail))->link_state = STREAM_LINK_TIMEOUT; + } + ret = 1; + } + else + { + if (STREAM_TYPE_TCP == pstream->type) + { + ((struct tcpdetail_private *)(pstream->pdetail))->link_state = STREAM_LINK_TIMEOUT; + tcp_free_stream(pindex, NULL, NULL, NULL); + ret = 2; + } + else + { + pstream_pr->stream_close_reason = STREAM_CLOSE_REASON_TIMEOUT; + udp_free_stream(pindex); + ret = 2; + } + } + } if(g_stream->user_define_timer_cnt > 0) { t = timeouts_get(g_stream->user_define_timer); @@ -491,7 +495,7 @@ int del_stream_by_time(struct stream_list *plist, const struct streamindex *curr unsigned char saved_pkt_state = tstream->pktstate; tstream->opstate = OP_STATE_TIMED; tstream->pktstate = OP_STATE_TIMED; - int app_ret = call_streamentry(funinfo->pstream, NULL, NULL, NULL, funinfo); + int app_ret = call_streamentry((struct streaminfo *)funinfo->pstream, NULL, NULL, NULL, funinfo); tstream->opstate = saved_op_state; tstream->pktstate = saved_pkt_state; @@ -516,7 +520,6 @@ int del_stream_by_time(struct stream_list *plist, const struct streamindex *curr int lrustream(struct streamindex *pindex) { struct stream_list *plist=NULL; - struct streamindex * next,*prev; struct streaminfo_private *pstream_pr=&(pindex->stream); struct streaminfo *pstream = &pstream_pr->stream_public; @@ -864,7 +867,6 @@ static void update_outer_ipv4addr_for_gtp_tunnel(const struct streaminfo_private struct streaminfo_private *pheap_gtp_stream_pr, struct streaminfo_private *pstack_gtp_stream_pr, struct streaminfo_private *pheap_ip_stream_pr, struct streaminfo_private *pstack_ip_stream_pr, unsigned char cur_pkt_dir) { - int ret; int addr_has_changed = 0; const struct stream_tuple4_v4 *stack_tuple4addr = pstack_ip_stream_pr->stream_public.addr.tuple4_v4; struct stream_tuple4_v4 *heap_tuple4addr = pheap_ip_stream_pr->stream_public.addr.tuple4_v4; @@ -901,7 +903,8 @@ static void update_outer_ipv4addr_for_gtp_tunnel(const struct streaminfo_private char ip_after_src_str[INET_ADDRSTRLEN], ip_after_dst_str[INET_ADDRSTRLEN]; unsigned int before_teid_c2s, before_teid_s2c, after_teid_c2s, after_teid_s2c; - if(addr_has_changed){ + //if(addr_has_changed) + { before_teid_c2s = ntohl(pheap_gtp_stream_pr->stream_public.addr.gtp->teid_c2s); before_teid_s2c = ntohl(pheap_gtp_stream_pr->stream_public.addr.gtp->teid_s2c); @@ -946,7 +949,6 @@ static void update_outer_ipv6addr_for_gtp_tunnel(const struct streaminfo_private struct streaminfo_private *pheap_gtp_stream_pr, struct streaminfo_private *pstack_gtp_stream_pr, struct streaminfo_private *pheap_ip_stream_pr, struct streaminfo_private *pstack_ip_stream_pr, unsigned char cur_pkt_dir) { - int ret; int addr_has_changed = 0; const struct stream_tuple4_v6 *stack_tuple6addr = pstack_ip_stream_pr->stream_public.addr.tuple4_v6; struct stream_tuple4_v6 *heap_tuple6addr = pheap_ip_stream_pr->stream_public.addr.tuple4_v6; @@ -983,7 +985,8 @@ static void update_outer_ipv6addr_for_gtp_tunnel(const struct streaminfo_private char ip_after_src_str[INET_ADDRSTRLEN], ip_after_dst_str[INET_ADDRSTRLEN]; unsigned int before_teid_c2s, before_teid_s2c, after_teid_c2s, after_teid_s2c; - if(addr_has_changed){ + //if(addr_has_changed) + { before_teid_c2s = ntohl(pheap_gtp_stream_pr->stream_public.addr.gtp->teid_c2s); before_teid_s2c = ntohl(pheap_gtp_stream_pr->stream_public.addr.gtp->teid_s2c); @@ -1508,122 +1511,152 @@ void hash_del_stream(struct streamindex *pindex) UCHAR threadnum = ptmp->threadnum; sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[threadnum]->sys_stat; - if(STREAM_TYPE_UDP==ptmp->type) - { - phashstream=G_MESA_GLOBAL_STREAM[threadnum]->udp_stream_table; - pelementcount=G_MESA_GLOBAL_STREAM[threadnum]->udp_stream_talbe_hash_count; - local_sys_stat->count[SAPP_STAT_UDP_STREAM_DEL]++; - if(ptmp->pudpdetail->clientpktnum+ptmp->pudpdetail->serverpktnum >= sapp_global_val->config.stream.udp.meaningful_statistics_minimum_pkt - && ptmp->pudpdetail->clientbytes+ptmp->pudpdetail->serverbytes >= sapp_global_val->config.stream.udp.meaningful_statistics_minimum_byte) - { - if(ptmp->dir == DIR_DOUBLE) - { - local_sys_stat->count[SAPP_STAT_UDP_STREAM_DOUBLE]++; - local_sys_stat->count[SAPP_STAT_UDP_STREAM_DOUBLE_PKTS]+=(ptmp->pudpdetail->clientpktnum+ptmp->pudpdetail->serverpktnum); - local_sys_stat->count[SAPP_STAT_UDP_STREAM_DOUBLE_BYTES]+=(ptmp->pudpdetail->clientbytes+ptmp->pudpdetail->serverbytes); - } - else if(ptmp->dir == DIR_C2S) - { - local_sys_stat->count[SAPP_STAT_UDP_STREAM_C2S]++; - local_sys_stat->count[SAPP_STAT_UDP_STREAM_C2S_PKTS]+=(ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); - local_sys_stat->count[SAPP_STAT_UDP_STREAM_C2S_BYTES]+=(ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); - } - else if(ptmp->dir == DIR_S2C) - { - local_sys_stat->count[SAPP_STAT_UDP_STREAM_S2C]++; - local_sys_stat->count[SAPP_STAT_UDP_STREAM_S2C_PKTS]+=(ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); - local_sys_stat->count[SAPP_STAT_UDP_STREAM_S2C_BYTES]+=(ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); - } - } - if(ptmp->dir == DIR_DOUBLE) - { - local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE]++; - local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE_PKTS] += (ptmp->pudpdetail->clientpktnum + ptmp->pudpdetail->serverpktnum); - local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE_BYTES] += (ptmp->pudpdetail->clientbytes + ptmp->pudpdetail->serverbytes); - } - else if(ptmp->dir == DIR_C2S) - { - local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_C2S]++; - local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_C2S_PKTS] += (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); - local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_C2S_BYTES] += (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); - } - else if(ptmp->dir == DIR_S2C) - { - local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_S2C]++; - local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_S2C_PKTS] += (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); - local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_S2C_BYTES] += (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); - } - } - else if (STREAM_TYPE_TCP==ptmp->type) - { - const struct tcpdetail_private *pdetail_pr=(struct tcpdetail_private*)(ptmp->pdetail); - phashstream=G_MESA_GLOBAL_STREAM[threadnum]->tcp_stream_table; - pelementcount=G_MESA_GLOBAL_STREAM[threadnum]->tcp_stream_talbe_hash_count; - local_sys_stat->count[SAPP_STAT_TCP_STREAM_DEL]++; - - if(pdetail_pr->has_lost_pkt_flag != 0){ - local_sys_stat->count[SAPP_STAT_TCP_LOST_PKT_STREAM_NUM]++; - } - - if(ptmp->ptcpdetail->clientpktnum+ptmp->ptcpdetail->serverpktnum >= sapp_global_val->config.stream.tcp.meaningful_statistics_minimum_pkt - && ptmp->ptcpdetail->clientbytes+ptmp->ptcpdetail->serverbytes >= sapp_global_val->config.stream.tcp.meaningful_statistics_minimum_byte) - { - if(ptmp->dir == DIR_DOUBLE) - { - local_sys_stat->count[SAPP_STAT_TCP_STREAM_DOUBLE]++; - local_sys_stat->count[SAPP_STAT_TCP_STREAM_DOUBLE_PKTS]+=(ptmp->ptcpdetail->clientpktnum+ptmp->ptcpdetail->serverpktnum); - local_sys_stat->count[SAPP_STAT_TCP_STREAM_DOUBLE_BYTES]+=(ptmp->ptcpdetail->clientbytes+ptmp->ptcpdetail->serverbytes ); - } - else if(ptmp->dir == DIR_C2S) - { - local_sys_stat->count[SAPP_STAT_TCP_STREAM_C2S]++; - local_sys_stat->count[SAPP_STAT_TCP_STREAM_C2S_PKTS]+=(ptmp->ptcpdetail->clientpktnum+ptmp->ptcpdetail->serverpktnum); - local_sys_stat->count[SAPP_STAT_TCP_STREAM_C2S_BYTES]+=(ptmp->ptcpdetail->clientbytes+ptmp->ptcpdetail->serverbytes ); - } - else if(ptmp->dir == DIR_S2C) - { - local_sys_stat->count[SAPP_STAT_TCP_STREAM_S2C]++; - local_sys_stat->count[SAPP_STAT_TCP_STREAM_S2C_PKTS]+=(ptmp->ptcpdetail->clientpktnum+ptmp->ptcpdetail->serverpktnum); - local_sys_stat->count[SAPP_STAT_TCP_STREAM_S2C_BYTES]+=(ptmp->ptcpdetail->clientbytes+ptmp->ptcpdetail->serverbytes ); - } - else - ; - } - - if(ptmp->dir == DIR_DOUBLE) - { - local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE]++; - local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE_PKTS] += (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); - local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE_BYTES] += (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); - } - else if(ptmp->dir == DIR_C2S) - { - local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_C2S]++; - local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_C2S_PKTS] += (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); - local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_C2S_BYTES] += (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); - } - else if(ptmp->dir == DIR_S2C) - { - local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_S2C]++; - local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_S2C_PKTS] += (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); - local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_S2C_BYTES] += (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); - } - - }else{ - phashstream = NULL; - pelementcount = 0; - assert(0); - } - - if(pindex->phashprev!=NULL) - { - pindex->phashprev->phashnext=pindex->phashnext; - } - else - { - phashstream[ptmp->hash_index] = pindex->phashnext; - } - if(pindex->phashnext!=NULL) + if (STREAM_TYPE_UDP == ptmp->type) + { + phashstream = G_MESA_GLOBAL_STREAM[threadnum]->udp_stream_table; + pelementcount = G_MESA_GLOBAL_STREAM[threadnum]->udp_stream_talbe_hash_count; + local_sys_stat->count[SAPP_STAT_UDP_STREAM_DEL]++; + if (ptmp->pudpdetail->clientpktnum + ptmp->pudpdetail->serverpktnum >= + sapp_global_val->config.stream.udp.meaningful_statistics_minimum_pkt && + ptmp->pudpdetail->clientbytes + ptmp->pudpdetail->serverbytes >= + sapp_global_val->config.stream.udp.meaningful_statistics_minimum_byte) + { + if (ptmp->dir == DIR_DOUBLE) + { + local_sys_stat->count[SAPP_STAT_UDP_STREAM_DOUBLE]++; + local_sys_stat->count[SAPP_STAT_UDP_STREAM_DOUBLE_PKTS] += + (ptmp->pudpdetail->clientpktnum + ptmp->pudpdetail->serverpktnum); + local_sys_stat->count[SAPP_STAT_UDP_STREAM_DOUBLE_BYTES] += + (ptmp->pudpdetail->clientbytes + ptmp->pudpdetail->serverbytes); + } + else if (ptmp->dir == DIR_C2S) + { + local_sys_stat->count[SAPP_STAT_UDP_STREAM_C2S]++; + local_sys_stat->count[SAPP_STAT_UDP_STREAM_C2S_PKTS] += + (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); + local_sys_stat->count[SAPP_STAT_UDP_STREAM_C2S_BYTES] += + (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); + } + else if (ptmp->dir == DIR_S2C) + { + local_sys_stat->count[SAPP_STAT_UDP_STREAM_S2C]++; + local_sys_stat->count[SAPP_STAT_UDP_STREAM_S2C_PKTS] += + (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); + local_sys_stat->count[SAPP_STAT_UDP_STREAM_S2C_BYTES] += + (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); + } + } + if (ptmp->dir == DIR_DOUBLE) + { + local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE]++; + local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE_PKTS] += + (ptmp->pudpdetail->clientpktnum + ptmp->pudpdetail->serverpktnum); + local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_DOUBLE_BYTES] += + (ptmp->pudpdetail->clientbytes + ptmp->pudpdetail->serverbytes); + } + else if (ptmp->dir == DIR_C2S) + { + local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_C2S]++; + local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_C2S_PKTS] += + (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); + local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_C2S_BYTES] += + (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); + } + else if (ptmp->dir == DIR_S2C) + { + local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_S2C]++; + local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_S2C_PKTS] += + (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); + local_sys_stat->count[SAPP_STAT_UDP_STREAM_TOTAL_S2C_BYTES] += + (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); + } + } + else if (STREAM_TYPE_TCP == ptmp->type) + { + const struct tcpdetail_private *pdetail_pr = (struct tcpdetail_private *)(ptmp->pdetail); + phashstream = G_MESA_GLOBAL_STREAM[threadnum]->tcp_stream_table; + pelementcount = G_MESA_GLOBAL_STREAM[threadnum]->tcp_stream_talbe_hash_count; + local_sys_stat->count[SAPP_STAT_TCP_STREAM_DEL]++; + + if (pdetail_pr->has_lost_pkt_flag != 0) + { + local_sys_stat->count[SAPP_STAT_TCP_LOST_PKT_STREAM_NUM]++; + } + + if (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum >= + sapp_global_val->config.stream.tcp.meaningful_statistics_minimum_pkt && + ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes >= + sapp_global_val->config.stream.tcp.meaningful_statistics_minimum_byte) + { + if (ptmp->dir == DIR_DOUBLE) + { + local_sys_stat->count[SAPP_STAT_TCP_STREAM_DOUBLE]++; + local_sys_stat->count[SAPP_STAT_TCP_STREAM_DOUBLE_PKTS] += + (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); + local_sys_stat->count[SAPP_STAT_TCP_STREAM_DOUBLE_BYTES] += + (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); + } + else if (ptmp->dir == DIR_C2S) + { + local_sys_stat->count[SAPP_STAT_TCP_STREAM_C2S]++; + local_sys_stat->count[SAPP_STAT_TCP_STREAM_C2S_PKTS] += + (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); + local_sys_stat->count[SAPP_STAT_TCP_STREAM_C2S_BYTES] += + (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); + } + else if (ptmp->dir == DIR_S2C) + { + local_sys_stat->count[SAPP_STAT_TCP_STREAM_S2C]++; + local_sys_stat->count[SAPP_STAT_TCP_STREAM_S2C_PKTS] += + (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); + local_sys_stat->count[SAPP_STAT_TCP_STREAM_S2C_BYTES] += + (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); + } + else + ; + } + + if (ptmp->dir == DIR_DOUBLE) + { + local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE]++; + local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE_PKTS] += + (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); + local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_DOUBLE_BYTES] += + (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); + } + else if (ptmp->dir == DIR_C2S) + { + local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_C2S]++; + local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_C2S_PKTS] += + (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); + local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_C2S_BYTES] += + (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); + } + else if (ptmp->dir == DIR_S2C) + { + local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_S2C]++; + local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_S2C_PKTS] += + (ptmp->ptcpdetail->clientpktnum + ptmp->ptcpdetail->serverpktnum); + local_sys_stat->count[SAPP_STAT_TCP_STREAM_TOTAL_S2C_BYTES] += + (ptmp->ptcpdetail->clientbytes + ptmp->ptcpdetail->serverbytes); + } + } + else + { + phashstream = NULL; + pelementcount = 0; + assert(0); + } + + if (pindex->phashprev != NULL) + { + pindex->phashprev->phashnext = pindex->phashnext; + } + else + { + phashstream[ptmp->hash_index] = pindex->phashnext; + } + if(pindex->phashnext!=NULL) { pindex->phashnext->phashprev=pindex->phashprev; } @@ -1833,7 +1866,6 @@ void addr_reverse_memcpy(const struct streaminfo_private *stack_stream_pr, void case ADDR_TYPE_MAC: /* 2015-06-15 lijia add, ľ������豸���� */ { - unsigned char tmp_mac_addr[ETH_ALEN]; const struct layer_addr_mac *cur_stack_mac_saddr = (const struct layer_addr_mac *) saddr; struct layer_addr_mac *heap_stream_mac_daddr = (struct layer_addr_mac *) daddr; @@ -2466,7 +2498,6 @@ struct streaminfo_private *copy_stream_info_to_heap_single_layer(int mem_used_ty void *heap_addr; struct streaminfo *heap_stream; const struct streaminfo *stack_stream; - struct streaminfo_private *pfather_pr; if(NULL == stack_stream_pr){ return NULL; @@ -2652,6 +2683,8 @@ static inline void sapp_get_dup_pkt_key_udp_v6(const struct mesa_ip6_hdr *ip6hdr return; } +extern int sapp_dup_pkt_identify_v4(int tid, const sapp_dup_pkt_key_v4_t *key); +extern int sapp_dup_pkt_mark_v4(int tid, const sapp_dup_pkt_key_v4_t *key); int sapp_dup_pkt_identify_udp_v4(int tid, struct streaminfo_private *pstream_pr, const struct mesa_ip4_hdr *ipv4_hdr, const struct mesa_udp_hdr *udp_h, int need_add_bloom_filter) @@ -2672,6 +2705,8 @@ int sapp_dup_pkt_identify_udp_v4(int tid, struct streaminfo_private *pstream_pr, return is_dup_pkt; } +extern int sapp_dup_pkt_identify_v6(int tid, const sapp_dup_pkt_key_v6_t *key); + int sapp_dup_pkt_identify_udp_v6(int tid, struct streaminfo_private *pstream_pr, const struct mesa_ip6_hdr *ipv6_hdr, const struct mesa_udp_hdr *udp_h) { @@ -2687,6 +2722,8 @@ int sapp_dup_pkt_identify_udp_v6(int tid, struct streaminfo_private *pstream_pr, return is_dup_pkt; } +extern int sapp_dup_pkt_mark_v6(int tid, const sapp_dup_pkt_key_v6_t *key); + void sapp_dup_pkt_mark_tcp(int tid, unsigned char addrtype, const void *ip_hdr, const struct mesa_tcp_hdr *tcp_h) { sapp_dup_pkt_key_v4_t dup_bloom_key_v4; @@ -2955,6 +2992,8 @@ extern unsigned int tuple4_v6_make_crc_hash(const struct stream_tuple4_v6 *tuple return tot_found_stream_num; } +extern int stream_bridge_init(void); + int init_stream_manage(int threadcount) { int i; diff --git a/src/inner_plug/g_device_plug.cpp b/src/inner_plug/g_device_plug.cpp index 3535da8..78b6007 100644 --- a/src/inner_plug/g_device_plug.cpp +++ b/src/inner_plug/g_device_plug.cpp @@ -15,6 +15,7 @@ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #include "stream_inc/gdev_keepalive.h" #include "field_stat2.h" diff --git a/src/inner_plug/gdev_assistant.c b/src/inner_plug/gdev_assistant.c index db176fb..f7049c9 100644 --- a/src/inner_plug/gdev_assistant.c +++ b/src/inner_plug/gdev_assistant.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #include "support/grule.h" #include "support/MESA_socket_wrap.h" diff --git a/src/inner_plug/sapp_assistant.cpp b/src/inner_plug/sapp_assistant.cpp index b6e2785..8cddd49 100644 --- a/src/inner_plug/sapp_assistant.cpp +++ b/src/inner_plug/sapp_assistant.cpp @@ -5,8 +5,11 @@ */ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #include "field_stat2.h" +#include "marsio.h" + static int sapp_fs2_init(void); static int sapp_line_protocol_init(void); diff --git a/src/packet_io/cycle_pkt_dump_through_write_offset.c b/src/packet_io/cycle_pkt_dump_through_write_offset.c index 8bc7804..ddd60cb 100644 --- a/src/packet_io/cycle_pkt_dump_through_write_offset.c +++ b/src/packet_io/cycle_pkt_dump_through_write_offset.c @@ -1,5 +1,6 @@ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #include "support/MESA_socket_wrap.h" /* diff --git a/src/packet_io/packet_io.c b/src/packet_io/packet_io.c index 4abfec0..fe807ed 100644 --- a/src/packet_io/packet_io.c +++ b/src/packet_io/packet_io.c @@ -1,5 +1,6 @@ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #include "support/MESA_feedback.h" /* 2015-04-15 diff --git a/src/packet_io/packet_io_device.c b/src/packet_io/packet_io_device.c index f4eb035..9b358ae 100644 --- a/src/packet_io/packet_io_device.c +++ b/src/packet_io/packet_io_device.c @@ -1,5 +1,6 @@ #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
#ifdef __cplusplus
extern "C" {
diff --git a/src/packet_io/packet_io_hook.c b/src/packet_io/packet_io_hook.c index e97a7d7..112b98c 100644 --- a/src/packet_io/packet_io_hook.c +++ b/src/packet_io/packet_io_hook.c @@ -1,5 +1,6 @@ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #include "support/MESA_feedback.h" /* 2020-09-28 add: diff --git a/src/packet_io/packet_io_log.c b/src/packet_io/packet_io_log.c index bd056e6..b1c544f 100644 --- a/src/packet_io/packet_io_log.c +++ b/src/packet_io/packet_io_log.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" extern void gdev_keepalive_log(void); extern void queue_full_detect(FILE *queue_log_fp); diff --git a/src/packet_io/packet_io_marsio.c b/src/packet_io/packet_io_marsio.c index 045ea98..1eb84c5 100644 --- a/src/packet_io/packet_io_marsio.c +++ b/src/packet_io/packet_io_marsio.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #include <assert.h> /* diff --git a/src/packet_io/packet_io_pcap.c b/src/packet_io/packet_io_pcap.c index adba38b..a62493f 100644 --- a/src/packet_io/packet_io_pcap.c +++ b/src/packet_io/packet_io_pcap.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
#include <pcap/pcap.h>
#include <sys/types.h>
diff --git a/src/packet_io/packet_io_status.cpp b/src/packet_io/packet_io_status.cpp index 9a2265c..b9ce1f3 100644 --- a/src/packet_io/packet_io_status.cpp +++ b/src/packet_io/packet_io_status.cpp @@ -6,6 +6,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #include <stdarg.h> volatile int update_packet_io_status_sw = 1; diff --git a/src/packet_io/sapp_compat_old_papp_api.c b/src/packet_io/sapp_compat_old_papp_api.c index 3ab1df5..b9ea6db 100644 --- a/src/packet_io/sapp_compat_old_papp_api.c +++ b/src/packet_io/sapp_compat_old_papp_api.c @@ -9,6 +9,7 @@ extern "C" { #endif
#include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
#ifndef GSERIAL_PLUGID_MAX
#define GSERIAL_PLUGID_MAX (64)
diff --git a/src/packet_io/sapp_inject.c b/src/packet_io/sapp_inject.c index fdd5e58..97fdf61 100644 --- a/src/packet_io/sapp_inject.c +++ b/src/packet_io/sapp_inject.c @@ -1,5 +1,6 @@ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #include "stream_inc/sapp_inject.h" diff --git a/src/packet_io/sendpacket.c b/src/packet_io/sendpacket.c index 4237441..076d716 100644 --- a/src/packet_io/sendpacket.c +++ b/src/packet_io/sendpacket.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" //#define KILL_TCP_RST_NUM (3) diff --git a/src/packet_io/under_ddos.cpp b/src/packet_io/under_ddos.cpp index 9a77a35..d6aff8f 100644 --- a/src/packet_io/under_ddos.cpp +++ b/src/packet_io/under_ddos.cpp @@ -9,6 +9,7 @@ #include "cpu_limit.h" #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #ifdef __cplusplus extern "C" { diff --git a/src/plugin/src/plugin.c b/src/plugin/src/plugin.c index c44f2b2..aff797b 100644 --- a/src/plugin/src/plugin.c +++ b/src/plugin/src/plugin.c @@ -99,6 +99,7 @@ int stream_register_fun(int funtype,char (*x)(void), int); #include "plugin.h" #include "plugin_serial.h" +#include "sapp_declaration.h" extern stProtocolPlugInfo* g_protocol_plug_info; extern stBusinessPlugInfo* g_business_plug_info; @@ -117,7 +118,7 @@ stPlugRuntimeInfo plugctrl_runtime_info; Lijia note: ����˳��Ҫ��enum fun_type_t����˳��һ��. */ -char* g_plugin_entryname[PLUGIN_MAX_ENTRYNUM] = +const char* g_plugin_entryname[PLUGIN_MAX_ENTRYNUM] = { SECTION_FUN_IP, SECTION_FUN_IPV6, @@ -187,7 +188,7 @@ static int reset_cwd() memset(cur_path, 0, sizeof(cur_path)); int path_len = readlink("/proc/self/exe", cur_path, sizeof(cur_path)); int i = 0, ret = 0; - if(path_len < 0 || path_len > sizeof(cur_path)) + if(path_len < 0 || path_len > (int)sizeof(cur_path)) { perror(NULL); return -1; @@ -504,8 +505,6 @@ int check_plug_conf(char* filename,int plugtype) *****************************************************************************/ int process_conf_entryname() { - int rec; - int len; //char filename[PLUGIN_FILENAME_MAXLEN] = {0}; char buf_entryname[PLUGIN_MAX_CONFLEN] = {0}; FILE* fp; @@ -587,7 +586,8 @@ int process_conf_entryname() } - +extern int plugin_load_new_plug(const char *plug_name, const char *plug_path); +extern int plugin_is_necessary(const char *plug_path); /**************************************************************************** ������:process_confelem_plugname() ���ܣ�������������ļ��IJ�����ֶ� @@ -880,8 +880,8 @@ plug_init_error: return -1; } - - +extern int plugin_load_new_plug_entry(const char *plug_name, const char *plug_entry_type, void *entry_addr); +extern int stream_register_fun(enum fun_type_t funtype,char (*x)(void), int plug_entry_id); /**************************************************************************** ������:process_confelem_platentry() ���ܣ�����ƽ̨��ں��� @@ -930,7 +930,7 @@ int process_confelem_platentry(char* filename,void* fp_dlopen,char* plugname) } plug_entry_id = plug_mange_get_entry_id(plugname, buf_funname); - ret=stream_register_fun(i,fun_pointer, plug_entry_id); + ret=stream_register_fun((enum fun_type_t)i,fun_pointer, plug_entry_id); if(ret==-1) { sapp_printf("\033[1;31;40m[Error]%s stream_register %s entry error\033[0m\n",filename,g_plugin_entryname[i]); @@ -1318,7 +1318,7 @@ static int fetch_section_name(char *filename, char *section_name) /* filename : ./plug/conflist.inf */ -static int process_conflist_single(char* filename, int plug_type, char *wanted_section_name) +static int process_conflist_single(char* filename, int plug_type, const char *wanted_section_name) { int rec = 0; char buf_confname[PLUGIN_FILENAME_MAXLEN] = {0}; @@ -1373,7 +1373,7 @@ static int process_conflist_single(char* filename, int plug_type, char *wanted_s static void confilist_file_check(void) { struct stat fstat; - int fres, ret; + int fres; fres = stat(ABBR_PLUG_LIST_CONF_FILE, &fstat); if(fres < 0){ @@ -1400,8 +1400,6 @@ static void confilist_file_check(void) int process_conflist(int plug_type) { int rec; - int len; - char buf_confname[PLUGIN_FILENAME_MAXLEN] = {0}; confilist_file_check(); @@ -1881,7 +1879,6 @@ static char session_multi_state_context_free(stSessionInfo* session_info,void ** char PROT_PROCESS(stSessionInfo* session_info, void **pme, int thread_seq,struct streaminfo *a_stream,const void *a_packet) { char ret1=PROT_STATE_DROPME; - char ret2=PROT_STATE_GIVEME; unsigned short plugid = session_info->plugid; int session_state = session_info->session_state; stProtocolPlugInfo* pluginfo; @@ -1961,7 +1958,6 @@ void plugctrl_destroy_all_plug() { stBusinessPlugInfo *plug_info, *plug_next; stProtocolPlugInfo *pro_plug_info, *pro_plug_next; - int i; sapp_runtime_log(RLOG_LV_INFO, "plugctrl_destroy_all_plug, begin destory all plugin !"); /***** call all plugins destory callback fun *****/ diff --git a/src/plugin/src/plugin_manage.cpp b/src/plugin/src/plugin_manage.cpp index 27e6629..15d0982 100644 --- a/src/plugin/src/plugin_manage.cpp +++ b/src/plugin/src/plugin_manage.cpp @@ -5,8 +5,8 @@ /* sapp挂载插件失败后,仅写错误日志,然后继续加载下一个插件, - 即便所有插件都加载失败,仍然会处理流量,空跑�? 有时候必要的插件如果不加载,sapp运行已无意义,应该退出,这样其他监控程序可以告警�? 而仅写一条错误日志,不方便通过第三方监测程序发现问题�? - sapp新增配置文件:./etc/necessary_plug_list.conf, 加载插件失败是否退出,根据项目需求灵活选择�?*/ + 即便所有插件都加载失败,仍然会处理流量,空跑�? 有时候必要的插件如果不加载,sapp运行已无意义,应该退出,这样其他监控程序可以告警�? 而仅写一条错误日志,不方便通过第三方监测程序发现问题�? + sapp新增配置文件:./etc/necessary_plug_list.conf, 加载插件失败是否退出,根据项目需求灵活选择�?*/ #ifdef __cplusplus extern "C" { @@ -22,7 +22,7 @@ static MESA_htable_handle g_plug_necessary_htable; struct plug_uniq_t{ const char *plug_path; int is_necessary; - int plug_id; /* 只有protocol解析层才有�? 其他�?1 */ + int plug_id; /* 只有protocol解析层才有�? 其他�?1 */ }; /* @@ -64,26 +64,26 @@ plug_global_entry_t g_plug_global_entry[SAPP_MAX_PLUG_ENTRY_NUM]; int g_plug_global_entry_index; /* TODO1: - 插件加载失败是否退�? 取决于g_plug_uniq_htable中的necessary是否设置; + 插件加载失败是否退�? 取决于g_plug_uniq_htable中的necessary是否设置; TODO2: 插件获取自己的pme, 传入streaminfo和plugname, entry_type_string, - 先从g_plug_manage_htable找到这个插件的entry函数入口地址, 这是全局�? 来自dlopen插件.so, 不会�? + 先从g_plug_manage_htable找到这个插件的entry函数入口地址, 这是全局�? 来自dlopen插件.so, 不会�? - 然后在当前streaminfo的三个pdetail_private里找插件列表, 参�? MESA_get_stream_plug_pme() + 然后在当前streaminfo的三个pdetail_private里找插件列表, 参�? MESA_get_stream_plug_pme() 其中有些函数可能是解析层函数入口, 可以通过 g_protocol_plug_info 比较得知; - 如果不是解析层函�? 等同于现在的MESA_get_stream_plug_pme, + 如果不是解析层函�? 等同于现在的MESA_get_stream_plug_pme, - 如果是解析层函数, 需要继续递归查找挂载到当前解析层插件的业务插件列�? + 如果是解析层函数, 需要继续递归查找挂载到当前解析层插件的业务插件列�? 先找到解析层的pme, 但是这个私有结构都是解析插件自定义的, 比如http_stream, 在http_stream里还有个指针, 才是业务插件函数调用链的pme, - 只有找到了这个pme, 才能转换�?stSessionFunInfo 结构, 然后通过比较appentry是否相同, 最后取出业务插件的pme. + 只有找到了这个pme, 才能转换�?stSessionFunInfo 结构, 然后通过比较appentry是否相同, 最后取出业务插件的pme. - 但是, 解析层插件暴露给sapp平台的pme, 和业务插件对解析层的pme不是一个变�? 如何能找到解析层的业务插件pme指针??? - 而且, 一个tcp流里可能有多个http session, 每个http session又对应了一个业务插件的pme调用�? 且只有解析层插件自己知道这个结构, - 仅在sapp内部, 目前是不可能找到解析层上挂载的每个业务层插件pme�?!! + 但是, 解析层插件暴露给sapp平台的pme, 和业务插件对解析层的pme不是一个变�? 如何能找到解析层的业务插件pme指针??? + 而且, 一个tcp流里可能有多个http session, 每个http session又对应了一个业务插件的pme调用�? 且只有解析层插件自己知道这个结构, + 仅在sapp内部, 目前是不可能找到解析层上挂载的每个业务层插件pme�?!! */ @@ -139,7 +139,7 @@ static MESA_htable_handle create_plug_necessary_htable(void) opt_int = HASH_ELIMINATE_ALGO_FIFO; MESA_htable_set_opt(htable, MHO_ELIMIMINATE_TYPE, &opt_int, sizeof(int)); - /* key是字符串, MHO_CBFUN_KEY_COMPARE, MHO_CBFUN_KEY_TO_INDEX使用htable内置的默认函�?*/ + /* key是字符串, MHO_CBFUN_KEY_COMPARE, MHO_CBFUN_KEY_TO_INDEX使用htable内置的默认函�?*/ MESA_htable_set_opt(htable, MHO_CBFUN_DATA_FREE, (void *)plug_necessary_htable_free_cb, sizeof(void *)); @@ -183,7 +183,7 @@ static MESA_htable_handle create_plug_uniq_htable(void) opt_int = HASH_ELIMINATE_ALGO_FIFO; MESA_htable_set_opt(htable, MHO_ELIMIMINATE_TYPE, &opt_int, sizeof(int)); - /* key是字符串, MHO_CBFUN_KEY_COMPARE, MHO_CBFUN_KEY_TO_INDEX使用htable内置的默认函数即�?*/ + /* key是字符串, MHO_CBFUN_KEY_COMPARE, MHO_CBFUN_KEY_TO_INDEX使用htable内置的默认函数即�?*/ MESA_htable_set_opt(htable, MHO_CBFUN_DATA_FREE, (void *)plug_uniq_htable_free_cb, sizeof(void *)); @@ -305,7 +305,7 @@ int plugin_is_necessary(const char *plug_path) } /* - 加载一个新的插�? 全局名称不能重复. + 加载一个新的插�? 全局名称不能重复. */ int plugin_load_new_plug(const char *plug_name, const char *plug_path) { @@ -329,7 +329,7 @@ int plugin_load_new_plug(const char *plug_name, const char *plug_path) /* - 加载一个新的插件的entry, 一个插件可以同时有多个不同层的entry, 如TCP, UDP, HTTP, DNS�?.. + 加载一个新的插件的entry, 一个插件可以同时有多个不同层的entry, 如TCP, UDP, HTTP, DNS�?.. */ int plugin_load_new_plug_entry(const char *plug_name, const char *plug_entry_type, void *entry_addr) { @@ -347,12 +347,11 @@ int plugin_load_new_plug_entry(const char *plug_name, const char *plug_entry_typ } /* - 根据插件名称和入口函数类�? 获取入口函数地址. + 根据插件名称和入口函数类�? 获取入口函数地址. */ void *plugin_get_plug_entry(const char *plug_name, const char *plug_entry_type) { struct plug_manage_key_t mg_key = {}; - int ret; void *plug_entry_addr; mg_key.plug_name = plug_name; @@ -365,7 +364,7 @@ void *plugin_get_plug_entry(const char *plug_name, const char *plug_entry_type) /* - 文件内容�?/plug/conflist.inf, 但是无段落标�? + 文件内容�?/plug/conflist.inf, 但是无段落标�? */ static int plugin_parse_necessary_conf(void) { @@ -374,7 +373,7 @@ static int plugin_parse_necessary_conf(void) fp = fopen(ABBR_NECESSARY_PLUG_CONF_FILE, "r"); if(NULL == fp){ - /* 没有此文�? 或空文件都不是错�? 表示没有必需的插�?*/ + /* 没有此文�? 或空文件都不是错�? 表示没有必需的插�?*/ return 0; } @@ -501,7 +500,7 @@ static void sapp_plug_modify_char(char *str, int raw_char, int new_char) { char *ptr; - while(ptr = strchr(str, raw_char)){ + while((ptr = strchr(str, raw_char))){ *ptr = (char)new_char; } } @@ -578,8 +577,8 @@ int plugin_manage_init(void) plugin_parse_necessary_conf(); - /* index 0保留, 全为内置插件, �?udp_teredo_identify_entry(), gdev_keepalive_udp_entry()等等 - 或者是暂不支持entry_id, 而直接调�? stream_register_xxx系列函数注册的插�? + /* index 0保留, 全为内置插件, �?udp_teredo_identify_entry(), gdev_keepalive_udp_entry()等等 + 或者是暂不支持entry_id, 而直接调�? stream_register_xxx系列函数注册的插�? */ g_plug_global_entry[0].entry_id = 0; g_plug_global_entry[0].plug_name = sapp_strdup("inner_plug"); diff --git a/src/project/project_requirement.c b/src/project/project_requirement.c index 4cc3303..9137cc7 100644 --- a/src/project/project_requirement.c +++ b/src/project/project_requirement.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
#include "MESA_list.h"
//extern int g_packet_io_thread_num;
diff --git a/src/project/raw_ip_frag_list.c b/src/project/raw_ip_frag_list.c index 269fff7..95c9acb 100644 --- a/src/project/raw_ip_frag_list.c +++ b/src/project/raw_ip_frag_list.c @@ -8,6 +8,7 @@ extern "C" { #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
//extern int g_packet_io_thread_num;
diff --git a/src/project/stream_bridge.c b/src/project/stream_bridge.c index d7479b8..c696824 100644 --- a/src/project/stream_bridge.c +++ b/src/project/stream_bridge.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #include "MESA_htable.h" #include "MESA_list.h" diff --git a/src/sapp_dev/sapp_global_val.c b/src/sapp_dev/sapp_global_val.c index 8cda235..6257eda 100644 --- a/src/sapp_dev/sapp_global_val.c +++ b/src/sapp_dev/sapp_global_val.c @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" sapp_global_t *sapp_global_val; diff --git a/src/sapp_dev/sapp_init.c b/src/sapp_dev/sapp_init.c index 1bdaaae..3b49389 100644 --- a/src/sapp_dev/sapp_init.c +++ b/src/sapp_dev/sapp_init.c @@ -1,5 +1,6 @@ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" /* Systemd */ #include <systemd/sd-daemon.h> diff --git a/src/sapp_dev/sapp_plug.c b/src/sapp_dev/sapp_plug.c index 6dc20ce..46e997c 100644 --- a/src/sapp_dev/sapp_plug.c +++ b/src/sapp_dev/sapp_plug.c @@ -1,5 +1,6 @@ #include "sapp_api.h" #include "sapp_private_api.h" +#include "sapp_declaration.h" #ifdef __cplusplus diff --git a/src/support/timestamp_record/timestamp_record.cpp b/src/support/timestamp_record/timestamp_record.cpp index d3360c3..ced6349 100644 --- a/src/support/timestamp_record/timestamp_record.cpp +++ b/src/support/timestamp_record/timestamp_record.cpp @@ -4,6 +4,7 @@ extern "C" { #include "sapp_api.h"
#include "sapp_private_api.h"
+#include "sapp_declaration.h"
#define CPU_CLOCK_TO_1US (2199) /* 1��ת����CPU������, ����2.2GHz����2200 */
diff --git a/src/timer/sapp_timer.c b/src/timer/sapp_timer.c index c552396..ba74ebe 100644 --- a/src/timer/sapp_timer.c +++ b/src/timer/sapp_timer.c @@ -1,6 +1,7 @@ #include "sapp_api.h" #include "sapp_private_api.h" #include "public/sapp_timer.h" +#include "sapp_declaration.h" #include "support/event2/event.h" #include <systemd/sd-daemon.h> |
