sortix-mirror/libc/sys/dnsconfig/getdnsconfig.2

131 lines
2.2 KiB
Groff
Raw Normal View History

.Dd December 13, 2021
.Dt GETDNSCOFIG 2
.Os
.Sh NAME
.Nm getdnsconfig ,
.Nm setdnsconfig
.Nd get and set the kernel DNS resolver list
.Sh SYNOPSIS
.In sys/dnsconfig.h
.Fd #define DNSCONFIG_MAX_SERVERS 3
.Ft int
.Fn getdnsconfig "struct dnsconfig *cfg"
.Ft int
.Fn getdnsconfig "const struct dnsconfig *cfg"
.Sh DESCRIPTION
.Fn getdnsconfig
gets and
.Fn setdnsconfig
sets the kernel DNS resolver list.
.Pp
.Fa cfg
points to a
.Vt struct dnsconfig
structure.
The
.Fa servers
array can contain up to
.Dv DNSCONFIG_MAX_SERVERS
DNS resolvers.
The
.Fa servers_count
field marks how many of the entries in
.Fa servers
are populated.
.Bd -literal
struct dnsconfig {
size_t servers_count;
struct dnsconfig_server servers[DNSCONFIG_MAX_SERVERS];
}
.Ed
.Pp
Each DNS resolver in the
.Fa servers
array is described by a
.Vt struct dnsconfig_server
structure.
The resolver can be defined by either an IPv4 or an IPv6 address.
.Pp
For an IPv4 address
.Fa family
is
.Dv AF_INET ,
.Fa addrsize
is
.Fn sizeof "struct in_addr" ,
and the address is stored in the
.Fa in
field of the
.Fa addr
union.
.Pp
For an IPv6 address
.Fa family
is
.Dv AF_INET6 ,
.Fa addrsize
is
.Fn sizeof "struct in_addr6" ,
and the address is stored in the
.Fa in6
field of the
.Fa addr
union.
.Bd -literal
union dnsconfig_server_union {
struct in_addr in;
struct in6_addr in6;
}
struct dnsconfig_server {
sa_family_t family;
size_t addrsize;
union dnsconfig_server_union addr;
}
.Ed
.Sh RETURN VALUES
On success 0 is returned.
On error -1 is returned, and
.Va errno
is set appropriately.
.Sh ERRORS
.Fn getdnsconfig
and
.Fn setdnsconfig
will fail if:
.Bl -tag -width "12345678"
.It Er EFAULT
.Fa cfg
points to an invalid address.
.El
.Pp
.Fn setdnsconfig
will additionally fail if:
.Bl -tag -width "12345678"
.It Er EAFNOSUPPORT
.Fa family
is set to an address family other than
.Dv AF_INET
or
.Dv AF_INET6 .
.It Er EINVAL
.Fa servers_count
is larger than
.Dv DNSCONFIG_MAX_SERVERS .
.It Er EINVAL
.Fa addrsize
does not match the size of the address corresponding to
.Fa family .
.El
.Sh SEE ALSO
Add networking stack. This change adds all the kernel parts of a network stack. The network stack is partial but implements many of the important parts. Add if(4) network interface abstraction. Network interfaces are registered in a global list that can be iterated and each assigned an unique integer identifier. Add reference counted packets with a cache that recycles recent packets. Add support for lo(4) loopback and ether(4) ethernet network interfaces. The /dev/lo0 loopback device is created automatically on boot. Add arp(4) address resolution protocol driver for translation of inet(4) network layer addresses into ether(4) link layer addresses. arp(4) entries are cached and evicted from the cache when needed or when the entry has not been used for a while. The cache is limited to 256 entries for now. Add ip(4) internet protocol version 4 support. IP fragmentation and options are not implemented yet. Add tcp(4) transmission control protocol sockets for a reliable transport layer protocol that provides a reliable byte stream connection between two hosts. The implementation is incomplete and does not yet implement out of band data, options, and high performance extensions. Add udp(4) user datagram protocol sockets for a connectionless transport layer that provides best-effort delivery of datagrams. Add ping(4) sockets for a best-effort delivery of echo datagrams. Change type of sa_family_t from unsigned short to uint16_t. Add --disable-network-drivers to the kernel(7) options and expose it with a bootloader menu. tix-iso-bootconfig can set this option by default. Import CRC32 code from libz for the Ethernet checksum. This is a compatible ABI change that adds features to socket(2) (AF_INET, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_PING), the ioctls for if(4), socket options, and the lo0 loopback interface. This commit is based on work by Meisaka Yukara contributed as the commit bbf7f1e8a5238a2bd1fe8eb1d2cc5c9c2421e2c4. Almost no lines of this work remains in this final commit as it has been rewritten or refactored away over the years, see the individual file headers for which files contain remnants of this work. Co-authored-by: Meisaka Yukara <Meisaka.Yukara@gmail.com>
2022-12-04 23:35:21 +00:00
.Xr inet 4 ,
.Xr inet6 4 ,
.Xr dhclient 8 ,
.Xr dnsconfig 8
.Sh HISTORY
The
.Fn getdnsconfig
and
.Fn setdnsconfig
system calls originally appeared in Sortix 1.1.