Commit f082070c authored by 's avatar
Browse files

test file for top


git-svn-id: file:///home/svn/mapi/trunk@268 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 5674e183
/*******************************************
*
* Testing PKT_COUNTER
*
*******************************************/
#include <stdio.h>
#include <unistd.h>
#include "../mapi.h"
#include "../stdlib/topx.h"
int main(MAPI_UNUSED int argc, char *argv[])
{
int fd;
int fid,i;
unsigned int *cnt,*tmp;
if(!argv[1])
{
printf("\nWrong arguments\n");
return -1;
}
fd=mapi_create_offline_flow(argv[1],MFF_PCAP);
fid=mapi_apply_function(fd,"TOP",10,TOPX_TCP,TOPX_TCP_DSTPORT);
mapi_connect(fd);
cnt=mapi_read_results(fd,fid,MAPI_REF);
while(1)
{
sleep(1);
printf("results: %d\n",*cnt);
tmp=cnt+1;
for(i=0;i<(*cnt);i++) {
printf("\tPort: %d ",*tmp);
tmp++;
printf("Instances: %d\n",*tmp);
tmp++;
}
}
mapi_close_flow(fd);
printf("\nTOP OK\n");
return 0;
}
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