ARES_MKQUERY(3)

πŸ“¦
version 1.34.9 Β· 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

ares_mkquery β€” bestie, we're composing a single-question DNS query buffer πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <ares.h>

int ares_mkquery(const char *name, int dnsclass, int type,
                 unsigned short id, int rd, unsigned char **buf,
                 int *buflen)

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so first things first, and I need you to hear me on this one: this function is deprecated as of c-ares 1.10, and you should be using ares_dns_record_create(3) instead. Like, it's giving legacy. It still works, but it's the old way, periodt. πŸ™ˆ

So what does ares_mkquery actually do? It composes a DNS query with a single question. One question, that's it, that's the whole vibe. ✨

Let's break down the parameters because there's a lot going on here and I want you to be fully caught up:

  • The parameter name gives the query name as a NUL-terminated C string of period-separated labels, optionally ending with a period. Periods and backslashes within a label must be escaped with a backslash. (The original page says "backlash" and honestly bestie, same energy, but yes β€” a backslash. 😭)
  • The parameters dnsclass and type give the class and type of the query, using the values defined in <arpa/nameser.h>.
  • The parameter id gives a 16-bit identifier for the query.
  • The parameter rd should be nonzero if recursion is desired, and zero if it is not. Nonzero = yes bestie, zero = nope.

The query itself gets placed in an allocated buffer, and a pointer to it gets stored in the variable pointed to by buf. The length of it gets stored in the variable pointed to by buflen. πŸ’–

Heads up: it is the caller's responsibility to free this buffer using ares_free_string(3) when it is no longer needed. Don't just leave it sitting there, that's not the move. 🫢

Usage of ares_mkquery(3) is deprecated, and the function is equivalent to ares_create_query(3) with max_udp_size set to 0. That's the whole tea. β˜•


πŸ”₯ RETURN VALUES πŸ”₯

ares_mkquery can return any of the following values, and each one is telling you something different:

  • ARES_SUCCESS β€” Construction of the DNS query succeeded. Slay, it worked, we ate. πŸ‘‘
  • ARES_ENOTFOUND β€” The query name name refers to a .onion domain name. See RFC 7686. Yeah, we don't do those here. πŸ§…
  • ARES_EBADNAME β€” The query name name could not be encoded as a domain name, either because it contained a zero-length label or because it contained a label of more than 63 characters. Sixty-three. That's the limit. No cap. πŸ’€
  • ARES_ENOMEM β€” Memory was exhausted. The RAM said "not today bestie." 😭

🌸 SEE ALSO 🌸


And that's the whole page, bestie!! This one came out of the Library Functions Manual, dated 20 Nov 2009 β€” yes, 2009, it's vintage, it's an icon, it's literally older than some of us, and it's still in the ARES_MKQUERY(3) section. Go forth and use the non-deprecated one though. Mwah. πŸ’–βœ¨πŸŽ€