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.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/include/gnunet_dnsparser_lib.h b/src/include/gnunet_dnsparser_lib.h
index 8064b554b..9a84f346f 100644
--- a/src/include/gnunet_dnsparser_lib.h
+++ b/src/include/gnunet_dnsparser_lib.h
@@ -84,6 +84,7 @@
84#define GNUNET_DNSPARSER_TYPE_NSEC3 50 84#define GNUNET_DNSPARSER_TYPE_NSEC3 50
85#define GNUNET_DNSPARSER_TYPE_NSEC3PARAM 51 85#define GNUNET_DNSPARSER_TYPE_NSEC3PARAM 51
86#define GNUNET_DNSPARSER_TYPE_TLSA 52 86#define GNUNET_DNSPARSER_TYPE_TLSA 52
87#define GNUNET_DNSPARSER_TYPE_SMIMEA 53
87#define GNUNET_DNSPARSER_TYPE_HIP 55 88#define GNUNET_DNSPARSER_TYPE_HIP 55
88#define GNUNET_DNSPARSER_TYPE_CDS 59 89#define GNUNET_DNSPARSER_TYPE_CDS 59
89#define GNUNET_DNSPARSER_TYPE_CDNSKEY 60 90#define GNUNET_DNSPARSER_TYPE_CDNSKEY 60
@@ -178,6 +179,33 @@ struct GNUNET_DNSPARSER_SrvRecord
178 179
179 180
180/** 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/**
181 * DNS CERT types as defined in RFC 4398. 209 * DNS CERT types as defined in RFC 4398.
182 */ 210 */
183enum GNUNET_DNSPARSER_CertType 211enum GNUNET_DNSPARSER_CertType
@@ -479,6 +507,11 @@ struct GNUNET_DNSPARSER_Record
479 struct GNUNET_DNSPARSER_SrvRecord *srv; 507 struct GNUNET_DNSPARSER_SrvRecord *srv;
480 508
481 /** 509 /**
510 * URI data for URI records.
511 */
512 struct GNUNET_DNSPARSER_UriRecord *uri;
513
514 /**
482 * Raw data for all other types. 515 * Raw data for all other types.
483 */ 516 */
484 struct GNUNET_DNSPARSER_RawRecord raw; 517 struct GNUNET_DNSPARSER_RawRecord raw;
@@ -743,6 +776,25 @@ GNUNET_DNSPARSER_builder_add_srv (char *dst,
743 size_t *off, 776 size_t *off,
744 const struct GNUNET_DNSPARSER_SrvRecord *srv); 777 const struct GNUNET_DNSPARSER_SrvRecord *srv);
745 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
746/* ***************** low-level parsing API ******************** */ 798/* ***************** low-level parsing API ******************** */
747 799
748/** 800/**
@@ -853,6 +905,21 @@ GNUNET_DNSPARSER_parse_srv (const char *udp_payload,
853 size_t udp_payload_length, 905 size_t udp_payload_length,
854 size_t *off); 906 size_t *off);
855 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
856/* ***************** low-level duplication API ******************** */ 923/* ***************** low-level duplication API ******************** */
857 924
858/** 925/**
@@ -909,6 +976,16 @@ GNUNET_DNSPARSER_duplicate_srv_record (const struct
909 GNUNET_DNSPARSER_SrvRecord *r); 976 GNUNET_DNSPARSER_SrvRecord *r);
910 977
911 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
912/* ***************** low-level deallocation API ******************** */ 989/* ***************** low-level deallocation API ******************** */
913 990
914/** 991/**
@@ -939,6 +1016,15 @@ GNUNET_DNSPARSER_free_srv (struct GNUNET_DNSPARSER_SrvRecord *srv);
939 1016
940 1017
941/** 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/**
942 * Free SOA information record. 1028 * Free SOA information record.
943 * 1029 *
944 * @param soa record to free 1030 * @param soa record to free