aboutsummaryrefslogtreecommitdiffstats
path: root/src/firedns.h
blob: e48e263cdbac1a891d582c9f64325c8c0d930d43 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
firedns.h - firedns library declarations
Copyright (C) 2002 Ian Gulliver

This file has been edited for use in BOPM - see the real library at
http://ares.penguinhosting.net/~ian/ before you judge firedns based
on this..

This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#ifndef _FIREDNS_H
#define _FIREDNS_H

/* max number of nameservers used */
#define FDNS_MAX              8
/* preferred firedns config file */
#define FDNS_CONFIG_PREF     HOPM_ETCDIR "/firedns.conf"
/* fallback config file */
#define FDNS_CONFIG_FBCK     "/etc/resolv.conf"
/* DNS well known port */
#define FDNS_PORT            53
/* name to IPv4 address */
#define FDNS_QRY_A            1
/* name to IPv6 address */
#define FDNS_QRY_AAAA        28

/* Success */
#define FDNS_ERR_NONE        0
/* Format error */
#define FDNS_ERR_FORMAT      1
/* Server failure */
#define FDNS_ERR_SERVFAIL    2
/* Name error */
#define FDNS_ERR_NXDOMAIN    3
/* Not implemented */
#define FDNS_ERR_NOIMPT      4
/* Refused */
#define FDNS_ERR_REFUSED     5

/* Local error codes */

/* Timeout */
#define FDNS_ERR_TIMEOUT     6
/* Network error */
#define FDNS_ERR_NETWORK     7
/* FD Limit reached */
#define FDNS_ERR_FDLIMIT     8
/* Other error */
#define FDNS_ERR_OTHER       9

/* Used with the above error values */
extern int firedns_errno;

struct firedns_result
{
  char text[1024];
  char lookup[256];
  void *info;
};

/* non-blocking functions */
extern int firedns_getip(int, const char *const, void *);
extern struct firedns_result *firedns_getresult(const int);

/* low-timeout blocking functions */
extern void *firedns_resolveip(int, const char *const);
extern struct in_addr *firedns_resolveip4(const char *const);
extern struct in6_addr *firedns_resolveip6(const char *const);

extern void firedns_init(void);
extern void firedns_cycle(void);
extern const char *firedns_strerror(int);

#endif