Commit a2c52531 authored by 's avatar
Browse files

fixes for cooking


git-svn-id: file:///home/svn/mapi/trunk@241 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent ead96908
......@@ -16,7 +16,7 @@ WITH_DAG=0
WITH_COMBO6=0
#Distributed MAPI functionality
WITH_DIMAPI=0
WITH_DIMAPI=1
#MAPI function statistics
#With this pkt counters for each function is enabled
......@@ -27,7 +27,7 @@ WITH_PRIORITIES=0
PRIORITIES=3
#Support for functions that modifies packets
WITH_MODIFY_PKTS=0
WITH_MODIFY_PKTS=1
#Support for anonymization
......
......@@ -774,6 +774,32 @@ mapid_get_lib_name(int libnumber)
#ifdef WITH_MODIFY_PKTS
#define NIC_PKTCAP_LEN 1514
unsigned char modified_packet_buf[NIC_PKTCAP_LEN];
struct headers_data {
unsigned char *header;
int header_len;
unsigned int caplen;
unsigned int wlen;
struct timeval ts;
void *decoded_pkt;
};
void free_header_list(flist_t *list,int method) {
flist_node_t *node=flist_head(list),*node2;
while(node) {
struct headers_data *data=flist_data(node);
node2=flist_next(node);
if(method==FLIST_FREE_DATA) {
free(data->header);
free(data);
}
free(node);
node=node2;
}
}
#endif
void mapid_process_pkt(mapidlib_instance_t *i,
......@@ -813,24 +839,24 @@ void mapid_process_pkt(mapidlib_instance_t *i,
// n = flist_head(i->flowlist);
#ifdef WITH_PRIORITIES
int j = 0;
int j = 0;
printf("========================================================================================\n");
for(j = 0; j < PRIORITIES; j++)
{
for(j = 0; j < PRIORITIES; j++) {
n = flist_head(i->flowlist[j]);
#else
n = flist_head(i->flowlist);
#endif
while (n)
{
while (n) {
flow=flist_data(n);
#ifdef WITH_PRIORITIES
printf("Running on flow %d with priority %d\n", flow->fd, flow->priority);
#endif
if(flow->status==FLOW_ACTIVE) {
#ifdef WITH_MODIFY_PKTS
flow->decoded_packet=NULL;
flow->client_headers=NULL;
......@@ -851,10 +877,12 @@ printf("========================================================================
}
}
#endif
n2=flist_head(flow->procfunctionlist);
ret=1;
while (n2 && ret && flow->status==FLOW_ACTIVE) {
funct = flist_data(n2);
#ifdef WITH_MODIFY_PKTS
if(flow->modifies==1)
ret=funct->def->process(funct,dev_pkt,flow->mod_pkt,&flow->mod_pkt_head);
......@@ -863,6 +891,7 @@ printf("========================================================================
#else
ret=funct->def->process(funct,dev_pkt,link_pkt,pkt_head);
#endif
#ifdef WITH_FUNCT_STATS
funct->pkts++;
if(ret)
......@@ -870,7 +899,22 @@ printf("========================================================================
#endif
n2 = flist_next(n2);
}
} else if(flow->delete==1) {
#ifdef WITH_MODIFY_PKTS
if(flow->client_headers) {
free_header_list(flow->client_headers,FLIST_FREE_DATA);
flist_init(flow->client_headers);
}
if(flow->server_headers) {
free_header_list(flow->server_headers,FLIST_FREE_DATA);
flist_init(flow->server_headers);
}
#endif
} //if(flow->status==FLOW_ACTIVE)
else if(flow->delete==1) {
struct mapidlibflow *f;
// n = flist_next(n);
......@@ -884,7 +928,7 @@ printf("========================================================================
f=flist_get(i->flowlist,flow->fd);
#endif
// f=flist_get(i->flowlist,flow->fd);
// f=flist_get(i->flowlist,flow->fd);
//TODO: Flow is still stored in flowlist for historical reference but
//should be removed from the flowlist when number of closed flows reach
//a configurable limit.
......@@ -897,8 +941,9 @@ printf("========================================================================
}
n = flist_next(n);
}
#ifdef WITH_PRIORITIES
}
}
#endif
}
......
......@@ -710,7 +710,7 @@ ip_defrag_stub(struct ip *iph, struct ip **defrag,int id)
timenow = 0;
while (timer_head[id] && timer_head[id]->expires < jiffies()) {
this_host[id] = ((struct ipq *) (timer_head[id]->data))->hf;
timer_head[id]->function(timer_head[id]->data);
timer_head[id]->function(timer_head[id]->data,id);
}
offset = ntohs(iph->ip_off);
flags = offset & ~IP_OFFSET;
......
No preview for this file type
......@@ -11,7 +11,7 @@
int main(MAPI_UNUSED int argc, char *argv[])
{
int fd,fid,*cnt;
int fd,fid,fid2,*cnt,*cnt2;
if(!argv[1])
{
......@@ -20,10 +20,11 @@ int main(MAPI_UNUSED int argc, char *argv[])
return -1;
}
fd=mapi_create_flow(argv[1]);
fd=mapi_create_offline_flow(argv[1],MFF_PCAP);
mapi_apply_function(fd,"COOKING",100000,10);
fid=mapi_apply_function(fd,"PKT_COUNTER");
mapi_apply_function(fd,"COOKING",100000,10);
fid2=mapi_apply_function(fd,"PKT_COUNTER");
mapi_connect(fd);
......@@ -31,7 +32,8 @@ int main(MAPI_UNUSED int argc, char *argv[])
{
sleep(1);
cnt = mapi_read_results(fd,fid,MAPI_REF);
printf("\nPacket read : %d",*cnt);
cnt2 = mapi_read_results(fd,fid2,MAPI_REF);
printf("\nPackets:: Before COOKING: %d After COOKING: %d",*cnt,*cnt2);
}
mapi_close_flow(fd);
......
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