Skip to content

Commit ad57dfc

Browse files
vasildfurszy
authored andcommitted
net: document enum Network
1 parent cb160de commit ad57dfc

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/netaddress.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,36 @@
1818
#include <string>
1919
#include <vector>
2020

21-
enum Network {
21+
/**
22+
* A network type.
23+
* @note An address may belong to more than one network, for example `10.0.0.1`
24+
* belongs to both `NET_UNROUTABLE` and `NET_IPV4`.
25+
* Keep these sequential starting from 0 and `NET_MAX` as the last entry.
26+
* We have loops like `for (int i = 0; i < NET_MAX; i++)` that expect to iterate
27+
* over all enum values and also `GetExtNetwork()` "extends" this enum by
28+
* introducing standalone constants starting from `NET_MAX`.
29+
*/
30+
enum Network
31+
{
32+
/// Addresses from these networks are not publicly routable on the global Internet.
2233
NET_UNROUTABLE = 0,
34+
35+
/// IPv4
2336
NET_IPV4,
37+
38+
/// IPv6
2439
NET_IPV6,
40+
41+
/// TORv2
2542
NET_ONION,
43+
44+
/// A set of dummy addresses that map a name to an IPv6 address. These
45+
/// addresses belong to RFC4193's fc00::/7 subnet (unique-local addresses).
46+
/// We use them to map a string or FQDN to an IPv6 address in CAddrMan to
47+
/// keep track of which DNS seeds were used.
2648
NET_INTERNAL,
2749

50+
/// Dummy value to indicate the number of NET_* constants.
2851
NET_MAX,
2952
};
3053

0 commit comments

Comments
 (0)