]>
jfr.im git - irc/rqf/shadowircd.git/blob - include/reslib.h
6 #ifndef _CHARYBDIS_RESLIB_H
7 #define _CHARYBDIS_RESLIB_H
9 /* Longest hostname we're willing to work with.
10 * Due to DNSBLs this is more than HOSTLEN.
12 #define IRCD_RES_HOSTLEN 255
14 /* Here we define some values lifted from nameser.h */
15 #define NS_NOTIFY_OP 4
17 #define NS_IN6ADDRSZ 16
20 #define NS_CMPRSFLGS 0xc0
21 #define NS_MAXCDNAME 255
39 unsigned id
:16; /* query identification number */
40 #ifdef WORDS_BIGENDIAN
41 /* fields in third byte */
42 unsigned qr
: 1; /* response flag */
43 unsigned opcode
: 4; /* purpose of message */
44 unsigned aa
: 1; /* authoritive answer */
45 unsigned tc
: 1; /* truncated message */
46 unsigned rd
: 1; /* recursion desired */
47 /* fields in fourth byte */
48 unsigned ra
: 1; /* recursion available */
49 unsigned unused
:1; /* unused bits (MBZ as of 4.9.3a3) */
50 unsigned ad
: 1; /* authentic data from named */
51 unsigned cd
: 1; /* checking disabled by resolver */
52 unsigned rcode
:4; /* response code */
54 /* fields in third byte */
55 unsigned rd
:1; /* recursion desired */
56 unsigned tc
:1; /* truncated message */
57 unsigned aa
:1; /* authoritive answer */
58 unsigned opcode
:4; /* purpose of message */
59 unsigned qr
:1; /* response flag */
60 /* fields in fourth byte */
61 unsigned rcode
:4; /* response code */
62 unsigned cd
: 1; /* checking disabled by resolver */
63 unsigned ad
: 1; /* authentic data from named */
64 unsigned unused
:1; /* unused bits (MBZ as of 4.9.3a3) */
65 unsigned ra
:1; /* recursion available */
68 unsigned qdcount
:16; /* number of question entries */
69 unsigned ancount
:16; /* number of answer entries */
70 unsigned nscount
:16; /* number of authority entries */
71 unsigned arcount
:16; /* number of resource entries */
75 * Inline versions of get/put short/long. Pointer is advanced.
77 #define IRC_NS_GET16(s, cp) { \
78 const unsigned char *t_cp = (const unsigned char *)(cp); \
79 (s) = ((u_int16_t)t_cp[0] << 8) \
80 | ((u_int16_t)t_cp[1]) \
85 #define IRC_NS_GET32(l, cp) { \
86 const unsigned char *t_cp = (const unsigned char *)(cp); \
87 (l) = ((u_int32_t)t_cp[0] << 24) \
88 | ((u_int32_t)t_cp[1] << 16) \
89 | ((u_int32_t)t_cp[2] << 8) \
90 | ((u_int32_t)t_cp[3]) \
95 #define IRC_NS_PUT16(s, cp) { \
96 u_int16_t t_s = (u_int16_t)(s); \
97 unsigned char *t_cp = (unsigned char *)(cp); \
100 (cp) += NS_INT16SZ; \
103 #define IRC_NS_PUT32(l, cp) { \
104 u_int32_t t_l = (u_int32_t)(l); \
105 unsigned char *t_cp = (unsigned char *)(cp); \
106 *t_cp++ = t_l >> 24; \
107 *t_cp++ = t_l >> 16; \
108 *t_cp++ = t_l >> 8; \
110 (cp) += NS_INT32SZ; \
113 extern int irc_res_init(void);
114 extern int irc_dn_expand(const unsigned char *msg
, const unsigned char *eom
, const unsigned char *src
, char *dst
, int dstsiz
);
115 extern int irc_dn_skipname(const unsigned char *ptr
, const unsigned char *eom
);
116 extern unsigned int irc_ns_get16(const unsigned char *src
);
117 extern unsigned long irc_ns_get32(const unsigned char *src
);
118 extern void irc_ns_put16(unsigned int src
, unsigned char *dst
);
119 extern void irc_ns_put32(unsigned long src
, unsigned char *dst
);
120 extern int irc_res_mkquery(const char *dname
, int class, int type
, unsigned char *buf
, int buflen
);
122 extern char irc_domain
[IRCD_RES_HOSTLEN
+ 1];