Commit 2e2b5e90 authored by 's avatar
Browse files

top is ready , read results work fine


git-svn-id: file:///home/svn/mapi/trunk@249 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 88082f9c
......@@ -262,26 +262,37 @@ static int topx_process(mapidflib_function_instance_t *instance,
unsigned char *packet=link_pkt;
struct topx_field field;
struct topx_data *data=(struct topx_data *)(instance->internal_data);
struct topx_list_node *tmp;
int i=0;
unsigned int *ptr;
extract_field(&field,packet,data->protocol,data->field);
//printf("data: %u len: %d\n",ntohs(*((unsigned short *)(field.pointer))),field.len);
add_field_to_list(&field,data);
pktcnt++;
if(pktcnt%10000) {
struct topx_list_node *tmp;
int i=0;
tmp=data->list_head;
ptr=(unsigned int *)(instance->result.data);
//write the number of results
if(data->list_size<=data->x)
*ptr=data->list_size;
else
*ptr=data->x;
ptr++;
//write results
while(tmp && i<data->x) {
printf("(%d,%d)->",tmp->value,tmp->count);
*ptr=tmp->value;
ptr++;
*ptr=tmp->count;
ptr++;
tmp=tmp->next;
i++;
}
printf("\n");
}
return 1;
}
......@@ -317,6 +328,7 @@ static int topx_init(mapidflib_function_instance_t *instance,
return 0;
}
static mapidflib_function_def_t topfinfo={
"", //libname
"TOP", //name
......@@ -324,7 +336,7 @@ static mapidflib_function_def_t topfinfo={
"iii", //argdescr
MAPI_DEVICE_ALL, //devoid
MAPIRES_SHM, //Use shared memory to return results
sizeof(unsigned long long), //shm size
2*sizeof(unsigned int)*1000+sizeof(unsigned int), //shm size
0, //modifies_pkts
NULL, //instance
topx_init, //init
......
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