Commit 97ccd5c6 authored by 's avatar
Browse files

Fixed bug in res2file.c and added error control messages.

git-svn-id: file:///home/svn/mapi/trunk@810 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent a8c1ce46
......@@ -239,6 +239,7 @@ static void fix_funct_ref(global_function_list_t *gflist,mapidflib_function_t *i
//Deletes a flow and frees all resources allocated by the flow
static void delete_flow(mapidlib_instance_t *i,struct mapidlibflow *flow) {
struct mapidlibflow *f;
void* temp=NULL;
flist_t *functions;
flist_node_t *funct_node;
mapidflib_function_t *funct;
......@@ -249,7 +250,13 @@ static void delete_flow(mapidlib_instance_t *i,struct mapidlibflow *flow) {
//global optimization
functions=((mapid_flow_info_t*)flist_get(flow->hwinfo->gflist->fflist,flow->fd))->flist;
temp = (void*)flist_get(flow->hwinfo->gflist->fflist,flow->fd);
if(!temp){
fprintf(stderr,"ERROR!! Trying to delete a flow that doesnt exist...");
return;
}
functions= ((mapid_flow_info_t*)temp)->flist;
if(functions!=NULL)
for(funct_node=flist_head(functions);funct_node!=NULL;funct_node=flist_next(funct_node)) {
funct=(mapidflib_function_t*)flist_data(funct_node);
......
......@@ -126,6 +126,8 @@
7009 = "Not supported"
#define MFUNCT_INVALID_ARGUMENT_DESCRIPTOR 7010
7010 = "Invalid argument descriptor"
#define MFUNCT_INVALID_ARGUMENT_6 7011
7011 = "Sixth argument passed to function is invalid"
#define ADMCTRL_MEM_ERROR 8000
8000 = "Admission control memory allocation error"
#define ADMCTRL_NO_AUTHDATA 8001
......
......@@ -9,6 +9,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <ctype.h>
#include "mapidflib.h"
#include "mapidlib.h"
#include "mapidevices.h"
......@@ -56,6 +57,7 @@ static int res2file_instance(mapidflib_function_instance_t *instance,
char buf[DATA_SIZE],*cfids;
char *types,*t,*t2,buf2[DATA_SIZE];
int min=0;
int reset = -1;
mapiFunctArg* fargs=instance->args;
if(!(types = getargstr(&fargs)))
......@@ -82,6 +84,10 @@ static int res2file_instance(mapidflib_function_instance_t *instance,
if((save=parse_save(savestr))<0)
return MFUNCT_INVALID_ARGUMENT_5;
reset = getargint(&fargs);
if(!(reset == 0 || reset == 1))
return(MFUNCT_INVALID_ARGUMENT_6);
//Loop through fids amd types and verify
strncpy(buf,fids,DATA_SIZE);
cfids=buf;
......@@ -229,12 +235,11 @@ static int res2file_init(mapidflib_function_instance_t *instance,
return MFUNCT_INVALID_ARGUMENT_5;
}
i->reset=getargint(&fargs);
if(!(i->reset==0 || i->reset==1))
return MFUNCT_INVALID_ARGUMENT;
/********CHANGED HERE************/
i->reset=getargint(&fargs);
//Count number of fids
c=0;
f=fids;
......
......@@ -8,6 +8,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include "mapi.h"
#include "mapi/res2file.h"
#include "mapi/pktinfo.h"
......@@ -68,7 +69,7 @@ DOT;
snprintf(fids,20,"%d@%d,%d@%d,%d@%d",fid,fd,pkt_size,fd,pkt_ts,fd);
snprintf(types,10,"%d,%d,%d",R2F_ULLSTR,R2F_ULLSTR,R2F_ULLSEC);
if((mapi_apply_function(fd,"RES2FILE",types,fids,"TEST","test.res","5s"))<0){
if((mapi_apply_function(fd,"RES2FILE",types,fids,"TEST","test.res","5s",1))<0){
fprintf(stderr, "Could not apply RES2FILE to flow %d\n", fd);
mapi_read_error( &err_no, error);
fprintf(stderr,"Erorcode :%d description: %s \n" ,err_no, error);
......@@ -77,6 +78,8 @@ DOT;
DOT;
if(mapi_connect(fd)<0){
fprintf(stderr, "Connecting to flow failed %d\n", fd);
mapi_read_error( &err_no, error);
......@@ -99,6 +102,9 @@ DOT;
return -1;
}
//Compare result files
f=fopen("res2file.res","r");
fread(buf,sizeof(char),1024,f);
......@@ -115,9 +121,7 @@ DOT;
else
printf("\nOffline RES2FILE OK\n");
/*
* Error checking starts
*/
fd =0;
if ((fd = mapi_create_offline_flow("./tracefile" , MFF_PCAP))<0){
......@@ -146,7 +150,7 @@ DOT;
DOT;
memcpy(format,types,10);
if(mapi_apply_function(fd,"RES2FILE",fids,format,"TEST", "ERROR_CASES", "-25s") <0){
if(mapi_apply_function(fd,"RES2FILE",fids,format,"TEST", "ERROR_CASES", "-25s",1) <0){
mapi_read_error( &err_no, error);
printf("Testing error case1: Erorcode :%d description: %s \n" ,err_no, error);
if(err_no != 7002){
......@@ -156,7 +160,7 @@ DOT;
}
DOT;
if(mapi_apply_function(fd,"RES2FILE",fids,format,"TEST", NULL, "5s") <0){
if(mapi_apply_function(fd,"RES2FILE",fids,format,"TEST", NULL, "5s",1) <0){
mapi_read_error( &err_no, error);
printf("Testing error case2: Erorcode :%d description: %s \n" ,err_no, error);
if(err_no != 6155){
......@@ -167,7 +171,7 @@ DOT;
sprintf(fids, "\r\r\r\r\r\r\r\r\r\r\r1232@231,123123124 , @KALIMERA");
if(mapi_apply_function(fd,"RES2FILE",fids,format,"TEST", "ERROR_CASES", "5s") <0){
if(mapi_apply_function(fd,"RES2FILE",fids,format,"TEST", "ERROR_CASES", "5s",1) <0){
mapi_read_error( &err_no, error);
printf("Testing error case3: Erorcode :%d description: %s \n" ,err_no, error);
if(err_no != 7002){
......@@ -179,7 +183,7 @@ DOT;
sprintf(format,"SKOUPIDIA" );
if(mapi_apply_function(fd,"RES2FILE",fids,format,"TEST", "ERROR_CASES", "5s") <0){
if(mapi_apply_function(fd,"RES2FILE",fids,format,"TEST", "ERROR_CASES", "5s",1) <0){
mapi_read_error( &err_no, error);
printf("Testing error case4: Erorcode :%d description: %s \n" ,err_no, error);
if(err_no != 7002){
......@@ -187,6 +191,15 @@ DOT;
flag = 1;
}
}
if(mapi_apply_function(fd,"RES2FILE",fids,format,"TEST", "ERROR_CASES", "5s",234) <0){
mapi_read_error( &err_no, error);
printf("Testing error case4: Erorcode :%d description: %s \n" ,err_no, error);
if(err_no != 7011){
printf(" Wrong ERRORCODE returned\n");
flag = 1;
}
}
DOT;
......
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