Allow /stats to accept long names for the displayed statistics.
[ircu2.10.12-pk.git] / include / res.h
1 /*
2  * include/ircd_res.h for referencing functions in ircd/ircd_res.c
3  *
4  * $Id$
5  */
6
7 #ifndef INCLUDED_res_h
8 #define INCLUDED_res_h
9
10 #ifndef INCLUDED_config_h
11 #include "config.h"
12 #endif
13
14 #ifndef INCLUDED_sys_types_h
15 #include <sys/types.h>
16 #define INCLUDED_sys_types_h
17 #endif
18
19 #ifndef INCLUDED_sys_socket_h
20 #include <sys/socket.h>
21 #define INCLUDED_sys_socket_h
22 #endif
23
24 #include <netdb.h>
25
26 #ifndef INCLUDED_netinet_in_h
27 #include <netinet/in.h>
28 #define INCLUDED_netinet_in_h
29 #endif
30
31 #ifdef HAVE_STDINT_H
32 #ifndef INCLUDED_stdint_h
33 #include <stdint.h>
34 #define INCLUDED_stdint_h
35 #endif
36 #endif
37
38 struct Client;
39 struct StatDesc;
40
41 /* Here we define some values lifted from nameser.h */
42 #define NS_NOTIFY_OP 4
43 #define NS_INT16SZ 2
44 #define NS_IN6ADDRSZ    16
45 #define NS_INADDRSZ      4
46 #define NS_INT32SZ 4
47 #define NS_CMPRSFLGS    0xc0
48 #define NS_MAXCDNAME 255
49 #define QUERY 0
50 #define IQUERY 1
51 #define NO_ERRORS 0
52 #define SERVFAIL 2
53 #define T_A 1
54 #define T_AAAA 28
55 #define T_PTR 12
56 #define T_CNAME 5
57 #define T_NULL 10
58 #define C_IN 1
59 #define QFIXEDSZ 4
60 #define RRFIXEDSZ 10
61 #define HFIXEDSZ 12
62
63 struct irc_in_addr
64 {
65   unsigned short in6_16[8];
66 };
67
68 struct irc_sockaddr
69 {
70   struct irc_in_addr addr;
71   unsigned short port;
72 };
73
74 struct DNSReply
75 {
76   char *h_name;
77   int h_addrtype;
78   struct irc_in_addr addr;
79 };
80
81 struct DNSQuery
82 {
83   void *vptr; /* pointer used by callback to identify request */
84   void (*callback)(void* vptr, struct DNSReply *reply); /* callback to call */
85 };
86
87 typedef struct
88 {
89         unsigned        id :16;         /* query identification number */
90 #ifdef WORDS_BIGENDIAN
91                         /* fields in third byte */
92         unsigned        qr: 1;          /* response flag */
93         unsigned        opcode: 4;      /* purpose of message */
94         unsigned        aa: 1;          /* authoritive answer */
95         unsigned        tc: 1;          /* truncated message */
96         unsigned        rd: 1;          /* recursion desired */
97                         /* fields in fourth byte */
98         unsigned        ra: 1;          /* recursion available */
99         unsigned        unused :1;      /* unused bits (MBZ as of 4.9.3a3) */
100         unsigned        ad: 1;          /* authentic data from named */
101         unsigned        cd: 1;          /* checking disabled by resolver */
102         unsigned        rcode :4;       /* response code */
103 #else
104                         /* fields in third byte */
105         unsigned        rd :1;          /* recursion desired */
106         unsigned        tc :1;          /* truncated message */
107         unsigned        aa :1;          /* authoritive answer */
108         unsigned        opcode :4;      /* purpose of message */
109         unsigned        qr :1;          /* response flag */
110                         /* fields in fourth byte */
111         unsigned        rcode :4;       /* response code */
112         unsigned        cd: 1;          /* checking disabled by resolver */
113         unsigned        ad: 1;          /* authentic data from named */
114         unsigned        unused :1;      /* unused bits (MBZ as of 4.9.3a3) */
115         unsigned        ra :1;          /* recursion available */
116 #endif
117                         /* remaining bytes */
118         unsigned        qdcount :16;    /* number of question entries */
119         unsigned        ancount :16;    /* number of answer entries */
120         unsigned        nscount :16;    /* number of authority entries */
121         unsigned        arcount :16;    /* number of resource entries */
122 } HEADER;
123
124 extern int init_resolver(void);
125 extern void restart_resolver(void);
126 extern void add_local_domain(char *hname, size_t size);
127 extern size_t cres_mem(struct Client* cptr);
128 extern void delete_resolver_queries(const void *vptr);
129 extern void report_dns_servers(struct Client *source_p, const struct StatDesc *sd, char *param);
130 extern void gethost_byname(const char *name, const struct DNSQuery *query);
131 extern void gethost_byaddr(const struct irc_in_addr *addr, const struct DNSQuery *query);
132
133 extern int irc_in_addr_valid(const struct irc_in_addr *addr);
134 extern int irc_in_addr_cmp(const struct irc_in_addr *a, const struct irc_in_addr *b);
135 extern int irc_in_addr_is_ipv4(const struct irc_in_addr *addr);
136 extern int irc_in_addr_is_loopback(const struct irc_in_addr *addr);
137
138 #endif