]> SAFE projects GIT repository - jmp/mailleur/commitdiff
working to check local IP number
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 11 Jun 2025 15:12:05 +0000 (11:12 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 11 Jun 2025 15:12:05 +0000 (11:12 -0400)
lib/Makefile
lib/devsoc.c
lib/devsoc.h
lib/modrec.c
lib/unitls.c
lib/unitls.h

index e4589fd527f62403dfc4c37b31b0f6242a5364c3..0dd77ab4af859c02e66ec9cad2ab86b8ce187197 100644 (file)
@@ -124,6 +124,9 @@ devsoc.h:                                   \
 uniprc.h:                                      \
           subrou.h
 
+unitls.h:                                      \
+          subafn.h
+
 #--------------------------------------------------------------------
 
 toremake:  Makefile
index a3ba5e5b57127e72834bc8568a698679afb85433..04c93320e8b055dc399d5724e60010b1a78c94ee 100644 (file)
@@ -595,17 +595,16 @@ return socptr;
 /*     definition.                                     */
 /*                                                     */
 /********************************************************/
-PUBLIC SOCPTR **soc_mkbindinf(SOCPTR **socptr,PROTYP proto,
-                              const char *ip,const char *port,int iteration)
+PUBLIC SOCPTR **soc_mkbindinf(SOCPTR **socptr,LISTYP *bind)
 
 {
 SOCTYP *soc;
 
 soc=newsocket();
-soc->proto=proto;
-soc->ip=strdup(ip);
-soc->port=strdup(port);
-soc->iteration=iteration;
+soc->proto=bind->proto;
+soc->ip=strdup(bind->afn->strnumip);
+soc->port=strdup(bind->port);
+soc->iteration=bind->iteration;
 socptr=(SOCPTR **)rou_addlist((void **)socptr,(void *)soc);
 return socptr;
 }
@@ -1304,7 +1303,7 @@ return (SOCPTR *)newsoc;
 */
 /********************************************************/
 /*                                                     */
-/*      Procedure to return the addrename or port       */
+/*      Procedure to return the address, name or port   */
 /*      for local or remote socket.                     */
 /*                                                     */
 /********************************************************/
index d8df075771634ad540b3dce11fcd4bfaa8346175..1dddfdcc8e58d38f33e14f446323bcb4d8976b69 100644 (file)
@@ -29,8 +29,7 @@ extern SOCPTR **soc_freebindinf(SOCPTR **socptr);
 
 //procedure to assign memory to be used by a TCP socket
 //definition
-extern SOCPTR **soc_mkbindinf(SOCPTR **s,PROTYP proto,
-                              const char *ip,const char *port,int iteration);
+extern SOCPTR **soc_mkbindinf(SOCPTR **s,LISTYP *bind);
 
 //procedure to open one exchange socket
 //to connect a remote smtp server
index 889b7f96340fb33f468e45504143d9836b7e0cce..a62f1a9c0f6292f27c97ae7cefb646a1aff4aa13 100644 (file)
@@ -46,16 +46,16 @@ static int prepbinding(SOCPTR ***bindings)
 {
 #define OPEP    "modrec.c:prepbinding"
 
-LISTYP **l;
+LISTYP **bind;
 
 *bindings=(SOCPTR **)0;
-if ((l=tls_get_bind_data())==(LISTYP **)0) {
+if ((bind=tls_get_bind_data())==(LISTYP **)0) {
   (void) rou_alert(0,"%s SMTPPORTS data fully missing (config?, bug?)",OPEP);
   (void) exit(-1);
   }
-while (*l!=(LISTYP *)0) {
-  *bindings=soc_mkbindinf(*bindings,(*l)->proto,(*l)->ipnum,(*l)->port,(*l)->iter);
-  l++;
+while (*bind!=(LISTYP *)0) {
+  *bindings=soc_mkbindinf(*bindings,*bind);
+  bind++;
   }
 return rou_nbrlist(*bindings);
 #undef  OPEP
index d50a8c99f3981f8bcc880b85a4680579944d823c..40f616c7de7c6deb3ae0736793ed4a10bb664ba7 100644 (file)
@@ -36,7 +36,7 @@ static LISTYP *freelisten(LISTYP *listen)
 
 {
 if (listen!=(LISTYP *)0) {
-  listen->ipnum=rou_freestr(listen->ipnum);
+  listen->afn=afn_freeipnum(listen->afn);
   listen->port=rou_freestr(listen->port);
   (void) free(listen);
   listen=(LISTYP *)0;
@@ -444,15 +444,15 @@ while (proceed==true) {
       while (seq!=(char *)0) {
         LISTYP *list;
         PROTYP proto;
-        char *ipnum;
+        AFNTYP *afn;
         char *port;
-        int iter;
+        int iteration;
         char *ptr;
 
         proto=pro_smtp;
-        ipnum=DIP;
+        afn=(AFNTYP *)0;
         port=DPORT;
-        iter=2;
+        iteration=2;
         if ((ptr=strchr(seq,','))!=(char *)0) {
           *ptr='\000';
           ptr++;
@@ -473,24 +473,28 @@ while (proceed==true) {
                 }
               break;
             case 1      :       
-              if (strlen(seq)>0)
-                ipnum=seq;
+              if (strlen(seq)==0)
+                seq=DIP;
+              if ((afn=afn_getipnum(seq))==(AFNTYP *)0)
+                (void) rou_alert(0,"%s, Not valid IP <%s> config",OPEP,seq);
               break;
             case 2      :       
               if (strlen(seq)>0)
                 port=seq;
               if (strlen(sofar)>0)
-                iter=atoi(sofar);
+                iteration=atoi(sofar);
               break;
             }
           seq=sofar;
           }
-        list=(LISTYP *)calloc(1,sizeof(LISTYP));
-        list->proto=proto;
-        list->ipnum=strdup(ipnum);;
-        list->port=strdup(port);;
-        list->iter=iter;
-        binds=(LISTYP **)rou_addlist((void **)binds,(void *)list);
+        if (afn!=(AFNTYP *)0) {
+          list=(LISTYP *)calloc(1,sizeof(LISTYP));
+          list->proto=proto;
+          list->port=strdup(port);;
+          list->iteration=iteration;
+          list->afn=afn;
+          binds=(LISTYP **)rou_addlist((void **)binds,(void *)list);
+          }
         seq=ptr;
         }
       break;
index 3a6f3e5d921f30a7956a9ead871f43444a9e0e3f..1efce0028235a6d56f720b6eb83dca9cb481ffa1 100644 (file)
@@ -11,6 +11,8 @@
 #include        <stdbool.h>
 #include        <openssl/ssl.h>
 
+#include        "subafn.h"
+
 //defining email protocol value.
 typedef enum    {
         pro_smtp,       //text SMTP protocol, in clear mode
@@ -21,9 +23,9 @@ typedef enum    {
 
 typedef struct  {       //structure about listening port
         PROTYP proto;   //Protocol to be used
-        char *ipnum;    //binding IP number
         char *port;     //binding port number
-        int iter;       //Number of binding iteration
+        int iteration;  //Number of binding iteration
+        AFNTYP *afn;    //Information about the IP
         }LISTYP;
 
 typedef struct  {