]>
jfr.im git - solanum.git/blob - include/reslib.h
4 * $Id: reslib.h 446 2006-02-12 02:46:54Z db $
7 #ifndef _CHARYBDIS_RESLIB_H
8 #define _CHARYBDIS_RESLIB_H
10 /* Longest hostname we're willing to work with.
11 * Due to DNSBLs this is more than HOSTLEN.
13 #define IRCD_RES_HOSTLEN 255
15 /* Here we define some values lifted from nameser.h */
16 #define NS_NOTIFY_OP 4
18 #define NS_IN6ADDRSZ 16
21 #define NS_CMPRSFLGS 0xc0
22 #define NS_MAXCDNAME 255
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 */
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 */
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 */
76 * Inline versions of get/put short/long. Pointer is advanced.
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]) \
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]) \
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); \
101 (cp) += NS_INT16SZ; \
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; \
111 (cp) += NS_INT32SZ; \
114 extern int irc_res_init(void);
115 extern int irc_dn_expand(const unsigned char *msg
, const unsigned char *eom
, const unsigned char *src
, char *dst
, int dstsiz
);
116 extern int irc_dn_skipname(const unsigned char *ptr
, const unsigned char *eom
);
117 extern unsigned int irc_ns_get16(const unsigned char *src
);
118 extern unsigned long irc_ns_get32(const unsigned char *src
);
119 extern void irc_ns_put16(unsigned int src
, unsigned char *dst
);
120 extern void irc_ns_put32(unsigned long src
, unsigned char *dst
);
121 extern int irc_res_mkquery(const char *dname
, int class, int type
, unsigned char *buf
, int buflen
);
123 extern char irc_domain
[IRCD_RES_HOSTLEN
+ 1];