Commit 45dba13f authored by 's avatar
Browse files

Size returned by TOP


git-svn-id: file:///home/svn/mapi/trunk@898 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 41c64c0b
......@@ -466,7 +466,6 @@ static int topx_process(mapidflib_function_instance_t *instance,
struct topx_list_node *tmp;
int i=0;
unsigned int *ptr;
unsigned long *lptr;
struct topx_result *result;
// struct timeval ts;
unsigned int cur_secs = 0;
......@@ -517,13 +516,6 @@ static int topx_process(mapidflib_function_instance_t *instance,
add_field_to_list(&field,data,(unsigned long long)(pkt_head->wlen - ether_len), data->last_rst);
tmp=data->list_head;
lptr=(unsigned long *)&(instance->result.info.shm.res_size);
//write the number of results
if(data->list_size<=data->x)
*lptr=(data->list_size * sizeof(struct topx_result) + sizeof(unsigned int));
else
*lptr=(data->x* sizeof(struct topx_result) + sizeof(unsigned int));
ptr=(unsigned int *)(instance->result.data);
//write the number of results
......@@ -562,10 +554,13 @@ static int topx_instance(mapidflib_function_instance_t *instance,
MAPI_UNUSED mapidflib_flow_mod_t *flow_mod)
{
mapiFunctArg *fargs = instance->args;
int x;
if (getargint(&fargs) > TOPX_MAX_X)
if ( (x=getargint(&fargs)) > TOPX_MAX_X)
return MFUNCT_INVALID_ARGUMENT_1;
instance->def->shm_size=sizeof(struct topx_result) * x + sizeof(unsigned int);
int protocol = getargint(&fargs);
if(protocol!=TOPX_IP && protocol!=TOPX_TCP && protocol!=TOPX_UDP)
return MFUNCT_INVALID_ARGUMENT_2;
......@@ -618,7 +613,7 @@ static mapidflib_function_def_t topfinfo={
"iiiii", //argdescr
MAPI_DEVICE_ALL, //devoid
MAPIRES_SHM, //Use shared memory to return results
sizeof(struct topx_result) * TOPX_MAX_X + sizeof(unsigned int), //shm size
0, //shm size. Set by instance
0, //modifies_pkts
0, //filters packets
MAPIOPT_AUTO, //Optimization
......
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