From: Jean-Marc Pigeon (Delson) Date: Tue, 1 Apr 2025 23:45:06 +0000 (-0400) Subject: Starting to implement feed command (GOTLS, SLEEP) X-Git-Tag: tag-0.7~33 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=7b91a2a22b672d7376ae928d4802624f944ec5a9;p=jmp%2Fmailleur Starting to implement feed command (GOTLS, SLEEP) --- diff --git a/app/feeder.c b/app/feeder.c index e2d1fe1..e076379 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -82,6 +82,78 @@ static void dooutgoing(SOCPTR *socptr,char *line) */ /********************************************************/ /* */ +/* Procedure to execute a command to test SMTP */ +/* protocol. */ +/* */ +/********************************************************/ +static int getcmd(const char *command) + + +{ +static struct { + int code; + const char *cmd; + }cmdavail[]={ + {1,"GOTLS"}, + {2,"SLEEP"}, + {0,(const char *)0} + }; + +int code; + +code=0; +for (int i=0;cmdavail[i].cmd!=(const char *)0;i++) { + if (strcasecmp(cmdavail[i].cmd,command)==0) { + code=cmdavail[i].code; + break; //Code found + } + } +return code; +} +/* + +*/ +/********************************************************/ +/* */ +/* Procedure to execute a command to test SMTP */ +/* protocol. */ +/* */ +/********************************************************/ +static _Bool docommand(SOCPTR *socptr,int numline,char *line) + +{ +_Bool status; +char *param; + +status=false; +if ((param=strchr(line,' '))!=(char *)0) { + *param='\000'; //cut line + param++; //pointer on parameter + } +switch (getcmd(line)) { + case 1 : //GOTLS + (void) rou_alert(0,"JMPDBG got GOTTLS"); + status=true; + break; + case 2 : //GOTLS + if (param==(char *)0) + (void) report(numline,line,"Missing 'seconds' parameters"); + else { + (void) sleep(atoi(param)); + status=true; + } + break; + default : + (void) report(numline,line,"Unknown command"); + break; + } +return status; +} +/* + +*/ +/********************************************************/ +/* */ /* Procedure to compare incoming data with expected*/ /* */ /********************************************************/ @@ -203,8 +275,8 @@ while (proceed==true) { break; case 2 : //discarding comment switch (line[0]) { - case 'T' : //Get the test titre - status=strncpy(testname,line+2,sizeof(testname)); + case 'C' : //command to execute + status=docommand(socptr,numline,line+2); break; case 'R' : //Receiving data status=doincoming(socptr,numline,line+2); @@ -212,8 +284,11 @@ while (proceed==true) { case 'S' : //sending data (void) dooutgoing(socptr,line+2); break; + case 'T' : //Get the test titre + status=strncpy(testname,line+2,sizeof(testname)); + break; default : //Unexpected - (void) report(numline,line+2,"Bigre unexpected directive"); + (void) report(numline,line+2,"Unexpected directive"); status=false; break; } diff --git a/data-tst/feed00.tst b/data-tst/feed00.tst index 82cbe58..12be1b2 100644 --- a/data-tst/feed00.tst +++ b/data-tst/feed00.tst @@ -3,9 +3,12 @@ #127.127.10.25 emlrcvr ##to have proper reverss-address within test # # comment +# C: command to execute +# GOTLS - Going in TLS mode +# SLEEP X - Stop for X seconds # R: incoming data # S: outgoing data -# T: Test titre +# T: Test titre or Info T:basic test function R:220 emlrcvr ESMTP emlrcvr... S:EHLO example.com @@ -17,6 +20,8 @@ R:250-8BITMIME R:250-ENHANCEDSTATUSCODES R:250-AUTH PLAIN LOGIN R:250 HELP +C:GOTLS +C:SLEEP 10 #send a empty ehlo S:EHLO R:501 5.5.4 syntax error (domain part missing), closing connection. diff --git a/lib/subrou.c b/lib/subrou.c index b9aeb41..abd6889 100644 --- a/lib/subrou.c +++ b/lib/subrou.c @@ -21,7 +21,7 @@ //version definition #define VERSION "0.6" -#define RELEASE "41" +#define RELEASE "42" #define BRANCH "dvl" //Public variables