---
name: "libval_async"
section: "3"
platform: "linux"
package: "dnssec-tools"
version: "2.2.3-16"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libval_async"
---

# libval\_async(3)

submits a request for asynchronous processing of DNS queries. val\_async\_select\_info() - set the appropriate file descriptors for outstanding asynchronous requests. val\_async\_check\_wait() - handle timeouts or processes DNS responses to outstanding queries. val\_async\_cancel() - cancel an asynchronous query request. val\_async\_cancel\_all() - cancel all asynchronous queries for a given context.

## NAME

val\_async\_submit() - submits a request for asynchronous processing of DNS queries.

val\_async\_select\_info() - set the appropriate file descriptors for outstanding asynchronous requests.

val\_async\_check\_wait() - handle timeouts or processes DNS responses to outstanding queries.

val\_async\_cancel() - cancel an asynchronous query request.

val\_async\_cancel\_all() - cancel all asynchronous queries for a given context.

## SYNOPSIS

\#include \<validator/validator.h\>

typedef int (\*val\_async\_event\_cb)(val\_async\_status \*async\_status,\
                     int event, val\_context\_t \*context,\
                     void \*cb\_data, val\_cb\_params\_t \*cbp);

int val\_async\_submit(val\_context\_t \*context,\
                     const char \* name, int class,\
                     int type, unsigned int flags,\
                     val\_async\_event\_cb callback, void \*cb\_data,\
                     val\_async\_status \*\*async\_status);

int val\_async\_select\_info(val\_context\_t \*context,\
                     fd\_set \*fds,\
                     int \*num\_fds,\
                     struct timeval \*timeout);

int val\_async\_check\_wait(val\_context\_t \*context,\
                     fd\_set \*pending\_desc, int \*nfds,\
                     struct timeval \*tv, unsigned int flags);

int val\_async\_cancel(val\_context\_t \*context,\
                     val\_async\_status \*as,\
                     unsigned int flags);

int val\_async\_cancel\_all(val\_context\_t \*context,\
                     unsigned int flags);

## DESCRIPTION

The asynchronous DNSSEC validator API allows an application to submit multiple requests, which can be processed in parallel. In most cases, this will result in validation completing much sooner than a series of synchronous requests.

The *ctx* parameter in the various functions below specifies the validation context, which can be set to NULL for default values (see *[libval(3)](/libval/3.md)* and *dnsval.conf* for more details on validation contexts and alidation policy).

The *val\_async\_submit()* function submits a request for asynchronous processing of DNS queries for the data associated with the given domain *name*, *class* and *type*.  The *async\_status* object uniquely identifies a particular  request and provides a handle for future operations on that  asynchronous request, including cancelling it prior to lookup completion.

The *flags* parameter affects when and how often the  callback is called. The following flags are defined.

- **VAL\_AS\_IGNORE\_CACHE**

  Don't use any internal cache for answers to this query.

- **VAL\_AS\_NO\_NEW\_QUERIES**

  Don't send any new queries. Answers will be returned  from the internal cache.

- **VAL\_AS\_NO\_ANSWERS**

  Caller doesn't care about the answer results.  This can be used for priming the cache.

- **VAL\_AS\_NO\_CALLBACKS**

  Don't call any callbacks.

- **VAL\_AS\_NO\_CANCEL\_CALLBACKS**

  Call callbacks with results, but don't call any callbacks when the request is canceled.

- **VAL\_AS\_INTERIM\_CALLBACKS**

  Call the callback function with interim results. If this flag is not specified, the callback function will only be called when all validation results are ready.

When results from the asynchronous call become available, the  *callback* function (if non-NULL) will be called with  the *cb\_data* value, originally supplied to the *val\_async\_submit()*  call, as one of its arguments. The results from the lookup are returned in *cb\_data*, which is a pointer to the *val\_cb\_params\_t* structure shown below.

```
    typedef struct val_cb_params_s {
        val_status_t             val_status;
        char                    *name;
        int                      class_h;
        int                      type_h;
        int                      retval;
        struct val_result_chain *results;
        struct val_answer_chain *answers;
    } val_cb_params_t;
```

The *val\_cb\_params\_t* structure contains the orginal query parameters in *name*, *class\_h* and *type\_h* respectively, the  return value for the lookup operation in *retval*, pointers to the *results* and *answers* chains (see [*libval*(3)](/libval/3.md) for more details),  and the final validation status of the lookup operation in *val\_status*. The application must release the memory associated with *results* and *answers* using the *val\_free\_result\_chain()* and *val\_free\_answer\_chain()* respectively (see [*libval*(3)](/libval/3.md) for more details).

On completion of the asynchronous lookup operation, an event code is returned in *event*.  The following event types are defined:

- **VAL\_AS\_EVENT\_COMPLETED**

  The request was completed.

- **VAL\_AS\_EVENT\_INTERIM**

  The request is still being processed, but some interim results are available.

- **VAL\_AS\_EVENT\_CANCELED**

  The request was canceled. The val\_status, results and answers members of the callback parameter structure are undefined.

The *val\_async\_select\_info()* function examines all outstanding asynchronous requests for the given context and sets the appropriate file descriptors, timeout value and maximum file descriptor value in preparation for a call to *select(3)*.

The file descriptor for each socket awating a response is set in the *fds* parameter and *max\_fd* is set to the highest file descriptor number of any pending asynchronous request unless that value is less than the current vaule of *max\_fd*, in which case it is left unchanged. The *timeout* field is set to the lowest timeout value of any pending asynchronous query timeout which is less than the current value in this field by the application.

After the application calls *select(3)*, it must also call  *val\_async\_check\_wait()* with the *fd\_set* and the number of ready file  descriptors, *ndfs*, returned by *select()*. The *val\_async\_check\_wait()* function handles timeouts or processes DNS responses to outstanding queries.  It also call callbacks for completed requests.

*val\_async\_check\_wait()* provides two modes of operation.  The first is for use with an application that has its own *select()* loop.  The applications sets its own file descriptors, calls *val\_async\_select\_info()* to set file descriptors for pending queries and calls *select(*). The *fds* and *nfds* parameters from select are passed in to val\_async\_check\_wait and the timeout value is ignored.  If responses for a file descriptor are processed, the  the appropriate file descriptor in *fds* is cleared and *nfds* is decremented.

In the second mode of operation, the application can set *fds* and *nfds* to NULL specify a value for *timeout*. Here,   *val\_async\_select\_info()* and *select()* are called internally and any responses received before the timeout value expires are processed.

The *val\_async\_cancel()* function can be used to cancel the asynchronous request identified by its handle *as*, while *val\_async\_cancel\_all()* can be used to cancel all asynchronous  requests associated with a given context. The following flag may be set for the cancellation request.

- **VAL\_AS\_CANCEL\_NO\_CALLBACKS**

  Do not call completed or cancelled callbacks.

## RETURN VALUES

The *val\_async\_submit()* function returns **VAL\_NO\_ERROR** on success  and one of **VAL\_RESOURCE\_UNAVAILABLE**, **VAL\_BAD\_ARGUMENT** or **VAL\_INTERNAL\_ERROR** on failure.

*val\_async\_select\_info()* returns **VAL\_NO\_ERROR** on success and **VAL\_BAD\_ARGUMENT** if an illegal argument was passed to the function.

*val\_async\_check\_wait()* returns 0 when no pending requests are found and a positive integer when requests are still pending. A value less than zero on error.

*val\_async\_cancel()* and *val\_async\_cancel\_all()* return **VAL\_NO\_ERROR** on success.

## COPYRIGHT

Copyright 2004-2013 SPARTA, Inc.  All rights reserved. See the COPYING file included with the DNSSEC-Tools package for details.

## AUTHORS

Robert Story

## SEE ALSO

*[libval(3)](/libval/3.md)*

draft-hayatnagarkar-dnsext-validator-api

http://www.dnssec-tools.org
