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