修改decrypt-mirror插件的文件名和目录结构。增加平台胶合层decrypt_mirror_plugin.h和decrypt_mirror_plugin.cpp
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#include "mirror_stream.h"
|
||||
#include <tfe_stream.h>
|
||||
|
||||
int decrypt_mirror_init(void *proxy)
|
||||
{
|
||||
const char* filepath="./conf/decrypt_mirror.conf";
|
||||
int thread_num=2;//todo: aquire from proxy;
|
||||
int mirro_stream_init(thread_num, filepath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum tfe_stream_action decrypt_mirror_on_open_cb(const struct tfe_stream * stream, unsigned int thread_id,
|
||||
enum tfe_conn_dir dir, const unsigned char * data, size_t len, void ** pme)
|
||||
{
|
||||
struct layer_addr* addr=NULL; //=stream->addr;
|
||||
int ret=0;
|
||||
ret=mirror_stream_open(thread_id, addr, pme);
|
||||
assert(ret==0);
|
||||
return ACTION_FORWARD_DATA;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
int ret=0;
|
||||
ret=mirror_stream_write(thread_id, data,len, pme, thread_id);
|
||||
return ACTION_FORWARD_DATA;
|
||||
}
|
||||
|
||||
void decrypt_mirror_on_close_cb(const struct tfe_stream * stream, unsigned int thread_id,
|
||||
enum tfe_stream_close_reason reason, void ** pme)
|
||||
{
|
||||
int ret=0;
|
||||
ret=mirror_stream_close(pme, thread_id);
|
||||
return;
|
||||
}
|
||||
void decrypt_mirror_deinit(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
#include <MESA/field_stat2.h>
|
||||
|
||||
#include <decrypt-mirroring.h>
|
||||
#include <decrypt-mirroring-inl.h>
|
||||
#include <mirror_stream.h>
|
||||
#include <mirror_stream_inl.h>
|
||||
#include <sendpkt-inl.h>
|
||||
|
||||
int g_deliver_version_VERSION_20180718;
|
||||
@@ -240,14 +240,14 @@ int deliver_sendpkt_ether(int thread_seq,int buflen,unsigned char* buf,unsigned
|
||||
}
|
||||
|
||||
|
||||
int deliver_init_pmeinfo(struct deliver_addr_info* addr,void** pme)
|
||||
int deliver_init_pmeinfo(struct origin_stream_addr* addr,void** pme)
|
||||
{
|
||||
//TODO:choose dst mac
|
||||
int i=deliver_rand()%(g_deliver_sendinfo.receiver_num);
|
||||
|
||||
struct deliver_pme_info* pmeinfo=(struct deliver_pme_info*)malloc(sizeof(struct deliver_pme_info));
|
||||
memset(pmeinfo,0,sizeof(struct deliver_pme_info));
|
||||
memcpy((void*)&pmeinfo->addr_info,(void*)addr,sizeof(struct deliver_addr_info));
|
||||
memcpy((void*)&pmeinfo->addr_info,(void*)addr,sizeof(struct origin_stream_addr));
|
||||
memcpy(pmeinfo->dst_macaddr,g_deliver_sendinfo.receiver_info[i].dst_macaddr,DELIVER_MACADDR_LEN);
|
||||
|
||||
*pme=pmeinfo;
|
||||
@@ -443,7 +443,7 @@ int deliver_send_ack(int thread_seq,struct deliver_pme_info* pmeinfo)
|
||||
}
|
||||
|
||||
|
||||
int deliver_set_pktinfo(struct deliver_pme_info* pmeinfo,int flag,int cur_dir,int payload_len)
|
||||
int deliver_set_pktinfo(struct deliver_pme_info* pmeinfo,int flag,enum tfe_conn_dir cur_dir,int payload_len)
|
||||
{
|
||||
struct deliver_pkt_info last_pkt_info;
|
||||
memcpy((void*)&last_pkt_info,(void*)&(pmeinfo->pkt_info),sizeof(struct deliver_pkt_info));
|
||||
@@ -498,7 +498,7 @@ int deliver_send_rst(int thread_seq,struct deliver_pme_info* pmeinfo)
|
||||
|
||||
|
||||
|
||||
int deliver_session_start(int thread_seq,struct deliver_addr_info* addr,void** pme)
|
||||
int mirror_stream_open(int thread_seq,struct origin_stream_addr* addr,void** pme)
|
||||
{
|
||||
struct deliver_pme_info* pmeinfo=NULL;
|
||||
|
||||
@@ -513,34 +513,34 @@ int deliver_session_start(int thread_seq,struct deliver_addr_info* addr,void** p
|
||||
|
||||
}
|
||||
|
||||
int deliver_session_data(int cur_dir,int thread_seq,int buflen,char*buf,void** pme)
|
||||
int mirror_stream_write(enum tfe_conn_dir cur_dir,const unsigned char * data, size_t len, void** pme,int thread_seq)
|
||||
{
|
||||
int i=0;
|
||||
char* payload=buf;
|
||||
char* payload=data;
|
||||
int payload_len=0;
|
||||
int remain_len=buflen;
|
||||
int pkt_num=(buflen/(g_deliver_sendinfo.mtu))+1;
|
||||
int remain_len=len;
|
||||
int pkt_num=(len/(g_deliver_sendinfo.mtu))+1;
|
||||
struct deliver_pme_info* pmeinfo=(struct deliver_pme_info*)*pme;
|
||||
|
||||
|
||||
deliver_set_filestate2(thread_seq,FS2_COLUME_RECVPKT,1);
|
||||
deliver_set_filestate2(thread_seq,FS2_COLUME_RECVBYTE,buflen);
|
||||
deliver_set_filestate2(thread_seq,FS2_COLUME_RECVBYTE,len);
|
||||
|
||||
pmeinfo->session_info.recv_pkt++;
|
||||
pmeinfo->session_info.recv_byte+=buflen;
|
||||
pmeinfo->session_info.recv_byte+=len;
|
||||
if(pmeinfo->addr_info.client.sa_family==AF_INET)
|
||||
{
|
||||
deliver_debug_log_v4(RLOG_LV_DEBUG,(char*)DELIVER_RECVPKT_DEBUG,pmeinfo,DELIVER_FLAG_RECVPKT,buflen);
|
||||
deliver_debug_log_v4(RLOG_LV_DEBUG,(char*)DELIVER_RECVPKT_DEBUG,pmeinfo,DELIVER_FLAG_RECVPKT,len);
|
||||
}
|
||||
else
|
||||
{
|
||||
deliver_debug_log_v6(RLOG_LV_DEBUG,(char*)DELIVER_RECVPKT_DEBUG,pmeinfo,DELIVER_FLAG_RECVPKT,buflen);
|
||||
deliver_debug_log_v6(RLOG_LV_DEBUG,(char*)DELIVER_RECVPKT_DEBUG,pmeinfo,DELIVER_FLAG_RECVPKT,len);
|
||||
}
|
||||
|
||||
for(i=0;i<pkt_num;i++)
|
||||
{
|
||||
payload_len=remain_len<(g_deliver_sendinfo.mtu)?remain_len:(g_deliver_sendinfo.mtu);
|
||||
payload=buf+(buflen-remain_len);
|
||||
payload=data+(len-remain_len);
|
||||
remain_len-=g_deliver_sendinfo.mtu;
|
||||
|
||||
deliver_set_pktinfo(pmeinfo,TH_ACK,cur_dir,payload_len);
|
||||
@@ -558,11 +558,11 @@ int deliver_session_data(int cur_dir,int thread_seq,int buflen,char*buf,void** p
|
||||
}
|
||||
|
||||
|
||||
int deliver_session_end(int thread_seq,void** pme)
|
||||
void mirror_stream_close(void** pme, int thread_id)
|
||||
{
|
||||
struct deliver_pme_info* pmeinfo=(struct deliver_pme_info*)*pme;
|
||||
|
||||
deliver_send_rst(thread_seq,pmeinfo);
|
||||
deliver_send_rst(thread_id,pmeinfo);
|
||||
|
||||
|
||||
if(*pme!=NULL)
|
||||
@@ -570,9 +570,7 @@ int deliver_session_end(int thread_seq,void** pme)
|
||||
free(*pme);
|
||||
*pme=NULL;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -599,7 +597,7 @@ int deliver_device_init()
|
||||
|
||||
}
|
||||
|
||||
int deliver_profile_init(char* filepath,int* logger_level,char* logger_filepath)
|
||||
int deliver_profile_init(const char* filepath,int* logger_level,char* logger_filepath)
|
||||
{
|
||||
int i=1;
|
||||
char mac_addr_str[DELIVER_MACADDR_STR_LEN];
|
||||
@@ -678,7 +676,7 @@ int deliver_init_log()
|
||||
|
||||
}
|
||||
|
||||
int deliver_init(int thread_num,char* filepath)
|
||||
int mirror_stream_init(int thread_num, const char* filepath)
|
||||
{
|
||||
int i=0;
|
||||
int logger_level;
|
||||
Reference in New Issue
Block a user