ARES_MKQUERY(3)
β¨ 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
namegives 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
dnsclassandtypegive the class and type of the query, using the values defined in<arpa/nameser.h>. - The parameter
idgives a 16-bit identifier for the query. - The parameter
rdshould 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 namenamerefers to a.oniondomain name. See RFC 7686. Yeah, we don't do those here. π§ARES_EBADNAMEβ The query namenamecould 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. πβ¨π
π¦ where this page comes from
- alpine 3.22: c-ares-doc 1.34.9-r0 Β· MIT
- alpine 3.23: c-ares-doc 1.34.9-r0 Β· MIT
- alpine 3.24: c-ares-doc 1.34.9-r0 Β· MIT
- arch rolling: c-ares 1.34.9-1 Β· MIT
- centos-stream 10: c-ares-devel 1.34.9-1.el10 Β· MIT
- debian trixie: libc-ares-dev 1.34.5-1+deb13u1 Β· MIT
- fedora 43: c-ares-devel 1.34.5-2.fc43 Β· MIT
- fedora 43: c-ares-devel 1.34.5-2.fc43 Β· MIT
- fedora 43: c-ares-devel 1.34.8-1.fc43 Β· MIT
- fedora 43: c-ares-devel 1.34.8-1.fc43 Β· MIT
- fedora 44: c-ares-devel 1.34.6-3.fc44 Β· MIT
- fedora 44: c-ares-devel 1.34.6-3.fc44 Β· MIT
- fedora 44: c-ares-devel 1.34.8-1.fc44 Β· MIT
- fedora 44: c-ares-devel 1.34.8-1.fc44 Β· MIT
- nixos 26.05: c-ares 1.34.9
- nixpkgs unstable: c-ares 1.34.8
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- ubuntu questing: libc-ares-dev 1.34.5-1
- ubuntu questing: libc-ares-dev 1.34.5-1ubuntu0.1
- ubuntu resolute: libc-ares-dev 1.34.6-1 Β· MIT
- ubuntu resolute: libc-ares-dev 1.34.6-1ubuntu0.1
- ubuntu resolute: libc-ares-dev 1.34.6-1ubuntu0.2 Β· MIT
- ubuntu stonking: libc-ares-dev 1.34.8-1 Β· MIT
- π the page's license: MIT
- Copyright 1998, 2000 by the Massachusetts Institute of Technology
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms