1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
* USA |
20 |
*/ |
21 |
|
22 |
/*! \file irc_res.h |
23 |
* \brief ircd resolver functions |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#ifndef INCLUDED_irc_res_h |
28 |
#define INCLUDED_irc_res_h |
29 |
|
30 |
#include "config.h" |
31 |
|
32 |
struct Client; /* XXX */ |
33 |
|
34 |
/* Here we define some values lifted from nameser.h */ |
35 |
#define NS_NOTIFY_OP 4 |
36 |
#define NS_INT16SZ 2 |
37 |
#define NS_IN6ADDRSZ 16 |
38 |
#define NS_INADDRSZ 4 |
39 |
#define NS_INT32SZ 4 |
40 |
#define NS_CMPRSFLGS 0xc0 |
41 |
#define NS_MAXCDNAME 255 |
42 |
#define QUERY 0 |
43 |
#define IQUERY 1 |
44 |
#define NO_ERRORS 0 |
45 |
#define SERVFAIL 2 |
46 |
#define NXDOMAIN 3 |
47 |
#define T_A 1 |
48 |
#define T_AAAA 28 |
49 |
#define T_PTR 12 |
50 |
#define T_CNAME 5 |
51 |
#define T_NULL 10 |
52 |
#define C_IN 1 |
53 |
#define QFIXEDSZ 4 |
54 |
#define RRFIXEDSZ 10 |
55 |
#define HFIXEDSZ 12 |
56 |
|
57 |
|
58 |
typedef struct |
59 |
{ |
60 |
unsigned id :16; /* query identification number */ |
61 |
#ifdef WORDS_BIGENDIAN |
62 |
/* fields in third byte */ |
63 |
unsigned qr: 1; /* response flag */ |
64 |
unsigned opcode: 4; /* purpose of message */ |
65 |
unsigned aa: 1; /* authoritive answer */ |
66 |
unsigned tc: 1; /* truncated message */ |
67 |
unsigned rd: 1; /* recursion desired */ |
68 |
|
69 |
/* fields in fourth byte */ |
70 |
unsigned ra: 1; /* recursion available */ |
71 |
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ |
72 |
unsigned ad: 1; /* authentic data from named */ |
73 |
unsigned cd: 1; /* checking disabled by resolver */ |
74 |
unsigned rcode :4; /* response code */ |
75 |
#else |
76 |
/* fields in third byte */ |
77 |
unsigned rd :1; /* recursion desired */ |
78 |
unsigned tc :1; /* truncated message */ |
79 |
unsigned aa :1; /* authoritive answer */ |
80 |
unsigned opcode :4; /* purpose of message */ |
81 |
unsigned qr :1; /* response flag */ |
82 |
|
83 |
/* fields in fourth byte */ |
84 |
unsigned rcode :4; /* response code */ |
85 |
unsigned cd: 1; /* checking disabled by resolver */ |
86 |
unsigned ad: 1; /* authentic data from named */ |
87 |
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ |
88 |
unsigned ra :1; /* recursion available */ |
89 |
#endif |
90 |
/* remaining bytes */ |
91 |
unsigned qdcount :16; /* number of question entries */ |
92 |
unsigned ancount :16; /* number of answer entries */ |
93 |
unsigned nscount :16; /* number of authority entries */ |
94 |
unsigned arcount :16; /* number of resource entries */ |
95 |
} HEADER; |
96 |
|
97 |
typedef void (*dns_callback_fnc)(void *, const struct irc_ssaddr *, const char *); |
98 |
|
99 |
extern void init_resolver(void); |
100 |
extern void restart_resolver(void); |
101 |
extern void delete_resolver_queries(const void *); |
102 |
extern void report_dns_servers(struct Client *); |
103 |
extern void gethost_byname_type(dns_callback_fnc , void *, const char *, int); |
104 |
extern void gethost_byname(dns_callback_fnc, void *, const char *); |
105 |
extern void gethost_byaddr(dns_callback_fnc, void *, const struct irc_ssaddr *); |
106 |
#endif |