47 char tmp[INET6_ADDRSTRLEN];
54 if (NULL == inet_ntop (AF_INET,
data, tmp,
sizeof(tmp)))
79 if ((NULL == cname) || (off !=
data_size))
102 "%s %s ( %u %u %u %u %u )",
137 if ((NULL == cert) || (off !=
data_size))
182 if (
data_size !=
sizeof(
struct in6_addr))
184 if (NULL == inet_ntop (AF_INET6,
data, tmp,
sizeof(tmp)))
248 (
unsigned int) tlsa->
usage,
271 memset (tag, 0,
sizeof(tag));
273 memcpy (tag, &caa[1], caa->
tag_len);
275 (
char *) &caa[1] + caa->
tag_len,
279 (
unsigned int) caa->
flags,
306 const char *mnemonic;
308 }
table[] = { {
"PKIX", 1 },
321 for (i = 0; NULL !=
table[i].mnemonic; i++)
322 if (0 == strcasecmp (mnemonic,
table[i].mnemonic))
339 const char *mnemonic;
341 }
table[] = { {
"RSAMD5", 1 },
347 {
"PRIVATEDNS", 253 },
348 {
"PRIVATEOID", 254 },
352 for (i = 0; NULL !=
table[i].mnemonic; i++)
353 if (0 == strcasecmp (mnemonic,
table[i].mnemonic))
377 struct in_addr value_a;
378 struct in6_addr value_aaaa;
386 if (1 != inet_pton (AF_INET, s, &value_a))
389 _ (
"Unable to parse IPv4 address `%s'\n"),
407 _ (
"Failed to serialize NS record with value `%s'\n"),
428 _ (
"Failed to serialize CNAME record with value `%s'\n"),
444 unsigned int cert_rrtype;
452 typep = strtok (sdup,
" ");
453 if ((NULL == typep) ||
455 ((1 != sscanf (typep,
"%u", &cert_rrtype)) || (cert_rrtype >
461 keyp = strtok (NULL,
" ");
462 if ((NULL == keyp) || (1 != sscanf (keyp,
"%u", &
key)) ||
469 algp = strtok (NULL,
" ");
470 if ((NULL == algp) ||
472 ((1 != sscanf (algp,
"%u", &alg)) || (alg > UINT8_MAX))))
477 certp = strtok (NULL,
" ");
478 if ((NULL == certp) || (0 == strlen (certp)))
485 (
void **) &cert_data);
503 _ (
"Failed to serialize CERT record with %u bytes\n"),
504 (
unsigned int) cert_size);
519 char soa_rname[253 + 1];
520 char soa_mname[253 + 1];
521 unsigned int soa_serial;
522 unsigned int soa_refresh;
523 unsigned int soa_retry;
524 unsigned int soa_expire;
525 unsigned int soa_min;
529 "%253s %253s ( %u %u %u %u %u )",
539 _ (
"Unable to parse SOA record `%s'\n"),
543 soa.
mname = soa_mname;
544 soa.
rname = soa_rname;
545 soa.
serial = (uint32_t) soa_serial;
546 soa.
refresh = (uint32_t) soa_refresh;
547 soa.
retry = (uint32_t) soa_retry;
548 soa.
expire = (uint32_t) soa_expire;
556 _ (
"Failed to serialize SOA record with mname `%s' and rname `%s'\n"),
576 _ (
"Failed to serialize PTR record with value `%s'\n"),
590 unsigned int mx_pref;
593 if (2 != sscanf (s,
"%u %253s", &mx_pref,
mxhost))
596 _ (
"Unable to parse MX record `%s'\n"),
608 _ (
"Failed to serialize MX record with hostname `%s'\n"),
621 char srvtarget[253 + 1];
631 _ (
"Unable to parse SRV record `%s'\n"),
644 _ (
"Failed to serialize SRV record with target `%s'\n"),
656 char target[strlen (s) + 1];
664 _ (
"Unable to parse URI record `%s'\n"),
676 if (strstr (
target,
":") == NULL ||
681 _ (
"Failed to serialize URI record with target `%s'\n"),
694 _ (
"Failed to serialize URI record with target `%s'\n"),
711 if (1 != inet_pton (AF_INET6, s, &value_aaaa))
714 _ (
"Unable to parse IPv6 address `%s'\n"),
726 unsigned int selector;
727 unsigned int matching_type;
728 size_t slen = strlen (s) + 1;
731 if (4 != sscanf (s,
"%u %u %u %s", &
usage, &selector, &matching_type,
735 _ (
"Unable to parse TLSA/SMIMEA record string `%s'\n"),
749 _ (
"Unable to parse TLSA/SMIMEA record string `%s'\n"),
763 char value[strlen (s) + 1];
765 if (3 != sscanf (s,
"%u %s %[^\n]", &
flags, tag,
value))
768 _ (
"Unable to parse CAA record string `%s'\n"),
777 memcpy (&caa[1], tag, strlen (tag));
811 { NULL, UINT32_MAX } };
static uint16_t port
Port number.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_NAMECACHE_Handle * ns
Handle to the namecache.
static char * value
Value of the record to add/remove.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static int result
Global testing status.
Plugin API for GNS record types.
#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.
char * GNUNET_DNSPARSER_bin_to_hex(const void *data, size_t data_size)
Convert a block of binary data to HEX.
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...
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.
#define GNUNET_DNSPARSER_TYPE_TLSA
#define GNUNET_DNSPARSER_TYPE_CAA
#define GNUNET_DNSPARSER_TYPE_SRV
#define GNUNET_DNSPARSER_TYPE_SOA
void GNUNET_DNSPARSER_free_cert(struct GNUNET_DNSPARSER_CertRecord *cert)
Free CERT information record.
#define GNUNET_DNSPARSER_TYPE_CERT
#define GNUNET_DNSPARSER_TYPE_A
size_t GNUNET_DNSPARSER_hex_to_bin(const char *hex, void *data)
Convert a HEX string to block of binary data.
void GNUNET_DNSPARSER_free_srv(struct GNUNET_DNSPARSER_SrvRecord *srv)
Free SRV information record.
#define GNUNET_DNSPARSER_TYPE_SMIMEA
#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.
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.
void GNUNET_DNSPARSER_free_uri(struct GNUNET_DNSPARSER_UriRecord *uri)
Free URI information record.
#define GNUNET_DNSPARSER_TYPE_NS
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.
#define GNUNET_DNSPARSER_TYPE_CNAME
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.
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.
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.
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.
void GNUNET_DNSPARSER_free_soa(struct GNUNET_DNSPARSER_SoaRecord *soa)
Free SOA information record.
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.
void GNUNET_DNSPARSER_free_mx(struct GNUNET_DNSPARSER_MxRecord *mx)
Free MX information record.
#define GNUNET_DNSPARSER_TYPE_AAAA
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.
#define GNUNET_DNSPARSER_TYPE_MX
#define GNUNET_DNSPARSER_TYPE_TXT
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
@ GNUNET_ERROR_TYPE_ERROR
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **output)
Decode from Base64.
size_t GNUNET_STRINGS_base64_encode(const void *in, size_t len, char **output)
Encode into Base64.
static struct PeerEntry ** table
Table with our interned peer IDs.
static enum GNUNET_GenericReturnValue dns_is_critical(void *cls, uint32_t type)
void * libgnunet_plugin_gnsrecord_dns_done(void *cls)
Exit point from the plugin.
static int dns_string_to_value(void *cls, uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a 'value' of a record to the binary representation.
static const char * dns_number_to_typename(void *cls, uint32_t type)
Convert a type number to the corresponding type string (e.g.
static unsigned int rfc4398_mnemonic_to_value(const char *mnemonic)
Convert RFC 4394 Mnemonics to the corresponding integer values.
static char * dns_value_to_string(void *cls, uint32_t type, const void *data, size_t data_size)
Convert the 'value' of a record to a string.
static struct @38 name_map[]
Mapping of record type numbers to human-readable record type names.
static uint32_t dns_typename_to_number(void *cls, const char *dns_typename)
Convert a type name (e.g.
void * libgnunet_plugin_gnsrecord_dns_init(void *cls)
Entry point for the plugin.
static unsigned int rfc4034_mnemonic_to_value(const char *mnemonic)
Convert RFC 4034 algorithm types to the corresponding integer values.
Information from CAA records (RFC 6844).
uint8_t flags
The flags of the CAA record.
uint8_t tag_len
The length of the tag.
Information from CERT records (RFC 4034).
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.
Information from MX records (RFC 1035).
char * mxhost
Name of the mail server.
uint16_t preference
Preference for this entry (lower value is higher preference).
Information from SOA records (RFC 1035).
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.
Information from SRV records (RFC 2782).
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.
Information from URI records (RFC 7553).
uint16_t priority
Preference for this entry (lower value is higher preference).
uint16_t weight
Relative weight for records with the same priority.
char * target
URI of the target, where the URI is as specified in RFC 3986.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
GNUNET_GNSRECORD_IsCriticalFunction is_critical
Is critical.
GNUNET_GNSRECORD_TypenameToNumberFunction typename_to_number
Typename to number.
GNUNET_GNSRECORD_NumberToTypenameFunction number_to_typename
Number to typename.
GNUNET_GNSRECORD_ValueToStringFunction value_to_string
Conversion to string.
void * cls
Closure for all of the callbacks.
GNUNET_GNSRECORD_StringToValueFunction string_to_value
Conversion to binary.
Payload of DNS CERT record.
Payload of DNSSEC TLSA record.
uint8_t selector
Selector What part will be matched against the cert presented by server 0: Full cert (in binary) 1: F...
uint8_t matching_type
Matching type (of selected content) 0: exact match 1: SHA-256 hash 2: SHA-512 hash.
uint8_t usage
Certificate usage 0: CA cert 1: Entity cert 2: Trust anchor 3: domain-issued cert.
Payload of DNS URI record (header).