Plan 9 from Bell Labs’s /usr/web/sources/contrib/anothy/src/lib/djb-ape/dns/dns_ip4.3

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


.TH dns_ip4 3
.SH NAME
dns_ip4 \- find IP addresses for FQDNs
.SH SYNTAX
.B #include <dns.h>

void \fBdns_ip4\fP(&\fIout\fR,&\fIfqdn\fR);
.br
void \fBdns_ip4_packet\fP(&\fIout\fR,char *\fIbuf\fR,unsigned int \fIlen\fR);

stralloc \fIout\fR = {0};
.br
stralloc \fIfqdn\fR = {0};

.SH DESCRIPTION
.B dns_ip4
looks up 4-byte IP addresses for the fully-qualified domain name in
\fIfqdn\fR. It puts the concatenation of the IP addresses into \fIout\fR and returns
0. If the domain does not exist in DNS, or has no IP addresses, \fIout\fR will
be empty.

If \fBdns_ip4\fR has trouble with the DNS lookup or runs out of memory, it
returns -1, setting \fIerrno\fR appropriately. It may or may not change \fIout\fR.

If \fIfqdn\fR is a dotted-decimal IP address, \fBdns_ip4\fR puts that IP
address into \fIout\fR without checking DNS. More generally, if
\fIfqdn\fR is a dot-separated sequence of dotted-decimal IP addresses,
\fBdns_ip4\fR puts those IP addresses into \fIout\fR without checking
DNS. Brackets may appear inside the dotted-decimal IP addresses; they
are ignored.

.B dns_ip4_packet
is a low-level component of \fBdns_ip4\fR, designed to support
asynchronous DNS lookups. It reads a DNS packet of length \fIlen\fR from \fIbuf\fR,
extracts IP addresses from the answer section of the packet, puts the
addresses into \fIout\fR, and returns 0 or -1 the same way as \fIdns_ip4\fR.

.SH "SEE ALSO"
dns_ip4_qualify(3), dns_ip6(3), dns_name4(3)

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.