Bitcoin ABC 0.30.5
P2P Digital Currency
dns.h
Go to the documentation of this file.
1// Copyright (c) 2017-2019 The Bitcoin developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_SEEDER_DNS_H
6#define BITCOIN_SEEDER_DNS_H 1
7
8#include <cstddef>
9#include <cstdint>
10
11constexpr int MAX_LABEL_LENGTH = 63;
12constexpr int MAX_QUERY_NAME_LENGTH = 255;
13// Max size of the null-terminated buffer parse_name() writes to.
15
16struct addr_t {
17 int v;
18 union {
19 uint8_t v4[4];
20 uint8_t v6[16];
22};
23
24struct dns_opt_t {
25 int port;
27 int nsttl;
28 const char *host;
29 const char *addr;
30 const char *ns;
31 const char *mbox;
32 uint32_t (*cb)(void *opt, char *requested_hostname, addr_t *addr,
33 uint32_t max, uint32_t ipv4, uint32_t ipv6);
34 // stats
35 uint64_t nRequests;
36};
37
38enum class ParseNameStatus {
39 OK,
40 // Premature end of input, forward reference, component > 63 char, invalid
41 // character
43 // Insufficient space in output
45};
46
47ParseNameStatus parse_name(const uint8_t **inpos, const uint8_t *inend,
48 const uint8_t *inbuf, char *buf, size_t bufsize);
49
50// 0: k
51// -1: component > 63 characters
52// -2: insufficent space in output
53// -3: two subsequent dots
54int write_name(uint8_t **outpos, const uint8_t *outend, const char *name,
55 int offset);
56
57int dnsserver(dns_opt_t *opt);
58
59#endif // BITCOIN_SEEDER_DNS_H
ParseNameStatus
Definition: dns.h:38
ParseNameStatus parse_name(const uint8_t **inpos, const uint8_t *inend, const uint8_t *inbuf, char *buf, size_t bufsize)
Definition: dns.cpp:66
int write_name(uint8_t **outpos, const uint8_t *outend, const char *name, int offset)
Definition: dns.cpp:132
constexpr int MAX_LABEL_LENGTH
Definition: dns.h:11
int dnsserver(dns_opt_t *opt)
Definition: dns.cpp:596
constexpr int MAX_QUERY_NAME_LENGTH
Definition: dns.h:12
constexpr int MAX_QUERY_NAME_BUFFER_LENGTH
Definition: dns.h:14
const char * name
Definition: rest.cpp:47
Definition: dns.h:16
uint8_t v6[16]
Definition: dns.h:20
union addr_t::@17 data
uint8_t v4[4]
Definition: dns.h:19
int v
Definition: dns.h:17
Definition: dns.h:24
int nsttl
Definition: dns.h:27
const char * ns
Definition: dns.h:30
uint32_t(* cb)(void *opt, char *requested_hostname, addr_t *addr, uint32_t max, uint32_t ipv4, uint32_t ipv6)
Definition: dns.h:32
int datattl
Definition: dns.h:26
const char * addr
Definition: dns.h:29
uint64_t nRequests
Definition: dns.h:35
const char * host
Definition: dns.h:28
int port
Definition: dns.h:25
const char * mbox
Definition: dns.h:31