]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Working about version
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Thu, 1 Aug 2024 20:13:09 +0000 (16:13 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Thu, 1 Aug 2024 20:13:09 +0000 (16:13 -0400)
lib/gestcp.c
lib/gestcp.h
lib/modrec.c

index d6cd0494522e6b3a11576ccb579eaada66343d10..f4d6909d32b370e3bc50332328893de4d4da5b2c 100644 (file)
@@ -8,6 +8,7 @@
 #include        <sys/socket.h>
 #include        <errno.h>
 #include        <fcntl.h>
+#include        <netdb.h>
 #include        <stdlib.h>
 #include        <stdio.h>
 #include        <string.h>
@@ -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;
index 401026529f1387cd93e6a82b1bf9fc3655c21f89..b28b752071d89a1dcecb48983c011cba1213baa1 100644 (file)
@@ -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
index ec667e8a2ead3ee9115b04f0f55bcd5d96203170..7686f736fb4f777c0f55fa6dd8b0be1860f9356b 100644 (file)
@@ -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;