]> jfr.im git - solanum.git/blame - authd/reslib.h
opm: properly disable opm on blacklist deletions.
[solanum.git] / authd / reslib.h
CommitLineData
ed62c46b
AC
1/*
2 * include/irc_reslib.h
3 *
ed62c46b
AC
4 */
5
6#ifndef _CHARYBDIS_RESLIB_H
7#define _CHARYBDIS_RESLIB_H
8
9/* Longest hostname we're willing to work with.
10 * Due to DNSBLs this is more than HOSTLEN.
11 */
12#define IRCD_RES_HOSTLEN 255
13
14/* Here we define some values lifted from nameser.h */
15#define NS_NOTIFY_OP 4
16#define NS_INT16SZ 2
17#define NS_IN6ADDRSZ 16
18#define NS_INADDRSZ 4
19#define NS_INT32SZ 4
20#define NS_CMPRSFLGS 0xc0
21#define NS_MAXCDNAME 255
22#define QUERY 0
23#define IQUERY 1
24#define NO_ERRORS 0
25#define SERVFAIL 2
26#define NXDOMAIN 3
27#define NOTIMP 4
28#define REFUSED 5
29#define T_A 1
30#define T_AAAA 28
31#define T_PTR 12
32#define T_CNAME 5
33#define T_NULL 10
34#define C_IN 1
35#define QFIXEDSZ 4
36#define RRFIXEDSZ 10
37#define HFIXEDSZ 12
38
39typedef struct
40{
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 */
55#else
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 */
68#endif
69 /* remaining bytes */
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 */
74} HEADER;
75
76/*
77 * Inline versions of get/put short/long. Pointer is advanced.
78 */
79#define IRC_NS_GET16(s, cp) { \
80 const unsigned char *t_cp = (const unsigned char *)(cp); \
2e45f5d8
MU
81 (s) = ((uint16_t)t_cp[0] << 8) \
82 | ((uint16_t)t_cp[1]) \
ed62c46b
AC
83 ; \
84 (cp) += NS_INT16SZ; \
85}
86
87#define IRC_NS_GET32(l, cp) { \
88 const unsigned char *t_cp = (const unsigned char *)(cp); \
2e45f5d8
MU
89 (l) = ((uint32_t)t_cp[0] << 24) \
90 | ((uint32_t)t_cp[1] << 16) \
91 | ((uint32_t)t_cp[2] << 8) \
92 | ((uint32_t)t_cp[3]) \
ed62c46b
AC
93 ; \
94 (cp) += NS_INT32SZ; \
95}
96
97#define IRC_NS_PUT16(s, cp) { \
2e45f5d8 98 uint16_t t_s = (uint16_t)(s); \
ed62c46b
AC
99 unsigned char *t_cp = (unsigned char *)(cp); \
100 *t_cp++ = t_s >> 8; \
101 *t_cp = t_s; \
102 (cp) += NS_INT16SZ; \
103}
104
105#define IRC_NS_PUT32(l, cp) { \
2e45f5d8 106 uint32_t t_l = (uint32_t)(l); \
ed62c46b
AC
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; \
111 *t_cp = t_l; \
112 (cp) += NS_INT32SZ; \
113}
114
115extern int irc_res_init(void);
116extern int irc_dn_expand(const unsigned char *msg, const unsigned char *eom, const unsigned char *src, char *dst, int dstsiz);
117extern int irc_dn_skipname(const unsigned char *ptr, const unsigned char *eom);
118extern unsigned int irc_ns_get16(const unsigned char *src);
119extern unsigned long irc_ns_get32(const unsigned char *src);
120extern void irc_ns_put16(unsigned int src, unsigned char *dst);
121extern void irc_ns_put32(unsigned long src, unsigned char *dst);
122extern int irc_res_mkquery(const char *dname, int class, int type, unsigned char *buf, int buflen);
123
124extern char irc_domain[IRCD_RES_HOSTLEN + 1];
125
126#endif