devsql.h devsql.c
unidns.o: \
- subrou.h \
+ subafn.h subrou.h \
unidns.h unidns.c
unieml.o: \
/* definition. */
/* */
/********************************************************/
-PUBLIC SOCPTR **soc_mkbindinf(SOCPTR **socptr,LISTYP *bind)
+PUBLIC SOCPTR **soc_mkbindinf(SOCPTR **socptr,const LISTYP *bind)
{
SOCTYP *soc;
break;
case 8 : //checking socket status
if ((status=checksockstat(handle))!=0) {
- (void) rou_alert(0,"%s Unable establish socklink with <%s> (error=<%s>)",
- OPEP,ip,strerror(status));
+ (void) rou_alert(0,"%s Unable establish socklink with <%s:%s> (error=<%s>)",
+ OPEP,ip,port,strerror(status));
(void) close(handle);
phase=999;
}
//procedure to assign memory to be used by a TCP socket
//definition
-extern SOCPTR **soc_mkbindinf(SOCPTR **s,LISTYP *bind);
+extern SOCPTR **soc_mkbindinf(SOCPTR **socptr,const LISTYP *bind);
//procedure to open one exchange socket
//to connect a remote smtp server
case 1 : //check about local domain, TEMPORARY code
int status;
- status=dns_is_domain_local(rcpt->domain);
+ status=dns_is_domain_local(rcpt->domain,tls_get_bind_afn());
switch (status) {
case dns_nomx :
done=false;
{
#define OPEP "modrec.c:prepbinding"
-LISTYP **bind;
+const LISTYP **bind;
*bindings=(SOCPTR **)0;
-if ((bind=tls_get_bind_data())==(LISTYP **)0) {
+if ((bind=tls_get_bind_data())==(const LISTYP **)0) {
(void) rou_alert(0,"%s SMTPPORTS data fully missing (config?, bug?)",OPEP);
(void) exit(-1);
}
u_char buf[B64K]; //according US Cert VU#738331
}RSPTYP;
-//list of SMTP local IPV4
-in_addr_t *local_ipv4=(in_addr_t *)0;
-int num_ipv4=0; //number of IP within local_ipv4
-
/*
\f
*/
/* local interface (serveur is primary MX). */
/* */
/********************************************************/
-PUBLIC LOCTYP dns_is_domain_local(const char *domain)
+PUBLIC LOCTYP dns_is_domain_local(const char *domain,AFNTYP **afns)
{
_Bool proceed;
status=dns_nomx;
+dns=(MXTYP **)0;
phase=0;
proceed=true;
while (proceed==true) {
if ((dns=dns_getmx(domain))==(MXTYP **)0)
phase=999; //domain without MX?
break;
- case 2 : //listing MX
- MXTYP **ptr;
-
- ptr=dns;
- while ((*ptr)!=(MXTYP *)0) {
- (void) rou_alert(0,"%s JMPDBG pref='%d' mxname=<%s>",
- OPEP,(*ptr)->preference,(*ptr)->mxname);
- ptr++;
- }
+ case 2 : //establishing MX IP
+ status=dns_remote;
+ if (afns==(AFNTYP **)0) //No local IP?
+ phase=999;
break;
- case 3 : //cleaning MX list
- dns=dns_freemxlist(dns);
+ case 3 : //checking best MX with local interface
+ while (*afns!=(AFNTYP *)0) {
+ if (dns_matchiprec((*dns)->mxname,*afns,32)==true) {
+ (void) rou_alert(0,"%s JMPDBG mxname=<%s> is local",OPEP,(*dns)->mxname);
+ status=dns_local;
+ }
+ afns++;
+ }
break;
default : //SAFE Guard
+ dns=dns_freemxlist(dns); //cleaning MX
proceed=false;
break;
}
//procedure to detect if a domain is served by a local
//smtp server
-extern LOCTYP dns_is_domain_local(const char *domain);
+extern LOCTYP dns_is_domain_local(const char *domain,AFNTYP **afns);
#endif
#define SSL_CIPHER_LIST "DEFAULT"
static _Bool modopen; //module open/close status
-static LISTYP **binds; //Binding information
+static const LISTYP **binds; //Binding information
+static AFNTYP **afns; //Binding information as AFN
/*
^L
*/
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);
+ (void) rou_alert(0,"%s, Not valid IP <%s> (config?)",OPEP,seq);
break;
case 2 :
if (strlen(seq)>0)
list->port=strdup(port);;
list->iteration=iteration;
list->afn=afn;
- binds=(LISTYP **)rou_addlist((void **)binds,(void *)list);
+ binds=(const LISTYP **)rou_addlist((void **)binds,(void *)list);
}
seq=ptr;
}
/* Procedure to return the list of binding data */
/* */
/********************************************************/
-PUBLIC LISTYP **tls_get_bind_data()
+PUBLIC const LISTYP **tls_get_bind_data()
{
return binds;
*/
/********************************************************/
/* */
+/* Procedure to return the AFN list of binding data*/
+/* */
+/********************************************************/
+PUBLIC AFNTYP **tls_get_bind_afn()
+
+{
+return afns;
+}
+/*
+^L
+*/
+/********************************************************/
+/* */
/* Procedure to "open/close" module and do */
/* homework purpose */
/* return zero if everything right */
(void) buildbinds();
break;
case false :
+ (void) free(afns);
(void) rou_freelist((void **)binds,(genfree_t)freelisten);
break;
default :
extern SSL *tls_setsocket(int handle,SSL_CTX *ctx);
//getting binding information
-extern LISTYP **tls_get_bind_data();
+extern const LISTYP **tls_get_bind_data();
+
+//getting binding information as AFN structure
+extern AFNTYP **tls_get_bind_afn();
//homework to be done before starting/stopping module.
extern int tls_modeunitls(_Bool mode);