From c2dfe4eff30ca48ccd5eea84aa0412f257a18cb1 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Thu, 1 Aug 2024 16:13:09 -0400 Subject: [PATCH] Working about version --- lib/gestcp.c | 28 ++++++++++++++++++++-------- lib/gestcp.h | 6 +++--- lib/modrec.c | 3 +++ 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/lib/gestcp.c b/lib/gestcp.c index d6cd049..f4d6909 100644 --- a/lib/gestcp.c +++ b/lib/gestcp.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -34,11 +35,9 @@ PUBLIC int tcp_write(CONTYP *contact,char *buffer,int parnum) { int sent; int got; -char zone[10]; sent=-1; -(void) strcpy(zone,"??"); -got=recv(contact->channel,zone,0,MSG_PEEK); +got=recv(contact->channel,(char *)0,0,MSG_PEEK); switch (got) { case -1 : if (errno==EWOULDBLOCK) @@ -54,7 +53,7 @@ switch (got) { } break; default : - (void) fprintf(stderr,"Got '%02d' zone=<%s>\n",got,zone); + (void) fprintf(stderr,"Got '%02d'\n",got); break; } return sent; @@ -74,6 +73,7 @@ PUBLIC CONTYP *tcp_getcontact(SOCTYP *binding) #define OPEP "gestcp.c:tcp_getcontact" CONTYP *contact; +SOCKADDR addr; int phase; _Bool proceed; @@ -90,21 +90,33 @@ while (proceed==true) { } break; case 1 : //waiting from contact - if ((contact->channel=soc_accept(binding,&(contact->addr)))<0) { + if ((contact->channel=soc_accept(binding,&addr))<0) { (void) rou_alert(0,"%s Unable to open contact",OPEP); (void) free(contact); contact=(CONTYP *)0; phase=999; //no contact } break; - case 2 : //check is contactis ok - (void) dprintf(contact->channel,"JMPDBG Bingo!\n"); + case 2 : //send signon to contact + if (contact!=(CONTYP *)0) { //always + #define FMT "220 %s ESMTP %s-%s;\n" + + char signon[100]; + + (void) snprintf(signon,sizeof(signon),FMT,"test",appname,rou_getversion()); + if (tcp_write(contact,signon,strlen(signon))<0) { + (void) rou_alert(0,"%s Unable to send signon to remote",OPEP); + (void) free(contact); + contact=(CONTYP *)0; + phase=999; //no contact + } + #undef FMT + } break; default : //SAFE guard proceed=false; break; } - //(void) rou_alert(0,"JMPDBG tcp_getcontact contat='%p' phase='%d'",contact,phase); phase++; } return contact; diff --git a/lib/gestcp.h b/lib/gestcp.h index 4010265..b28b752 100644 --- a/lib/gestcp.h +++ b/lib/gestcp.h @@ -12,9 +12,9 @@ #include "unisoc.h" typedef struct { - int channel; //xchang channle handle - SOCKADDR addr; //Remote address - SOCTYP *binding;//extablised contact context + int channel; //exchange channel handle + SOCKADDR addr; //remote address (see getnameinfo) + SOCTYP *binding;//established contact context }CONTYP; //Transmit formated data to the contact channel diff --git a/lib/modrec.c b/lib/modrec.c index ec667e8..7686f73 100644 --- a/lib/modrec.c +++ b/lib/modrec.c @@ -60,6 +60,8 @@ while (proceed==true) { int sent; char buffer[100]; + if ((hangup==true)||(reload==true)) + break; printf("send string\n"); sprintf(buffer,"Remote pid=%d iter=%d/%d\n",getpid(),i,TESTL); sent=tcp_write(contact,buffer,strlen(buffer)); @@ -239,6 +241,7 @@ _Bool proceed; maxretry=30; //5 seconds max retry bindings=(SOCTYP **)0; bindings=soc_mkbindinf(bindings,pro_smtp,"127.0.0.1","2525",3); +bindings=soc_mkbindinf(bindings,pro_smtp,"192.219.254.70","2525",3); bindings=soc_mkbindinf(bindings,pro_smtp,"127.0.0.26","2626",1); phase=0; proceed=true; -- 2.47.3