getdns_service(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_service(3) πŸ’–

okay bestie, welcome to the getdns manual, part of the getdns docs situation. this one's about looking up a service, and yes it's as cute as it sounds 🌸


✨ NAME ✨

getdns_service, getdns_service_sync β€” getdns lookup of a service πŸ¦‹


πŸ“š LIBRARY πŸ“š

DNS Resolver library (libgetdns, -lgetdns)


🌟 SYNOPSIS 🌟

#include <getdns.h>

getdns_return_t
getdns_service (getdns_context *context,
   const char *name,
   getdns_dict *extensions,
   void *userarg,
   getdns_transaction_t *transaction_id,
   getdns_callback_t callbackfn)

getdns_return_t
getdns_service_sync (getdns_context *context,
   const char *name,
   getdns_dict *extensions,
   getdns_dict **response)

🫢 DESCRIPTION 🫢

so. getdns_service (3) and getdns_service_sync are the public entry points into the getdns API library, and their whole job is retrieving the SRV information given a name. iconic behavior honestly ✨

  • context β€” a pointer to the previously created DNS context that's gonna be used with this DNS request. go peek at getdns_context (3) if you need the lore πŸ’…
  • name β€” the service name to resolve πŸŽ€
  • extensions β€” extensions for this request, NULL if there are no extensions. libgetdns (3) has a whole detailed description of extensions, go read it bestie
  • userarg β€” this gets returned to the callback function untouched, and it can be NULL 🌸
  • transaction_id β€” populated by the API, and used to identify the callback (for example, to hand to getdns_cancel_callback). it can be NULL, and it's set to 0 if the function fails πŸ’€
  • callbackfn β€” a non-NULL pointer to a callback function defined by the application, typically used to process the response. only the asynchronous signature accepts a callback function, the synchronous signature does not include a callback, no cap. libgetdns (3) has a more detailed discussion of callback functions if you wanna get deep 🧚
  • response β€” a getdns_dict type is returned in response, and it always contains at least three names: replies_full (a list containing the DNS response as binary data), replies_tree (a list containing the parsed DNS response data) and status (an int). the storage associated with this must be freed by a call to getdns_free_sync_request_memory (3) β€” don't forget, or that's a memory leak and we don't do that here πŸ™ˆ

πŸ‘‘ RETURN VALUES πŸ‘‘

upon successful completion the functions return GETDNS_RETURN_GOOD πŸ’– otherwise, here's the error values that can come back at you:

  • GETDNS_RETURN_BAD_CONTEXT β€” if the context pointer is invalid, or the context has internal deficiencies 😭
  • GETDNS_RETURN_BAD_DOMAIN_NAME β€” if the domain name passed to the function is invalid
  • GETDNS_RETURN_EXTENSION_MISFORMAT β€” if the data type specified in one or more of the extensions does not match the specifications
  • GETDNS_RETURN_GENERIC_ERROR β€” if some problem was encountered in the function that isn't addressed by one of the more specific return codes
  • GETDNS_RETURN_INVALID PARAMETER β€” if one or more parameters has an invalid value
  • GETDNS_RETURN_MEMORY_ERROR β€” if unable to allocate the memory required πŸ’€
  • GETDNS_RETURN_NO_SUCH_EXTENSION β€” if one or more of the strings specified in the extensions are not valid

🌈 the status values 🌈

the values of status included in the response parameter are:

  • GETDNS_RESPSTATUS_GOOD β€” if at least one response was returned πŸŽ‰
  • GETDNS_RESPSTATUS_NO_NAME β€” if queries for the name yielded all negative responses
  • GETDNS_RESPSTATUS_ALL_TIMEOUT β€” if all queries for the name timed out 😭
  • GETDNS_RESPSTATUS_NO_SECURE_ANSWERS β€” if only secure replies are accepted (per context) and at least one response was received, but no DNS responses were secure through DNSSEC πŸ”’

for a more detailed explanation of the response object, see libgetdns (3) πŸ“–


πŸ’… EXAMPLES πŸ’…

TBD 🫠 (the docs said TBD and honestly, same)


πŸ“ FILES πŸ“

  • /etc/hosts
  • /etc/resolv.conf

πŸ”₯ SEE ALSO πŸ”₯

libgetdns(3), getdns_context(3), getdns_free_sync_request_memory(3), getdns_general(3), getdns_hostname(3), getdns_address(3),


bestie reminder: response memory goes to getdns_free_sync_request_memory (3) or it just lives in your heap forever. free your girl. 🫢

and that's the whole page! this one's from getdns 1.7.3, dated December 2015 β€” yeah she's vintage, and she still ate πŸ’–βœ¨πŸ‘‘