Qsmtp
0.30dev
|
DNS helper functions that do no network actions. More...
#include <qdns.h>
#include <arpa/inet.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
Functions | |
int | domainvalid (const char *const host) |
void | freeips (struct ips *p) |
static int | ip6_sort (const void *l, const void *r) |
void | sortmx (struct ips **p) |
sort MX list by priority More... | |
struct ips * | in6_to_ips (struct in6_addr *a, unsigned int cnt, const unsigned int priority) |
convert an array of in6_addr structs to a list of struct ips More... | |
int | inet_pton_v4mapped (const char *str, struct in6_addr *addr) |
read an IPv4 address and convert it to a v4mapped IPv6 address More... | |
DNS helper functions that do no network actions.
int domainvalid | ( | const char *const | host | ) |
check if a string is a valid fqdn
host | the name to check |
0 | everything is ok |
1 | on syntax error |
if there is a standard function doing the same throw this one away
void freeips | ( | struct ips * | p | ) |
free memory of IP list
p | IP list to free |
struct ips* in6_to_ips | ( | struct in6_addr * | a, |
unsigned int | cnt, | ||
const unsigned int | priority | ||
) |
convert an array of in6_addr structs to a list of struct ips
a | the input array |
cnt | the address count in a (must be >0) |
priority | priority of the new records |
NULL | an allocation error happened during conversion |
a will always be freed.
int inet_pton_v4mapped | ( | const char * | str, |
struct in6_addr * | addr | ||
) |
read an IPv4 address and convert it to a v4mapped IPv6 address
str | the string to read in |
addr | where to store the resulting address |
1 | address was successfully read in |
void sortmx | ( | struct ips ** | p | ) |
sort MX list by priority
p | list of MX entries |
Inside each entry of p the IPv6 entries are moved to the front so that IPv6 addresses are prefered. If 2 entries of p have the same priority those that contain IPv6 addresses will be moved to the front for the same reason.
If IPV4ONLY is defined all IPv6 addresses will be stripped from the list.