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