Qsmtp  0.30dev
Functions | Variables
smtproutes.c File Reference

functions for handling of control/smtproutes More...

#include <qremote/qremote.h>
#include <control.h>
#include <diropen.h>
#include <log.h>
#include <match.h>
#include <mmap.h>
#include <qdns.h>
#include <qremote/starttlsr.h>
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <string.h>
#include <sys/socket.h>
#include <syslog.h>
#include <unistd.h>

Functions

static int hascolon (const char *s)
 check smtproutes entries for basic syntax errors More...
 
static int validroute (const char *s)
 callback for loadlistfd() to check validity of smtprouts.d file contents More...
 
static const char * tagvalue (char **lines, const unsigned int idx)
 
static int parse_route_params (struct ips **mx, const char *remhost, unsigned int *targetport, void *buf, const char *host, const char *port)
 parse the parts of an smtproute More...
 
struct ipssmtproute (const char *remhost, const size_t reml, unsigned int *targetport)
 get static route for domain More...
 

Variables

char * clientcertbuf
 
static const char * tags []
 
static unsigned int tagmask
 

Detailed Description

functions for handling of control/smtproutes

Function Documentation

static int hascolon ( const char *  s)
static

check smtproutes entries for basic syntax errors

Returns
0 if the line is valid, i.e. it contains exactly 1 or 2 colons
static int parse_route_params ( struct ips **  mx,
const char *  remhost,
unsigned int *  targetport,
void *  buf,
const char *  host,
const char *  port 
)
static

parse the parts of an smtproute

Parameters
mxMX result list is stored here
remhostoriginal remote host
targetporttargetport will be stored here
bufadditional buffer, will be freed in case of fatal error
hosthost name of smtproute or NULL
portport string of smtproute of NULL
Return values
0values were successfully parsed
<0error code during setup

The function will abort the program if a parse error occurs.

struct ips* smtproute ( const char *  remhost,
const size_t  reml,
unsigned int *  targetport 
)

get static route for domain

Parameters
remhosttarget to look up
remlstrlen(remhost)
targetportport on the remote host to connect to
Returns
MX list if route present
Return values
NULLa runtime error occurred while reading the control file, errno is set

If control/smtproutes contains a syntax error the program is terminated. On runtime error (out of memory) NULL is returned and errno is set.

static int validroute ( const char *  s)
static

callback for loadlistfd() to check validity of smtprouts.d file contents

Parameters
sthe line to check

This not only checks the current line, but also sets tagmask to detect duplicate lines.

Variable Documentation

const char* tags[]
static
Initial value:
= {
"relay",
"port",
"clientcert",
"outgoingip",
"outgoingip6",
NULL
}