1ARES_PARSE_CAA_REPLY(3)    Library Functions Manual    ARES_PARSE_CAA_REPLY(3)
2
3
4

NAME

6       ares_parse_caa_reply - Parse a reply to a DNS query of type CAA
7

SYNOPSIS

9       #include <ares.h>
10
11       int ares_parse_caa_reply(const unsigned char* abuf, int alen,
12                                struct ares_caa_reply **caa_out);
13

DESCRIPTION

15       The  ares_parse_caa_reply  function  parses  the response to a query of
16       type CAA into a linked list (one  element  per  sub-string)  of  struct
17       ares_caa_reply  The  parameters  abuf and alen give the contents of the
18       response.  The result is stored in allocated memory and a pointer to it
19       stored into the variable pointed to by caa_out.  It is the caller's re‐
20       sponsibility to free the resulting caa_out  structure  when  it  is  no
21       longer needed using the function ares_free_data(3)
22
23       The structure ares_caa_reply(3) contains the following fields:
24
25           struct ares_caa_reply {
26             struct ares_caa_reply *next;
27             int                    critical;
28             unsigned char         *property;
29             size_t                 plength; /* plength excludes null */
30             unsigned char         *value;
31             size_t                 length;  /* length excludes null */
32           };
33

RETURN VALUES

35       ares_parse_caa_reply can return any of the following values:
36
37       ARES_SUCCESS   The response was successfully parsed.
38
39       ARES_EBADRESP  The response was malformatted.
40
41       ARES_ENODATA   The response did not contain an answer to the query.
42
43       ARES_ENOMEM    Memory was exhausted.
44

EXAMPLE

46       #include <arpa/inet.h>
47       #include <time.h>
48       #include <sys/time.h>
49       #include <netdb.h>
50
51       #include <unistd.h>
52       #include <stdio.h>
53       #include <stdlib.h>
54
55       #include "ares.h"
56
57       static void dns_callback(void *arg,
58                                int status,
59                                int timeouts,
60                                unsigned char *abuf,
61                                int alen)
62         {
63           struct ares_caa_reply *caa_out;
64           int err;
65
66           err = ares_parse_caa_reply (abuf, alen, &caa_out);
67           if (err == ARES_SUCCESS)
68             {
69               struct ares_caa_reply *caa_curr;
70               for (caa_curr=caa_out; caa_curr; caa_curr=caa_curr->next)
71                 printf ("%s. CAA %i %s \"%s\"\n", arg,
72                                                   caa_curr->critical,
73                                                   caa_curr->property,
74                                                   caa_curr->value);
75             }
76           else
77             {
78               printf ("err=%i\n", err);
79             }
80           ares_free_data (caa_out);
81         }
82
83       static void main_loop(ares_channel *channel)
84         {
85           int nfds, count;
86           fd_set readers, writers;
87           struct timeval tv, *tvp;
88           while (1)
89             {
90               FD_ZERO (&readers);
91               FD_ZERO (&writers);
92               nfds = ares_fds (*channel, &readers, &writers);
93               if (nfds == 0)
94                 break;
95               tvp = ares_timeout (*channel, NULL, &tv);
96               count = select (nfds, &readers, &writers, NULL, tvp);
97               ares_process (*channel, &readers, &writers);
98             }
99         }
100
101       int main(int argc, char **argv)
102         {
103           const char *sversion;
104           int iversion;
105           int err;
106
107           sversion = ares_version (&iversion);
108           printf ("c-ares version %s\n", sversion);
109
110           char *domain = "wikipedia.org";
111           if (argc > 1)
112             domain = argv[1];
113
114           ares_channel channel;
115           if ((err = ares_init (&channel)) != ARES_SUCCESS)
116             {
117               printf ("ares_init() failed (%i)\n", err);
118               exit (EXIT_FAILURE);
119             }
120
121           ares_query (channel, domain,
122                       1,   /* ns_c_in */
123                       257, /* T_CAA */
124                       dns_callback, domain);
125
126           main_loop (&channel);
127
128           ares_destroy (channel);
129
130           exit (EXIT_SUCCESS);
131         }
132

AVAILABILITY

134       This function was first introduced in c-ares version 1.17.0.
135

SEE ALSO

137       ares_query(3) ares_free_data(3)
138

AUTHOR

140       Written  by  Danny  Sonnenschein  <my.card.god@web.de>,  on  behalf  of
141       platynum, https://platynum.ch
142
143
144
145                               16 September 2020       ARES_PARSE_CAA_REPLY(3)
Impressum