fixed ssl.c bug when ssl backend returns IO_BLOCKED but IO engine doesn't get informe...
[ircu2.10.12-pk.git] / include / ircd_reslib.h
1 /*
2  * include/ircd_reslib.h
3  * (C)opyright 1992 Darren Reed.
4  */
5 /** @file
6  * @brief Interface from ircd resolver to its support functions.
7  * @version $Id: ircd_reslib.h 1231 2004-10-05 04:21:37Z entrope $
8  */
9 #ifndef INCLUDED_ircdreslib_h
10 #define INCLUDED_ircdreslib_h
11
12 #include <netdb.h>
13
14 /*
15  * Inline versions of get/put short/long.  Pointer is advanced.
16  */
17 /** Get a 16-bit network endian value from \a cp and assign to \a s. */
18 #define IRC_NS_GET16(s, cp) { \
19         const unsigned char *t_cp = (const unsigned char *)(cp); \
20         (s) = ((uint16_t)t_cp[0] << 8) \
21             | ((uint16_t)t_cp[1]) \
22             ; \
23         (cp) += NS_INT16SZ; \
24 }
25
26 /** Get a 32-bit network endian value from \a cp and assign to \a s. */
27 #define IRC_NS_GET32(l, cp) { \
28         const unsigned char *t_cp = (const unsigned char *)(cp); \
29         (l) = ((uint32_t)t_cp[0] << 24) \
30             | ((uint32_t)t_cp[1] << 16) \
31             | ((uint32_t)t_cp[2] << 8) \
32             | ((uint32_t)t_cp[3]) \
33             ; \
34         (cp) += NS_INT32SZ; \
35 }
36
37 /** Put \a s at \a cp as a 16-bit network endian value. */
38 #define IRC_NS_PUT16(s, cp) { \
39         uint16_t t_s = (uint16_t)(s); \
40         unsigned char *t_cp = (unsigned char *)(cp); \
41         *t_cp++ = t_s >> 8; \
42         *t_cp   = t_s; \
43         (cp) += NS_INT16SZ; \
44 }
45
46 /** Put \a s at \a cp as a 32-bit network endian value. */
47 #define IRC_NS_PUT32(l, cp) { \
48         uint32_t t_l = (uint32_t)(l); \
49         unsigned char *t_cp = (unsigned char *)(cp); \
50         *t_cp++ = t_l >> 24; \
51         *t_cp++ = t_l >> 16; \
52         *t_cp++ = t_l >> 8; \
53         *t_cp   = t_l; \
54         (cp) += NS_INT32SZ; \
55 }
56
57 /** Maximum number of nameservers to bother with. */
58 #define IRCD_MAXNS 8
59
60 int irc_res_init(void);
61 int irc_dn_expand(const unsigned char *msg, const unsigned char *eom, const unsigned char *src, char *dst, int dstsiz);
62 int irc_ns_name_uncompress(const unsigned char *msg, const unsigned char *eom, const unsigned char *src, char *dst, size_t dstsiz);
63 int irc_ns_name_unpack(const unsigned char *msg, const unsigned char *eom, const unsigned char *src, unsigned char *dst, size_t dstsiz);
64 int irc_ns_name_ntop(const char *src, char *dst, size_t dstsiz);
65 int irc_dn_comp(const char *src, unsigned char *dst, int dstsiz, unsigned char **dnptrs, unsigned char **lastdnptr);
66 int irc_dn_skipname(const unsigned char *ptr, const unsigned char *eom);
67 int irc_ns_name_skip(const unsigned char **ptrptr, const unsigned char *eom);
68 unsigned int irc_ns_get16(const unsigned char *src);
69 unsigned long irc_ns_get32(const unsigned char *src);
70 void irc_ns_put16(unsigned int src, unsigned char *dst);
71 void irc_ns_put32(unsigned long src, unsigned char *dst);
72 int irc_ns_name_pton(const char *src, unsigned char *dst, size_t dstsiz);
73 int irc_ns_name_pack(const unsigned char *src, unsigned char *dst, int dstsiz, const unsigned char **dnptrs, const unsigned char **lastdnptr);
74 int irc_res_mkquery(const char *dname, int class, int type, unsigned char *buf, int buflen);
75 #endif /* INCLUDED_res_h */