Qsmtp  0.30dev
Macros | Functions | Variables
conn.c File Reference

functions for establishing connection to remote SMTP server More...

#include <qremote/conn.h>
#include <control.h>
#include <log.h>
#include <netio.h>
#include <qdns.h>
#include <qremote/client.h>
#include <qremote/qremote.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>

Macros

#define SOCK_CLOEXEC   0
 

Functions

static int conn (const struct in6_addr remoteip, const struct in6_addr *outip)
 create a socket and connect to the given ip More...
 
int tryconn (struct ips *mx, const struct in6_addr *outip4, const struct in6_addr *outip6)
 
void getmxlist (char *remhost, struct ips **mx)
 

Variables

unsigned int targetport = 25
 

Detailed Description

functions for establishing connection to remote SMTP server

Function Documentation

static int conn ( const struct in6_addr  remoteip,
const struct in6_addr *  outip 
)
static

create a socket and connect to the given ip

Parameters
remoteipthe target address
outipthe local IP the connection should originate from
Returns
the socket descriptor or a negative error code
void getmxlist ( char *  remhost,
struct ips **  mx 
)

get all IPs for the MX entries of target address

Parameters
remhosttarget address
mxlist of MX entries will be stored here, memory will be malloced
int tryconn ( struct ips mx,
const struct in6_addr *  outip4,
const struct in6_addr *  outip6 
)

try to estabish an SMTP connection to one of the hosts in the ip list

Parameters
mxlist of IP adresses to try
outip4local IPv4 to bind
outip6local IPv6 to bind
Returns
the socket descriptor of the open connection
Return values
-ENOENTno IP address left to connect to

Every entry where a connection attempt was made is marked with a priority of MX_PRIORITY_USED, the last one tried with MX_PRIORITY_CURRENT.

Variable Documentation

unsigned int targetport = 25

the port on the destination host to connect to