#include <unistd.h>
#include "subrou.h"
+#include "subafn.h"
#include "unidns.h"
/*
{
int status;
int try;
+AFNTYP *afnnum;
char *curname;
int phase;
_Bool proceed;
status=0;
try=0;
+afnnum=(AFNTYP *)0;
if ((curname=strrchr(argv[0],'/'))==(char *)0)
curname=argv[0];
else
(void) rou_setappname(curname);
if (argc<2) {
(void) rou_alert(0,"%s need 2 arguments (domain,IP)",appname);
- for (int i=1;i<optind;i++)
+ for (int i=1;i<=argc;i++)
(void) rou_alert(0,"\targ[%d]=<%s>",i,argv[i]);
phase=999;
}
break;
- case 1 : //initialising process
+ case 1 : //checking IP
+ if ((afnnum=afn_getipnum(argv[2]))==(AFNTYP *)0) {
+ (void) rou_alert(0,"%s is not an IP (aborting)",argv[2]);
+ phase=999;
+ }
+ break;
+ case 2 : //initialisation
+ (void) afn_modesubafn(true);
(void) rou_modesubrou(true);
break;
- case 2 : //doing main tash
- if (argv[1]!=(char *)0) { //always
+ case 3 : //doing main tash
+ if (argc>1) { //always
SPFENU spf;
- spf=dns_get_spf_status(&try,argv[1],argv[2]);
+ afnnum=afn_getipnum(argv[2]);
+ spf=dns_get_spf_status(&try,argv[1],afnnum);
(void) rou_alert(0,"%s %s ==> %s",argv[1],argv[2],dns_spfASCII(spf));
}
break;
- case 3 : //doing main tash
+ case 4 : //doing main tash
(void) rou_modesubrou(false);
+ (void) afn_modesubafn(false);
+ afnnum=afn_freeipnum(afnnum);
break;
default : //end of task
proceed=false;
#include <string.h>
#include <unistd.h>
-#include "subafn.h"
#include "subrou.h"
#include "unidns.h"
/* Procedure to display SPF debug information */
/* */
/********************************************************/
-static void dbgspf(int dbg,char *peerip,char *seq,SPFENU status)
+static void dbgspf(int dbg,AFNTYP *afnnum,char *seq,SPFENU status)
{
if (debug>-dbg) {
(void) rou_alert(dbg,"Current SPF Value <%s>\n\tIP=[%s]\n\tSPF=<%s>",
- dns_spfASCII(status),peerip,seq);
+ dns_spfASCII(status),afnnum->strnumip,seq);
}
}
/*
/* spf sequence */
/* */
/********************************************************/
-static _Bool checkip(char *peerip,char *seq)
+static _Bool checkip(AFNTYP *afnnum,char *seq)
{
_Bool bingo;
bingo=false;
-(void) printf("JMPDBG checkip peerip=<%s> seq=<%s>\n",peerip,seq);
+(void) printf("JMPDBG checkip peerip=<%s> seq=<%s>\n",afnnum->strnumip,seq);
return bingo;
}
/*
/* sequence contents */
/* */
/********************************************************/
-static SPFENU checkseq(int *try,char *seq,char *peerip,SPFENU spf)
+static SPFENU checkseq(int *try,char *seq,AFNTYP *afnnum,SPFENU spf)
{
#define OPEP "unidns.c:checkseq"
spf=locspf;
break;
case mch_ip4 : //include sub domain
- if (checkip(peerip,seq+1)==true)
+ if (checkip(afnnum,seq+1)==true)
spf=locspf;
break;
case mch_include : //include sub domain
if (seq[0]==':') {
(*try)++;
- spf=dns_get_spf_status(try,seq+1,peerip);
+ spf=dns_get_spf_status(try,seq+1,afnnum);
}
else {
(void) rou_alert(0,"%s wrong SPF include seq <%s> (SPF format?)",
/* spf allowed IP */
/* */
/********************************************************/
-static SPFENU is_peerip_ok(int *try,char *peerip,char *spfrec)
+static SPFENU is_peerip_ok(int *try,AFNTYP *afnnum,char *spfrec)
{
#define OPEP "unidns.c:is_peerip_ok"
break;
case 2 : //making sure spfrec is an SPF1
spfrec+=strlen(SPF1);
- (void) dbgspf(2,peerip,spfrec,spf);
+ (void) dbgspf(2,afnnum,spfrec,spf);
if (strlen(spfrec)>0) {
char *seq;
while ((seq=getspfseq(spfrec))!=(char *)0) {
spfrec=strstr(spfrec,seq);
spfrec+=strlen(seq);
- spf=checkseq(try,seq,peerip,spf);
+ spf=checkseq(try,seq,afnnum,spf);
seq=rou_freestr(seq);
if (spf!=spf_neutral)
break; //Found a status breaking loop
/* domain name and and an IP. */
/* */
/********************************************************/
-PUBLIC SPFENU dns_get_spf_status(int *try,char *domain,char *peerip)
+PUBLIC SPFENU dns_get_spf_status(int *try,char *domain,AFNTYP *afnnum)
{
#define OPEP "unidns.c:dns_get_spf_status"
list=(char **)0;
phase=0;
proceed=true;
-(void) printf("JMPDBG try='%02d' domain=<%s> peerip=<%s>\n",*try,domain,peerip);
+(void) printf("JMPDBG try='%02d' domain=<%s> peerip=<%s>\n",
+ *try,domain,afnnum->strnumip);
while (proceed==true) {
switch (phase) {
case 0 : //Are the parameters available
- if ((domain==(char *)0)||(peerip==(char *)0)) {
+ if ((domain==(char *)0)||(afnnum==(AFNTYP *)0)) {
(void) rou_alert(0,"%s missing one or both needed argument",OPEP);
phase=999; //trouble trouble
}
}
break;
case 4 : //gett the spf LIST related to SPF
- spf=is_peerip_ok(try,peerip,list[0]);
+ spf=is_peerip_ok(try,afnnum,list[0]);
list=(char **)rou_freelist((void **)list,(freehandler_t)rou_freestr);
break;
default : //SAFE guard