Utility functions

Functions

getdns_return_t getdns_convert_dns_name_to_fqdn (const getdns_bindata *dns_name_wire_fmt, char **fqdn_as_string)
 
getdns_return_t getdns_convert_fqdn_to_dns_name (const char *fqdn_as_string, getdns_bindata **dns_name_wire_fmt)
 
char * getdns_convert_ulabel_to_alabel (const char *ulabel)
 
char * getdns_convert_alabel_to_ulabel (const char *alabel)
 
char * getdns_display_ip_address (const getdns_bindata *bindata_of_ipv4_or_ipv6_address)
 
const char * getdns_get_errorstr_by_id (uint16_t err)
 
getdns_dictgetdns_pubkey_pin_create_from_string (const getdns_context *context, const char *str)
 
getdns_return_t getdns_pubkey_pinset_sanity_check (const getdns_list *pinset, getdns_list *errorlist)
 

Detailed Description

remove the value associated with the specified name

Parameters
dictdictionary from which to fetch the integer
namea name/key value to look up in the dictionary
Returns
GETDNS_RETURN_GOOD on success
GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist

Function Documentation

◆ getdns_convert_dns_name_to_fqdn()

getdns_return_t getdns_convert_dns_name_to_fqdn ( const getdns_bindata dns_name_wire_fmt,
char **  fqdn_as_string 
)

Convert a domain name in DNS wire format to presentation format. The newly allocated string should be freed with free.

Parameters
dns_name_wire_fmtA bindata to the DNS name in wire format
fqdn_as_stringA reference to a pointer that will be set to a newly allocated string containing the presentation format of the name. The caller is responsible for deallocate this space with free().
Returns
GETDNS_RETURN_GOOD on success or GETDNS_RETURN_GENERIC_ERROR when the wireformat name could not be parsed.

◆ getdns_convert_fqdn_to_dns_name()

getdns_return_t getdns_convert_fqdn_to_dns_name ( const char *  fqdn_as_string,
getdns_bindata **  dns_name_wire_fmt 
)

Convert a domain name in presentation format to DNS wire format.

Parameters
fqdn_as_stringThe name to convert in presentation format.
dns_name_wire_fmtA reference to a pointer that will be set to a newly allocated bindata containing the DNS wire format of the name. The caller is responsible for deallocate this space with free().
Returns
GETDNS_RETURN_GOOD on success or GETDNS_RETURN_GENERIC_ERROR when the presentation format name could not be parsed.

◆ getdns_convert_ulabel_to_alabel()

char* getdns_convert_ulabel_to_alabel ( const char *  ulabel)

Convert an Unicode encoded label to ASCII encoding following the rules for IDNA 2008 described in RFC 5890-5892.

Parameters
ulabelThe Unicode encoded label to convert.
Returns
The ASCII encoding label. The caller is responsible for deallocate this space with free().

◆ getdns_convert_alabel_to_ulabel()

char* getdns_convert_alabel_to_ulabel ( const char *  alabel)

Convert an ASCII encoded label to Unicode encoding following the rules for IDNA 2008 described in RFC 5890-5892.

Parameters
alabelThe ASCII encoded label to convert.
Returns
The Unicode encoding label. The caller is responsible for deallocation with free().

◆ getdns_display_ip_address()

char* getdns_display_ip_address ( const getdns_bindata bindata_of_ipv4_or_ipv6_address)

Converts a getdns_bindata representing an IPv4 or IPv6 address to a textual representation.

Parameters
bindata_of_ipv4_or_ipv6_addressThe IP address to convert.
Returns
character array (caller must free this) containing the textual representation of the address.

◆ getdns_get_errorstr_by_id()

const char* getdns_get_errorstr_by_id ( uint16_t  err)

Returns a text describing the getdns error code, or NULL when the error code is unknown.

Parameters
errThe error code for which to return the describing text
Returns
The describing text for the error code. The string is in library space and the caller must not free this.

◆ getdns_pubkey_pin_create_from_string()

getdns_dict* getdns_pubkey_pin_create_from_string ( const getdns_context context,
const char *  str 
)

Public Key Pinning functionality:

a public key pinset is a list of dicts. each dict should have a "digest" and a "value".

"digest": a string indicating the type of digest. at the moment, we only support a "digest" of "sha256".

"value": a binary representation of the digest provided.

given a such a pinset, we should be able to validate a chain properly according to section 2.6 of RFC 7469. convert an HPKP-style pin description to an appropriate getdns data structure. An example string is: (with the quotes, without any leading or trailing whitespace):

pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="

It is the caller's responsibility to call getdns_dict_destroy() on the dict returned when it is no longer needed.

Parameters
contexta context to use to create the dict, or NULL to create it generically
strthe pinning string to parse
Returns
a dict created from ctx, or NULL if the string did not match.

◆ getdns_pubkey_pinset_sanity_check()

getdns_return_t getdns_pubkey_pinset_sanity_check ( const getdns_list pinset,
getdns_list errorlist 
)

Test whether a given pinset is reasonable, including:

is it well-formed? are there at least two pins? are the digests used sane?

Parameters
pinsetthe set of public key pins to check for sanity. This should be a list of dicts.
errorlistif not NULL, a list of human-readable strings is appended to errorlist.
Returns
GETDNS_RETURN_GOOD if the pinset passes the sanity check.