dns_func.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (C) 2013 [email protected]
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. /*!
  17. * \file
  18. * \brief Kamailio core :: DNS wrappers
  19. * \author [email protected]
  20. * \ingroup core
  21. * Module: \ref core
  22. */
  23. #include "dns_func.h"
  24. #include <netinet/in.h>
  25. #include <resolv.h>
  26. #include <sys/types.h>
  27. #include <netdb.h>
  28. struct hostent;
  29. struct dns_func_t dns_func = {
  30. res_init,
  31. res_search,
  32. gethostbyname,
  33. #ifdef HAVE_GETHOSTBYNAME2
  34. gethostbyname2
  35. #else
  36. NULL
  37. #endif
  38. };
  39. void load_dnsfunc(struct dns_func_t *d) {
  40. dns_func.sr_res_init = d->sr_res_init;
  41. dns_func.sr_res_search = d->sr_res_search;
  42. dns_func.sr_gethostbyname = d->sr_gethostbyname;
  43. dns_func.sr_gethostbyname2 = d->sr_gethostbyname2;
  44. }