lookup.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef LOOKUP_H
  2. #define LOOKUP_H
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. #include <features.h>
  6. #include <netinet/in.h>
  7. #include <netdb.h>
  8. #define hidden __attribute__((__visibility__("hidden")))
  9. struct aibuf {
  10. struct addrinfo ai;
  11. union sa {
  12. struct sockaddr_in sin;
  13. struct sockaddr_in6 sin6;
  14. } sa;
  15. volatile int lock[1];
  16. short slot, ref;
  17. };
  18. struct address {
  19. int family;
  20. unsigned scopeid;
  21. uint8_t addr[16];
  22. int sortkey;
  23. };
  24. struct service {
  25. uint16_t port;
  26. unsigned char proto, socktype;
  27. };
  28. #define MAXNS 3
  29. struct resolvconf {
  30. struct address ns[MAXNS];
  31. unsigned nns, attempts, ndots;
  32. unsigned timeout;
  33. };
  34. /* The limit of 48 results is a non-sharp bound on the number of addresses
  35. * that can fit in one 512-byte DNS packet full of v4 results and a second
  36. * packet full of v6 results. Due to headers, the actual limit is lower. */
  37. #define MAXADDRS 48
  38. #define MAXSERVS 2
  39. hidden int __lookup_serv(struct service buf[static MAXSERVS], const char *name, int proto, int socktype, int flags);
  40. hidden int __lookup_name(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, int flags);
  41. hidden int __lookup_ipliteral(struct address buf[static 1], const char *name, int family);
  42. hidden int __get_resolv_conf(struct resolvconf *, char *, size_t);
  43. hidden int __res_msend_rc(int, const unsigned char *const *, const int *, unsigned char *const *, int *, int, const struct resolvconf *);
  44. hidden int __dns_parse(const unsigned char *, int, int (*)(void *, int, const void *, int, const void *), void *);
  45. #endif