Qsmtp  0.30dev
Macros | Functions
libowfatconn.c File Reference

connector functions for libowfat DNS functions More...

#include <libowfatconn.h>
#include <dns.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <stralloc.h>
#include <string.h>

Macros

#define const_stralloc_from_string(str)
 create a stralloc for the given string More...
 

Functions

static int mangle_ip_ret (struct stralloc *sa, char **out, size_t *len, int r)
 handle the libowfat return codes More...
 
int dnsip6 (char **out, size_t *len, const char *host)
 query DNS for IPv6 address of host More...
 
int dnsip4 (char **out, size_t *len, const char *host)
 query DNS for IPv4 address of host More...
 
int dnsmx (char **out, size_t *len, const char *host)
 query DNS for MX entries More...
 
int dnstxt (char **out, const char *host)
 query DNS for TXT entries More...
 
int dnsname (char **out, const struct in6_addr *ip)
 query DNS for name for a given IP address More...
 

Detailed Description

connector functions for libowfat DNS functions

Macro Definition Documentation

#define const_stralloc_from_string (   str)
Value:
{ \
.a = strlen(str) + 1, \
.len = strlen(str), \
.s = (char *)str \
}

create a stralloc for the given string

Even if the s member of the stralloc is not const, we trust everyone who takes a const stralloc not to change it.

Function Documentation

int dnsip4 ( char **  out,
size_t *  len,
const char *  host 
)

query DNS for IPv4 address of host

Parameters
outresult string will be stored here, memory is malloced
lenlength of out
hosthost name to look up
Return values
0success
-1an error occurred, errno is set
int dnsip6 ( char **  out,
size_t *  len,
const char *  host 
)

query DNS for IPv6 address of host

Parameters
outresult string will be stored here, memory is malloced
lenlength of out
hosthost name to look up
Return values
0success
-1an error occurred, errno is set
int dnsmx ( char **  out,
size_t *  len,
const char *  host 
)

query DNS for MX entries

Parameters
outresult string will be stored here, memory is malloced
lenlength of out
hosthost name to look up
Return values
0success
-1an error occurred, errno is set
int dnsname ( char **  out,
const struct in6_addr *  ip 
)

query DNS for name for a given IP address

Parameters
outDNS name of host will be stored here, memory is malloced
ipIPv6 address of host to look up
Return values
0success
-1an error occurred, errno is set
int dnstxt ( char **  out,
const char *  host 
)

query DNS for TXT entries

Parameters
outTXT record of host will be stored here, memory is malloced
hostname of host to look up
Return values
0success
-1an error occurred, errno is set
static int mangle_ip_ret ( struct stralloc *  sa,
char **  out,
size_t *  len,
int  r 
)
static

handle the libowfat return codes

Parameters
sathe result buffer passed to libowfat function
outresult string from sa will be stored here on success
lenlength of out
rreturn code from libowfat function
Returns
r

libowfat functions can allocate memory into sa even if the function returns with an error. Also memory will be allocated even if the function returns 0 and sa.len is 0. Make sure the memory is freed in this cases.