summaryrefslogtreecommitdiff
path: root/src/spf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/spf.c')
-rw-r--r--src/spf.c85
1 files changed, 41 insertions, 44 deletions
diff --git a/src/spf.c b/src/spf.c
index a4d31d3..aec0bdc 100644
--- a/src/spf.c
+++ b/src/spf.c
@@ -42,19 +42,19 @@ char ip6remote[16] = {16 * 0};
/* Sample SPF TXT records:
Standard example: example.net TXT "v=spf1 mx a:pluto.example.net include:aspmx.googlemail.com -all"
-Fehcom's example: fehcom.net TXT "v=spf1 ip4:85.25.149.179/32 ip6:2001:4dd0:ff00:3d4::2/64 -all"
+Fehcom's example: fehcom.net TXT "v=spf1 ip4:85.25.149.179/32 ip6:2001:4dd0:ff00:3d4::2/64 -all"
Include example: mailing.com TXT "v=spf1 a:smtpout.mailing.com include:spf.nl2go.com ~all"
-Exists+Expand: exists.com TXT "v=spf1 exists:%{ir}.%{l1r+-}._spf.%{d} -all"
+Exists+Expand: exists.com TXT "v=spf1 exists:%{ir}.%{l1r+-}._spf.%{d} -all"
*/
/* Entry point: -------------------------------------- Go for SPF */
/**
- @brief spf_query
- prepares the SPF TXT record query
- @param input: pointer to remoteip, helo, mf, localhost, and flagIP6
- @return int r = SPF return code
- */
+ @brief spf_query
+ prepares the SPF TXT record query
+ @param input: pointer to remoteip, helo, mf, localhost, and flagIP6
+ @return int r = SPF return code
+*/
int spf_query(
@@ -155,13 +155,13 @@ static struct spf_aliases {
};
/**
- @brief spf_lookup
- calles the actual (recursive) SPF DNS query
- @param input: pointer to stralloc domain (fqdn)
- @input stralloc spflocalrules (if provided -- for artificial results)
- @output stralloc spfdata with RDATA (+ artificial information)
- @return int r = SPF return code
- */
+ @brief spf_lookup
+ calles the actual (recursive) SPF DNS query
+ @param input: pointer to stralloc domain (fqdn)
+ @input stralloc spflocalrules (if provided -- for artificial results)
+ @output stralloc spfdata with RDATA (+ artificial information)
+ @return int r = SPF return code
+*/
int spf_lookup(stralloc *domain)
{
@@ -416,14 +416,13 @@ static struct mechanisms {
};
/**
- @brief spf_mechanism
- evaluates the provided mechanisms in the SPF record [RFC7208 Sec 5.]
- @param input: pointer to mechanism, SPF specification from record, CIDR prefix length, domain
- @input stralloc spflocalrules (if provided)
- @output pointer to spfspec: data evaluated
- @return int r
- */
-
+ @brief spf_mechanism
+ evaluates the provided mechanisms in the SPF record [RFC7208 Sec 5.]
+ @param input: pointer to mechanism, SPF specification from record, CIDR prefix length, domain
+ @input stralloc spflocalrules (if provided)
+ @output pointer to spfspec: data evaluated
+ @return int r
+*/
int spf_mechanism(char *mechanism, char *spfspec, char *prefix, char *domain)
{
struct mechanisms *mech;
@@ -458,12 +457,11 @@ int spf_mechanism(char *mechanism, char *spfspec, char *prefix, char *domain)
}
/**
- @brief spf_include
- deals with recursive evaluation of SPF record [RFC7208 Sec. 5.2]
- @param input: pointer to included SPF specification; CIDR prefix length
- @return int r = 1 ok; 0 failure
- */
-
+ @brief spf_include
+ deals with recursive evaluation of SPF record [RFC7208 Sec. 5.2]
+ @param input: pointer to included SPF specification; CIDR prefix length
+ @return int r = 1 ok; 0 failure
+*/
int spf_include(char *spfspec, char *prefix)
{
stralloc sa = {0};
@@ -486,14 +484,13 @@ int spf_include(char *spfspec, char *prefix)
}
/**
- @brief spf_parse
- parses the substructure of the SPF record and calls spf_macros
- @param input: pointer to SPF specification, pointer to domain
- output: stralloc sa --
- @output pointer to spfspec: with found data
- @return int r = 1 ok; 0 failure
- */
-
+ @brief spf_parse
+ parses the substructure of the SPF record and calls spf_macros
+ @param input: pointer to SPF specification, pointer to domain
+ output: stralloc sa --
+ @output pointer to spfspec: with found data
+ @return int r = 1 ok; 0 failure
+*/
int spf_parse(stralloc *sa, char *spfspec, char *domain)
{
char *p;
@@ -533,13 +530,12 @@ int spf_parse(stralloc *sa, char *spfspec, char *domain)
}
/**
- @brief spf_macros
- deals with macros in the SPF specificaton [RFC7208 Sec. 7ff]
- @param input: pointer to SPF macro, pointer to domain
- output: pointer to stralloc expand(ed information)
- @return int r = 1 ok; 0 failure
- */
-
+ @brief spf_macros
+ deals with macros in the SPF specificaton [RFC7208 Sec. 7ff]
+ @param input: pointer to SPF macro, pointer to domain
+ output: pointer to stralloc expand(ed information)
+ @return int r = 1 ok; 0 failure
+*/
int spf_macros(stralloc *expand, char *macro, char *domain)
{
static const char hextab[] = "0123456789abcdef";
@@ -681,8 +677,9 @@ int spf_macros(stralloc *expand, char *macro, char *domain)
}
}
if (!stralloc_catb(expand, sa.s, pos)) return 0;
- } else if (!stralloc_cats(expand, sa.s))
+ } else if (!stralloc_cats(expand, sa.s)) {
return 0;
+ }
if (urlencode) {
stralloc_copyb(&sa, expand->s + start, expand->len - start);