ARES_PARSE_CAA_REPLY(3)
π ARES_PARSE_CAA_REPLY π
okay bestie, so this one's from the Library Functions Manual and it's called ares_parse_caa_reply, and no cap it is SO much simpler than it sounds. it's the CAA parser. that's it. that's the whole vibe. π¦
β¨ NAME β¨
ares_parse_caa_reply β parse a reply to a DNS query of type CAA
like. the name literally tells you everything. she parses. she's a CAA reply. iconic behaviour honestly. π
πΈ SYNOPSIS πΈ
#include <ares.h>
int ares_parse_caa_reply(const unsigned char* abuf, int alen,
struct ares_caa_reply **caa_out);
π DESCRIPTION π
so ares_parse_caa_reply takes the response to a query of type CAA and turns it into a linked list β one element per sub-string, bestie, don't forget that part β made of struct ares_caa_reply β¨
the params abuf and alen are literally just the contents of the response, hand them over and she'll do her thing. the result gets stored in allocated memory, and a pointer to it gets stored into the variable pointed to by caa_out. π
β οΈ and listen β it is the caller's responsibility to free the resultingcaa_outstructure when it's no longer needed, usingares_free_data(3). do NOT forget. she will not clean up after you. that's your job, bestie. π
the structure ares_caa_reply(3) has these fields, and they're giving very much:
struct ares_caa_reply {
struct ares_caa_reply *next;
int critical;
unsigned char *property;
size_t plength; /* plength excludes null */
unsigned char *value;
size_t length; /* length excludes null */
};
quick notes so you don't get confused later: plength does NOT include the null, and length also does NOT include the null. she's precise like that. π
β RETURN VALUES β
ares_parse_caa_reply can return any of these, so let's go through them one by one, no skipping:
ARES_SUCCESSβ the response was successfully parsed. slay! πARES_EBADRESPβ the response was malformatted. it's giving broken. πARES_ENODATAβ the response did not contain an answer to the query. empty. void. nothing there. πARES_ENOMEMβ memory was exhausted. she ran out of room, it happens. π
π EXAMPLE π
okay here's a whole entire working example, copy it, love it, run it:
#include <arpa/inet.h>
#include <time.h>
#include <sys/time.h>
#include <netdb.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "ares.h"
static void dns_callback(void *arg,
int status,
int timeouts,
unsigned char *abuf,
int alen)
{
struct ares_caa_reply *caa_out;
int err;
err = ares_parse_caa_reply (abuf, alen, &caa_out);
if (err == ARES_SUCCESS)
{
struct ares_caa_reply *caa_curr;
for (caa_curr=caa_out; caa_curr; caa_curr=caa_curr->next)
printf ("%s. CAA %i %s \"%s\"\n", arg,
caa_curr->critical,
caa_curr->property,
caa_curr->value);
}
else
{
printf ("err=%i\n", err);
}
ares_free_data (caa_out);
}
static void main_loop(ares_channel_t **channel)
{
int nfds, count;
fd_set readers, writers;
struct timeval tv, *tvp;
while (1)
{
FD_ZERO (&readers);
FD_ZERO (&writers);
nfds = ares_fds (*channel, &readers, &writers);
if (nfds == 0)
break;
tvp = ares_timeout (*channel, NULL, &tv);
count = select (nfds, &readers, &writers, NULL, tvp);
ares_process (*channel, &readers, &writers);
}
}
int main(int argc, char **argv)
{
const char *sversion;
int iversion;
int err;
sversion = ares_version (&iversion);
printf ("c-ares version %s\n", sversion);
char *domain = "wikipedia.org";
if (argc > 1)
domain = argv[1];
ares_channel_t *channel;
if ((err = ares_init (&channel)) != ARES_SUCCESS)
{
printf ("ares_init() failed (%i)\n", err);
exit (EXIT_FAILURE);
}
ares_query (channel, domain,
1, /* ns_c_in */
257, /* T_CAA */
dns_callback, domain);
main_loop (&channel);
ares_destroy (channel);
exit (EXIT_SUCCESS);
}
see how she loops over caa_curr=caa_out; caa_curr; caa_curr=caa_curr->next? that's the linked list walk, bestie. and notice 257 is T_CAA and 1 is ns_c_in β the comments are right there, iykyk. π₯
π§ AVAILABILITY π§
this function was first introduced in c-ares version 1.17.0. so if you're on something older, sorry babe, she doesn't exist yet. π
π SEE ALSO π
and that's the whole page!! mwah π this was ARES_PARSE_CAA_REPLY(3) from the Library Functions Manual, dated 16 September 2020. go parse some CAA records and free your memory, bestie π«Άπβ¨
π¦ 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 2020 Danny Sonnenschein <my.card.god@web.de>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms