Commit 1e0904aa authored by 's avatar
Browse files

some tests for DiMAPI

git-svn-id: file:///home/svn/mapi/trunk@270 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent e48f27b1
...@@ -8,7 +8,7 @@ LDFLAGS = ...@@ -8,7 +8,7 @@ LDFLAGS =
CC = gcc CC = gcc
AR = ar AR = ar
RM = rm -f RM = rm -f
BINS = test_get_next_pkt test_counters test_bpf net_utilization worm test_to_file test_admctrlcl BINS = test_get_next_pkt test_counters test_bpf net_utilization worm test_to_file test_admctrlcl test_top
.PHONY: all clean .PHONY: all clean
...@@ -32,6 +32,9 @@ test_to_file: test_to_file.o ...@@ -32,6 +32,9 @@ test_to_file: test_to_file.o
test_admctrlcl: test_admctrlcl.o test_admctrlcl: test_admctrlcl.o
$(CC) $(CFLAGS) ../mapi.so $< -o $@ $(CC) $(CFLAGS) ../mapi.so $< -o $@
test_top: test_top.o
$(CC) $(CFLAGS) ../mapi.so $< -o $@
net_utilization: net_utilization.o net_utilization: net_utilization.o
$(CC) $(CFLAGS) ../mapi.so $< -o $@ $(CC) $(CFLAGS) ../mapi.so $< -o $@
......
/*******************************************
*
* 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_flow(argv[1]);
fid=mapi_apply_function(fd,"TOP",10,TOPX_TCP,TOPX_TCP_DSTPORT);
mapi_connect(fd);
while (1)
{
cnt=((struct dmapi_results*)mapi_read_results(fd,fid,MAPI_REF))->res[0].result;
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