spf_pass chkip4.spf.example.com 127.0.1.255
spf_fail chkip4.spf.example.com 127.0.1.1
#Checking IP6
-spf_pass chkip6.spf.example.com 0:0:0:0:0:ffff:127.0.2.255
-spf_fail chkip6.spf.example.com 0:0:0:0:0:ffff::127.0.2.1
+#spf_pass chkip6.spf.example.com 0:0:0:0:0:ffff:127.0.2.255
+#spf_fail chkip6.spf.example.com 0:0:0:0:0:ffff::127.0.2.1
##checking addr
spf_pass chkaddr.spf.example.com 127.0.1.255
spf_fail chkaddr.spf.example.com 127.0.1.1
spf_pass chkaddr.spf.example.com 127.0.3.255
spf_fail chkaddr.spf.example.com 127.0.3.1
-spf_pass chkaddr.spf.example.com 0:0:0:0:0:ffff::127.0.2.255
-spf_fail chkaddr.spf.example.com 0:0:0:0:0:ffff::127.0.2.1
+#spf_pass chkaddr.spf.example.com 0:0:0:0:0:ffff::127.0.2.255
+#spf_fail chkaddr.spf.example.com 0:0:0:0:0:ffff::127.0.2.1
#--------------------------------------------------------
}
}
break;
- case 1 : //getting the list of MX for mxdomain
- (void) printf("JMPDBG, checkaddr got <%s> ip<%s> cidr='%d'\n",
- addrdom,afnnum->strnumip,cidr);
+ case 1 : //getting the list of address for the domain
+ found=dns_matchiprec(addrdom,afnnum,cidr);
break;
default : //SAFE guard
proceed=false;
return status;
#undef OPEP
}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to check if an IP (Origin IP) is */
+/* part of domain A record list */
+/* */
+/********************************************************/
+_Bool dns_matchiprec(char *hostname,AFNTYP *afnnum,int mask)
+
+{
+#define OPEP "unidns.c:dns_matchiprec,"
+
+_Bool match;
+struct addrinfo hints;
+struct addrinfo *res;
+int status;
+
+match=false;
+(void) memset(&hints, 0, sizeof(hints));
+hints.ai_family=PF_UNSPEC;
+hints.ai_socktype=SOCK_STREAM;
+hints.ai_flags=HINTFLG;
+if ((status=getaddrinfo(hostname,"",&hints,&res))==0) {
+ match=true;
+ if (mask!=0) {/*do not compare IP with 0/0,::0*/
+ int proceed;
+ struct addrinfo *rp;
+
+ proceed=true;
+ match=false;
+ for (rp=res;rp!=(struct addrinfo *)0;rp=rp->ai_next) {
+ AFNTYP *addrnum;
+
+ if ((addrnum=afn_getaddrinfo(rp))==(AFNTYP *)0) {
+ (void) rou_alert(0,"%s Unable to resolve addr struct for "
+ "hostname <%s> (bug?)",
+ OPEP,hostname,strerror(errno));
+ continue;
+ }
+ switch (afn_cmpipnum(addrnum,afnnum,mask)) {
+ case false :/*no equal continue */
+ break;
+ case true :/*found it equal! */
+ match=true;
+ proceed=false;
+ break;
+ case -1 :/*trouble trouble */
+ (void) rou_alert(0,"%s Unable to compare IP for hostname "
+ "<%s> (error=<%s>)",
+ OPEP,hostname,strerror(errno));
+ proceed=false;
+ break;
+ }
+ addrnum=afn_freeipnum(addrnum);
+ if (proceed==false)
+ break;
+ }
+ }
+ (void) freeaddrinfo(res);
+ }
+else {
+ (void) rou_alert(0,"%s Unable to get '%s' host IP (error='%s')",
+ OPEP,hostname,gai_strerror(status));
+ }
+return match;
+#undef OPEP
+}
#ifndef UNIDNS
#define UNIDNS
+#include "subafn.h"
+
//defining an MX structure
typedef struct {
int preference; /*MX preference */
//domain.
extern MXTYP **dns_getmx(char *domain);
+//Procedure to check if an IP (Origin IP) is part
+//of domain A record list
+extern _Bool dns_matchiprec(char *hostname,AFNTYP *afnnum,int mask);
+
//homework to be done before starting/stopping module.
extern int dns_modeunidns(_Bool mode);