Commit a90f315f authored by 's avatar
Browse files

fixes , it seems that everything compiles ok and no errors are returned when...

fixes , it seems that everything compiles ok and no errors are returned when running mapid. time for debug!



git-svn-id: file:///home/svn/mapi/trunk@192 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 13e1df15
No preview for this file type
......@@ -923,7 +923,6 @@ void anonymize_field(int protocol, int field, int function,mapipacket *packet,st
mapid_pkthdr_t *last_header_seen=NULL;
mapipacket decoded_packet;
//extern unsigned int client_size;
int anonymize_stream(mapidflib_function_instance_t *instance,struct mapidlibflow *flow,struct anonymize_data *params,mapid_pkthdr_t* pkt_head) {
struct pcap_pkthdr pkthdr;
......
......@@ -218,10 +218,6 @@ static int uncook_instance(mapidflib_function_instance_t *instance, flist_t *flo
return 0;
}
extern int client_size,server_size;
extern char *ret_client_data;
extern char *ret_server_data;
static int uncook_process(mapidflib_function_instance_t *instance,const unsigned char* dev_pkt,const unsigned char* link_pkt, mapid_pkthdr_t* pkt_head)
{
struct mapidlibflow *flow;
......@@ -235,10 +231,10 @@ static int uncook_process(mapidflib_function_instance_t *instance,const unsigned
flow->uncook_ready = 1;
if(flow->decoded_packet!=NULL) {
rebuild_fragments(instance,flow->client_headers,((mapipacket *)flow->decoded_packet)->data,client_size);
rebuild_fragments(instance,flow->client_headers,((mapipacket *)flow->decoded_packet)->data,flow->client_size);
}
else {
rebuild_fragments(instance,flow->client_headers,ret_client_data,client_size);
rebuild_fragments(instance,flow->client_headers,flow->ret_client_data,flow->client_size);
}
flow->client_headers=merge_lists(flow->client_headers,flow->server_headers);
......
......@@ -128,6 +128,11 @@ typedef struct mapidlibflow {
flist_t *server_headers;
unsigned int client_size;
unsigned int server_size;
flist_t *ret_client_headers;
flist_t *ret_server_headers;
unsigned char* ret_client_data;
unsigned char* ret_server_data;
char uncook_ready;
void *decoded_packet;
#endif
......
......@@ -37,13 +37,9 @@ static unsigned int timeout = 0;
struct mapidlibflow *mod_flow = NULL;
char* ret_client_data = NULL;
char* ret_server_data = NULL;
char* to_free = NULL;
char* to_free2 = NULL;
flist_t *ret_client_headers = NULL;
flist_t *ret_server_headers = NULL;
struct headers_data *headers = NULL;
char *precooked_data = NULL;
......@@ -113,7 +109,7 @@ void create_mod_pkt(unsigned char *dev_pkt,struct mapidlibflow *flow,mapid_pkthd
memcpy(&flow->mod_pkt[ether_len], ip, ip_len);
memcpy(&flow->mod_pkt[ether_len + ip_len], tcp, tcp_len);
memcpy(&flow->mod_pkt[ether_len + ip_len + tcp_len], ret_client_data, flow->client_size);
memcpy(&flow->mod_pkt[ether_len + ip_len + tcp_len], flow->ret_client_data, flow->client_size);
//server packet
flow->server_mod_pkt = malloc(sizeof(char) * (flow->server_size + ether_len + ip_len + tcp_len));
......@@ -124,11 +120,11 @@ void create_mod_pkt(unsigned char *dev_pkt,struct mapidlibflow *flow,mapid_pkthd
memcpy(flow->server_mod_pkt, eth, ether_len);
memcpy(&flow->server_mod_pkt[ether_len], ip, ip_len);
memcpy(&flow->server_mod_pkt[ether_len + ip_len], tcp, tcp_len);
memcpy(&flow->server_mod_pkt[ether_len + ip_len + tcp_len], ret_server_data, flow->server_size);
memcpy(&flow->server_mod_pkt[ether_len + ip_len + tcp_len], flow->ret_server_data, flow->server_size);
flow->server_mod_pkt_head.caplen = flow->server_mod_pkt_head.wlen = flow->server_size + ether_len + ip_len + tcp_len;
flow->client_headers = ret_client_headers;
flow->server_headers = ret_server_headers;
flow->client_headers = flow->ret_client_headers;
flow->server_headers = flow->ret_server_headers;
pkt_head->caplen = flow->client_size + ether_len + ip_len + tcp_len;
pkt_head->wlen = flow->client_size + ether_len + ip_len + tcp_len;
......@@ -190,14 +186,13 @@ void tcp_callback(struct tcp_stream *ns, void **param)
status = CHECKED;
if(ns->nids_state == NIDS_EXITING) {
struct mapidlibflow *flow;
ret_client_data = ns->client.reassembled_data;
ret_server_data = ns->server.reassembled_data;
flow->ret_client_data = ns->client.reassembled_data;
flow->ret_server_data = ns->server.reassembled_data;
flow->client_size = ns->client.read;
flow->server_size = ns->server.read;
ret_client_headers = ns->client.headers;
ret_server_headers = ns->server.headers;
flow->ret_client_headers = ns->client.headers;
flow->ret_server_headers = ns->server.headers;
flow=(struct mapidlibflow *)(ns->flow);
create_mod_pkt(last_dev_pkt,flow,&flow->mod_pkt_head);
......@@ -214,20 +209,20 @@ void tcp_callback(struct tcp_stream *ns, void **param)
if(ns->client.total_read < ns->client.count || threshold == -1)
{
if(ret_client_data == NULL)
if(flow->ret_client_data == NULL)
{
ret_client_data = ns->client.reassembled_data;
ret_server_data = ns->server.reassembled_data;
flow->ret_client_data = ns->client.reassembled_data;
flow->ret_server_data = ns->server.reassembled_data;
to_free = ret_client_data;
to_free2 = ret_server_data;
to_free = flow->ret_client_data;
to_free2 = flow->ret_server_data;
flow->client_size = ns->client.read;
flow->server_size = ns->server.read;
ret_client_headers = ns->client.headers;
ret_server_headers = ns->server.headers;
flow->ret_client_headers = ns->client.headers;
flow->ret_server_headers = ns->server.headers;
//fprintf(stderr,"final data: %d %d %d\n",flow->client_size,flist_size(ns->client.headers),ns->nids_state==NIDS_EXITING);
return;
......@@ -235,19 +230,19 @@ void tcp_callback(struct tcp_stream *ns, void **param)
}
else if(ns->server.total_read < ns->server.count || threshold ==-1)
{
if(ret_server_data == NULL)
if(flow->ret_server_data == NULL)
{
ret_server_data = ns->server.reassembled_data;
ret_client_data = ns->client.reassembled_data;
to_free = ret_server_data;
to_free2 = ret_client_data;
flow->ret_server_data = ns->server.reassembled_data;
flow->ret_client_data = ns->client.reassembled_data;
to_free = flow->ret_server_data;
to_free2 = flow->ret_client_data;
flow->server_size = ns->server.read;
flow->client_size = ns->client.read;
//fprintf(stderr,"++final data: %d %d\n",server_size,flist_size(ns->server.headers));
ret_server_headers = ns->server.headers;
ret_client_headers = ns->client.headers;
flow->ret_server_headers = ns->server.headers;
flow->ret_client_headers = ns->client.headers;
return;
}
......@@ -280,14 +275,14 @@ void tcp_callback(struct tcp_stream *ns, void **param)
{
dest = &ns->client.reassembled_data[ns->client.read];
ret_client_headers = ns->client.headers;
ret_client_data = ns->client.reassembled_data;
flow->ret_client_headers = ns->client.headers;
flow->ret_client_data = ns->client.reassembled_data;
flow->client_size = ns->client.read + ns->client.count_new;
ns->client.total_read = ns->client.count;
ns->client.read = 0;
ret_server_headers = ns->server.headers;
ret_server_data = ns->server.reassembled_data;
flow->ret_server_headers = ns->server.headers;
flow->ret_server_data = ns->server.reassembled_data;
flow->server_size=ns->server.read;
ns->server.total_read = ns->server.count;
ns->server.read = 0;
......@@ -330,12 +325,12 @@ void tcp_callback(struct tcp_stream *ns, void **param)
{
dest = &ns->server.reassembled_data[ns->server.read];
ret_server_headers = ns->server.headers;
ret_server_data = ns->server.reassembled_data;
flow->ret_server_headers = ns->server.headers;
flow->ret_server_data = ns->server.reassembled_data;
flow->server_size = ns->server.read + ns->server.count_new;
ret_client_headers = ns->client.headers;
ret_client_data = ns->client.reassembled_data;
flow->ret_client_headers = ns->client.headers;
flow->ret_client_data = ns->client.reassembled_data;
flow->client_size = ns->client.read;
ns->client.total_read = ns->client.count;
ns->client.read=0;
......@@ -425,8 +420,8 @@ static int cook_process(mapidflib_function_instance_t *instance,unsigned char* d
status = NON_CHECKED;
ret_client_data = NULL;
ret_server_data = NULL;
flow->ret_client_data = NULL;
flow->ret_server_data = NULL;
flow->client_size=flow->server_size=0;
callbacks=0;
......@@ -525,7 +520,7 @@ static int cook_process(mapidflib_function_instance_t *instance,unsigned char* d
}
}
if(ret_client_data != NULL || ret_server_data!=NULL)
if(flow->ret_client_data != NULL || flow->ret_server_data!=NULL)
{
// Set pseudoheader and new cooked packet to return to the daemon
create_mod_pkt(dev_pkt,flow,pkt_head);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment