From: Jean-Marc Pigeon (Delson) Date: Tue, 6 May 2025 13:23:40 +0000 (-0400) Subject: Commenting test sequence is working fine X-Git-Tag: tag-0.8~131 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=b45798dd706eec811db163961f90f703c470886a;p=jmp%2Fmailleur Commenting test sequence is working fine --- diff --git a/Makefile b/Makefile index 04588e3..d3dcf37 100644 --- a/Makefile +++ b/Makefile @@ -57,11 +57,11 @@ onefeed : debug @ bin/feeder \ -f \ -d2 \ - -i 127.63.31.15 \ -c ./conf/feeder.conf.dvl \ $(TESTIP) \ $(TESTPORT) \ $(DATATST)/feed00.tst + # -i 127.63.31.15 #direct test tstfeed : debug diff --git a/app/feeder.c b/app/feeder.c index 2b73132..9fc7551 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -30,10 +30,18 @@ static char testname[100]; //dest description typedef struct { char *destip; //IP to connect to char *destport; //Port to connect to - char *srcip; //Ip to be used as source + char *srcip; //IP to be used as source + _Bool commented; //feed in comment mode SOCPTR *socptr; //connection socket }FEEDTYP; +typedef enum { //List of command + cmd_gotls, //going in tls mode + cmd_restart, //restart connection with remote server + cmd_wait, //delay exchange with remote + cmd_comment, //Test sequence in int/out comment mode + cmd_unknown + }CMDTYP; /* */ @@ -94,6 +102,31 @@ return count; */ /************************************************/ /* */ +/* procedure to set feed scan in comment */ +/* mode. */ +/* */ +/************************************************/ +static _Bool setcomment(FEEDTYP *fd,char *action) + +{ +_Bool done; +_Bool flag; + +done=false; +flag=false; +if (strcmp("START",action)==0) + flag=true; +if (flag!=fd->commented) { + fd->commented=flag; + done=true; + } +return done; +} +/* +^L +*/ +/************************************************/ +/* */ /* procedure to set the link in TLS mode */ /* */ /************************************************/ @@ -163,14 +196,16 @@ static struct { int code; const char *cmd; }cmdavail[]={ - {1,"GOTLS"}, - {2,"SLEEP"}, - {0,(const char *)0} + {cmd_comment,"COMMENT"}, + {cmd_gotls,"GOTLS"}, + {cmd_restart,"RESTART"}, + {cmd_wait,"WAIT"}, + {cmd_unknown,(const char *)0} }; int code; -code=0; +code=cmd_unknown; for (int i=0;cmdavail[i].cmd!=(const char *)0;i++) { if (strcasecmp(cmdavail[i].cmd,command)==0) { code=cmdavail[i].code; @@ -188,7 +223,7 @@ return code; /* protocol. */ /* */ /********************************************************/ -static _Bool docommand(SOCPTR *socptr,int numline,char *line) +static _Bool docommand(FEEDTYP *fd,int numline,char *line) { _Bool status; @@ -200,11 +235,11 @@ if ((param=strchr(line,' '))!=(char *)0) { param++; //pointer on parameter } switch (getcmd(line)) { - case 1 : //GOTLS - if ((status=gomodetls(socptr))==false) + case cmd_gotls : //GOTLS + if ((status=gomodetls(fd->socptr))==false) (void) report(numline,line,"Unable to set TLS mode"); break; - case 2 : //SLEEP + case cmd_wait : //SLEEP mode if (param!=(char *)0) (void) sleep(atoi(param)); else { @@ -212,6 +247,20 @@ switch (getcmd(line)) { status=false; } break; + case cmd_restart : //restart link + fd->socptr=soc_closefeedsock(fd->socptr); + (void) usleep(100000); //wait 10 millisec + fd->socptr=soc_openfeedsock(pro_smtp,fd->srcip,fd->destip,fd->destport); + if (fd->socptr==(SOCPTR *)0) { + (void) report(numline,line,"Unable to restart feed socket!"); + status=false; + } + break; + case cmd_comment : //restart link + if (setcomment(fd,param)==false) + (void) report(numline,line,"Unable to set comment mode"); + break; + case cmd_unknown : default : (void) report(numline,line,"Unknown command"); status=false; @@ -352,17 +401,7 @@ while (proceed==true) { case 2 : //discarding comment switch (action) { case 'C' : //command to execute - status=docommand(fd->socptr,numline,line); - break; - case 'L' : //Restart Session - fd->socptr=soc_closefeedsock(fd->socptr); - (void) usleep(100000); //wait 10 millisec - fd->socptr=soc_openfeedsock(pro_smtp,fd->srcip,fd->destip,fd->destport); - if (fd->socptr==(SOCPTR *)0) { - (void) report(numline,line,"Unable to restart feed socket!"); - status=false; - phase=999; //Aborting feed job - } + status=docommand(fd,numline,line); break; case 'R' : //Receiving data status=doincoming(fd->socptr,numline,line); @@ -373,9 +412,6 @@ while (proceed==true) { case 'T' : //Get the test titre status=strncpy(testname,line,sizeof(testname)); break; - case 'W' : //Wait X second - (void) sleep(atoi(line)); - break; default : //Unexpected line-=2; (void) report(numline,line,"Unexpected directive"); @@ -453,6 +489,8 @@ while (proceed==true) { numline++; while ((ptr=strrchr(line,'\n'))!=(char *)0) *ptr='\000'; + if ((fd->commented==true)&&(strncmp(line,"C:",2)!=0)) + continue; if (scanline(fd,numline,line)==false) { phase=999; //Trouble trouble exiting break; diff --git a/data-tst/feed00.tst b/data-tst/feed00.tst index cfb2407..d91e38e 100644 --- a/data-tst/feed00.tst +++ b/data-tst/feed00.tst @@ -13,15 +13,17 @@ # T: Test titre or Info C:COMMENT START #==================================================== -#Please update /etc/hosts with +#Please update /etc/hosts with with following +#start of /etc/host addon #---------------------------------------------------- #Definition to validate mailleur daemon (emlrcvr) server #The test serveur itself 127.127.10.25 mailleur.example.com mailleur #remote access -#127.168.0.1 no reverss detection +#127.168.0.1 no reverss address detection 127.168.10.1 foreign1.badserver.tld foreign1 #---------------------------------------------------- +#end of /etc/host addon #==================================================== C:COMMENT STOP #====================================================