val_getaddrinfo(3)
π val_getaddrinfo(3) β the DNSSEC-validated glow-up of getaddrinfo π
okay bestie, sit down, we're doing a val_getaddrinfo(3) deep dive and it's genuinely iconic. this is a Programmer's Manual page, so grab a strawberry something and let's go πβ¨
β¨ NAME β¨
val_getaddrinfo() β get DNSSEC-validated network address and service translation
like, it's the version of getaddrinfo that actually checked its sources first. no cap. π
π SYNOPSIS π
#include <validator/validator.h>
int val_getaddrinfo(const struct val_context *ctx,
const char *nodename,
const char *servname,
const struct addrinfo *hints,
struct addrinfo **res,
val_status_t * val_status);
int val_getnameinfo(val_context_t * ctx,
const struct sockaddr *sa,
socklen_t salen,
char *host,
size_t hostlen,
char *serv,
size_t servlen,
int flags,
val_status_t * val_status);
two functions, one page, both serving. π
π¦ DESCRIPTION π¦
so val_getaddrinfo() and val_getnameinfo do DNSSEC validation of DNS queries. they're literally designed to be the DNSSEC-aware replacements for getaddrinfo(3) and getnameinfo(3). glow-up era fr fr.
val_getaddrinfo() returns a network address value of type struct addrinfo in the res parameter. and val_getnameinfo is the one you call to convert a sockaddr structure into a pair of host name and service strings. two different jobs, both eating. π₯
val_status gives the combined validation status value for all answers returned by the each of the functions. and listen β val_istrusted() and val_isvalidated() are your besties for figuring out whether data is actually trustworthy, and p_val_status() can show that status value to the user in ASCII format. (See libval(3) more for information.) π
the ctx parameter specifies the validation context, and you can set it to NULL for default values. (see libval(3) and dnsval.conf for more details on validation contexts and validation policy.) like, NULL = just use the defaults, it's giving low-effort-but-correct. π
the nodename, servname, and hints parameters have similar syntax and semantics as the corresponding parameters for the original getaddrinfo() function. the res parameter is similar to the res parameter for getaddrinfo(). and please, bestie, see the manual page for getaddrinfo(3) for more details about these parameters. i'm not gatekeeping, i'm just pointing you to the source. π
π RETURN VALUES π
val_getaddrinfo() returns 0 on success and a non-zero error code on failure. slay when it's 0, screaming crying when it's not. π
*res will point to a dynamically allocated linked list of addrinfo structures on success, and will be NULL if no answer was available. so if you get NULL, that's not a bug, that's the vibe. π«Ά
the val_status parameter gives an indication for trustworthiness of data. if *res is NULL, this value gives an indication of whether the non-existence of data can be trusted or not. so even the "nothing here" has lore. π
β EXAMPLE β
here's the whole thing, verbatim, no edits, we respect the source code in this house:
#include <stdio.h>
#include <stdlib.h>
#include <validator.h>
int main(int argc, char *argv[])
{
struct addrinfo *ainfo = NULL;
int retval;
if (argc < 2) {
printf("Usage: %s <hostname>\n", argv[0]);
exit(1);
}
retval = val_getaddrinfo(NULL, argv[1], NULL, NULL, &ainfo);
if ((retval == 0) && (ainfo != NULL)) {
printf("Validation Status = %d [%s]\n",
ainfo->ai_val_status,
p_val_status(ainfo->ai_val_status));
val_freeaddrinfo(ainfo);
}
return 0;
}
not the val_freeaddrinfo(ainfo) at the end though β clean up after yourself, bestie, memory leaks are NOT the aesthetic. π§
π COPYRIGHT π
Copyright 2004-2013 SPARTA, Inc. All rights reserved. See the COPYING file included with the DNSSEC-Tools package for details.
(legal stuff but make it fashion π)
π AUTHORS π
Abhijit Hayatnagarkar, Michael Baer
the icons who wrote this. we stan. πΈ
π SEE ALSO π
and that's the page, bestie!! π this whole thing shipped as perl v5.18.4 dated 2015-04-27 β yeah, she's vintage, she's a classic, and she still validates. periodt. π
β¨π¦
π¦ where this page comes from
- arch rolling: dnssec-tools 2.2.3-16 Β· BSD
- fedora 43: dnssec-tools-libs-devel 2.2.3-30.fc43 Β· LicenseRef-Callaway-BSD
- fedora 43: dnssec-tools-libs-devel 2.2.3-30.fc43 Β· LicenseRef-Callaway-BSD
- fedora 44: dnssec-tools-libs-devel 2.2.3-32.fc44 Β· LicenseRef-Callaway-BSD
- fedora 44: dnssec-tools-libs-devel 2.2.3-32.fc44 Β· LicenseRef-Callaway-BSD
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms