GNUnet 0.22.0
DNS parser library

Helper library to parse DNS packets. More...

Collaboration diagram for DNS parser library:

Data Structures

struct  GNUNET_DNSPARSER_Query
 A DNS query. More...
 
struct  GNUNET_DNSPARSER_MxRecord
 Information from MX records (RFC 1035). More...
 
struct  GNUNET_DNSPARSER_SrvRecord
 Information from SRV records (RFC 2782). More...
 
struct  GNUNET_DNSPARSER_UriRecord
 Information from URI records (RFC 7553). More...
 
struct  GNUNET_DNSPARSER_CertRecord
 Information from CERT records (RFC 4034). More...
 
struct  GNUNET_DNSPARSER_SoaRecord
 Information from SOA records (RFC 1035). More...
 
struct  GNUNET_DNSPARSER_CaaRecord
 Information from CAA records (RFC 6844). More...
 
struct  GNUNET_DNSPARSER_RawRecord
 Binary record information (unparsed). More...
 
struct  GNUNET_DNSPARSER_Record
 A DNS response record. More...
 
struct  GNUNET_DNSPARSER_Packet
 Easy-to-process, parsed version of a DNS packet. More...
 

Macros

#define GNUNET_DNSPARSER_MAX_LABEL_LENGTH   63
 Maximum length of a label in DNS. More...
 
#define GNUNET_DNSPARSER_MAX_NAME_LENGTH   253
 Maximum length of a name in DNS. More...
 
#define GNUNET_DNSPARSER_TYPE_ANY   0
 A few common DNS types. More...
 
#define GNUNET_DNSPARSER_TYPE_A   1
 
#define GNUNET_DNSPARSER_TYPE_NS   2
 
#define GNUNET_DNSPARSER_TYPE_CNAME   5
 
#define GNUNET_DNSPARSER_TYPE_SOA   6
 
#define GNUNET_DNSPARSER_TYPE_PTR   12
 
#define GNUNET_DNSPARSER_TYPE_MX   15
 
#define GNUNET_DNSPARSER_TYPE_TXT   16
 
#define GNUNET_DNSPARSER_TYPE_RP   17
 
#define GNUNET_DNSPARSER_TYPE_AFSDB   18
 
#define GNUNET_DNSPARSER_TYPE_SIG   24
 
#define GNUNET_DNSPARSER_TYPE_KEY   25
 
#define GNUNET_DNSPARSER_TYPE_AAAA   28
 
#define GNUNET_DNSPARSER_TYPE_LOC   29
 
#define GNUNET_DNSPARSER_TYPE_SRV   33
 
#define GNUNET_DNSPARSER_TYPE_NAPTR   35
 
#define GNUNET_DNSPARSER_TYPE_KX   36
 
#define GNUNET_DNSPARSER_TYPE_CERT   37
 
#define GNUNET_DNSPARSER_TYPE_DNAME   39
 
#define GNUNET_DNSPARSER_TYPE_APL   42
 
#define GNUNET_DNSPARSER_TYPE_DS   43
 
#define GNUNET_DNSPARSER_TYPE_SSHFP   44
 
#define GNUNET_DNSPARSER_TYPE_IPSECKEY   45
 
#define GNUNET_DNSPARSER_TYPE_RRSIG   46
 
#define GNUNET_DNSPARSER_TYPE_NSEC   47
 
#define GNUNET_DNSPARSER_TYPE_DNSKEY   48
 
#define GNUNET_DNSPARSER_TYPE_DHCID   49
 
#define GNUNET_DNSPARSER_TYPE_NSEC3   50
 
#define GNUNET_DNSPARSER_TYPE_NSEC3PARAM   51
 
#define GNUNET_DNSPARSER_TYPE_TLSA   52
 
#define GNUNET_DNSPARSER_TYPE_SMIMEA   53
 
#define GNUNET_DNSPARSER_TYPE_HIP   55
 
#define GNUNET_DNSPARSER_TYPE_CDS   59
 
#define GNUNET_DNSPARSER_TYPE_CDNSKEY   60
 
#define GNUNET_DNSPARSER_TYPE_OPENPGPKEY   61
 
#define GNUNET_DNSPARSER_TYPE_TKEY   249
 
#define GNUNET_DNSPARSER_TYPE_TSIG   250
 
#define GNUNET_DNSPARSER_TYPE_ALL   255
 
#define GNUNET_DNSPARSER_TYPE_URI   256
 
#define GNUNET_DNSPARSER_TYPE_CAA   257
 
#define GNUNET_DNSPARSER_TYPE_TA   32768
 

Enumerations

enum  GNUNET_DNSPARSER_CertType {
  GNUNET_DNSPARSER_CERTTYPE_RESERVED = 0 , GNUNET_DNSPARSER_CERTTYPE_PKIX = 1 , GNUNET_DNSPARSER_CERTTYPE_SKPI = 2 , GNUNET_DNSPARSER_CERTTYPE_PGP = 3 ,
  GNUNET_DNSPARSER_CERTTYPE_IPKIX = 4 , GNUNET_DNSPARSER_CERTTYPE_ISKPI = 5 , GNUNET_DNSPARSER_CERTTYPE_IPGP = 6 , GNUNET_DNSPARSER_CERTTYPE_ACPKIX = 7 ,
  GNUNET_DNSPARSER_CERTTYPE_IACKPIX = 8
}
 DNS CERT types as defined in RFC 4398. More...
 
enum  GNUNET_DNSPARSER_CertAlgorithm {
  GNUNET_DNSPARSER_CERTALGO_UNDEFINED = 0 , GNUNET_DNSPARSER_CERTALGO_RSAMD5 = 1 , GNUNET_DNSPARSER_CERTALGO_DH = 2 , GNUNET_DNSPARSER_CERTALGO_DSASHA = 3 ,
  GNUNET_DNSPARSER_CERTALGO_RSRVD4 = 4 , GNUNET_DNSPARSER_CERTALGO_RSASHA = 5 , GNUNET_DNSPARSER_CERTALGO_DSANSEC3 = 6 , GNUNET_DNSPARSER_CERTALGO_RSANSEC3 = 7 ,
  GNUNET_DNSPARSER_CERTALGO_RSASHA256 = 8 , GNUNET_DNSPARSER_CERTALGO_RSRVD9 = 9 , GNUNET_DNSPARSER_CERTALGO_RSASHA512 = 10 , GNUNET_DNSPARSER_CERTALGO_GOST_R34 = 12 ,
  GNUNET_DNSPARSER_CERTALGO_ECDSA_P256SHA256 = 13 , GNUNET_DNSPARSER_CERTALGO_ECDSA_P384SHA384 = 14
}
 DNSCERT algorithms as defined in http://www.iana.org/assignments/ dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml, under dns-sec-alg-numbers-1. More...
 

Functions

int GNUNET_DNSPARSER_check_label (const char *label)
 Check if a label in UTF-8 format can be coded into valid IDNA. More...
 
int GNUNET_DNSPARSER_check_name (const char *name)
 Check if a hostname in UTF-8 format can be coded into valid IDNA. More...
 
struct GNUNET_DNSPARSER_PacketGNUNET_DNSPARSER_parse (const char *udp_payload, size_t udp_payload_length)
 Parse a UDP payload of a DNS packet in to a nice struct for further processing and manipulation. More...
 
void GNUNET_DNSPARSER_free_packet (struct GNUNET_DNSPARSER_Packet *p)
 Free memory taken by a packet. More...
 
int GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p, uint16_t max, char **buf, size_t *buf_length)
 Given a DNS packet p, generate the corresponding UDP payload. More...
 
int GNUNET_DNSPARSER_builder_add_name (char *dst, size_t dst_len, size_t *off, const char *name)
 Add a DNS name to the UDP packet at the given location, converting the name to IDNA notation as necessary. More...
 
int GNUNET_DNSPARSER_builder_add_query (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_Query *query)
 Add a DNS query to the UDP packet at the given location. More...
 
int GNUNET_DNSPARSER_builder_add_mx (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_MxRecord *mx)
 Add an MX record to the UDP packet at the given location. More...
 
int GNUNET_DNSPARSER_builder_add_soa (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_SoaRecord *soa)
 Add an SOA record to the UDP packet at the given location. More...
 
int GNUNET_DNSPARSER_builder_add_cert (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_CertRecord *cert)
 Add CERT record to the UDP packet at the given location. More...
 
int GNUNET_DNSPARSER_builder_add_srv (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_SrvRecord *srv)
 Add an SRV record to the UDP packet at the given location. More...
 
int GNUNET_DNSPARSER_builder_add_uri (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_UriRecord *uri)
 Add an URI record to the UDP packet at the given location. More...
 
int GNUNET_DNSPARSER_parse_record (const char *udp_payload, size_t udp_payload_length, size_t *off, struct GNUNET_DNSPARSER_Record *r)
 Parse a DNS record entry. More...
 
char * GNUNET_DNSPARSER_parse_name (const char *udp_payload, size_t udp_payload_length, size_t *off)
 Parse name inside of a DNS query or record. More...
 
int GNUNET_DNSPARSER_parse_query (const char *udp_payload, size_t udp_payload_length, size_t *off, struct GNUNET_DNSPARSER_Query *q)
 Parse a DNS query entry. More...
 
struct GNUNET_DNSPARSER_SoaRecordGNUNET_DNSPARSER_parse_soa (const char *udp_payload, size_t udp_payload_length, size_t *off)
 Parse a DNS SOA record. More...
 
struct GNUNET_DNSPARSER_CertRecordGNUNET_DNSPARSER_parse_cert (const char *udp_payload, size_t udp_payload_length, size_t *off)
 Parse a DNS CERT record. More...
 
struct GNUNET_DNSPARSER_MxRecordGNUNET_DNSPARSER_parse_mx (const char *udp_payload, size_t udp_payload_length, size_t *off)
 Parse a DNS MX record. More...
 
struct GNUNET_DNSPARSER_SrvRecordGNUNET_DNSPARSER_parse_srv (const char *udp_payload, size_t udp_payload_length, size_t *off)
 Parse a DNS SRV record. More...
 
struct GNUNET_DNSPARSER_UriRecordGNUNET_DNSPARSER_parse_uri (const char *udp_payload, size_t udp_payload_length, size_t *off)
 Parse a DNS URI record. More...
 
struct GNUNET_DNSPARSER_RecordGNUNET_DNSPARSER_duplicate_record (const struct GNUNET_DNSPARSER_Record *r)
 Duplicate (deep-copy) the given DNS record. More...
 
struct GNUNET_DNSPARSER_SoaRecordGNUNET_DNSPARSER_duplicate_soa_record (const struct GNUNET_DNSPARSER_SoaRecord *r)
 Duplicate (deep-copy) the given DNS record. More...
 
struct GNUNET_DNSPARSER_CertRecordGNUNET_DNSPARSER_duplicate_cert_record (const struct GNUNET_DNSPARSER_CertRecord *r)
 Duplicate (deep-copy) the given DNS record. More...
 
struct GNUNET_DNSPARSER_MxRecordGNUNET_DNSPARSER_duplicate_mx_record (const struct GNUNET_DNSPARSER_MxRecord *r)
 Duplicate (deep-copy) the given DNS record. More...
 
struct GNUNET_DNSPARSER_SrvRecordGNUNET_DNSPARSER_duplicate_srv_record (const struct GNUNET_DNSPARSER_SrvRecord *r)
 Duplicate (deep-copy) the given DNS record. More...
 
struct GNUNET_DNSPARSER_UriRecordGNUNET_DNSPARSER_duplicate_uri_record (const struct GNUNET_DNSPARSER_UriRecord *r)
 Duplicate (deep-copy) the given DNS record. More...
 
void GNUNET_DNSPARSER_free_record (struct GNUNET_DNSPARSER_Record *r)
 Free the given DNS record. More...
 
void GNUNET_DNSPARSER_free_mx (struct GNUNET_DNSPARSER_MxRecord *mx)
 Free MX information record. More...
 
void GNUNET_DNSPARSER_free_srv (struct GNUNET_DNSPARSER_SrvRecord *srv)
 Free SRV information record. More...
 
void GNUNET_DNSPARSER_free_uri (struct GNUNET_DNSPARSER_UriRecord *uri)
 Free URI information record. More...
 
void GNUNET_DNSPARSER_free_soa (struct GNUNET_DNSPARSER_SoaRecord *soa)
 Free SOA information record. More...
 
void GNUNET_DNSPARSER_free_cert (struct GNUNET_DNSPARSER_CertRecord *cert)
 Free CERT information record. More...
 
char * GNUNET_DNSPARSER_bin_to_hex (const void *data, size_t data_size)
 Convert a block of binary data to HEX. More...
 
size_t GNUNET_DNSPARSER_hex_to_bin (const char *hex, void *data)
 Convert a HEX string to block of binary data. More...
 

Detailed Description

Helper library to parse DNS packets.

Macro Definition Documentation

◆ GNUNET_DNSPARSER_MAX_LABEL_LENGTH

#define GNUNET_DNSPARSER_MAX_LABEL_LENGTH   63

Maximum length of a label in DNS.

Definition at line 46 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_MAX_NAME_LENGTH

#define GNUNET_DNSPARSER_MAX_NAME_LENGTH   253

Maximum length of a name in DNS.

Definition at line 51 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_ANY

#define GNUNET_DNSPARSER_TYPE_ANY   0

A few common DNS types.

Definition at line 57 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_A

#define GNUNET_DNSPARSER_TYPE_A   1

Definition at line 58 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_NS

#define GNUNET_DNSPARSER_TYPE_NS   2

Definition at line 59 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_CNAME

#define GNUNET_DNSPARSER_TYPE_CNAME   5

Definition at line 60 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_SOA

#define GNUNET_DNSPARSER_TYPE_SOA   6

Definition at line 61 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_PTR

#define GNUNET_DNSPARSER_TYPE_PTR   12

Definition at line 62 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_MX

#define GNUNET_DNSPARSER_TYPE_MX   15

Definition at line 63 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_TXT

#define GNUNET_DNSPARSER_TYPE_TXT   16

Definition at line 64 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_RP

#define GNUNET_DNSPARSER_TYPE_RP   17

Definition at line 65 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_AFSDB

#define GNUNET_DNSPARSER_TYPE_AFSDB   18

Definition at line 66 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_SIG

#define GNUNET_DNSPARSER_TYPE_SIG   24

Definition at line 67 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_KEY

#define GNUNET_DNSPARSER_TYPE_KEY   25

Definition at line 68 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_AAAA

#define GNUNET_DNSPARSER_TYPE_AAAA   28

Definition at line 69 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_LOC

#define GNUNET_DNSPARSER_TYPE_LOC   29

Definition at line 70 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_SRV

#define GNUNET_DNSPARSER_TYPE_SRV   33

Definition at line 71 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_NAPTR

#define GNUNET_DNSPARSER_TYPE_NAPTR   35

Definition at line 72 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_KX

#define GNUNET_DNSPARSER_TYPE_KX   36

Definition at line 73 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_CERT

#define GNUNET_DNSPARSER_TYPE_CERT   37

Definition at line 74 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_DNAME

#define GNUNET_DNSPARSER_TYPE_DNAME   39

Definition at line 75 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_APL

#define GNUNET_DNSPARSER_TYPE_APL   42

Definition at line 76 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_DS

#define GNUNET_DNSPARSER_TYPE_DS   43

Definition at line 77 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_SSHFP

#define GNUNET_DNSPARSER_TYPE_SSHFP   44

Definition at line 78 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_IPSECKEY

#define GNUNET_DNSPARSER_TYPE_IPSECKEY   45

Definition at line 79 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_RRSIG

#define GNUNET_DNSPARSER_TYPE_RRSIG   46

Definition at line 80 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_NSEC

#define GNUNET_DNSPARSER_TYPE_NSEC   47

Definition at line 81 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_DNSKEY

#define GNUNET_DNSPARSER_TYPE_DNSKEY   48

Definition at line 82 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_DHCID

#define GNUNET_DNSPARSER_TYPE_DHCID   49

Definition at line 83 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_NSEC3

#define GNUNET_DNSPARSER_TYPE_NSEC3   50

Definition at line 84 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_NSEC3PARAM

#define GNUNET_DNSPARSER_TYPE_NSEC3PARAM   51

Definition at line 85 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_TLSA

#define GNUNET_DNSPARSER_TYPE_TLSA   52

Definition at line 86 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_SMIMEA

#define GNUNET_DNSPARSER_TYPE_SMIMEA   53

Definition at line 87 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_HIP

#define GNUNET_DNSPARSER_TYPE_HIP   55

Definition at line 88 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_CDS

#define GNUNET_DNSPARSER_TYPE_CDS   59

Definition at line 89 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_CDNSKEY

#define GNUNET_DNSPARSER_TYPE_CDNSKEY   60

Definition at line 90 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_OPENPGPKEY

#define GNUNET_DNSPARSER_TYPE_OPENPGPKEY   61

Definition at line 91 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_TKEY

#define GNUNET_DNSPARSER_TYPE_TKEY   249

Definition at line 92 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_TSIG

#define GNUNET_DNSPARSER_TYPE_TSIG   250

Definition at line 93 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_ALL

#define GNUNET_DNSPARSER_TYPE_ALL   255

Definition at line 94 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_URI

#define GNUNET_DNSPARSER_TYPE_URI   256

Definition at line 95 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_CAA

#define GNUNET_DNSPARSER_TYPE_CAA   257

Definition at line 96 of file gnunet_dnsparser_lib.h.

◆ GNUNET_DNSPARSER_TYPE_TA

#define GNUNET_DNSPARSER_TYPE_TA   32768

Definition at line 97 of file gnunet_dnsparser_lib.h.

Enumeration Type Documentation

◆ GNUNET_DNSPARSER_CertType

DNS CERT types as defined in RFC 4398.

Enumerator
GNUNET_DNSPARSER_CERTTYPE_RESERVED 

Reserved value.

GNUNET_DNSPARSER_CERTTYPE_PKIX 

An x509 PKIX certificate.

GNUNET_DNSPARSER_CERTTYPE_SKPI 

A SKPI certificate.

GNUNET_DNSPARSER_CERTTYPE_PGP 

A PGP certificate.

GNUNET_DNSPARSER_CERTTYPE_IPKIX 

An x509 PKIX cert URL.

GNUNET_DNSPARSER_CERTTYPE_ISKPI 

A SKPI cert URL.

GNUNET_DNSPARSER_CERTTYPE_IPGP 

A PGP cert fingerprint and URL.

GNUNET_DNSPARSER_CERTTYPE_ACPKIX 

An attribute Certificate.

GNUNET_DNSPARSER_CERTTYPE_IACKPIX 

An attribute cert URL.

Definition at line 211 of file gnunet_dnsparser_lib.h.

212{
217
222
227
232
237
242
247
252
257};
@ GNUNET_DNSPARSER_CERTTYPE_SKPI
A SKPI certificate.
@ GNUNET_DNSPARSER_CERTTYPE_ISKPI
A SKPI cert URL.
@ GNUNET_DNSPARSER_CERTTYPE_IPGP
A PGP cert fingerprint and URL.
@ GNUNET_DNSPARSER_CERTTYPE_IACKPIX
An attribute cert URL.
@ GNUNET_DNSPARSER_CERTTYPE_PGP
A PGP certificate.
@ GNUNET_DNSPARSER_CERTTYPE_ACPKIX
An attribute Certificate.
@ GNUNET_DNSPARSER_CERTTYPE_RESERVED
Reserved value.
@ GNUNET_DNSPARSER_CERTTYPE_PKIX
An x509 PKIX certificate.
@ GNUNET_DNSPARSER_CERTTYPE_IPKIX
An x509 PKIX cert URL.

◆ GNUNET_DNSPARSER_CertAlgorithm

DNSCERT algorithms as defined in http://www.iana.org/assignments/ dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml, under dns-sec-alg-numbers-1.

Enumerator
GNUNET_DNSPARSER_CERTALGO_UNDEFINED 

No defined.

GNUNET_DNSPARSER_CERTALGO_RSAMD5 

RSA/MD5.

GNUNET_DNSPARSER_CERTALGO_DH 

Diffie-Hellman.

GNUNET_DNSPARSER_CERTALGO_DSASHA 

DSA/SHA1.

GNUNET_DNSPARSER_CERTALGO_RSRVD4 

Reserved.

GNUNET_DNSPARSER_CERTALGO_RSASHA 

RSA/SHA1.

GNUNET_DNSPARSER_CERTALGO_DSANSEC3 

DSA/NSEC3/SHA.

GNUNET_DNSPARSER_CERTALGO_RSANSEC3 

RSA/NSEC3/SHA.

GNUNET_DNSPARSER_CERTALGO_RSASHA256 

RSA/SHA256.

GNUNET_DNSPARSER_CERTALGO_RSRVD9 

Reserved.

GNUNET_DNSPARSER_CERTALGO_RSASHA512 

RSA/SHA512.

GNUNET_DNSPARSER_CERTALGO_GOST_R34 

GHOST R 34.10-2001.

GNUNET_DNSPARSER_CERTALGO_ECDSA_P256SHA256 

ECDSA Curve P-256/SHA256.

GNUNET_DNSPARSER_CERTALGO_ECDSA_P384SHA384 

ECDSA Curve P-384/SHA384.

Definition at line 264 of file gnunet_dnsparser_lib.h.

265{
270
275
280
285
290
295
300
305
310
315
320
325
330
335};
@ GNUNET_DNSPARSER_CERTALGO_RSAMD5
RSA/MD5.
@ GNUNET_DNSPARSER_CERTALGO_RSASHA
RSA/SHA1.
@ GNUNET_DNSPARSER_CERTALGO_RSRVD9
Reserved.
@ GNUNET_DNSPARSER_CERTALGO_GOST_R34
GHOST R 34.10-2001.
@ GNUNET_DNSPARSER_CERTALGO_RSASHA256
RSA/SHA256.
@ GNUNET_DNSPARSER_CERTALGO_RSRVD4
Reserved.
@ GNUNET_DNSPARSER_CERTALGO_DSANSEC3
DSA/NSEC3/SHA.
@ GNUNET_DNSPARSER_CERTALGO_ECDSA_P256SHA256
ECDSA Curve P-256/SHA256.
@ GNUNET_DNSPARSER_CERTALGO_RSASHA512
RSA/SHA512.
@ GNUNET_DNSPARSER_CERTALGO_DH
Diffie-Hellman.
@ GNUNET_DNSPARSER_CERTALGO_ECDSA_P384SHA384
ECDSA Curve P-384/SHA384.
@ GNUNET_DNSPARSER_CERTALGO_RSANSEC3
RSA/NSEC3/SHA.
@ GNUNET_DNSPARSER_CERTALGO_DSASHA
DSA/SHA1.
@ GNUNET_DNSPARSER_CERTALGO_UNDEFINED
No defined.

Function Documentation

◆ GNUNET_DNSPARSER_check_label()

int GNUNET_DNSPARSER_check_label ( const char *  label)

Check if a label in UTF-8 format can be coded into valid IDNA.

This can fail if the ASCII-conversion becomes longer than 63 characters.

Parameters
labellabel to check (UTF-8 string)
Returns
GNUNET_OK if the label can be converted to IDNA, GNUNET_SYSERR if the label is not valid for DNS names

Definition at line 53 of file dnsparser.c.

54{
55 char *output;
56 size_t slen;
57
58 if (NULL != strchr (label, '.'))
59 return GNUNET_SYSERR; /* not a label! Did you mean GNUNET_DNSPARSER_check_name? */
60 if (0 == strcmp (label, "@")) /* '@' is reserved for the empty label, see #GNUNET_GNS_EMPTY_LABEL_AT */
61 return GNUNET_SYSERR;
62 if (IDNA_SUCCESS != idna_to_ascii_8z (label, &output, IDNA_ALLOW_UNASSIGNED))
63 return GNUNET_SYSERR;
64 slen = strlen (output);
65 free (output);
66 return (slen > 63) ? GNUNET_SYSERR : GNUNET_OK;
67}
@ GNUNET_OK
@ GNUNET_SYSERR

References GNUNET_OK, and GNUNET_SYSERR.

Referenced by GNUNET_DNSPARSER_check_name().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_check_name()

int GNUNET_DNSPARSER_check_name ( const char *  name)

Check if a hostname in UTF-8 format can be coded into valid IDNA.

This can fail if a label becomes longer than 63 characters or if the entire name exceeds 253 characters.

Parameters
namename to check (UTF-8 string)
Returns
GNUNET_OK if the label can be converted to IDNA, GNUNET_SYSERR if the label is not valid for DNS names

Check if a hostname in UTF-8 format can be coded into valid IDNA.

This can fail if the ASCII-conversion becomes longer than 253 characters.

Parameters
namename to check (UTF-8 string)
Returns
GNUNET_OK if the label can be converted to IDNA, GNUNET_SYSERR if the label is not valid for DNS names

Definition at line 79 of file dnsparser.c.

80{
81 char *ldup;
82 char *output;
83 size_t slen;
84 char *tok;
85
86 ldup = GNUNET_strdup (name);
87 for (tok = strtok (ldup, "."); NULL != tok; tok = strtok (NULL, "."))
89 {
90 GNUNET_free (ldup);
91 return GNUNET_SYSERR;
92 }
93 GNUNET_free (ldup);
94 if (IDNA_SUCCESS != idna_to_ascii_8z (name, &output, IDNA_ALLOW_UNASSIGNED))
95 return GNUNET_SYSERR;
96 slen = strlen (output);
97 free (output);
98 return (slen > 253) ? GNUNET_SYSERR : GNUNET_OK;
99}
static char * name
Name (label) of the records to list.
int GNUNET_DNSPARSER_check_label(const char *label)
Check if a label in UTF-8 format can be coded into valid IDNA.
Definition: dnsparser.c:53
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_DNSPARSER_check_label(), GNUNET_free, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, and name.

Referenced by queue(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_parse()

struct GNUNET_DNSPARSER_Packet * GNUNET_DNSPARSER_parse ( const char *  udp_payload,
size_t  udp_payload_length 
)

Parse a UDP payload of a DNS packet in to a nice struct for further processing and manipulation.

Parameters
udp_payloadwire-format of the DNS packet
udp_payload_lengthnumber of bytes in udp_payload
Returns
NULL on error, otherwise the parsed packet

Definition at line 729 of file dnsparser.c.

730{
732 const struct GNUNET_TUN_DnsHeader *dns;
733 size_t off;
734 unsigned int n;
735
736 if (udp_payload_length < sizeof(struct GNUNET_TUN_DnsHeader))
737 return NULL;
738 dns = (const struct GNUNET_TUN_DnsHeader *) udp_payload;
739 off = sizeof(struct GNUNET_TUN_DnsHeader);
741 p->flags = dns->flags;
742 p->id = dns->id;
743 n = ntohs (dns->query_count);
744 if (n > 0)
745 {
746 p->queries = GNUNET_new_array (n, struct GNUNET_DNSPARSER_Query);
747 p->num_queries = n;
748 for (unsigned int i = 0; i < n; i++)
749 if (GNUNET_OK != GNUNET_DNSPARSER_parse_query (udp_payload,
750 udp_payload_length,
751 &off,
752 &p->queries[i]))
753 goto error;
754 }
755 n = ntohs (dns->answer_rcount);
756 if (n > 0)
757 {
758 p->answers = GNUNET_new_array (n, struct GNUNET_DNSPARSER_Record);
759 p->num_answers = n;
760 for (unsigned int i = 0; i < n; i++)
761 if (GNUNET_OK != GNUNET_DNSPARSER_parse_record (udp_payload,
762 udp_payload_length,
763 &off,
764 &p->answers[i]))
765 goto error;
766 }
767 n = ntohs (dns->authority_rcount);
768 if (n > 0)
769 {
770 p->authority_records = GNUNET_new_array (n, struct GNUNET_DNSPARSER_Record);
771 p->num_authority_records = n;
772 for (unsigned int i = 0; i < n; i++)
773 if (GNUNET_OK != GNUNET_DNSPARSER_parse_record (udp_payload,
774 udp_payload_length,
775 &off,
776 &p->authority_records[i]))
777 goto error;
778 }
779 n = ntohs (dns->additional_rcount);
780 if (n > 0)
781 {
782 p->additional_records =
784 p->num_additional_records = n;
785 for (unsigned int i = 0; i < n; i++)
786 {
787 if (GNUNET_OK !=
789 udp_payload_length,
790 &off,
791 &p->additional_records[i]))
792 goto error;
793 }
794 }
795 return p;
796error:
797 GNUNET_break_op (0);
799 return NULL;
800}
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
void GNUNET_DNSPARSER_free_packet(struct GNUNET_DNSPARSER_Packet *p)
Free memory taken by a packet.
Definition: dnsparser.c:949
int GNUNET_DNSPARSER_parse_query(const char *udp_payload, size_t udp_payload_length, size_t *off, struct GNUNET_DNSPARSER_Query *q)
Parse a DNS query entry.
Definition: dnsparser.c:372
int GNUNET_DNSPARSER_parse_record(const char *udp_payload, size_t udp_payload_length, size_t *off, struct GNUNET_DNSPARSER_Record *r)
Parse a DNS record entry.
Definition: dnsparser.c:622
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
Easy-to-process, parsed version of a DNS packet.
A DNS response record.
struct GNUNET_TUN_DnsFlags flags
Flags.
uint16_t query_count
Number of queries.
uint16_t authority_rcount
Number of authoritative answers.
uint16_t id
Unique identifier for the request/response.
uint16_t additional_rcount
Number of additional records.
uint16_t answer_rcount
Number of answers.

References GNUNET_TUN_DnsHeader::additional_rcount, GNUNET_TUN_DnsHeader::answer_rcount, GNUNET_TUN_DnsHeader::authority_rcount, GNUNET_TUN_DnsHeader::flags, GNUNET_break_op, GNUNET_DNSPARSER_free_packet(), GNUNET_DNSPARSER_parse_query(), GNUNET_DNSPARSER_parse_record(), GNUNET_new, GNUNET_new_array, GNUNET_OK, GNUNET_TUN_DnsHeader::id, p, and GNUNET_TUN_DnsHeader::query_count.

Referenced by display_request(), dns_post_request_handler(), dns_result_parser(), dns_result_processor(), handle_dns_request(), handle_request(), handle_resolve_result(), modify_request(), and process_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_free_packet()

void GNUNET_DNSPARSER_free_packet ( struct GNUNET_DNSPARSER_Packet p)

Free memory taken by a packet.

Parameters
ppacket to free

Definition at line 949 of file dnsparser.c.

950{
951 for (unsigned int i = 0; i < p->num_queries; i++)
952 GNUNET_free (p->queries[i].name);
953 GNUNET_free (p->queries);
954 for (unsigned int i = 0; i < p->num_answers; i++)
955 GNUNET_DNSPARSER_free_record (&p->answers[i]);
956 GNUNET_free (p->answers);
957 for (unsigned int i = 0; i < p->num_authority_records; i++)
958 GNUNET_DNSPARSER_free_record (&p->authority_records[i]);
959 GNUNET_free (p->authority_records);
960 for (unsigned int i = 0; i < p->num_additional_records; i++)
961 GNUNET_DNSPARSER_free_record (&p->additional_records[i]);
962 GNUNET_free (p->additional_records);
963 GNUNET_free (p);
964}
void GNUNET_DNSPARSER_free_record(struct GNUNET_DNSPARSER_Record *r)
Free the given DNS record.
Definition: dnsparser.c:184

References GNUNET_DNSPARSER_free_record(), GNUNET_free, and p.

Referenced by display_request(), dns_post_request_handler(), dns_result_parser(), do_timeout(), finish_request(), GNS_interceptor_done(), GNUNET_DNSPARSER_parse(), handle_dns_request(), handle_request(), handle_resolve_result(), modify_request(), process_result(), recursive_dns_resolution(), reply_to_dns(), result_processor(), send_response(), and vpn_allocation_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_pack()

int GNUNET_DNSPARSER_pack ( const struct GNUNET_DNSPARSER_Packet p,
uint16_t  max,
char **  buf,
size_t *  buf_length 
)

Given a DNS packet p, generate the corresponding UDP payload.

Note that we do not attempt to pack the strings with pointers as this would complicate the code and this is about being simple and secure, not fast, fancy and broken like bind.

Parameters
ppacket to pack
maxmaximum allowed size for the resulting UDP payload
bufset to a buffer with the packed message
buf_lengthset to the length of buf
Returns
GNUNET_SYSERR if p is invalid GNUNET_NO if p was truncated (but there is still a result in buf) GNUNET_OK if p was packed completely into buf

Definition at line 1394 of file dnsparser.c.

1398{
1399 struct GNUNET_TUN_DnsHeader dns;
1400 size_t off;
1401 char tmp[max];
1402 int ret;
1403 int trc;
1404
1405 if ((p->num_queries > UINT16_MAX) || (p->num_answers > UINT16_MAX) ||
1406 (p->num_authority_records > UINT16_MAX) ||
1407 (p->num_additional_records > UINT16_MAX))
1408 return GNUNET_SYSERR;
1409 dns.id = p->id;
1410 dns.flags = p->flags;
1411 dns.query_count = htons (p->num_queries);
1412 dns.answer_rcount = htons (p->num_answers);
1413 dns.authority_rcount = htons (p->num_authority_records);
1414 dns.additional_rcount = htons (p->num_additional_records);
1415
1416 off = sizeof(struct GNUNET_TUN_DnsHeader);
1417 trc = GNUNET_NO;
1418 for (unsigned int i = 0; i < p->num_queries; i++)
1419 {
1421 sizeof(tmp),
1422 &off,
1423 &p->queries[i]);
1424 if (GNUNET_SYSERR == ret)
1425 return GNUNET_SYSERR;
1426 if (GNUNET_NO == ret)
1427 {
1428 dns.query_count = htons ((uint16_t) (i - 1));
1429 trc = GNUNET_YES;
1430 break;
1431 }
1432 }
1433 for (unsigned int i = 0; i < p->num_answers; i++)
1434 {
1435 ret = add_record (tmp, sizeof(tmp), &off, &p->answers[i]);
1436 if (GNUNET_SYSERR == ret)
1437 return GNUNET_SYSERR;
1438 if (GNUNET_NO == ret)
1439 {
1440 dns.answer_rcount = htons ((uint16_t) (i - 1));
1441 trc = GNUNET_YES;
1442 break;
1443 }
1444 }
1445 for (unsigned int i = 0; i < p->num_authority_records; i++)
1446 {
1447 ret = add_record (tmp, sizeof(tmp), &off, &p->authority_records[i]);
1448 if (GNUNET_SYSERR == ret)
1449 return GNUNET_SYSERR;
1450 if (GNUNET_NO == ret)
1451 {
1452 dns.authority_rcount = htons ((uint16_t) (i - 1));
1453 trc = GNUNET_YES;
1454 break;
1455 }
1456 }
1457 for (unsigned int i = 0; i < p->num_additional_records; i++)
1458 {
1459 ret = add_record (tmp, sizeof(tmp), &off, &p->additional_records[i]);
1460 if (GNUNET_SYSERR == ret)
1461 return GNUNET_SYSERR;
1462 if (GNUNET_NO == ret)
1463 {
1464 dns.additional_rcount = htons (i - 1);
1465 trc = GNUNET_YES;
1466 break;
1467 }
1468 }
1469
1470 if (GNUNET_YES == trc)
1471 dns.flags.message_truncated = 1;
1472 GNUNET_memcpy (tmp, &dns, sizeof(struct GNUNET_TUN_DnsHeader));
1473
1474 *buf = GNUNET_malloc (off);
1475 *buf_length = off;
1476 GNUNET_memcpy (*buf, tmp, off);
1477 if (GNUNET_YES == trc)
1478 return GNUNET_NO;
1479 return GNUNET_OK;
1480}
static int add_record(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_Record *record)
Add a DNS record to the UDP packet at the given location.
Definition: dnsparser.c:1286
static int ret
Final status code.
Definition: gnunet-arm.c:93
int GNUNET_DNSPARSER_builder_add_query(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_Query *query)
Add a DNS query to the UDP packet at the given location.
Definition: dnsparser.c:1061
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_malloc(size)
Wrapper around malloc.
#define max(x, y)

References add_record(), GNUNET_TUN_DnsHeader::additional_rcount, GNUNET_TUN_DnsHeader::answer_rcount, GNUNET_TUN_DnsHeader::authority_rcount, GNUNET_TUN_DnsHeader::flags, GNUNET_DNSPARSER_builder_add_query(), GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_TUN_DnsHeader::id, max, GNUNET_TUN_DnsFlags::message_truncated, p, GNUNET_TUN_DnsHeader::query_count, and ret.

Referenced by build_dns_query(), finish_request(), modify_request(), pack(), queue(), recursive_dns_resolution(), reply_to_dns(), and send_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_builder_add_name()

int GNUNET_DNSPARSER_builder_add_name ( char *  dst,
size_t  dst_len,
size_t *  off,
const char *  name 
)

Add a DNS name to the UDP packet at the given location, converting the name to IDNA notation as necessary.

Parameters
dstwhere to write the name (UDP packet)
dst_lennumber of bytes in dst
offpointer to offset where to write the name (increment by bytes used) must not be changed if there is an error
namename to write
Returns
GNUNET_SYSERR if name is invalid GNUNET_NO if name did not fit GNUNET_OK if name was added to dst

Definition at line 984 of file dnsparser.c.

988{
989 const char *dot;
990 const char *idna_name;
991 char *idna_start;
992 size_t start;
993 size_t pos;
994 size_t len;
995 Idna_rc rc;
996
997 if (NULL == name)
998 return GNUNET_SYSERR;
999
1000 if (IDNA_SUCCESS !=
1001 (rc = idna_to_ascii_8z (name, &idna_start, IDNA_ALLOW_UNASSIGNED)))
1002 {
1004 _ (
1005 "Failed to convert UTF-8 name `%s' to DNS IDNA format: %s\n"),
1006 name,
1007 idna_strerror (rc));
1008 return GNUNET_NO;
1009 }
1010 idna_name = idna_start;
1011 start = *off;
1012 if (start + strlen (idna_name) + 2 > dst_len)
1013 goto fail;
1014 pos = start;
1015 do
1016 {
1017 dot = strchr (idna_name, '.');
1018 if (NULL == dot)
1019 len = strlen (idna_name);
1020 else
1021 len = dot - idna_name;
1022 if (len == 0)
1023 break;
1024 if (len >= 64)
1025 {
1027 "Invalid DNS name `%s': label with %u characters encountered\n",
1028 name,
1029 (unsigned int) len);
1030 goto fail; /* label too long or empty */
1031 }
1032 dst[pos++] = (char) (uint8_t) len;
1033 GNUNET_memcpy (&dst[pos], idna_name, len);
1034 pos += len;
1035 idna_name += len + 1; /* also skip dot */
1036 }
1037 while (NULL != dot);
1038 dst[pos++] = '\0'; /* terminator */
1039 *off = pos;
1040 free (idna_start);
1041 return GNUNET_OK;
1042fail:
1043 free (idna_start);
1044 return GNUNET_NO;
1045}
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:38
char * idna_name
DNS IDNA name to lookup.
Definition: gnunet-gns.c:63
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
#define _(String)
GNU gettext support macro.
Definition: platform.h:178

References _, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, idna_name, name, and start.

Referenced by add_record(), check_for_glue(), dns_result_parser(), dns_string_to_value(), gns_string_to_value(), GNUNET_DNSPARSER_builder_add_mx(), GNUNET_DNSPARSER_builder_add_query(), GNUNET_DNSPARSER_builder_add_soa(), GNUNET_DNSPARSER_builder_add_srv(), handle_gns_resolution_result(), and process_record().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_builder_add_query()

int GNUNET_DNSPARSER_builder_add_query ( char *  dst,
size_t  dst_len,
size_t *  off,
const struct GNUNET_DNSPARSER_Query query 
)

Add a DNS query to the UDP packet at the given location.

Parameters
dstwhere to write the query
dst_lennumber of bytes in dst
offpointer to offset where to write the query (increment by bytes used) must not be changed if there is an error
queryquery to write
Returns
GNUNET_SYSERR if query is invalid GNUNET_NO if query did not fit GNUNET_OK if query was added to dst

Definition at line 1061 of file dnsparser.c.

1065{
1066 int ret;
1067 struct GNUNET_TUN_DnsQueryLine ql;
1068
1070 dst_len
1071 - sizeof(
1073 off,
1074 query->name);
1075 if (ret != GNUNET_OK)
1076 return ret;
1077 ql.type = htons (query->type);
1078 ql.dns_traffic_class = htons (query->dns_traffic_class);
1079 GNUNET_memcpy (&dst[*off], &ql, sizeof(ql));
1080 (*off) += sizeof(ql);
1081 return GNUNET_OK;
1082}
int GNUNET_DNSPARSER_builder_add_name(char *dst, size_t dst_len, size_t *off, const char *name)
Add a DNS name to the UDP packet at the given location, converting the name to IDNA notation as neces...
Definition: dnsparser.c:984
uint16_t dns_traffic_class
See GNUNET_TUN_DNS_CLASS_*.
uint16_t type
See GNUNET_DNSPARSER_TYPE_*.
char * name
Name of the record that the query is for (0-terminated).
DNS query prefix.

References GNUNET_DNSPARSER_Query::dns_traffic_class, GNUNET_TUN_DnsQueryLine::dns_traffic_class, GNUNET_DNSPARSER_builder_add_name(), GNUNET_memcpy, GNUNET_OK, GNUNET_DNSPARSER_Query::name, ret, GNUNET_DNSPARSER_Query::type, and GNUNET_TUN_DnsQueryLine::type.

Referenced by GNUNET_DNSPARSER_pack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_builder_add_mx()

int GNUNET_DNSPARSER_builder_add_mx ( char *  dst,
size_t  dst_len,
size_t *  off,
const struct GNUNET_DNSPARSER_MxRecord mx 
)

Add an MX record to the UDP packet at the given location.

Parameters
dstwhere to write the mx record
dst_lennumber of bytes in dst
offpointer to offset where to write the mx information (increment by bytes used); can also change if there was an error
mxmx information to write
Returns
GNUNET_SYSERR if mx is invalid GNUNET_NO if mx did not fit GNUNET_OK if mx was added to dst

Definition at line 1098 of file dnsparser.c.

1102{
1103 uint16_t mxpref;
1104
1105 if (*off + sizeof(uint16_t) > dst_len)
1106 return GNUNET_NO;
1107 mxpref = htons (mx->preference);
1108 GNUNET_memcpy (&dst[*off], &mxpref, sizeof(mxpref));
1109 (*off) += sizeof(mxpref);
1110 return GNUNET_DNSPARSER_builder_add_name (dst, dst_len, off, mx->mxhost);
1111}
char * mxhost
Name of the mail server.
uint16_t preference
Preference for this entry (lower value is higher preference).

References GNUNET_DNSPARSER_builder_add_name(), GNUNET_memcpy, GNUNET_NO, GNUNET_DNSPARSER_MxRecord::mxhost, and GNUNET_DNSPARSER_MxRecord::preference.

Referenced by add_record(), dns_result_parser(), dns_string_to_value(), handle_gns_resolution_result(), and process_record().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_builder_add_soa()

int GNUNET_DNSPARSER_builder_add_soa ( char *  dst,
size_t  dst_len,
size_t *  off,
const struct GNUNET_DNSPARSER_SoaRecord soa 
)

Add an SOA record to the UDP packet at the given location.

Parameters
dstwhere to write the SOA record
dst_lennumber of bytes in dst
offpointer to offset where to write the SOA information (increment by bytes used) can also change if there was an error
soaSOA information to write
Returns
GNUNET_SYSERR if soa is invalid GNUNET_NO if soa did not fit GNUNET_OK if soa was added to dst

Definition at line 1174 of file dnsparser.c.

1178{
1179 struct GNUNET_TUN_DnsSoaRecord sd;
1180 int ret;
1181
1182 if ((GNUNET_OK !=
1183 (ret =
1184 GNUNET_DNSPARSER_builder_add_name (dst, dst_len, off, soa->mname))) ||
1185 (GNUNET_OK !=
1186 (ret =
1187 GNUNET_DNSPARSER_builder_add_name (dst, dst_len, off, soa->rname))))
1188 return ret;
1189 if (*off + sizeof(struct GNUNET_TUN_DnsSoaRecord) > dst_len)
1190 return GNUNET_NO;
1191 sd.serial = htonl (soa->serial);
1192 sd.refresh = htonl (soa->refresh);
1193 sd.retry = htonl (soa->retry);
1194 sd.expire = htonl (soa->expire);
1195 sd.minimum = htonl (soa->minimum_ttl);
1196 GNUNET_memcpy (&dst[*off], &sd, sizeof(sd));
1197 (*off) += sizeof(sd);
1198 return GNUNET_OK;
1199}
uint32_t retry
Time interval that should elapse before a failed refresh should be retried.
char * mname
The domainname of the name server that was the original or primary source of data for this zone.
uint32_t refresh
Time interval before the zone should be refreshed.
uint32_t minimum_ttl
The bit minimum TTL field that should be exported with any RR from this zone.
char * rname
A domainname which specifies the mailbox of the person responsible for this zone.
uint32_t expire
Time value that specifies the upper limit on the time interval that can elapse before the zone is no ...
uint32_t serial
The version number of the original copy of the zone.
Payload of DNS SOA record (header).

References GNUNET_DNSPARSER_SoaRecord::expire, GNUNET_TUN_DnsSoaRecord::expire, GNUNET_DNSPARSER_builder_add_name(), GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_TUN_DnsSoaRecord::minimum, GNUNET_DNSPARSER_SoaRecord::minimum_ttl, GNUNET_DNSPARSER_SoaRecord::mname, GNUNET_DNSPARSER_SoaRecord::refresh, GNUNET_TUN_DnsSoaRecord::refresh, ret, GNUNET_DNSPARSER_SoaRecord::retry, GNUNET_TUN_DnsSoaRecord::retry, GNUNET_DNSPARSER_SoaRecord::rname, GNUNET_DNSPARSER_SoaRecord::serial, and GNUNET_TUN_DnsSoaRecord::serial.

Referenced by add_record(), dns_result_parser(), dns_string_to_value(), handle_gns_resolution_result(), and process_record().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_builder_add_cert()

int GNUNET_DNSPARSER_builder_add_cert ( char *  dst,
size_t  dst_len,
size_t *  off,
const struct GNUNET_DNSPARSER_CertRecord cert 
)

Add CERT record to the UDP packet at the given location.

Parameters
dstwhere to write the CERT record
dst_lennumber of bytes in dst
offpointer to offset where to write the CERT information (increment by bytes used) can also change if there was an error
certCERT information to write
Returns
GNUNET_SYSERR if soa is invalid GNUNET_NO if soa did not fit GNUNET_OK if soa was added to dst

Add CERT record to the UDP packet at the given location.

Parameters
dstwhere to write the CERT record
dst_lennumber of bytes in dst
offpointer to offset where to write the CERT information (increment by bytes used); can also change if there was an error
certCERT information to write
Returns
GNUNET_SYSERR if cert is invalid GNUNET_NO if cert did not fit GNUNET_OK if cert was added to dst

Definition at line 1127 of file dnsparser.c.

1132{
1133 struct GNUNET_TUN_DnsCertRecord dcert;
1134
1135#ifdef __clang__
1136#pragma clang diagnostic push
1137#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
1138#endif
1139 if ((cert->cert_type > UINT16_MAX) || (cert->algorithm > UINT8_MAX))
1140 {
1141 GNUNET_break (0);
1142 return GNUNET_SYSERR;
1143 }
1144#ifdef __clang__
1145#pragma clang diagnostic pop
1146#endif
1147 if (*off + sizeof(struct GNUNET_TUN_DnsCertRecord) + cert->certificate_size >
1148 dst_len)
1149 return GNUNET_NO;
1150 dcert.cert_type = htons ((uint16_t) cert->cert_type);
1151 dcert.cert_tag = htons ((uint16_t) cert->cert_tag);
1152 dcert.algorithm = (uint8_t) cert->algorithm;
1153 GNUNET_memcpy (&dst[*off], &dcert, sizeof(dcert));
1154 (*off) += sizeof(dcert);
1155 GNUNET_memcpy (&dst[*off], cert->certificate_data, cert->certificate_size);
1156 (*off) += cert->certificate_size;
1157 return GNUNET_OK;
1158}
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
enum GNUNET_DNSPARSER_CertType cert_type
Certificate type.
char * certificate_data
Data of the certificate.
enum GNUNET_DNSPARSER_CertAlgorithm algorithm
Algorithm.
size_t certificate_size
Number of bytes in certificate_data.
uint16_t cert_tag
Certificate KeyTag.
Payload of DNS CERT record.

References GNUNET_DNSPARSER_CertRecord::algorithm, GNUNET_TUN_DnsCertRecord::algorithm, GNUNET_DNSPARSER_CertRecord::cert_tag, GNUNET_TUN_DnsCertRecord::cert_tag, GNUNET_DNSPARSER_CertRecord::cert_type, GNUNET_TUN_DnsCertRecord::cert_type, GNUNET_DNSPARSER_CertRecord::certificate_data, GNUNET_DNSPARSER_CertRecord::certificate_size, GNUNET_break, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, and GNUNET_SYSERR.

Referenced by add_record(), dns_string_to_value(), and process_record().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_builder_add_srv()

int GNUNET_DNSPARSER_builder_add_srv ( char *  dst,
size_t  dst_len,
size_t *  off,
const struct GNUNET_DNSPARSER_SrvRecord srv 
)

Add an SRV record to the UDP packet at the given location.

Parameters
dstwhere to write the SRV record
dst_lennumber of bytes in dst
offpointer to offset where to write the SRV information (increment by bytes used) can also change if there was an error
srvSRV information to write
Returns
GNUNET_SYSERR if srv is invalid GNUNET_NO if srv did not fit GNUNET_OK if srv was added to dst

Definition at line 1215 of file dnsparser.c.

1219{
1220 struct GNUNET_TUN_DnsSrvRecord sd;
1221 int ret;
1222
1223 if (*off + sizeof(struct GNUNET_TUN_DnsSrvRecord) > dst_len)
1224 return GNUNET_NO;
1225 sd.prio = htons (srv->priority);
1226 sd.weight = htons (srv->weight);
1227 sd.port = htons (srv->port);
1228 GNUNET_memcpy (&dst[*off], &sd, sizeof(sd));
1229 (*off) += sizeof(sd);
1230 if (GNUNET_OK !=
1231 (ret =
1232 GNUNET_DNSPARSER_builder_add_name (dst, dst_len, off, srv->target)))
1233 return ret;
1234 return GNUNET_OK;
1235}
uint16_t port
TCP or UDP port of the service.
uint16_t weight
Relative weight for records with the same priority.
uint16_t priority
Preference for this entry (lower value is higher preference).
char * target
Hostname offering the service.
Payload of DNS SRV record (header).

References GNUNET_DNSPARSER_builder_add_name(), GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_DNSPARSER_SrvRecord::port, GNUNET_TUN_DnsSrvRecord::port, GNUNET_TUN_DnsSrvRecord::prio, GNUNET_DNSPARSER_SrvRecord::priority, ret, GNUNET_DNSPARSER_SrvRecord::target, GNUNET_DNSPARSER_SrvRecord::weight, and GNUNET_TUN_DnsSrvRecord::weight.

Referenced by add_record(), dns_result_parser(), dns_string_to_value(), handle_gns_resolution_result(), and process_record().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_builder_add_uri()

int GNUNET_DNSPARSER_builder_add_uri ( char *  dst,
size_t  dst_len,
size_t *  off,
const struct GNUNET_DNSPARSER_UriRecord uri 
)

Add an URI record to the UDP packet at the given location.

Parameters
dstwhere to write the URI record
dst_lennumber of bytes in dst
offpointer to offset where to write the URI information (increment by bytes used) can also change if there was an error
uriURI information to write
Returns
GNUNET_SYSERR if uri is invalid GNUNET_NO if uri did not fit GNUNET_OK if uri was added to dst

Definition at line 1251 of file dnsparser.c.

1255{
1256 struct GNUNET_TUN_DnsUriRecord sd;
1257
1258 if (*off + sizeof(struct GNUNET_TUN_DnsUriRecord) > dst_len)
1259 return GNUNET_NO;
1260 sd.prio = htons (uri->priority);
1261 sd.weight = htons (uri->weight);
1262 GNUNET_memcpy (&dst[*off], &sd, sizeof(sd));
1263 (*off) += sizeof(sd);
1264 strncpy (&dst[*off], uri->target, dst_len - sizeof(struct
1266 - 1);
1267 (*off) += strlen (uri->target);
1268 dst[*off] = '\0';
1269 return GNUNET_OK;
1270}
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
Payload of DNS URI record (header).

References GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_TUN_DnsUriRecord::prio, uri, and GNUNET_TUN_DnsUriRecord::weight.

Referenced by add_record(), dns_result_parser(), dns_string_to_value(), handle_gns_resolution_result(), and process_record().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_parse_record()

int GNUNET_DNSPARSER_parse_record ( const char *  udp_payload,
size_t  udp_payload_length,
size_t *  off,
struct GNUNET_DNSPARSER_Record r 
)

Parse a DNS record entry.

Parameters
udp_payloadentire UDP payload
udp_payload_lengthlength of udp_payload
offpointer to the offset of the record to parse in the udp_payload (to be incremented by the size of the record)
rwhere to write the record information
Returns
GNUNET_OK on success, GNUNET_SYSERR if the record is malformed

Definition at line 622 of file dnsparser.c.

626{
627 char *name;
628 struct GNUNET_TUN_DnsRecordLine rl;
629 size_t old_off;
630 uint16_t data_len;
631
632 name = GNUNET_DNSPARSER_parse_name (udp_payload, udp_payload_length, off);
633 if (NULL == name)
634 {
635 GNUNET_break_op (0);
636 return GNUNET_SYSERR;
637 }
638 r->name = name;
639 if (*off + sizeof(struct GNUNET_TUN_DnsRecordLine) > udp_payload_length)
640 {
641 GNUNET_break_op (0);
642 return GNUNET_SYSERR;
643 }
644 GNUNET_memcpy (&rl, &udp_payload[*off], sizeof(rl));
645 (*off) += sizeof(rl);
646 r->type = ntohs (rl.type);
647 r->dns_traffic_class = ntohs (rl.dns_traffic_class);
650 data_len = ntohs (rl.data_len);
651 if (*off + data_len > udp_payload_length)
652 {
653 GNUNET_break_op (0);
654 return GNUNET_SYSERR;
655 }
656 old_off = *off;
657 switch (r->type)
658 {
663 r->data.hostname =
664 GNUNET_DNSPARSER_parse_name (udp_payload, udp_payload_length, off);
665 if ((NULL == r->data.hostname) || (old_off + data_len != *off))
666 return GNUNET_SYSERR;
667 return GNUNET_OK;
668
670 r->data.soa =
671 GNUNET_DNSPARSER_parse_soa (udp_payload, udp_payload_length, off);
672 if ((NULL == r->data.soa) || (old_off + data_len != *off))
673 {
674 GNUNET_break_op (0);
675 return GNUNET_SYSERR;
676 }
677 return GNUNET_OK;
678
680 r->data.mx =
681 GNUNET_DNSPARSER_parse_mx (udp_payload, udp_payload_length, off);
682 if ((NULL == r->data.mx) || (old_off + data_len != *off))
683 {
684 GNUNET_break_op (0);
685 return GNUNET_SYSERR;
686 }
687 return GNUNET_OK;
688
690 r->data.srv =
691 GNUNET_DNSPARSER_parse_srv (udp_payload, udp_payload_length, off);
692 if ((NULL == r->data.srv) || (old_off + data_len != *off))
693 {
694 GNUNET_break_op (0);
695 return GNUNET_SYSERR;
696 }
697 return GNUNET_OK;
698
700 r->data.uri =
701 GNUNET_DNSPARSER_parse_uri (udp_payload, udp_payload_length, off);
702 if ((NULL == r->data.uri) || (old_off + data_len != *off))
703 {
704 GNUNET_break_op (0);
705 return GNUNET_SYSERR;
706 }
707 return GNUNET_OK;
708
709 default:
712 GNUNET_memcpy (r->data.raw.data, &udp_payload[*off], data_len);
713 break;
714 }
715 (*off) += data_len;
716 return GNUNET_OK;
717}
#define GNUNET_DNSPARSER_TYPE_URI
struct GNUNET_DNSPARSER_MxRecord * GNUNET_DNSPARSER_parse_mx(const char *udp_payload, size_t udp_payload_length, size_t *off)
Parse a DNS MX record.
Definition: dnsparser.c:455
#define GNUNET_DNSPARSER_TYPE_SRV
#define GNUNET_DNSPARSER_TYPE_SOA
#define GNUNET_DNSPARSER_TYPE_PTR
struct GNUNET_DNSPARSER_SoaRecord * GNUNET_DNSPARSER_parse_soa(const char *udp_payload, size_t udp_payload_length, size_t *off)
Parse a DNS SOA record.
Definition: dnsparser.c:410
#define GNUNET_DNSPARSER_TYPE_NS
#define GNUNET_DNSPARSER_TYPE_CNAME
#define GNUNET_DNSPARSER_TYPE_DNAME
struct GNUNET_DNSPARSER_UriRecord * GNUNET_DNSPARSER_parse_uri(const char *udp_payload, size_t udp_payload_length, size_t *off)
Parse a DNS URI record.
Definition: dnsparser.c:537
struct GNUNET_DNSPARSER_SrvRecord * GNUNET_DNSPARSER_parse_srv(const char *udp_payload, size_t udp_payload_length, size_t *off)
Parse a DNS SRV record.
Definition: dnsparser.c:496
char * GNUNET_DNSPARSER_parse_name(const char *udp_payload, size_t udp_payload_length, size_t *off)
Parse name inside of a DNS query or record.
Definition: dnsparser.c:353
#define GNUNET_DNSPARSER_TYPE_MX
#define GNUNET_TIME_UNIT_SECONDS
One second.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:316
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:486
void * data
Binary record data.
size_t data_len
Number of bytes in data.
uint16_t dns_traffic_class
See GNUNET_TUN_DNS_CLASS_*.
struct GNUNET_DNSPARSER_SoaRecord * soa
SOA data for SOA records.
struct GNUNET_DNSPARSER_SrvRecord * srv
SRV data for SRV records.
struct GNUNET_DNSPARSER_MxRecord * mx
MX data for MX records.
char * hostname
For NS, CNAME and PTR records, this is the uncompressed 0-terminated hostname.
uint16_t type
See GNUNET_DNSPARSER_TYPE_*.
struct GNUNET_TIME_Absolute expiration_time
When does the record expire?
char * name
Name of the record that the query is for (0-terminated).
struct GNUNET_DNSPARSER_RawRecord raw
Raw data for all other types.
union GNUNET_DNSPARSER_Record::@20 data
Payload of the record (which one of these is valid depends on the 'type').
struct GNUNET_DNSPARSER_UriRecord * uri
URI data for URI records.
General DNS record prefix.
uint16_t data_len
Number of bytes of data that follow.

References GNUNET_DNSPARSER_RawRecord::data, GNUNET_DNSPARSER_Record::data, GNUNET_DNSPARSER_RawRecord::data_len, GNUNET_TUN_DnsRecordLine::data_len, GNUNET_DNSPARSER_Record::dns_traffic_class, GNUNET_TUN_DnsRecordLine::dns_traffic_class, GNUNET_DNSPARSER_Record::expiration_time, GNUNET_break_op, GNUNET_DNSPARSER_parse_mx(), GNUNET_DNSPARSER_parse_name(), GNUNET_DNSPARSER_parse_soa(), GNUNET_DNSPARSER_parse_srv(), GNUNET_DNSPARSER_parse_uri(), GNUNET_DNSPARSER_TYPE_CNAME, GNUNET_DNSPARSER_TYPE_DNAME, GNUNET_DNSPARSER_TYPE_MX, GNUNET_DNSPARSER_TYPE_NS, GNUNET_DNSPARSER_TYPE_PTR, GNUNET_DNSPARSER_TYPE_SOA, GNUNET_DNSPARSER_TYPE_SRV, GNUNET_DNSPARSER_TYPE_URI, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_SECONDS, GNUNET_DNSPARSER_Record::hostname, GNUNET_DNSPARSER_Record::mx, name, GNUNET_DNSPARSER_Record::name, GNUNET_DNSPARSER_Record::raw, GNUNET_DNSPARSER_Record::soa, GNUNET_DNSPARSER_Record::srv, GNUNET_TUN_DnsRecordLine::ttl, GNUNET_DNSPARSER_Record::type, GNUNET_TUN_DnsRecordLine::type, and GNUNET_DNSPARSER_Record::uri.

Referenced by GNUNET_DNSPARSER_parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_parse_name()

char * GNUNET_DNSPARSER_parse_name ( const char *  udp_payload,
size_t  udp_payload_length,
size_t *  off 
)

Parse name inside of a DNS query or record.

Parameters
udp_payloadentire UDP payload
udp_payload_lengthlength of udp_payload
offpointer to the offset of the name to parse in the udp_payload (to be incremented by the size of the name)
Returns
name as 0-terminated C string on success, NULL if the payload is malformed

Definition at line 353 of file dnsparser.c.

356{
357 return parse_name (udp_payload, udp_payload_length, off, 0);
358}
static char * parse_name(const char *udp_payload, size_t udp_payload_length, size_t *off, unsigned int depth)
Parse name inside of a DNS query or record.
Definition: dnsparser.c:233

References parse_name().

Referenced by dns_value_to_string(), gns_value_to_string(), GNUNET_DNSPARSER_parse_mx(), GNUNET_DNSPARSER_parse_query(), GNUNET_DNSPARSER_parse_record(), GNUNET_DNSPARSER_parse_soa(), GNUNET_DNSPARSER_parse_srv(), handle_gns_resolution_result(), recursive_cname_resolution(), recursive_gns2dns_resolution(), and reply_to_dns().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_parse_query()

int GNUNET_DNSPARSER_parse_query ( const char *  udp_payload,
size_t  udp_payload_length,
size_t *  off,
struct GNUNET_DNSPARSER_Query q 
)

Parse a DNS query entry.

Parameters
udp_payloadentire UDP payload
udp_payload_lengthlength of udp_payload
offpointer to the offset of the query to parse in the udp_payload (to be incremented by the size of the query)
qwhere to write the query information
Returns
GNUNET_OK on success, GNUNET_SYSERR if the query is malformed

Definition at line 372 of file dnsparser.c.

376{
377 char *name;
378 struct GNUNET_TUN_DnsQueryLine ql;
379
380 name = GNUNET_DNSPARSER_parse_name (udp_payload, udp_payload_length, off);
381 if (NULL == name)
382 {
383 GNUNET_break_op (0);
384 return GNUNET_SYSERR;
385 }
386 q->name = name;
387 if (*off + sizeof(struct GNUNET_TUN_DnsQueryLine) > udp_payload_length)
388 {
389 GNUNET_break_op (0);
390 return GNUNET_SYSERR;
391 }
392 GNUNET_memcpy (&ql, &udp_payload[*off], sizeof(ql));
393 *off += sizeof(ql);
394 q->type = ntohs (ql.type);
395 q->dns_traffic_class = ntohs (ql.dns_traffic_class);
396 return GNUNET_OK;
397}
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.

References GNUNET_TUN_DnsQueryLine::dns_traffic_class, GNUNET_break_op, GNUNET_DNSPARSER_parse_name(), GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, name, q, and GNUNET_TUN_DnsQueryLine::type.

Referenced by GNUNET_DNSPARSER_parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_parse_soa()

struct GNUNET_DNSPARSER_SoaRecord * GNUNET_DNSPARSER_parse_soa ( const char *  udp_payload,
size_t  udp_payload_length,
size_t *  off 
)

Parse a DNS SOA record.

Parameters
udp_payloadreference to UDP packet
udp_payload_lengthlength of udp_payload
offpointer to the offset of the query to parse in the SOA record (to be incremented by the size of the record), unchanged on error
Returns
the parsed SOA record, NULL on error

Definition at line 410 of file dnsparser.c.

413{
414 struct GNUNET_DNSPARSER_SoaRecord *soa;
415 struct GNUNET_TUN_DnsSoaRecord soa_bin;
416 size_t old_off;
417
418 old_off = *off;
420 soa->mname =
421 GNUNET_DNSPARSER_parse_name (udp_payload, udp_payload_length, off);
422 soa->rname =
423 GNUNET_DNSPARSER_parse_name (udp_payload, udp_payload_length, off);
424 if ((NULL == soa->mname) || (NULL == soa->rname) ||
425 (*off + sizeof(struct GNUNET_TUN_DnsSoaRecord) > udp_payload_length))
426 {
427 GNUNET_break_op (0);
429 *off = old_off;
430 return NULL;
431 }
432 GNUNET_memcpy (&soa_bin,
433 &udp_payload[*off],
434 sizeof(struct GNUNET_TUN_DnsSoaRecord));
435 soa->serial = ntohl (soa_bin.serial);
436 soa->refresh = ntohl (soa_bin.refresh);
437 soa->retry = ntohl (soa_bin.retry);
438 soa->expire = ntohl (soa_bin.expire);
439 soa->minimum_ttl = ntohl (soa_bin.minimum);
440 (*off) += sizeof(struct GNUNET_TUN_DnsSoaRecord);
441 return soa;
442}
void GNUNET_DNSPARSER_free_soa(struct GNUNET_DNSPARSER_SoaRecord *soa)
Free SOA information record.
Definition: dnsparser.c:108
Information from SOA records (RFC 1035).

References GNUNET_DNSPARSER_SoaRecord::expire, GNUNET_TUN_DnsSoaRecord::expire, GNUNET_break_op, GNUNET_DNSPARSER_free_soa(), GNUNET_DNSPARSER_parse_name(), GNUNET_memcpy, GNUNET_new, GNUNET_TUN_DnsSoaRecord::minimum, GNUNET_DNSPARSER_SoaRecord::minimum_ttl, GNUNET_DNSPARSER_SoaRecord::mname, GNUNET_DNSPARSER_SoaRecord::refresh, GNUNET_TUN_DnsSoaRecord::refresh, GNUNET_DNSPARSER_SoaRecord::retry, GNUNET_TUN_DnsSoaRecord::retry, GNUNET_DNSPARSER_SoaRecord::rname, GNUNET_DNSPARSER_SoaRecord::serial, and GNUNET_TUN_DnsSoaRecord::serial.

Referenced by dns_value_to_string(), GNUNET_DNSPARSER_parse_record(), handle_gns_resolution_result(), and reply_to_dns().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_parse_cert()

struct GNUNET_DNSPARSER_CertRecord * GNUNET_DNSPARSER_parse_cert ( const char *  udp_payload,
size_t  udp_payload_length,
size_t *  off 
)

Parse a DNS CERT record.

Parameters
udp_payloadreference to UDP packet
udp_payload_lengthlength of udp_payload
offpointer to the offset of the query to parse in the CERT record (to be incremented by the size of the record), unchanged on error
Returns
the parsed CERT record, NULL on error

Definition at line 581 of file dnsparser.c.

584{
585 struct GNUNET_DNSPARSER_CertRecord *cert;
586 struct GNUNET_TUN_DnsCertRecord dcert;
587
588 if (*off + sizeof(struct GNUNET_TUN_DnsCertRecord) >= udp_payload_length)
589 {
590 GNUNET_break_op (0);
591 return NULL;
592 }
593 GNUNET_memcpy (&dcert,
594 &udp_payload[*off],
595 sizeof(struct GNUNET_TUN_DnsCertRecord));
596 (*off) += sizeof(struct GNUNET_TUN_DnsCertRecord);
598 cert->cert_type = ntohs (dcert.cert_type);
599 cert->cert_tag = ntohs (dcert.cert_tag);
600 cert->algorithm = dcert.algorithm;
601 cert->certificate_size = udp_payload_length - (*off);
604 &udp_payload[*off],
605 cert->certificate_size);
606 (*off) += cert->certificate_size;
607 return cert;
608}
Information from CERT records (RFC 4034).

References GNUNET_DNSPARSER_CertRecord::algorithm, GNUNET_TUN_DnsCertRecord::algorithm, GNUNET_DNSPARSER_CertRecord::cert_tag, GNUNET_TUN_DnsCertRecord::cert_tag, GNUNET_DNSPARSER_CertRecord::cert_type, GNUNET_TUN_DnsCertRecord::cert_type, GNUNET_DNSPARSER_CertRecord::certificate_data, GNUNET_DNSPARSER_CertRecord::certificate_size, GNUNET_break_op, GNUNET_malloc, GNUNET_memcpy, and GNUNET_new.

Referenced by dns_value_to_string().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_parse_mx()

struct GNUNET_DNSPARSER_MxRecord * GNUNET_DNSPARSER_parse_mx ( const char *  udp_payload,
size_t  udp_payload_length,
size_t *  off 
)

Parse a DNS MX record.

Parameters
udp_payloadreference to UDP packet
udp_payload_lengthlength of udp_payload
offpointer to the offset of the query to parse in the MX record (to be incremented by the size of the record), unchanged on error
Returns
the parsed MX record, NULL on error

Definition at line 455 of file dnsparser.c.

458{
459 struct GNUNET_DNSPARSER_MxRecord *mx;
460 uint16_t mxpref;
461 size_t old_off;
462
463 old_off = *off;
464 if (*off + sizeof(uint16_t) > udp_payload_length)
465 {
466 GNUNET_break_op (0);
467 return NULL;
468 }
469 GNUNET_memcpy (&mxpref, &udp_payload[*off], sizeof(uint16_t));
470 (*off) += sizeof(uint16_t);
472 mx->preference = ntohs (mxpref);
473 mx->mxhost =
474 GNUNET_DNSPARSER_parse_name (udp_payload, udp_payload_length, off);
475 if (NULL == mx->mxhost)
476 {
477 GNUNET_break_op (0);
479 *off = old_off;
480 return NULL;
481 }
482 return mx;
483}
void GNUNET_DNSPARSER_free_mx(struct GNUNET_DNSPARSER_MxRecord *mx)
Free MX information record.
Definition: dnsparser.c:169
Information from MX records (RFC 1035).

References GNUNET_break_op, GNUNET_DNSPARSER_free_mx(), GNUNET_DNSPARSER_parse_name(), GNUNET_memcpy, GNUNET_new, GNUNET_DNSPARSER_MxRecord::mxhost, and GNUNET_DNSPARSER_MxRecord::preference.

Referenced by dns_value_to_string(), GNUNET_DNSPARSER_parse_record(), handle_gns_resolution_result(), and reply_to_dns().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_parse_srv()

struct GNUNET_DNSPARSER_SrvRecord * GNUNET_DNSPARSER_parse_srv ( const char *  udp_payload,
size_t  udp_payload_length,
size_t *  off 
)

Parse a DNS SRV record.

Parameters
udp_payloadreference to UDP packet
udp_payload_lengthlength of udp_payload
offpointer to the offset of the query to parse in the SRV record (to be incremented by the size of the record), unchanged on error
Returns
the parsed SRV record, NULL on error

Definition at line 496 of file dnsparser.c.

499{
500 struct GNUNET_DNSPARSER_SrvRecord *srv;
501 struct GNUNET_TUN_DnsSrvRecord srv_bin;
502 size_t old_off;
503
504 old_off = *off;
505 if (*off + sizeof(struct GNUNET_TUN_DnsSrvRecord) > udp_payload_length)
506 return NULL;
507 GNUNET_memcpy (&srv_bin,
508 &udp_payload[*off],
509 sizeof(struct GNUNET_TUN_DnsSrvRecord));
510 (*off) += sizeof(struct GNUNET_TUN_DnsSrvRecord);
512 srv->priority = ntohs (srv_bin.prio);
513 srv->weight = ntohs (srv_bin.weight);
514 srv->port = ntohs (srv_bin.port);
515 srv->target =
516 GNUNET_DNSPARSER_parse_name (udp_payload, udp_payload_length, off);
517 if (NULL == srv->target)
518 {
520 *off = old_off;
521 return NULL;
522 }
523 return srv;
524}
void GNUNET_DNSPARSER_free_srv(struct GNUNET_DNSPARSER_SrvRecord *srv)
Free SRV information record.
Definition: dnsparser.c:139
Information from SRV records (RFC 2782).

References GNUNET_DNSPARSER_free_srv(), GNUNET_DNSPARSER_parse_name(), GNUNET_memcpy, GNUNET_new, GNUNET_DNSPARSER_SrvRecord::port, GNUNET_TUN_DnsSrvRecord::port, GNUNET_TUN_DnsSrvRecord::prio, GNUNET_DNSPARSER_SrvRecord::priority, GNUNET_DNSPARSER_SrvRecord::target, GNUNET_DNSPARSER_SrvRecord::weight, and GNUNET_TUN_DnsSrvRecord::weight.

Referenced by dns_value_to_string(), GNUNET_DNSPARSER_parse_record(), and handle_gns_resolution_result().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_parse_uri()

struct GNUNET_DNSPARSER_UriRecord * GNUNET_DNSPARSER_parse_uri ( const char *  udp_payload,
size_t  udp_payload_length,
size_t *  off 
)

Parse a DNS URI record.

Parameters
udp_payloadreference to UDP packet
udp_payload_lengthlength of udp_payload
offpointer to the offset of the query to parse in the URI record (to be incremented by the size of the record), unchanged on error
Returns
the parsed URI record, NULL on error

Definition at line 537 of file dnsparser.c.

540{
542 struct GNUNET_TUN_DnsUriRecord uri_bin;
543 size_t old_off;
544 int max_len;
545 int len;
546
547 old_off = *off;
548 if (*off + sizeof(struct GNUNET_TUN_DnsUriRecord) > udp_payload_length)
549 return NULL;
550 GNUNET_memcpy (&uri_bin,
551 &udp_payload[*off],
552 sizeof(struct GNUNET_TUN_DnsUriRecord));
553 (*off) += sizeof(struct GNUNET_TUN_DnsUriRecord);
555 uri->priority = ntohs (uri_bin.prio);
556 uri->weight = ntohs (uri_bin.weight);
557 max_len = udp_payload_length - sizeof(struct GNUNET_TUN_DnsUriRecord);
558 len = GNUNET_asprintf (&(uri->target), "%.*s", max_len,
559 &udp_payload[*off]);
560 (*off) += len;
561 if (NULL == uri->target)
562 {
564 *off = old_off;
565 return NULL;
566 }
567 return uri;
568}
void GNUNET_DNSPARSER_free_uri(struct GNUNET_DNSPARSER_UriRecord *uri)
Free URI information record.
Definition: dnsparser.c:154
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
Information from URI records (RFC 7553).

References GNUNET_asprintf(), GNUNET_DNSPARSER_free_uri(), GNUNET_memcpy, GNUNET_new, GNUNET_TUN_DnsUriRecord::prio, uri, and GNUNET_TUN_DnsUriRecord::weight.

Referenced by dns_value_to_string(), GNUNET_DNSPARSER_parse_record(), handle_gns_resolution_result(), and reply_to_dns().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_duplicate_record()

struct GNUNET_DNSPARSER_Record * GNUNET_DNSPARSER_duplicate_record ( const struct GNUNET_DNSPARSER_Record r)

Duplicate (deep-copy) the given DNS record.

Parameters
rthe record
Returns
the newly allocated record

Definition at line 810 of file dnsparser.c.

811{
812 struct GNUNET_DNSPARSER_Record *dup = GNUNET_memdup (r, sizeof(*r));
813
814 dup->name = GNUNET_strdup (r->name);
815 switch (r->type)
816 {
821 break;
822 }
823
826 break;
827 }
828
831 break;
832 }
833
836 break;
837 }
838
841 break;
842 }
843
846 break;
847 }
848
849 default: {
851 r->data.raw.data_len);
852 }
853 }
854 return dup;
855}
struct GNUNET_DNSPARSER_MxRecord * GNUNET_DNSPARSER_duplicate_mx_record(const struct GNUNET_DNSPARSER_MxRecord *r)
Duplicate (deep-copy) the given DNS record.
Definition: dnsparser.c:900
struct GNUNET_DNSPARSER_SoaRecord * GNUNET_DNSPARSER_duplicate_soa_record(const struct GNUNET_DNSPARSER_SoaRecord *r)
Duplicate (deep-copy) the given DNS record.
Definition: dnsparser.c:865
#define GNUNET_DNSPARSER_TYPE_CERT
struct GNUNET_DNSPARSER_SrvRecord * GNUNET_DNSPARSER_duplicate_srv_record(const struct GNUNET_DNSPARSER_SrvRecord *r)
Duplicate (deep-copy) the given DNS record.
Definition: dnsparser.c:916
struct GNUNET_DNSPARSER_CertRecord * GNUNET_DNSPARSER_duplicate_cert_record(const struct GNUNET_DNSPARSER_CertRecord *r)
Duplicate (deep-copy) the given DNS record.
Definition: dnsparser.c:883
struct GNUNET_DNSPARSER_UriRecord * GNUNET_DNSPARSER_duplicate_uri_record(const struct GNUNET_DNSPARSER_UriRecord *r)
Duplicate (deep-copy) the given DNS record.
Definition: dnsparser.c:933
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
struct GNUNET_DNSPARSER_CertRecord * cert
CERT data for CERT records.

References GNUNET_DNSPARSER_Record::cert, GNUNET_DNSPARSER_RawRecord::data, GNUNET_DNSPARSER_Record::data, GNUNET_DNSPARSER_RawRecord::data_len, GNUNET_DNSPARSER_duplicate_cert_record(), GNUNET_DNSPARSER_duplicate_mx_record(), GNUNET_DNSPARSER_duplicate_soa_record(), GNUNET_DNSPARSER_duplicate_srv_record(), GNUNET_DNSPARSER_duplicate_uri_record(), GNUNET_DNSPARSER_TYPE_CERT, GNUNET_DNSPARSER_TYPE_CNAME, GNUNET_DNSPARSER_TYPE_MX, GNUNET_DNSPARSER_TYPE_NS, GNUNET_DNSPARSER_TYPE_PTR, GNUNET_DNSPARSER_TYPE_SOA, GNUNET_DNSPARSER_TYPE_SRV, GNUNET_DNSPARSER_TYPE_URI, GNUNET_memdup, GNUNET_strdup, GNUNET_DNSPARSER_Record::hostname, GNUNET_DNSPARSER_Record::mx, GNUNET_DNSPARSER_Record::name, GNUNET_DNSPARSER_Record::raw, GNUNET_DNSPARSER_Record::soa, GNUNET_DNSPARSER_Record::srv, GNUNET_DNSPARSER_Record::type, and GNUNET_DNSPARSER_Record::uri.

Referenced by cache_answers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_duplicate_soa_record()

struct GNUNET_DNSPARSER_SoaRecord * GNUNET_DNSPARSER_duplicate_soa_record ( const struct GNUNET_DNSPARSER_SoaRecord r)

Duplicate (deep-copy) the given DNS record.

Parameters
rthe record
Returns
the newly allocated record

Definition at line 865 of file dnsparser.c.

867{
868 struct GNUNET_DNSPARSER_SoaRecord *dup = GNUNET_memdup (r, sizeof(*r));
869
870 dup->mname = GNUNET_strdup (r->mname);
871 dup->rname = GNUNET_strdup (r->rname);
872 return dup;
873}

References GNUNET_memdup, GNUNET_strdup, GNUNET_DNSPARSER_SoaRecord::mname, and GNUNET_DNSPARSER_SoaRecord::rname.

Referenced by GNUNET_DNSPARSER_duplicate_record().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_duplicate_cert_record()

struct GNUNET_DNSPARSER_CertRecord * GNUNET_DNSPARSER_duplicate_cert_record ( const struct GNUNET_DNSPARSER_CertRecord r)

Duplicate (deep-copy) the given DNS record.

Parameters
rthe record
Returns
the newly allocated record

Definition at line 883 of file dnsparser.c.

885{
886 struct GNUNET_DNSPARSER_CertRecord *dup = GNUNET_memdup (r, sizeof(*r));
887
889 return dup;
890}

References GNUNET_DNSPARSER_CertRecord::certificate_data, GNUNET_memdup, and GNUNET_strdup.

Referenced by GNUNET_DNSPARSER_duplicate_record().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_duplicate_mx_record()

struct GNUNET_DNSPARSER_MxRecord * GNUNET_DNSPARSER_duplicate_mx_record ( const struct GNUNET_DNSPARSER_MxRecord r)

Duplicate (deep-copy) the given DNS record.

Parameters
rthe record
Returns
the newly allocated record

Definition at line 900 of file dnsparser.c.

901{
902 struct GNUNET_DNSPARSER_MxRecord *dup = GNUNET_memdup (r, sizeof(*r));
903
904 dup->mxhost = GNUNET_strdup (r->mxhost);
905 return dup;
906}

References GNUNET_memdup, GNUNET_strdup, and GNUNET_DNSPARSER_MxRecord::mxhost.

Referenced by GNUNET_DNSPARSER_duplicate_record().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_duplicate_srv_record()

struct GNUNET_DNSPARSER_SrvRecord * GNUNET_DNSPARSER_duplicate_srv_record ( const struct GNUNET_DNSPARSER_SrvRecord r)

Duplicate (deep-copy) the given DNS record.

Parameters
rthe record
Returns
the newly allocated record

Definition at line 916 of file dnsparser.c.

918{
919 struct GNUNET_DNSPARSER_SrvRecord *dup = GNUNET_memdup (r, sizeof(*r));
920
921 dup->target = GNUNET_strdup (r->target);
922 return dup;
923}

References GNUNET_memdup, GNUNET_strdup, and GNUNET_DNSPARSER_SrvRecord::target.

Referenced by GNUNET_DNSPARSER_duplicate_record().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_duplicate_uri_record()

struct GNUNET_DNSPARSER_UriRecord * GNUNET_DNSPARSER_duplicate_uri_record ( const struct GNUNET_DNSPARSER_UriRecord r)

Duplicate (deep-copy) the given DNS record.

Parameters
rthe record
Returns
the newly allocated record

Definition at line 933 of file dnsparser.c.

935{
936 struct GNUNET_DNSPARSER_UriRecord *dup = GNUNET_memdup (r, sizeof(*r));
937
938 dup->target = GNUNET_strdup (r->target);
939 return dup;
940}
char * target
URI of the target, where the URI is as specified in RFC 3986.

References GNUNET_memdup, GNUNET_strdup, and GNUNET_DNSPARSER_UriRecord::target.

Referenced by GNUNET_DNSPARSER_duplicate_record().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_free_record()

void GNUNET_DNSPARSER_free_record ( struct GNUNET_DNSPARSER_Record r)

Free the given DNS record.

Parameters
rrecord to free

Definition at line 184 of file dnsparser.c.

185{
186 GNUNET_free (r->name);
187 switch (r->type)
188 {
191 break;
192
195 break;
196
199 break;
200
203 break;
204
207 break;
208
213 break;
214
215 default:
217 break;
218 }
219}
void GNUNET_DNSPARSER_free_cert(struct GNUNET_DNSPARSER_CertRecord *cert)
Free CERT information record.
Definition: dnsparser.c:124

References GNUNET_DNSPARSER_Record::cert, GNUNET_DNSPARSER_RawRecord::data, GNUNET_DNSPARSER_Record::data, GNUNET_DNSPARSER_free_cert(), GNUNET_DNSPARSER_free_mx(), GNUNET_DNSPARSER_free_soa(), GNUNET_DNSPARSER_free_srv(), GNUNET_DNSPARSER_free_uri(), GNUNET_DNSPARSER_TYPE_CERT, GNUNET_DNSPARSER_TYPE_CNAME, GNUNET_DNSPARSER_TYPE_MX, GNUNET_DNSPARSER_TYPE_NS, GNUNET_DNSPARSER_TYPE_PTR, GNUNET_DNSPARSER_TYPE_SOA, GNUNET_DNSPARSER_TYPE_SRV, GNUNET_DNSPARSER_TYPE_URI, GNUNET_free, GNUNET_DNSPARSER_Record::hostname, GNUNET_DNSPARSER_Record::mx, GNUNET_DNSPARSER_Record::name, GNUNET_DNSPARSER_Record::raw, GNUNET_DNSPARSER_Record::soa, GNUNET_DNSPARSER_Record::srv, GNUNET_DNSPARSER_Record::type, and GNUNET_DNSPARSER_Record::uri.

Referenced by free_cache_entry(), free_hosts_entry(), GNUNET_DNSPARSER_free_packet(), and remove_expired().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_free_mx()

void GNUNET_DNSPARSER_free_mx ( struct GNUNET_DNSPARSER_MxRecord mx)

Free MX information record.

Parameters
mxrecord to free

Definition at line 169 of file dnsparser.c.

170{
171 if (NULL == mx)
172 return;
173 GNUNET_free (mx->mxhost);
174 GNUNET_free (mx);
175}

References GNUNET_free, and GNUNET_DNSPARSER_MxRecord::mxhost.

Referenced by dns_value_to_string(), GNUNET_DNSPARSER_free_record(), GNUNET_DNSPARSER_parse_mx(), and handle_gns_resolution_result().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_free_srv()

void GNUNET_DNSPARSER_free_srv ( struct GNUNET_DNSPARSER_SrvRecord srv)

Free SRV information record.

Parameters
srvrecord to free

Definition at line 139 of file dnsparser.c.

140{
141 if (NULL == srv)
142 return;
143 GNUNET_free (srv->target);
144 GNUNET_free (srv);
145}

References GNUNET_free, and GNUNET_DNSPARSER_SrvRecord::target.

Referenced by dns_value_to_string(), GNUNET_DNSPARSER_free_record(), GNUNET_DNSPARSER_parse_srv(), and handle_gns_resolution_result().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_free_uri()

void GNUNET_DNSPARSER_free_uri ( struct GNUNET_DNSPARSER_UriRecord uri)

Free URI information record.

Parameters
urirecord to free

Definition at line 154 of file dnsparser.c.

155{
156 if (NULL == uri)
157 return;
158 GNUNET_free (uri->target);
160}

References GNUNET_free, and uri.

Referenced by dns_value_to_string(), GNUNET_DNSPARSER_free_record(), GNUNET_DNSPARSER_parse_uri(), and handle_gns_resolution_result().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_free_soa()

void GNUNET_DNSPARSER_free_soa ( struct GNUNET_DNSPARSER_SoaRecord soa)

Free SOA information record.

Parameters
soarecord to free

Definition at line 108 of file dnsparser.c.

109{
110 if (NULL == soa)
111 return;
112 GNUNET_free (soa->mname);
113 GNUNET_free (soa->rname);
114 GNUNET_free (soa);
115}

References GNUNET_free, GNUNET_DNSPARSER_SoaRecord::mname, and GNUNET_DNSPARSER_SoaRecord::rname.

Referenced by dns_value_to_string(), GNUNET_DNSPARSER_free_record(), GNUNET_DNSPARSER_parse_soa(), and handle_gns_resolution_result().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_free_cert()

void GNUNET_DNSPARSER_free_cert ( struct GNUNET_DNSPARSER_CertRecord cert)

Free CERT information record.

Parameters
certrecord to free

Definition at line 124 of file dnsparser.c.

125{
126 if (NULL == cert)
127 return;
129 GNUNET_free (cert);
130}

References GNUNET_DNSPARSER_CertRecord::certificate_data, and GNUNET_free.

Referenced by dns_value_to_string(), and GNUNET_DNSPARSER_free_record().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_bin_to_hex()

char * GNUNET_DNSPARSER_bin_to_hex ( const void *  data,
size_t  data_size 
)

Convert a block of binary data to HEX.

Parameters
databinary data to convert
data_sizenumber of bytes in data
Returns
HEX string (lower case)

Definition at line 1491 of file dnsparser.c.

1492{
1493 char *ret;
1494 size_t off;
1495 const uint8_t *idata;
1496
1497 idata = data;
1498 ret = GNUNET_malloc (data_size * 2 + 1);
1499 for (off = 0; off < data_size; off++)
1500 sprintf (&ret[off * 2], "%02x", idata[off]);
1501 return ret;
1502}
static char * data
The data to insert into the dht.
static size_t data_size
Number of bytes in data.

References data, data_size, GNUNET_malloc, and ret.

Referenced by dns_value_to_string().

Here is the caller graph for this function:

◆ GNUNET_DNSPARSER_hex_to_bin()

size_t GNUNET_DNSPARSER_hex_to_bin ( const char *  hex,
void *  data 
)

Convert a HEX string to block of binary data.

Parameters
hexHEX string to convert (may contain mixed case)
datawhere to write result, must be at least strlen(hex)/2 bytes long
Returns
number of bytes written to data

Definition at line 1514 of file dnsparser.c.

1515{
1516 size_t data_size;
1517 size_t off;
1518 uint8_t *idata;
1519 unsigned int h;
1520 char in[3];
1521
1522 data_size = strlen (hex) / 2;
1523 idata = data;
1524 in[2] = '\0';
1525 for (off = 0; off < data_size; off++)
1526 {
1527 in[0] = tolower ((unsigned char) hex[off * 2]);
1528 in[1] = tolower ((unsigned char) hex[off * 2 + 1]);
1529 if (1 != sscanf (in, "%x", &h))
1530 return off;
1531 idata[off] = (uint8_t) h;
1532 }
1533 return off;
1534}
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98

References data, data_size, and h.

Referenced by dns_string_to_value().

Here is the caller graph for this function: