From a433e22aa4cd0cd3915bcac5923cf835faa0d149 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Wed, 11 Jun 2025 11:12:05 -0400 Subject: [PATCH] working to check local IP number --- lib/Makefile | 3 +++ lib/devsoc.c | 13 ++++++------- lib/devsoc.h | 3 +-- lib/modrec.c | 10 +++++----- lib/unitls.c | 32 ++++++++++++++++++-------------- lib/unitls.h | 6 ++++-- 6 files changed, 37 insertions(+), 30 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index e4589fd..0dd77ab 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -124,6 +124,9 @@ devsoc.h: \ uniprc.h: \ subrou.h +unitls.h: \ + subafn.h + #-------------------------------------------------------------------- toremake: Makefile diff --git a/lib/devsoc.c b/lib/devsoc.c index a3ba5e5..04c9332 100644 --- a/lib/devsoc.c +++ b/lib/devsoc.c @@ -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. */ /* */ /********************************************************/ diff --git a/lib/devsoc.h b/lib/devsoc.h index d8df075..1dddfdc 100644 --- a/lib/devsoc.h +++ b/lib/devsoc.h @@ -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 diff --git a/lib/modrec.c b/lib/modrec.c index 889b7f9..a62f1a9 100644 --- a/lib/modrec.c +++ b/lib/modrec.c @@ -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 diff --git a/lib/unitls.c b/lib/unitls.c index d50a8c9..40f616c 100644 --- a/lib/unitls.c +++ b/lib/unitls.c @@ -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; diff --git a/lib/unitls.h b/lib/unitls.h index 3a6f3e5..1efce00 100644 --- a/lib/unitls.h +++ b/lib/unitls.h @@ -11,6 +11,8 @@ #include #include +#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 { -- 2.47.3