Qsmtp  0.30dev
Macros | Enumerations | Functions
antispam.h File Reference

headers of antispam helper functions More...

#include <sys/types.h>

Go to the source code of this file.

Macros

#define SPF_IS_FAILURE(x)   (((x) == SPF_FAIL) || ((x) == SPF_PERMERROR))
 

Enumerations

enum  spf_eval_result {
  SPF_NONE = 0, SPF_PASS = 1, SPF_NEUTRAL = 2, SPF_SOFTFAIL = 3,
  SPF_FAIL = 4, SPF_PERMERROR = 5, SPF_TEMPERROR = 7, SPF_DNS_HARD_ERROR = 8,
  SPF_IGNORE = 15
}
 

Functions

void dotip6 (char *)
 
int check_rbl (char *const *, char **)
 
void tarpit (void)
 
int domainmatch (const char *fqdn, const size_t len, const char **list)
 
int lookupipbl (int)
 
int check_host (const char *)
 
int spfreceived (int, const int)
 

Detailed Description

headers of antispam helper functions

Macro Definition Documentation

#define SPF_IS_FAILURE (   x)    (((x) == SPF_FAIL) || ((x) == SPF_PERMERROR))

check if one of the conditions is given to fail SPF policy

Enumeration Type Documentation

Enumerator
SPF_NONE 

no SPF policy given

SPF_PASS 

host matches SPF policy

SPF_NEUTRAL 

host has neutral match in SPF policy

SPF_SOFTFAIL 

host has softfail match in SPF policy

SPF_FAIL 

host is denied by SPF policy

SPF_PERMERROR 

SPF entry is malformed

SPF_TEMPERROR 

temporary DNS error while SPF testing

SPF_DNS_HARD_ERROR 

permanent DNS error while SPF testing

SPF_IGNORE 

SPF policy for this host will not be tested

Function Documentation

int check_host ( const char *  domain)

look up SPF records for domain

This works a like the check_host in the SPF draft but takes two arguments less. The remote ip and the full sender address can be taken directly from xmitstat.

Parameters
domainno idea what this might be for ;)
Returns
one of the SPF_* constants defined in include/antispam.h
int check_rbl ( char *const *  rbls,
char **  txt 
)

do a rbl lookup for remoteip

Parameters
rblsa NULL terminated array of rbls
txtpointer to "char *" where the TXT record of the listing will be stored if existent
Returns
index of first match
Return values
-1if not listed or error (if not listed errno is set to 0)

If no match was found but temporary DNS errors were encountered errno is set to EAGAIN.

If txt is NULL no TXT record lookup will be performed.

int domainmatch ( const char *  fqdn,
const size_t  len,
const char **  list 
)

check if a given host name matches against domain list

Parameters
fqdnhostname to check
lenlength of fqdn
listlist of domains and hosts to check against, NULL terminated
Returns
1 on match, 0 otherwise

-if list is NULL terminated and every list[x] and fqdn are 0-terminated there can't be any errors

void dotip6 ( char *  buffer)

print IPv6 address of remote host in dotted form in buffer

Parameters
bufferbuffer to store result
int lookupipbl ( int  fd)

check if the remote host is listed in local IP map file given by fd

Parameters
fdfile descriptor to file
Return values
<0on error
>0on match
0no match

fd will always be closed.

int spfreceived ( int  fd,
const int  spf 
)

print "Received-SPF:" to message header

Parameters
fdfile descriptor of message body
spfSPF status of mail transaction
Returns
0 if everything goes right, -1 on write error
void tarpit ( void  )

delay the next reply to the client

This should be used in all places where the client seems to be a spammer. This will delay him so he can't send so much spams.

tarpit does not sleep if there is input pending. If the client is using pipelining or (more likely) a worm or spambot ignoring our replies we kick him earlier and save some traffic.