aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_dnsparser_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_dnsparser_lib.h')
-rw-r--r--src/include/gnunet_dnsparser_lib.h98
1 files changed, 96 insertions, 2 deletions
diff --git a/src/include/gnunet_dnsparser_lib.h b/src/include/gnunet_dnsparser_lib.h
index f77073264..9a84f346f 100644
--- a/src/include/gnunet_dnsparser_lib.h
+++ b/src/include/gnunet_dnsparser_lib.h
@@ -18,7 +18,15 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
25
21/** 26/**
27 * @addtogroup libgnunetutil
28 * @{
29 *
22 * @author Philipp Toelke 30 * @author Philipp Toelke
23 * @author Christian Grothoff 31 * @author Christian Grothoff
24 * 32 *
@@ -32,8 +40,6 @@
32#ifndef GNUNET_DNSPARSER_LIB_H 40#ifndef GNUNET_DNSPARSER_LIB_H
33#define GNUNET_DNSPARSER_LIB_H 41#define GNUNET_DNSPARSER_LIB_H
34 42
35#include "gnunet_util_lib.h"
36
37/** 43/**
38 * Maximum length of a label in DNS. 44 * Maximum length of a label in DNS.
39 */ 45 */
@@ -78,6 +84,7 @@
78#define GNUNET_DNSPARSER_TYPE_NSEC3 50 84#define GNUNET_DNSPARSER_TYPE_NSEC3 50
79#define GNUNET_DNSPARSER_TYPE_NSEC3PARAM 51 85#define GNUNET_DNSPARSER_TYPE_NSEC3PARAM 51
80#define GNUNET_DNSPARSER_TYPE_TLSA 52 86#define GNUNET_DNSPARSER_TYPE_TLSA 52
87#define GNUNET_DNSPARSER_TYPE_SMIMEA 53
81#define GNUNET_DNSPARSER_TYPE_HIP 55 88#define GNUNET_DNSPARSER_TYPE_HIP 55
82#define GNUNET_DNSPARSER_TYPE_CDS 59 89#define GNUNET_DNSPARSER_TYPE_CDS 59
83#define GNUNET_DNSPARSER_TYPE_CDNSKEY 60 90#define GNUNET_DNSPARSER_TYPE_CDNSKEY 60
@@ -172,6 +179,33 @@ struct GNUNET_DNSPARSER_SrvRecord
172 179
173 180
174/** 181/**
182 * Information from URI records (RFC 7553).
183 */
184struct GNUNET_DNSPARSER_UriRecord
185{
186 /**
187 * URI of the target,
188 * where the URI is as specified in RFC 3986.
189 */
190 char *target;
191
192 /**
193 * Preference for this entry (lower value is higher preference). Clients
194 * will contact hosts from the lowest-priority group first and fall back
195 * to higher priorities if the low-priority entries are unavailable.
196 */
197 uint16_t priority;
198
199 /**
200 * Relative weight for records with the same priority. Clients will use
201 * the hosts of the same (lowest) priority with a probability proportional
202 * to the weight given.
203 */
204 uint16_t weight;
205};
206
207
208/**
175 * DNS CERT types as defined in RFC 4398. 209 * DNS CERT types as defined in RFC 4398.
176 */ 210 */
177enum GNUNET_DNSPARSER_CertType 211enum GNUNET_DNSPARSER_CertType
@@ -473,6 +507,11 @@ struct GNUNET_DNSPARSER_Record
473 struct GNUNET_DNSPARSER_SrvRecord *srv; 507 struct GNUNET_DNSPARSER_SrvRecord *srv;
474 508
475 /** 509 /**
510 * URI data for URI records.
511 */
512 struct GNUNET_DNSPARSER_UriRecord *uri;
513
514 /**
476 * Raw data for all other types. 515 * Raw data for all other types.
477 */ 516 */
478 struct GNUNET_DNSPARSER_RawRecord raw; 517 struct GNUNET_DNSPARSER_RawRecord raw;
@@ -737,6 +776,25 @@ GNUNET_DNSPARSER_builder_add_srv (char *dst,
737 size_t *off, 776 size_t *off,
738 const struct GNUNET_DNSPARSER_SrvRecord *srv); 777 const struct GNUNET_DNSPARSER_SrvRecord *srv);
739 778
779
780/**
781 * Add an URI record to the UDP packet at the given location.
782 *
783 * @param dst where to write the URI record
784 * @param dst_len number of bytes in @a dst
785 * @param off pointer to offset where to write the URI information (increment by bytes used)
786 * can also change if there was an error
787 * @param uri URI information to write
788 * @return #GNUNET_SYSERR if @a uri is invalid
789 * #GNUNET_NO if @a uri did not fit
790 * #GNUNET_OK if @a uri was added to @a dst
791 */
792int
793GNUNET_DNSPARSER_builder_add_uri (char *dst,
794 size_t dst_len,
795 size_t *off,
796 const struct GNUNET_DNSPARSER_UriRecord *uri);
797
740/* ***************** low-level parsing API ******************** */ 798/* ***************** low-level parsing API ******************** */
741 799
742/** 800/**
@@ -847,6 +905,21 @@ GNUNET_DNSPARSER_parse_srv (const char *udp_payload,
847 size_t udp_payload_length, 905 size_t udp_payload_length,
848 size_t *off); 906 size_t *off);
849 907
908
909/**
910 * Parse a DNS URI record.
911 *
912 * @param udp_payload reference to UDP packet
913 * @param udp_payload_length length of @a udp_payload
914 * @param off pointer to the offset of the query to parse in the URI record (to be
915 * incremented by the size of the record), unchanged on error
916 * @return the parsed URI record, NULL on error
917 */
918struct GNUNET_DNSPARSER_UriRecord *
919GNUNET_DNSPARSER_parse_uri (const char *udp_payload,
920 size_t udp_payload_length,
921 size_t *off);
922
850/* ***************** low-level duplication API ******************** */ 923/* ***************** low-level duplication API ******************** */
851 924
852/** 925/**
@@ -903,6 +976,16 @@ GNUNET_DNSPARSER_duplicate_srv_record (const struct
903 GNUNET_DNSPARSER_SrvRecord *r); 976 GNUNET_DNSPARSER_SrvRecord *r);
904 977
905 978
979/**
980 * Duplicate (deep-copy) the given DNS record
981 *
982 * @param r the record
983 * @return the newly allocated record
984 */
985struct GNUNET_DNSPARSER_UriRecord *
986GNUNET_DNSPARSER_duplicate_uri_record (const struct
987 GNUNET_DNSPARSER_UriRecord *r);
988
906/* ***************** low-level deallocation API ******************** */ 989/* ***************** low-level deallocation API ******************** */
907 990
908/** 991/**
@@ -933,6 +1016,15 @@ GNUNET_DNSPARSER_free_srv (struct GNUNET_DNSPARSER_SrvRecord *srv);
933 1016
934 1017
935/** 1018/**
1019 * Free URI information record.
1020 *
1021 * @param uri record to free
1022 */
1023void
1024GNUNET_DNSPARSER_free_uri (struct GNUNET_DNSPARSER_UriRecord *uri);
1025
1026
1027/**
936 * Free SOA information record. 1028 * Free SOA information record.
937 * 1029 *
938 * @param soa record to free 1030 * @param soa record to free
@@ -978,3 +1070,5 @@ GNUNET_DNSPARSER_hex_to_bin (const char *hex,
978#endif 1070#endif
979 1071
980/** @} */ /* end of group */ 1072/** @} */ /* end of group */
1073
1074/** @} */ /* end of group addition */