diff --git a/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp b/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp index 481c9c1..697c091 100644 --- a/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp +++ b/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp @@ -1,32 +1,32 @@ #include "mirror_stream.h" #include -#include #include #include + +extern unsigned int tfe_proxy_get_work_thread_count(void); + int decrypt_mirror_init(struct tfe_proxy * proxy) { const char* filepath="./conf/tfe/decrypt_mirror.conf"; - int thread_num=2; - UNUSED int ret=0;//todo: aquire from proxy; + int ret=0; + int thread_num = tfe_proxy_get_work_thread_count(); ret=mirror_stream_init(thread_num, filepath); -// assert(ret==0); - return 0; + return ret; } int decrypt_mirror_on_open_cb(const struct tfe_stream * stream, unsigned int thread_id, enum tfe_conn_dir dir, void ** pme) { - UNUSED int ret=0; + int ret=0; ret=mirror_stream_open(thread_id, stream->addr, pme); -// assert(ret==0); - return 0; + return ret; } enum tfe_stream_action decrypt_mirror_on_data_cb(const struct tfe_stream * stream, unsigned int thread_id, enum tfe_conn_dir dir, const unsigned char * data, size_t len, void ** pme) { - UNUSED int ret=0; + int ret=0; ret=mirror_stream_write(dir, data,len, pme, thread_id); return ACTION_FORWARD_DATA; } diff --git a/plugin/business/decrypt-mirroring/src/mirror_stream.cpp b/plugin/business/decrypt-mirroring/src/mirror_stream.cpp index 6533d39..ba89855 100644 --- a/plugin/business/decrypt-mirroring/src/mirror_stream.cpp +++ b/plugin/business/decrypt-mirroring/src/mirror_stream.cpp @@ -553,7 +553,9 @@ int mirror_stream_write(int cur_dir,const unsigned char * data, size_t len, void const unsigned char* payload=data; int payload_len=0; int remain_len=len; - int pkt_num=(len/(g_deliver_globle_info.sendinfo.mtu))+1; + int max_payloadlen_per=0; + int pkt_num=0; +// int pkt_num=(len/(g_deliver_globle_info.sendinfo.mtu))+1; struct deliver_pme_info* pmeinfo=(struct deliver_pme_info*)*pme; @@ -565,22 +567,31 @@ int mirror_stream_write(int cur_dir,const unsigned char * data, size_t len, void if(pmeinfo->addr_info->addrtype==TFE_ADDR_STREAM_TUPLE4_V4) { deliver_debug_log_v4(RLOG_LV_DEBUG,(char*)DELIVER_RECVPKT_DEBUG,pmeinfo,DELIVER_FLAG_RECVPKT,len); + max_payloadlen_per=g_deliver_globle_info.sendinfo.mtu-sizeof(struct mesa_tcp_hdr)-sizeof(struct mesa_ip4_hdr); } else if(pmeinfo->addr_info->addrtype==TFE_ADDR_STREAM_TUPLE4_V6) { deliver_debug_log_v6(RLOG_LV_DEBUG,(char*)DELIVER_RECVPKT_DEBUG,pmeinfo,DELIVER_FLAG_RECVPKT,len); + max_payloadlen_per=g_deliver_globle_info.sendinfo.mtu-sizeof(struct mesa_tcp_hdr)-sizeof(struct mesa_ip6_hdr); } else { //TODO } + + pkt_num=(len/(max_payloadlen_per))+1; for(i=0;iaddr_info->addrtype==TFE_ADDR_STREAM_TUPLE4_V4) { @@ -760,7 +771,7 @@ int mirror_stream_init(int thread_num, const char* filepath) g_deliver_globle_info.sendinfo.send_socket=(int*)malloc(g_deliver_globle_info.sendinfo.thread_num*sizeof(int)); for(i=0;i