from small one page howto to huge articles all in one place

search text in:




Other .linuxhowtos.org sites:gentoo.linuxhowtos.org



Last additions:
using iotop to find disk usage hogs

using iotop to find disk usage hogs

words:

887

views:

209583

userrating:


May 25th. 2007:
Words

486

Views

258591

why adblockers are bad


Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

words:

161

views:

149881

userrating:


April, 26th. 2006:

Druckversion
You are here: manpages





ARES_PARSE_CAA_REPLY

Section: C Library Functions (3)
Updated: 16 September 2020
Index Return to Main Contents
 

NAME

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

SYNOPSIS

#include <ares.h>

int ares_parse_caa_reply(const unsigned char* abuf, int alen,
                         struct ares_caa_reply **caa_out);
 

DESCRIPTION

The ares_parse_caa_reply function parses the response to a query of type CAA into a linked list (one element per su-string) of struct ares_caa_reply The parameters abuf and alen give the contents of the response. The result is stored in allocated memory and a pointer to it stored into the variable pointed to by caa_out. It is the caller's responsibility to free the resulting caa_out structure when it is no longer needed using the function ares_free_data(3)

The structure ares_caa_reply(3) contains the following fields:

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 */
};

 

RETURN VALUES

ares_parse_caa_reply can return any of the following values:
ARES_SUCCESS
The response was successfully parsed.
ARES_EBADRESP
The response was malformatted.
ARES_ENODATA
The response did not contain an answer to the query.
ARES_ENOMEM
Memory was exhausted.
 

EXAMPLE

#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_cur->next)
          printf ("%s. CAA %i %s "%s"n", arg,
                                            caa_cur->critical,
                                            caa_cur->property,
                                            caa_cur->value);
      }
    else
      {
        printf ("err=%in", 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 ("-ares version %sn", 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);
  }
 

AVAILABILITY

This function was first introduced in -ares version 1.17.0.  

SEE ALSO

ares_query(3) ares_free_data(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUES
EXAMPLE
AVAILABILITY
SEE ALSO





Support us on Content Nation
rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004-2025 Sascha Nitsch Unternehmensberatung GmbH
Valid XHTML1.1 : Valid CSS
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 12.7 ms