/contrib/bind9/lib/dns/include/dns/fixedname.h

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 86 lines · 21 code · 13 blank · 52 comment · 1 complexity · 0642098ff327a4f780f4f4fd3de233b6 MD5 · raw file

  1. /*
  2. * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
  3. * Copyright (C) 1999-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: fixedname.h,v 1.19 2007/06/19 23:47:16 tbox Exp $ */
  18. #ifndef DNS_FIXEDNAME_H
  19. #define DNS_FIXEDNAME_H 1
  20. /*****
  21. ***** Module Info
  22. *****/
  23. /*! \file dns/fixedname.h
  24. * \brief
  25. * Fixed-size Names
  26. *
  27. * dns_fixedname_t is a convenience type containing a name, an offsets table,
  28. * and a dedicated buffer big enough for the longest possible name.
  29. *
  30. * MP:
  31. *\li The caller must ensure any required synchronization.
  32. *
  33. * Reliability:
  34. *\li No anticipated impact.
  35. *
  36. * Resources:
  37. *\li Per dns_fixedname_t:
  38. *\code
  39. * sizeof(dns_name_t) + sizeof(dns_offsets_t) +
  40. * sizeof(isc_buffer_t) + 255 bytes + structure padding
  41. *\endcode
  42. *
  43. * Security:
  44. *\li No anticipated impact.
  45. *
  46. * Standards:
  47. *\li None.
  48. */
  49. /*****
  50. ***** Imports
  51. *****/
  52. #include <isc/buffer.h>
  53. #include <dns/name.h>
  54. /*****
  55. ***** Types
  56. *****/
  57. struct dns_fixedname {
  58. dns_name_t name;
  59. dns_offsets_t offsets;
  60. isc_buffer_t buffer;
  61. unsigned char data[DNS_NAME_MAXWIRE];
  62. };
  63. #define dns_fixedname_init(fn) \
  64. do { \
  65. dns_name_init(&((fn)->name), (fn)->offsets); \
  66. isc_buffer_init(&((fn)->buffer), (fn)->data, \
  67. DNS_NAME_MAXWIRE); \
  68. dns_name_setbuffer(&((fn)->name), &((fn)->buffer)); \
  69. } while (0)
  70. #define dns_fixedname_invalidate(fn) \
  71. dns_name_invalidate(&((fn)->name))
  72. #define dns_fixedname_name(fn) (&((fn)->name))
  73. #endif /* DNS_FIXEDNAME_H */