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.

parse.h 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 PARSE_H_
  24. #define PARSE_H_
  25. #include "dns_private.h"
  26. /**
  27. * Compare request and reply checking names
  28. * @param req request object
  29. * @param in incoming packet
  30. * @param len length of the incoming packet
  31. * @return new position in the incoming packet or NULL if request is not equal to reply
  32. */
  33. uint8_t * rdns_request_reply_cmp (struct rdns_request *req, uint8_t *in, int len);
  34. /**
  35. * Parse labels in the packet
  36. * @param in incoming packet
  37. * @param target target to write the parsed label (out)
  38. * @param pos output position in the packet (it/out)
  39. * @param rep dns reply
  40. * @param remain remaining bytes (in/out)
  41. * @param make_name create name or just skip to the next label
  42. * @return true if a label has been successfully parsed
  43. */
  44. bool rdns_parse_labels (struct rdns_resolver *resolver,
  45. uint8_t *in, char **target,
  46. uint8_t **pos, struct rdns_reply *rep,
  47. int *remain, bool make_name);
  48. /**
  49. * Parse resource record
  50. * @param in incoming packet
  51. * @param elt new reply entry
  52. * @param pos output position in the packet (it/out)
  53. * @param rep dns reply
  54. * @param remain remaining bytes (in/out)
  55. * @return 1 if rr has been parsed, 0 if rr has been skipped and -1 if there was a parsing error
  56. */
  57. int rdns_parse_rr (struct rdns_resolver *resolver,
  58. uint8_t *in, struct rdns_reply_entry *elt, uint8_t **pos,
  59. struct rdns_reply *rep, int *remain);
  60. #endif /* PARSE_H_ */