Commit 2e01b3cc authored by 's avatar
Browse files

anonymization as option in Makefile


git-svn-id: file:///home/svn/mapi/trunk@210 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent e43e819e
......@@ -13,7 +13,7 @@ DEBUG=1
WITH_DAG=0
#COMBO6 cards
WITH_COMBO6=1
WITH_COMBO6=0
#Distributed MAPI functionality
WITH_DIMAPI=0
......@@ -29,6 +29,9 @@ PRIORITIES=3
#Support for functions that modifies packets
WITH_MODIFY_PKTS=0
#support for anonymization
WITH_ANONYMIZATION=1
#Ipfix flow record generation
WITH_IPFIX=0
......
......@@ -969,6 +969,95 @@ int mapi_apply_function(int fd, char* funct, ...)
va_start(vl,funct);
pos = qbuf.data; // point to start of arguments buffer
#ifdef WITH_ANONYMIZATION
if(strcmp(funct,"ANONYMIZE")==0) {
int function,pattern_type,i;
char *marshalBuffer,*tmps;
char **repvec;
tmp = va_arg(vl, int); //protocol
addarg(&pos, &tmp, INT);
tmp = va_arg(vl, int); //field
addarg(&pos, &tmp, INT);
function = va_arg(vl, int); //function
addarg(&pos, &function, INT);
marshalBuffer=(char *)malloc(1024*sizeof(char));
marshalBuffer[0]='\0';
switch(function) {
case UNCHANGED:
case MAP:
case ZERO:
case PREFIX_PRESERVING:
case FILENAME_RANDOM:
case RANDOM:
case CHECKSUM_ADJUST:
printf("NO PARAMETERS TO APPLY\n");
break;
case STRIP:
tmp = va_arg(vl, int); //seed
sprintf(marshalBuffer,"%d",tmp);
break;
case REPLACE:
tmps=va_arg(vl, char *);
sprintf(marshalBuffer,"%s",tmps);
break;
case HASHED:
tmp = va_arg(vl, int); //hashing algorithm
sprintf(marshalBuffer,"%d",tmp);
tmp = va_arg(vl, int); //padding behavior
sprintf(marshalBuffer,"%s#%d",marshalBuffer,tmp);
break;
case MAP_DISTRIBUTION:
tmp = va_arg(vl, int); //distribution type
sprintf(marshalBuffer,"%d",tmp);
tmp = va_arg(vl, int); //median
sprintf(marshalBuffer,"%s#%d",marshalBuffer,tmp);
tmp = va_arg(vl, int); //standard deviation
sprintf(marshalBuffer,"%s#%d",marshalBuffer,tmp);
break;
case PATTERN_FILL:
pattern_type=va_arg(vl, int); //pattern type
sprintf(marshalBuffer,"%d",pattern_type);
switch(pattern_type) {
case INTEGER:
tmp = va_arg(vl, int); //integer to fill in
sprintf(marshalBuffer,"%s#%d",marshalBuffer,tmp);
break;
case STR:
tmps=va_arg(vl, char *);
sprintf(marshalBuffer,"%s#%s",marshalBuffer,tmps);
break;
default:
printf("UNKNOWN PATTERN TYPE\n");
return -1;
}
break;
case REGEXP:
tmps=va_arg(vl, char *);
sprintf(marshalBuffer,"%s",tmps);
repvec=va_arg(vl, char **);
tmp=va_arg(vl, int);
if(tmp==0) {
return -1;
}
sprintf(marshalBuffer,"%s#%d",marshalBuffer,tmp);
for(i=0;i<tmp;i++) {
if(repvec[i]!=NULL) {
sprintf(marshalBuffer,"%s#%s",marshalBuffer,repvec[i]);
}
else {
sprintf(marshalBuffer,"%s#NULL",marshalBuffer);
}
}
break;
}
addarg(&pos,marshalBuffer,STRING);
}
#else
// parse function arguments
if(strncmp(fdef->argdescr, "", 1)) { // there are some args
argdescr_ptr = fdef->argdescr;
......@@ -1023,7 +1112,7 @@ int mapi_apply_function(int fd, char* funct, ...)
}
#endif
tmp=open(filename,O_WRONLY|O_TRUNC|O_CREAT|O_LARGEFILE,S_IRUSR|S_IWUSR);
if(tmp==-1) { //|| numfd==256) {
if(tmp==-1) { //|| numfd==256)
DEBUG_CMD(printf("Error creating file: %s [%s:%d]\n",filename,__FILE__,__LINE__));
local_err=MAPI_ERROR_FILE;
return -1;
......@@ -1042,7 +1131,8 @@ int mapi_apply_function(int fd, char* funct, ...)
argdescr_ptr++; // move to the next arg
}
}
#endif
#ifdef DIMAPI
if(is_remote){//flow is remote
......
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