/contrib/bind9/lib/lwres/include/lwres/context.h

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 136 lines · 44 code · 23 blank · 69 comment · 0 complexity · 64f1e92952425f9358aebc933b4ebbf9 MD5 · raw file

  1. /*
  2. * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC")
  3. * Copyright (C) 2000, 2001 Internet Software Consortium.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  10. * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  11. * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  12. * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  13. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  14. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. * PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. /* $Id: context.h,v 1.23 2008/12/17 23:47:58 tbox Exp $ */
  18. #ifndef LWRES_CONTEXT_H
  19. #define LWRES_CONTEXT_H 1
  20. /*! \file lwres/context.h */
  21. #include <stddef.h>
  22. #include <lwres/lang.h>
  23. #include <lwres/int.h>
  24. #include <lwres/result.h>
  25. /*!
  26. * Used to set various options such as timeout, authentication, etc
  27. */
  28. typedef struct lwres_context lwres_context_t;
  29. LWRES_LANG_BEGINDECLS
  30. typedef void *(*lwres_malloc_t)(void *arg, size_t length);
  31. typedef void (*lwres_free_t)(void *arg, void *mem, size_t length);
  32. /*
  33. * XXXMLG
  34. *
  35. * Make the server reload /etc/resolv.conf periodically.
  36. *
  37. * Make the server do sortlist/searchlist.
  38. *
  39. * Client side can disable the search/sortlist processing.
  40. *
  41. * Use an array of addresses/masks and searchlist for client-side, and
  42. * if added to the client disable the processing on the server.
  43. *
  44. * Share /etc/resolv.conf data between contexts.
  45. */
  46. /*!
  47. * _SERVERMODE
  48. * Don't allocate and connect a socket to the server, since the
  49. * caller _is_ a server.
  50. *
  51. * _USEIPV4, _USEIPV6
  52. * Use IPv4 and IPv6 transactions with remote servers, respectively.
  53. * For backward compatibility, regard both flags as being set when both
  54. * are cleared.
  55. */
  56. #define LWRES_CONTEXT_SERVERMODE 0x00000001U
  57. #define LWRES_CONTEXT_USEIPV4 0x00000002U
  58. #define LWRES_CONTEXT_USEIPV6 0x00000004U
  59. lwres_result_t
  60. lwres_context_create(lwres_context_t **contextp, void *arg,
  61. lwres_malloc_t malloc_function,
  62. lwres_free_t free_function,
  63. unsigned int flags);
  64. /**<
  65. * Allocate a lwres context. This is used in all lwres calls.
  66. *
  67. * Memory management can be replaced here by passing in two functions.
  68. * If one is non-NULL, they must both be non-NULL. "arg" is passed to
  69. * these functions.
  70. *
  71. * Contexts are not thread safe. Document at the top of the file.
  72. * XXXMLG
  73. *
  74. * If they are NULL, the standard malloc() and free() will be used.
  75. *
  76. *\pre contextp != NULL && contextp == NULL.
  77. *
  78. *\return Returns 0 on success, non-zero on failure.
  79. */
  80. void
  81. lwres_context_destroy(lwres_context_t **contextp);
  82. /**<
  83. * Frees all memory associated with a lwres context.
  84. *
  85. *\pre contextp != NULL && contextp == NULL.
  86. */
  87. lwres_uint32_t
  88. lwres_context_nextserial(lwres_context_t *ctx);
  89. /**<
  90. * XXXMLG Document
  91. */
  92. void
  93. lwres_context_initserial(lwres_context_t *ctx, lwres_uint32_t serial);
  94. void
  95. lwres_context_freemem(lwres_context_t *ctx, void *mem, size_t len);
  96. void *
  97. lwres_context_allocmem(lwres_context_t *ctx, size_t len);
  98. int
  99. lwres_context_getsocket(lwres_context_t *ctx);
  100. lwres_result_t
  101. lwres_context_send(lwres_context_t *ctx,
  102. void *sendbase, int sendlen);
  103. lwres_result_t
  104. lwres_context_recv(lwres_context_t *ctx,
  105. void *recvbase, int recvlen,
  106. int *recvd_len);
  107. lwres_result_t
  108. lwres_context_sendrecv(lwres_context_t *ctx,
  109. void *sendbase, int sendlen,
  110. void *recvbase, int recvlen,
  111. int *recvd_len);
  112. LWRES_LANG_ENDDECLS
  113. #endif /* LWRES_CONTEXT_H */