2 * include/ircd_reslib.h
3 * (C)opyright 1992 Darren Reed.
6 * @brief Interface from ircd resolver to its support functions.
9 #ifndef INCLUDED_ircdreslib_h
10 #define INCLUDED_ircdreslib_h
15 * Inline versions of get/put short/long. Pointer is advanced.
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]) \
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]) \
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); \
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; \
57 /** Maximum number of nameservers to bother with. */
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 */