]> jfr.im git - irc/rqf/shadowircd.git/blame - include/reslib.h
Show throttle info in /stats t.
[irc/rqf/shadowircd.git] / include / reslib.h
CommitLineData
212380e3 1/*
2 * include/irc_reslib.h
3 *
4 * $Id: reslib.h 446 2006-02-12 02:46:54Z db $
5 */
6
7#ifndef _CHARYBDIS_RESLIB_H
8#define _CHARYBDIS_RESLIB_H
9
570ca08a
JT
10/* Longest hostname we're willing to work with.
11 * Due to DNSBLs this is more than HOSTLEN.
12 */
13#define IRCD_RES_HOSTLEN 255
14
212380e3 15/* Here we define some values lifted from nameser.h */
16#define NS_NOTIFY_OP 4
17#define NS_INT16SZ 2
18#define NS_IN6ADDRSZ 16
19#define NS_INADDRSZ 4
20#define NS_INT32SZ 4
21#define NS_CMPRSFLGS 0xc0
22#define NS_MAXCDNAME 255
23#define QUERY 0
24#define IQUERY 1
25#define NO_ERRORS 0
26#define SERVFAIL 2
27#define NXDOMAIN 3
28#define T_A 1
29#define T_AAAA 28
30#define T_PTR 12
31#define T_CNAME 5
32#define T_NULL 10
33#define C_IN 1
34#define QFIXEDSZ 4
35#define RRFIXEDSZ 10
36#define HFIXEDSZ 12
37
38typedef struct
39{
40 unsigned id :16; /* query identification number */
41#ifdef WORDS_BIGENDIAN
42 /* fields in third byte */
43 unsigned qr: 1; /* response flag */
44 unsigned opcode: 4; /* purpose of message */
45 unsigned aa: 1; /* authoritive answer */
46 unsigned tc: 1; /* truncated message */
47 unsigned rd: 1; /* recursion desired */
48 /* fields in fourth byte */
49 unsigned ra: 1; /* recursion available */
50 unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
51 unsigned ad: 1; /* authentic data from named */
52 unsigned cd: 1; /* checking disabled by resolver */
53 unsigned rcode :4; /* response code */
54#else
55 /* fields in third byte */
56 unsigned rd :1; /* recursion desired */
57 unsigned tc :1; /* truncated message */
58 unsigned aa :1; /* authoritive answer */
59 unsigned opcode :4; /* purpose of message */
60 unsigned qr :1; /* response flag */
61 /* fields in fourth byte */
62 unsigned rcode :4; /* response code */
63 unsigned cd: 1; /* checking disabled by resolver */
64 unsigned ad: 1; /* authentic data from named */
65 unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
66 unsigned ra :1; /* recursion available */
67#endif
68 /* remaining bytes */
69 unsigned qdcount :16; /* number of question entries */
70 unsigned ancount :16; /* number of answer entries */
71 unsigned nscount :16; /* number of authority entries */
72 unsigned arcount :16; /* number of resource entries */
73} HEADER;
74
75/*
76 * Inline versions of get/put short/long. Pointer is advanced.
77 */
78#define IRC_NS_GET16(s, cp) { \
79 const unsigned char *t_cp = (const unsigned char *)(cp); \
80 (s) = ((u_int16_t)t_cp[0] << 8) \
81 | ((u_int16_t)t_cp[1]) \
82 ; \
83 (cp) += NS_INT16SZ; \
84}
85
86#define IRC_NS_GET32(l, cp) { \
87 const unsigned char *t_cp = (const unsigned char *)(cp); \
88 (l) = ((u_int32_t)t_cp[0] << 24) \
89 | ((u_int32_t)t_cp[1] << 16) \
90 | ((u_int32_t)t_cp[2] << 8) \
91 | ((u_int32_t)t_cp[3]) \
92 ; \
93 (cp) += NS_INT32SZ; \
94}
95
96#define IRC_NS_PUT16(s, cp) { \
97 u_int16_t t_s = (u_int16_t)(s); \
98 unsigned char *t_cp = (unsigned char *)(cp); \
99 *t_cp++ = t_s >> 8; \
100 *t_cp = t_s; \
101 (cp) += NS_INT16SZ; \
102}
103
104#define IRC_NS_PUT32(l, cp) { \
105 u_int32_t t_l = (u_int32_t)(l); \
106 unsigned char *t_cp = (unsigned char *)(cp); \
107 *t_cp++ = t_l >> 24; \
108 *t_cp++ = t_l >> 16; \
109 *t_cp++ = t_l >> 8; \
110 *t_cp = t_l; \
111 (cp) += NS_INT32SZ; \
112}
113
114extern int irc_res_init(void);
115extern int irc_dn_expand(const unsigned char *msg, const unsigned char *eom, const unsigned char *src, char *dst, int dstsiz);
116extern int irc_dn_skipname(const unsigned char *ptr, const unsigned char *eom);
117extern unsigned int irc_ns_get16(const unsigned char *src);
118extern unsigned long irc_ns_get32(const unsigned char *src);
119extern void irc_ns_put16(unsigned int src, unsigned char *dst);
120extern void irc_ns_put32(unsigned long src, unsigned char *dst);
121extern int irc_res_mkquery(const char *dname, int class, int type, unsigned char *buf, int buflen);
122
570ca08a 123extern char irc_domain[IRCD_RES_HOSTLEN + 1];
c465dbcd 124
212380e3 125#endif