]>
jfr.im git - solanum.git/blob - include/reslib.h
13360550a57decb1097f1014183ad1f8667348ae
4 * $Id: reslib.h 446 2006-02-12 02:46:54Z db $
7 #ifndef _CHARYBDIS_RESLIB_H
8 #define _CHARYBDIS_RESLIB_H
10 /* Here we define some values lifted from nameser.h */
11 #define NS_NOTIFY_OP 4
13 #define NS_IN6ADDRSZ 16
16 #define NS_CMPRSFLGS 0xc0
17 #define NS_MAXCDNAME 255
35 unsigned id
:16; /* query identification number */
36 #ifdef WORDS_BIGENDIAN
37 /* fields in third byte */
38 unsigned qr
: 1; /* response flag */
39 unsigned opcode
: 4; /* purpose of message */
40 unsigned aa
: 1; /* authoritive answer */
41 unsigned tc
: 1; /* truncated message */
42 unsigned rd
: 1; /* recursion desired */
43 /* fields in fourth byte */
44 unsigned ra
: 1; /* recursion available */
45 unsigned unused
:1; /* unused bits (MBZ as of 4.9.3a3) */
46 unsigned ad
: 1; /* authentic data from named */
47 unsigned cd
: 1; /* checking disabled by resolver */
48 unsigned rcode
:4; /* response code */
50 /* fields in third byte */
51 unsigned rd
:1; /* recursion desired */
52 unsigned tc
:1; /* truncated message */
53 unsigned aa
:1; /* authoritive answer */
54 unsigned opcode
:4; /* purpose of message */
55 unsigned qr
:1; /* response flag */
56 /* fields in fourth byte */
57 unsigned rcode
:4; /* response code */
58 unsigned cd
: 1; /* checking disabled by resolver */
59 unsigned ad
: 1; /* authentic data from named */
60 unsigned unused
:1; /* unused bits (MBZ as of 4.9.3a3) */
61 unsigned ra
:1; /* recursion available */
64 unsigned qdcount
:16; /* number of question entries */
65 unsigned ancount
:16; /* number of answer entries */
66 unsigned nscount
:16; /* number of authority entries */
67 unsigned arcount
:16; /* number of resource entries */
71 * Inline versions of get/put short/long. Pointer is advanced.
73 #define IRC_NS_GET16(s, cp) { \
74 const unsigned char *t_cp = (const unsigned char *)(cp); \
75 (s) = ((u_int16_t)t_cp[0] << 8) \
76 | ((u_int16_t)t_cp[1]) \
81 #define IRC_NS_GET32(l, cp) { \
82 const unsigned char *t_cp = (const unsigned char *)(cp); \
83 (l) = ((u_int32_t)t_cp[0] << 24) \
84 | ((u_int32_t)t_cp[1] << 16) \
85 | ((u_int32_t)t_cp[2] << 8) \
86 | ((u_int32_t)t_cp[3]) \
91 #define IRC_NS_PUT16(s, cp) { \
92 u_int16_t t_s = (u_int16_t)(s); \
93 unsigned char *t_cp = (unsigned char *)(cp); \
99 #define IRC_NS_PUT32(l, cp) { \
100 u_int32_t t_l = (u_int32_t)(l); \
101 unsigned char *t_cp = (unsigned char *)(cp); \
102 *t_cp++ = t_l >> 24; \
103 *t_cp++ = t_l >> 16; \
104 *t_cp++ = t_l >> 8; \
106 (cp) += NS_INT32SZ; \
109 extern int irc_res_init(void);
110 extern int irc_dn_expand(const unsigned char *msg
, const unsigned char *eom
, const unsigned char *src
, char *dst
, int dstsiz
);
111 extern int irc_dn_skipname(const unsigned char *ptr
, const unsigned char *eom
);
112 extern unsigned int irc_ns_get16(const unsigned char *src
);
113 extern unsigned long irc_ns_get32(const unsigned char *src
);
114 extern void irc_ns_put16(unsigned int src
, unsigned char *dst
);
115 extern void irc_ns_put32(unsigned long src
, unsigned char *dst
);
116 extern int irc_res_mkquery(const char *dname
, int class, int type
, unsigned char *buf
, int buflen
);
118 extern char irc_domain
[HOSTLEN
+ 1];