ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
dns.h
Go to the documentation of this file.
1// ProtoCore v1.0.16 - Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4/**
5 * @file dns.h
6 * @brief Layer 3 (Network) - name resolution, both directions: asking and answering.
7 *
8 * RFC 1034 sec 2.4 names two of the DNS's three major components as programs: RESOLVERS, "programs
9 * that extract information from name servers in response to client requests", described in sec 5,
10 * and NAME SERVERS, "server programs which hold information about the domain tree's structure and
11 * set information", described in sec 4. This module holds one of each and nothing else.
12 *
13 * Each component is reached through its own handle: ::Resolver and ::DnsServer. Behind @ref
14 * DnsNs::internal they are pointers rather than values, because a table in one translation unit is
15 * not a constant expression in another, so a by-value member could not be initialized from here.
16 *
17 * A component its feature flag leaves out is not a member at all, so dns.c names only what the
18 * image already contains.
19 *
20 * @author Douglas Quigg (dstroy0)
21 * @date 2026
22 */
23
24#ifndef PROTOCORE_DNS_H
25#define PROTOCORE_DNS_H
26
27#include "protocore_config.h" // the entry point: the enable gate below, and the widths
28
29#if PROTOCORE_ENABLE_DNS
30
31#if PROTOCORE_ENABLE_DNS_RESOLVER
32#include "network_drivers/network/dns/dns_resolver/dns_resolver.h" // ResolverNs: the RESOLVER (RFC 1034 sec 5)
33#endif
34#if PROTOCORE_ENABLE_DNS_SERVER
35#include "network_drivers/network/dns/dns_server/dns_server.h" // DnsServerNs: the NAME SERVER (RFC 1034 sec 4)
36#endif
38
39/**
40 * @brief Name resolution (RFC 1034 sec 2.4).
41 *
42 * The handle carries no arguments and no results: it takes no call of its own, and each component
43 * takes its own arguments off its own handle.
44 *
45 * No storage member: the RESOLVER's timer and in-flight query belong to dns_resolver.c and the NAME
46 * SERVER's record table to dns_server.c, so this module owns no pool.
47 *
48 * @var DnsNs::resolver extracts information from name servers in response to client requests
49 * (RFC 1034 sec 5)
50 * @var DnsNs::server holds the domain tree's structure and set information (RFC 1034 sec 4)
51 * @var DnsNs::present what the table holds when both components are gated out: nothing
52 *
53 * Pointers rather than values because a table in one translation unit is not a constant expression
54 * in another, so a by-value member could not be initialized from dns.c. A struct with no members is
55 * not valid C, so @ref DnsNs::present stands in when both flags are off.
56 */
57typedef struct
58{
59#if PROTOCORE_ENABLE_DNS_RESOLVER
60 ResolverNs *const resolver;
61#endif
62#if PROTOCORE_ENABLE_DNS_SERVER
63 DnsServerNs *const server;
64#endif
65#if !PROTOCORE_ENABLE_DNS_RESOLVER && !PROTOCORE_ENABLE_DNS_SERVER
66 proto_bool present;
67#endif
68} DnsNs;
69
70/** @brief The one symbol this module exports. */
71extern DnsNs Dns;
72
74
75#endif // PROTOCORE_ENABLE_DNS
76
77#endif // PROTOCORE_DNS_H
Layer 3 (Network) - the asking side of DNS: a question out, an A record back (PROTOCORE_ENABLE_DNS_RE...
Layer 3 name service - the answering side of DNS (RFC 1035), UDP port 53.
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
Definition types.h:96
_Bool proto_bool
The truth value.
Definition types.h:64
#define PROTOCORE_END_DECLS
Definition types.h:97