]>
jfr.im git - solanum.git/blob - authd/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
42 unsigned id
:16; /* query identification number */
43 #ifdef WORDS_BIGENDIAN
44 /* fields in third byte */
45 unsigned qr
: 1; /* response flag */
46 unsigned opcode
: 4; /* purpose of message */
47 unsigned aa
: 1; /* authoritive answer */
48 unsigned tc
: 1; /* truncated message */
49 unsigned rd
: 1; /* recursion desired */
50 /* fields in fourth byte */
51 unsigned ra
: 1; /* recursion available */
52 unsigned unused
:1; /* unused bits (MBZ as of 4.9.3a3) */
53 unsigned ad
: 1; /* authentic data from named */
54 unsigned cd
: 1; /* checking disabled by resolver */
55 unsigned rcode
:4; /* response code */
57 /* fields in third byte */
58 unsigned rd
:1; /* recursion desired */
59 unsigned tc
:1; /* truncated message */
60 unsigned aa
:1; /* authoritive answer */
61 unsigned opcode
:4; /* purpose of message */
62 unsigned qr
:1; /* response flag */
63 /* fields in fourth byte */
64 unsigned rcode
:4; /* response code */
65 unsigned cd
: 1; /* checking disabled by resolver */
66 unsigned ad
: 1; /* authentic data from named */
67 unsigned unused
:1; /* unused bits (MBZ as of 4.9.3a3) */
68 unsigned ra
:1; /* recursion available */
71 unsigned qdcount
:16; /* number of question entries */
72 unsigned ancount
:16; /* number of answer entries */
73 unsigned nscount
:16; /* number of authority entries */
74 unsigned arcount
:16; /* number of resource entries */
78 * Inline versions of get/put short/long. Pointer is advanced.
80 #define IRC_NS_GET16(s, cp) { \
81 const unsigned char *t_cp = (const unsigned char *)(cp); \
82 (s) = ((u_int16_t)t_cp[0] << 8) \
83 | ((u_int16_t)t_cp[1]) \
88 #define IRC_NS_GET32(l, cp) { \
89 const unsigned char *t_cp = (const unsigned char *)(cp); \
90 (l) = ((u_int32_t)t_cp[0] << 24) \
91 | ((u_int32_t)t_cp[1] << 16) \
92 | ((u_int32_t)t_cp[2] << 8) \
93 | ((u_int32_t)t_cp[3]) \
98 #define IRC_NS_PUT16(s, cp) { \
99 u_int16_t t_s = (u_int16_t)(s); \
100 unsigned char *t_cp = (unsigned char *)(cp); \
101 *t_cp++ = t_s >> 8; \
103 (cp) += NS_INT16SZ; \
106 #define IRC_NS_PUT32(l, cp) { \
107 u_int32_t t_l = (u_int32_t)(l); \
108 unsigned char *t_cp = (unsigned char *)(cp); \
109 *t_cp++ = t_l >> 24; \
110 *t_cp++ = t_l >> 16; \
111 *t_cp++ = t_l >> 8; \
113 (cp) += NS_INT32SZ; \
116 extern int irc_res_init(void);
117 extern int irc_dn_expand(const unsigned char *msg
, const unsigned char *eom
, const unsigned char *src
, char *dst
, int dstsiz
);
118 extern int irc_dn_skipname(const unsigned char *ptr
, const unsigned char *eom
);
119 extern unsigned int irc_ns_get16(const unsigned char *src
);
120 extern unsigned long irc_ns_get32(const unsigned char *src
);
121 extern void irc_ns_put16(unsigned int src
, unsigned char *dst
);
122 extern void irc_ns_put32(unsigned long src
, unsigned char *dst
);
123 extern int irc_res_mkquery(const char *dname
, int class, int type
, unsigned char *buf
, int buflen
);
125 extern char irc_domain
[IRCD_RES_HOSTLEN
+ 1];