getdns_convert(3)

πŸ“¦
version 1.7.3 Β· 2 versions
, in alpine 3.24, arch rolling, epel 10, epel 9, fedora 43, fedora 44, nixpkgs unstable, ubuntu resolute, ubuntu stonking

πŸ’– getdns_convert β€” the manual, but make it make sense πŸ’–

okay bestie, so you know how DNS stores names in the most feral little byte-gremlin format imaginable? yeah. this page is about the two lil helper functions that translate between that chaos and the normal string you actually recognize. their names are getdns_convert_dns_name_to_fqdn and getdns_convert_fqdn_to_dns_name (the umbrella name is just getdns_convert). they're gonna carry your entire conversion arc, no cap. πŸ¦‹


🌈 LIBRARY

DNS Resolver library β€” that's libgetdns, and you link it with -lgetdns. slay. πŸ’…


✨ SYNOPSIS ✨

#include <getdns.h>

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 (char *fqdn_as_string,
   const getdns_bindata **dns_name_wire_fmt)

copy it exactly like that, don't freestyle the prototypes, i'm begging 🫢


πŸ’… DESCRIPTION πŸ’…

so. names in DNS fields are stored in a way that is deeply different from the presentation format that normal applications use. the DNS format is the one described in the first paragraph of Section 3.1 of RFC 1035 β€” yes, RFC 1035, we love her, she's the blueprint πŸ‘‘ β€” and the presentation format here is just a null-terminated string with interior dots. cozy. familiar. main character energy.

⚠️ here's the important part, do not skip it: these helper functions only work with names in DNS format that are not compressed. that's it. that's the boundary. they're useful for converting domain names in the replies_tree to and from the FQDN presentation format. 🌸

getdns_convert_dns_name_to_fqdn() β€” takes a domain name in DNS format and converts it to presentation format. iconic behavior. for example, the hex sequence

03 77 77 77 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00

would be converted to "www.example.com". like… the glow-up is real. 😭✨

getdns_convert_fqdn_to_dns_name() β€” does the reverse. it takes a null-terminated string in FQDN format and converts it to bytes in DNS format. round trip, bestie, we're going both ways. πŸŽ€

the args, explained with love

  • dns_name_wire_fmt β€” the non-compressed DNS wire format name (per RFC 1035) sitting inside a bindata structure, which will be converted to/from an fqdn. 🧚 heads up: in getdns_convert_fqdn_to_dns_name the storage is allocated using the system allocator (malloc) and must be freed by the caller. that's a you problem now. free your memory. i'm serious. πŸ™ˆ
  • fqdn_as_string β€” a null terminated string to be converted to/from a non-compressed DNS wire format name (per RFC 1035). 🧚 heads up again: in getdns_convert_dns_name_to_fqdn the storage is allocated using the system allocator (malloc) and must be freed by the caller. same deal. free it. ✨
not me warning you twice about malloc β€” but fr fr, leaking memory is not the vibe check you want to fail. πŸ’€

🌟 RETURN VALUES 🌟

upon successful completion, the function returns GETDNS_RETURN_GOOD. that's it. that's the whole list. she's simple, she's clean, she ate. πŸ“


πŸŽ€ EXAMPLES πŸŽ€

TBD

(yeah. that's literally what it says. the examples are a mystery, a blank canvas, an unfinished symphony. when the authors drop them, we'll all be seated. πŸ’œ)


πŸ”₯ SEE ALSO πŸ”₯

  • libgetdns(3) β€” go read her next, she's the whole universe these two live in.

mwah, that's the page πŸ’– go convert some names, free your mallocs, and stay uncompressed (the functions require it, and honestly? mood).

signed off with love from the getdns crew β€” version 1.7.3, dated December 2015, page getdns_convert(3). periodt. πŸ’…βœ¨