// vim: smarttab tabstop=8 shiftwidth=2 expandtab
/********************************************************/
/* */
-/* Main SMTP Daemon */
+/* Validation program to check SPF extraction */
+/* library. */
/* */
/********************************************************/
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include "subrou.h"
{
int status;
+char *curname;
int phase;
_Bool proceed;
status=0;
+if ((curname=strrchr(argv[0],'/'))==(char *)0)
+ curname=argv[0];
+else
+ curname++;
phase=0;
proceed=true;
while (proceed==true) {
switch (phase) {
case 0 : //checking parameters
+ foreground=true;
+ (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++)
+ (void) rou_alert(0,"\targ[%d]=<%s>",i,argv[i]);
+ phase=999;
+ }
break;
case 1 : //initialising process
(void) rou_modesubrou(true);
break;
case 2 : //doing main tash
+ if (argv[1]!=(char *)0) { //always
+ SPFENU spf;
+
+ spf=dns_get_spf_status(argv[1],argv[2]);
+ (void) rou_alert(0,"%s %s ==> %s",argv[1],argv[2],dns_spfascii(spf));
+ }
break;
case 3 : //doing main tash
(void) rou_modesubrou(false);
//version definition
#define VERSION "0.4.2"
-#define RELEASE "1"
+#define RELEASE "2"
//Public variables
PUBLIC int debug=0; //debug level
static _Bool modopen; //module open/close status
+/*
+^L
+*/
+/********************************************************/
+/* */
+/* Procedure to return the SPF status string value */
+/* */
+/********************************************************/
+PUBLIC const char *dns_spfascii(SPFENU spf)
+
+{
+static char *spfascii[]=
+ {
+ "spf_pass",
+ "spf_fail",
+ "spf_softfail",
+ "spf_neutral",
+ "spf_timeout",
+ "spf_missing",
+ "spf_unknown"
+ };
+
+const char *ascii;
+
+ascii="Unset (Bug?)";
+switch (spf) {
+ case spf_pass :
+ case spf_fail :
+ case spf_softfail :
+ case spf_neutral :
+ case spf_timeout :
+ case spf_missing :
+ case spf_unknown :
+ ascii=spfascii[spf];
+ break;
+ default :
+ break;
+ }
+return ascii;
+}
+/*
+^L
+*/
+/********************************************************/
+/* */
+/* Procedure to get the SPF status according a */
+/* domain name and and an IP. */
+/* */
+/********************************************************/
+PUBLIC SPFENU dns_get_spf_status(char *domain,char *peerip)
+
+{
+SPFENU spf;
+
+spf=spf_unknown;
+return spf;
+}
/*
^L
*/
#ifndef UNIDNS
#define UNIDNS
+typedef enum {
+ spf_pass, //OK if condition apply
+ spf_fail, //NOK if condition apply
+ spf_softfail, //Msg origin is dubious
+ spf_neutral, //same status as no SPF
+ spf_timeout, //no answer within time
+ spf_missing, //SPF not found
+ spf_unknown //Unknown SPF directive
+ }SPFENU;
+
+//procedure to return spf status as an ASCII string
+extern const char *dns_spfascii(SPFENU spf);
+
+//get the SPF status for a specific domain and a remote peer IP
+extern SPFENU dns_get_spf_status(char *domain,char *peerip);
+
//homework to be done before starting/stopping module.
extern int dns_modeunidns(_Bool mode);