---
name: "val_res_query"
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/val_res_query"
---

# val\_res\_query(3)

DNSSEC-validated resolution of DNS queries

## NAME

val\_res\_query(), val\_res\_search() - DNSSEC-validated resolution of DNS queries

## SYNOPSIS

```
  #include <validator/validator.h>
  int val_res_query(const val_context_t *ctx,
                    const char *dname,
                    int class,
                    int type,
                    unsigned char *answer,
                    int anslen,
                    val_status_t *val_status);
  int val_res_search(val_context_t * ctx,
            const char *dname,
            int class_h,
            int type,
            unsigned char * answer,
            int anslen,
            val_status_t * val_status);
```

## DESCRIPTION

The *val\_res\_query()* function performs DNSSEC validation of DNS queries.  It is a DNSSEC-aware substitute for the *[res\_query(3)](/res_query/3.md)* legacy function. *val\_res\_search()* performs an operation similar to *val\_res\_query()*. In addition, it uses the search paths specified within the **/etc/resolv.conf** file to create the fully qualified domain name. *val\_res\_search()* is a DNSSEC-aware substitute for the *[res\_search(3)](/res_search/3.md)* function.

The *ctx* parameter is the validator context and can be set to NULL for default settings.  More information about this field can be found in *[libval(3)](/libval/3.md)*.

The *dname* parameter specifies the domain name, *class* specifies the DNS class and *type* specifies the DNS type.

The validation status values for *val\_res\_query()* and *val\_res\_search()* functions are returned in their respective *val\_status* fields. *p\_val\_status()* returns a brief string description of the error code.  *val\_istrusted()* determines if the status code indicates that the response can be trusted and *val\_isvalidated()* determines if the status code indicates that the response was validated.  (See *[libval(3)](/libval/3.md)* for further information).

## RETURN VALUES

*val\_res\_query()* and *val\_res\_search()* return the number of bytes received on success and -1 on failure.

## COPYRIGHT

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

## AUTHORS

Abhijit Hayatnagarkar, Suresh Krishnaswamy, Robert Story.

## SEE ALSO

*[res\_query(3)](/res_query/3.md)*

*get\_context(3)*, *[val\_getaddrinfo(3)](/val_getaddrinfo/3.md)*, *[val\_gethostbyname(3)](/val_gethostbyname/3.md)*

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

http://www.dnssec-tools.org
