Commit 6bc9b42f authored by 's avatar
Browse files

bug with flow pointer fixed in anonymization, cooking and uncook



git-svn-id: file:///home/svn/mapi/trunk@213 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent c5737db5
......@@ -279,13 +279,14 @@ static int anonymize_instance(mapidflib_function_instance_t *instance,
mapiFunctArg* args=instance->args;
int protocol, field_description, anonymization_function;
char *marshalledBuffer;
struct anonymize_data *data;
protocol=getargint(&args);
field_description=getargint(&args);
anonymization_function=getargint(&args);
marshalledBuffer=getargstr(&args);
//printf("PROTOCOL: %d FIELD_DESCRIPTION: %d FUNCTION: %d\n",protocol,field_description,anonymization_function);
printf("PROTOCOL: %d FIELD_DESCRIPTION: %d FUNCTION: %d\n",protocol,field_description,anonymization_function);
//printf("MARSHALLED PARAMETERS: %s\n",marshalledBuffer);
//first trivial sanity checks
......@@ -341,8 +342,14 @@ static int anonymize_instance(mapidflib_function_instance_t *instance,
n = flist_next(n);
}
tmp_flow=flow;
data=(struct anonymize_data *)malloc(sizeof(struct anonymize_data));
data->protocol=protocol;
data->field=field_description;
data->function=anonymization_function;
data->flow=flow;
instance->internal_data=(void *)data;
return 0;
};
......@@ -373,17 +380,8 @@ static int anonymize_init(mapidflib_function_instance_t *instance, flist_t *flis
anonymization_function=getargint(&args);
marshalledBuffer=getargstr(&args);
data=(struct anonymize_data *)malloc(sizeof(struct anonymize_data));
data->protocol=protocol;
data->field=field_description;
data->function=anonymization_function;
data->flow=tmp_flow;
//printf("FLOW POINTER : %p\n",tmp_flow);
data=(struct anonymize_data *)(instance->internal_data);
instance->internal_data=(void *)data;
switch(anonymization_function) {
case UNCHANGED:
case MAP:
......
......@@ -19,8 +19,6 @@ void rebuild_fragments(mapidflib_function_instance_t *instance,flist_t *list,uns
int myflist_insert_before(flist_t *list, flist_node_t *before, void *data);
flist_t *merge_lists(flist_t *cl,flist_t *sv);
struct mapidlibflow *uncook_tmp_flow;
void rebuild_fragments(mapidflib_function_instance_t *instance,flist_t *list,unsigned char *payload,int large_payload_size) {
flist_node_t *n,*prev;
struct headers_data *data;
......@@ -184,11 +182,6 @@ struct uncook_data {
};
static int uncook_init(mapidflib_function_instance_t *instance, flist_t *flist) {
struct uncook_data *data;
data=(struct uncook_data *)malloc(sizeof(struct uncook_data));
data->flow=uncook_tmp_flow;
instance->internal_data=(void *)data;
return 0;
}
......@@ -196,8 +189,9 @@ static int uncook_init(mapidflib_function_instance_t *instance, flist_t *flist)
static int uncook_instance(mapidflib_function_instance_t *instance, flist_t *flow_flist, mapidflib_flow_mod_t *flow_mod,function_manipulation_t* manip) {
flist_node_t *n;
struct mapidlibflow *flow;
struct mapidlibflow *flow=NULL;
mapidlib_instance_t *i;
struct uncook_data *data;
i = flow_mod->mi;
n = flist_head(i->flowlist);
......@@ -214,7 +208,9 @@ static int uncook_instance(mapidflib_function_instance_t *instance, flist_t *flo
n = flist_next(n);
}
uncook_tmp_flow=flow;
data=(struct uncook_data *)malloc(sizeof(struct uncook_data));
data->flow=flow;
instance->internal_data=(void *)data;
return 0;
}
......
......@@ -836,12 +836,12 @@ printf("========================================================================
flow->client_headers=NULL;
flow->server_headers=NULL;
if(flow->modifies && flow->mod_pkt!=(unsigned char *)(&modified_packet_buf[0])) {
free(flow->mod_pkt);
flow->mod_pkt=&modified_packet_buf[0];
}
if(flow->modifies==1) {
if(flow->mod_pkt!=(unsigned char *)(&modified_packet_buf[0])) {
free(flow->mod_pkt);
flow->mod_pkt=&modified_packet_buf[0];
}
memcpy(modified_packet_buf,link_pkt,pkt_head->caplen);
memcpy(&flow->mod_pkt_head,pkt_head,sizeof(mapid_pkthdr_t));
flow->mod_pkt =&modified_packet_buf[0];
......
......@@ -41,17 +41,12 @@ char* to_free2 = NULL;
struct headers_data *headers = NULL;
char *precooked_data = NULL;
extern struct pcap_pkthdr *nids_last_pcap_header;
mapid_pkthdr_t *last_mapid_header;
int status;
int cooked_pkts = 0;
int un_cooked_pkts = 0;
unsigned char *last_dev_pkt;
int callbacks=0;
struct mapidlibflow *cook_tmp_flow=NULL;
static int cooking_id=0;
......@@ -63,6 +58,7 @@ static int cook_instance(mapidflib_function_instance_t* instance, flist_t *flist
flist_node_t *n;
struct mapidlibflow *flow=NULL;
mapidlib_instance_t *i;
struct cooking_data* data;
i = flow_mod->mi;
......@@ -78,7 +74,8 @@ static int cook_instance(mapidflib_function_instance_t* instance, flist_t *flist
n = flist_next(n);
}
cook_tmp_flow=flow;
data= (struct cooking_data*)malloc(sizeof(struct cooking_data));
data->flow=flow;
return 0;
......@@ -138,8 +135,6 @@ void process_flushed_data(struct mapidlibflow *flow) {
void tcp_callback(struct tcp_stream *ns, void **param)
{
callbacks++;
cooked_pkts++;
struct mapidlibflow *flow;
flow=ns->flow;
......@@ -362,14 +357,14 @@ void tcp_callback(struct tcp_stream *ns, void **param)
static int cook_init(mapidflib_function_instance_t *instance,
flist_t *flist)
{
struct cooking_data* data = (struct cooking_data*)malloc(sizeof(struct cooking_data));
mapiFunctArg* fargs;
struct pcap desc;
struct cooking_data *data;
fargs=instance->args;
data=(struct cooking_data *)(instance->internal_data);
data->threshold=getargint(&fargs);
data->timeout=getargint(&fargs);
data->flow=cook_tmp_flow;
data->id=cooking_id;
cooking_id++;
......@@ -407,7 +402,6 @@ static int cook_process(mapidflib_function_instance_t *instance,const unsigned c
struct mapidlibflow *flow;
//fprintf(stderr,"I am COOKING\n");
precooked_data = link_pkt;
last_dev_pkt= link_pkt;
last_mapid_header = pkt_head;
......@@ -428,7 +422,6 @@ static int cook_process(mapidflib_function_instance_t *instance,const unsigned c
flow->ret_server_data = NULL;
flow->client_size=flow->server_size=0;
callbacks=0;
eth = (ether_header*)link_pkt;
ether_len = sizeof(ether_header);
......@@ -438,8 +431,6 @@ static int cook_process(mapidflib_function_instance_t *instance,const unsigned c
return 1;
nids_mapi_next(&h, link_pkt,data->id);
//if(callbacks>1)
//fprintf(stderr,">> %d %d %d\n",callbacks,status,pkt_head->caplen);
if(status == NON_CHECKED)
{
......@@ -481,7 +472,6 @@ static int cook_process(mapidflib_function_instance_t *instance,const unsigned c
//fprintf(stderr,"Stream not found\n");
return 1;
}
un_cooked_pkts++;
return 0;
}
else {
......
Markdown is supported
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