Functions for converting between getdns DNS dicts, DNS wire format and DNS presentation format

Functions

getdns_return_t getdns_rr_dict2wire (const getdns_dict *rr_dict, uint8_t **wire, size_t *wire_sz)
 
getdns_return_t getdns_rr_dict2wire_buf (const getdns_dict *rr_dict, uint8_t *wire, size_t *wire_sz)
 
getdns_return_t getdns_rr_dict2wire_scan (const getdns_dict *rr_dict, uint8_t **wire, int *wire_sz)
 
getdns_return_t getdns_wire2rr_dict (const uint8_t *wire, size_t wire_sz, getdns_dict **rr_dict)
 
getdns_return_t getdns_wire2rr_dict_buf (const uint8_t *wire, size_t *wire_sz, getdns_dict **rr_dict)
 
getdns_return_t getdns_wire2rr_dict_scan (const uint8_t **wire, size_t *wire_sz, getdns_dict **rr_dict)
 
getdns_return_t getdns_rr_dict2str (const getdns_dict *rr_dict, char **str)
 
getdns_return_t getdns_rr_dict2str_buf (const getdns_dict *rr_dict, char *str, size_t *str_len)
 
getdns_return_t getdns_rr_dict2str_scan (const getdns_dict *rr_dict, char **str, int *str_len)
 
getdns_return_t getdns_str2rr_dict (const char *str, getdns_dict **rr_dict, const char *origin, uint32_t default_ttl)
 
getdns_return_t getdns_fp2rr_list (FILE *in, getdns_list **rr_list, const char *origin, uint32_t default_ttl)
 
getdns_return_t getdns_msg_dict2wire (const getdns_dict *msg_dict, uint8_t **wire, size_t *wire_sz)
 
getdns_return_t getdns_msg_dict2wire_buf (const getdns_dict *msg_dict, uint8_t *wire, size_t *wire_sz)
 
getdns_return_t getdns_msg_dict2wire_scan (const getdns_dict *msg_dict, uint8_t **wire, int *wire_sz)
 
getdns_return_t getdns_wire2msg_dict (const uint8_t *wire, size_t wire_sz, getdns_dict **msg_dict)
 
getdns_return_t getdns_wire2msg_dict_buf (const uint8_t *wire, size_t *wire_sz, getdns_dict **msg_dict)
 
getdns_return_t getdns_wire2msg_dict_scan (const uint8_t **wire, size_t *wire_sz, getdns_dict **msg_dict)
 
getdns_return_t getdns_msg_dict2str (const getdns_dict *msg_dict, char **str)
 
getdns_return_t getdns_msg_dict2str_buf (const getdns_dict *msg_dict, char *str, size_t *str_len)
 
getdns_return_t getdns_msg_dict2str_scan (const getdns_dict *msg_dict, char **str, int *str_len)
 

Detailed Description

Function Documentation

getdns_return_t getdns_rr_dict2wire ( const getdns_dict rr_dict,
uint8_t **  wire,
size_t *  wire_sz 
)

Convert rr_dict to wireformat representation of the resource record.

Parameters
rr_dictThe getdns dict representation of the resource record
wireA newly allocated buffer which will contain the wireformat.
wire_szThe size of the allocated buffer and the wireformat.
Returns
GETDNS_RETURN_GOOD on success or an error code on failure.
getdns_return_t getdns_rr_dict2wire_buf ( const getdns_dict rr_dict,
uint8_t *  wire,
size_t *  wire_sz 
)

Convert rr_dict to wireformat representation of the resource record.

Parameters
rr_dictThe getdns dict representation of the resource record
wireThe buffer in which the wireformat will be written
wire_szOn input the size of the wire buffer, On output the amount of wireformat needed for the wireformat representation of the resource record; even if it did not fit.
Returns
GETDNS_RETURN_GOOD on success or an error code on failure. GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too small. wire_sz will be set to the needed buffer space then.
getdns_return_t getdns_rr_dict2wire_scan ( const getdns_dict rr_dict,
uint8_t **  wire,
int *  wire_sz 
)

Convert rr_dict to wireformat representation of the resource record.

Parameters
rr_dictThe getdns dict representation of the resource record
wireA pointer to the buffer pointer in which the wireformat will be written. On output the buffer pointer will have moved along the buffer and point right after the just written RR.
wire_szOn input the size of the wire buffer, On output the amount of wireformat needed for the wireformat will have been substracted from wire_sz.
Returns
GETDNS_RETURN_GOOD on success or an error code on failure. GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too small. The function will pretend that it had written beyond the end of the buffer, and wire will point past the buffer and wire_sz will contain a negative value.
getdns_return_t getdns_wire2rr_dict ( const uint8_t *  wire,
size_t  wire_sz,
getdns_dict **  rr_dict 
)

Convert wireformat resource record in a getdns rr_dict representation.

Parameters
wireBuffer containing the wireformat rr
wire_szSize of the wire buffer
rr_dictThe returned rr_dict
Returns
GETDNS_RETURN_GOOD on success or an error code on failure.
getdns_return_t getdns_wire2rr_dict_buf ( const uint8_t *  wire,
size_t *  wire_sz,
getdns_dict **  rr_dict 
)

Convert wireformat resource record in a getdns rr_dict representation.

Parameters
wireBuffer containing the wireformat rr
wire_szOn input the size of the wire buffer On output the length of the wireformat rr.
rr_dictThe returned rr_dict
Returns
GETDNS_RETURN_GOOD on success or an error code on failure.
getdns_return_t getdns_wire2rr_dict_scan ( const uint8_t **  wire,
size_t *  wire_sz,
getdns_dict **  rr_dict 
)

Convert wireformat resource record in a getdns rr_dict representation.

Parameters
wireA pointer to the pointer of the wireformat buffer. On return this pointer is moved to after first read in resource record.
wire_szOn input the size of the wire buffer On output the size is decreased with the length of the wireformat resource record.
rr_dictThe returned rr_dict
Returns
GETDNS_RETURN_GOOD on success or an error code on failure.
getdns_return_t getdns_rr_dict2str ( const getdns_dict rr_dict,
char **  str 
)

Convert rr_dict to the string representation of the resource record.

Parameters
rr_dictThe getdns dict representation of the resource record
strA newly allocated string representation of the rr
Returns
GETDNS_RETURN_GOOD on success or an error code on failure.
getdns_return_t getdns_rr_dict2str_buf ( const getdns_dict rr_dict,
char *  str,
size_t *  str_len 
)

Convert rr_dict to the string representation of the resource record.

Parameters
rr_dictThe getdns dict representation of the resource record
strThe buffer in which the string will be written
str_lenOn input the size of the text buffer, On output the amount of characters needed to write the string representation of the rr. Even if it does not fit.
Returns
GETDNS_RETURN_GOOD on success or an error code on failure. GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too small. str_len will be set to the needed buffer space then.
getdns_return_t getdns_rr_dict2str_scan ( const getdns_dict rr_dict,
char **  str,
int *  str_len 
)

Convert rr_dict to the string representation of the resource record.

Parameters
rr_dictThe getdns dict representation of the resource record
strA pointer to the buffer pointer in which the string will be written. On output the buffer pointer will have moved along the buffer and point right after the just written RR.
str_lenOn input the size of the str buffer, On output the number of characters needed for the string will have been substracted from strlen.
Returns
GETDNS_RETURN_GOOD on success or an error code on failure. GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too small. The function will pretend that it had written beyond the end of the buffer, and str will point past the buffer and str_len will contain a negative value.
getdns_return_t getdns_str2rr_dict ( const char *  str,
getdns_dict **  rr_dict,
const char *  origin,
uint32_t  default_ttl 
)

Convert the string representation of the resource record to rr_dict format.

Parameters
strString representation of the resource record.
rr_dictThe result getdns dict representation of the resource record
originDefault suffix for not fully qualified domain names
default_ttlDefault ttl
Returns
GETDNS_RETURN_GOOD on success or an error code on failure.
getdns_return_t getdns_fp2rr_list ( FILE *  in,
getdns_list **  rr_list,
const char *  origin,
uint32_t  default_ttl 
)

Read the zonefile and convert to a list of rr_dict's.

Parameters
inAn opened FILE pointer on the zone file.
rr_listThe result list of rr_dicts representing the zone file.
originDefault suffix for not fully qualified domain names
default_ttlDefault ttl
Returns
GETDNS_RETURN_GOOD on success or an error code on failure.
getdns_return_t getdns_msg_dict2wire ( const getdns_dict msg_dict,
uint8_t **  wire,
size_t *  wire_sz 
)

Convert DNS message dict to wireformat representation.

Parameters
msg_dictThe getdns dict representation of a DNS message
wireA newly allocated buffer which will contain the wireformat.
wire_szThe size of the allocated buffer and the wireformat.
Returns
GETDNS_RETURN_GOOD on success or an error code on failure.
getdns_return_t getdns_msg_dict2wire_buf ( const getdns_dict msg_dict,
uint8_t *  wire,
size_t *  wire_sz 
)

Convert DNS message dict to wireformat representation.

Parameters
msg_dictThe getdns dict representation of a DNS message
wireThe buffer in which the wireformat will be written
wire_szOn input the size of the wire buffer, On output the amount of wireformat needed for the wireformat representation of the DNS message; even if it did not fit.
Returns
GETDNS_RETURN_GOOD on success or an error code on failure. GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too small. wire_sz will be set to the needed buffer space then.
getdns_return_t getdns_msg_dict2wire_scan ( const getdns_dict msg_dict,
uint8_t **  wire,
int *  wire_sz 
)

Convert DNS message dict to wireformat representation.

Parameters
msg_dictThe getdns dict representation of the DNS message
wireA pointer to the buffer pointer in which the wireformat will be written. On output the buffer pointer will have moved along the buffer and point right after the just written RR.
wire_szOn input the size of the wire buffer, On output the amount of wireformat needed for the wireformat will have been substracted from wire_sz.
Returns
GETDNS_RETURN_GOOD on success or an error code on failure. GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too small. The function will pretend that it had written beyond the end of the buffer, and wire will point past the buffer and wire_sz will contain a negative value.
getdns_return_t getdns_wire2msg_dict ( const uint8_t *  wire,
size_t  wire_sz,
getdns_dict **  msg_dict 
)

Convert wireformat DNS message in a getdns msg_dict representation.

Parameters
wireBuffer containing the wireformat rr
wire_szSize of the wire buffer
msg_dictThe returned DNS message
Returns
GETDNS_RETURN_GOOD on success or an error code on failure.
getdns_return_t getdns_wire2msg_dict_buf ( const uint8_t *  wire,
size_t *  wire_sz,
getdns_dict **  msg_dict 
)

Convert wireformat DNS message in a getdns msg_dict representation.

Parameters
wireBuffer containing the wireformat rr
wire_szOn input the size of the wire buffer On output the length of the wireformat rr.
msg_dictThe returned DNS message
Returns
GETDNS_RETURN_GOOD on success or an error code on failure.
getdns_return_t getdns_wire2msg_dict_scan ( const uint8_t **  wire,
size_t *  wire_sz,
getdns_dict **  msg_dict 
)

Convert wireformat DNS message in a getdns msg_dic representation.

Parameters
wireA pointer to the pointer of the wireformat buffer. On return this pointer is moved to after first read in resource record.
wire_szOn input the size of the wire buffer On output the size is decreased with the length of the wireformat DNS message.
msg_dictThe returned DNS message
Returns
GETDNS_RETURN_GOOD on success or an error code on failure.
getdns_return_t getdns_msg_dict2str ( const getdns_dict msg_dict,
char **  str 
)

Convert msg_dict to the string representation of the DNS message.

Parameters
msg_dictThe getdns dict representation of the DNS message
strA newly allocated string representation of the rr
Returns
GETDNS_RETURN_GOOD on success or an error code on failure.
getdns_return_t getdns_msg_dict2str_buf ( const getdns_dict msg_dict,
char *  str,
size_t *  str_len 
)

Convert msg_dict to the string representation of the DNS message.

Parameters
msg_dictThe getdns dict representation of the resource record
strThe buffer in which the string will be written
str_lenOn input the size of the text buffer, On output the amount of characters needed to write the string representation of the rr. Even if it does not fit.
Returns
GETDNS_RETURN_GOOD on success or an error code on failure. GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too small. str_len will be set to the needed buffer space then.
getdns_return_t getdns_msg_dict2str_scan ( const getdns_dict msg_dict,
char **  str,
int *  str_len 
)

Convert msg_dict to the string representation of the resource record.

Parameters
msg_dictThe getdns dict representation of the resource record
strA pointer to the buffer pointer in which the string will be written. On output the buffer pointer will have moved along the buffer and point right after the just written RR.
str_lenOn input the size of the str buffer, On output the number of characters needed for the string will have been substracted from strlen.
Returns
GETDNS_RETURN_GOOD on success or an error code on failure. GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too small. The function will pretend that it had written beyond the end of the buffer, and str will point past the buffer and str_len will contain a negative value.