You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

packet.h 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Copyright (c) 2014, Vsevolod Stakhov
  2. * All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. * * Redistributions of source code must retain the above copyright
  7. * notice, this list of conditions and the following disclaimer.
  8. * * Redistributions in binary form must reproduce the above copyright
  9. * notice, this list of conditions and the following disclaimer in the
  10. * documentation and/or other materials provided with the distribution.
  11. *
  12. * THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY
  13. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  15. * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
  16. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  18. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  21. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. */
  23. #ifndef PACKET_H_
  24. #define PACKET_H_
  25. #include <stdbool.h>
  26. #include <stdint.h>
  27. #include "dns_private.h"
  28. struct kh_rdns_compression_hash_s;
  29. /**
  30. * Allocate dns packet suitable to handle up to `namelen` name
  31. * @param req request
  32. * @param namelen requested name
  33. */
  34. void rdns_allocate_packet (struct rdns_request* req, unsigned int namelen);
  35. /**
  36. * Add basic header to the dns packet
  37. * @param req
  38. */
  39. void rdns_make_dns_header (struct rdns_request *req, unsigned int qcount);
  40. /**
  41. * Add a resource record to the DNS packet
  42. * @param req request
  43. * @param name requested name
  44. * @param type type of resource record
  45. */
  46. bool rdns_add_rr (struct rdns_request *req, const char *name, unsigned int len,
  47. enum dns_type type, struct kh_rdns_compression_hash_s **comp);
  48. /**
  49. * Add EDNS0 section
  50. * @param req
  51. */
  52. bool rdns_add_edns0 (struct rdns_request *req);
  53. #endif /* PACKET_H_ */