1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
// Copyright (c) 2026 Erik Lening (hollowpointer) and Contributors
//
// This file is part of Zond Engine, licensed under the GNU Affero General
// Public License, version 3 or later. See the LICENSE file for details, or
// <https://www.gnu.org/licenses/agpl-3.0.html>.
//
// SPDX-License-Identifier: AGPL-3.0-or-later
//! # Which IP protocols a host's stack accepts
//!
//! A port scan asks what is listening behind a transport. This asks a question
//! one layer down: which protocols the host's stack takes delivery of at all.
//! GRE, ESP, OSPF and IPIP have no ports to enumerate, so a scan that asks about
//! TCP and UDP reports a tunnel endpoint or a router as an empty host.
//!
//! It also reads a different policy. A firewall has a rule for which ports it
//! forwards and a rule for which protocols it forwards, and the second is
//! usually the shorter list and the more revealing one: a host whose every TCP
//! port is closed and which answers for protocol 47 is one end of a tunnel.
//!
//! ## Not a port under another name
//!
//! An IP protocol number is not a port, and the difference is not a matter of
//! taste. The numbers this enumerates are a set that contains the transports:
//! [`Protocol::Tcp`](crate::model::port::Protocol::Tcp) is protocol 6,
//! [`Udp`](crate::model::port::Protocol::Udp) is 17 and
//! [`Sctp`](crate::model::port::Protocol::Sctp) is 132, so a variant sitting
//! beside those three to mean "an IP protocol" would be a category naming its
//! own members. A [`Port`](crate::model::port::Port) also carries a service, a
//! TLS handshake and the account of a segment, none of which a protocol number
//! has, and reusing it would put four empty halves on every record.
//!
//! So this is a fact about the host, kept where the other whole-host conclusions
//! are, beside [`Filtering`](super::Filtering).
/// What a scan established about a host accepting one IP protocol.
///
/// Ordered from least definitive to most, so that [`Host::merge`](super::Host)
/// promotes by an ordinary comparison and two probes that disagree resolve to
/// whichever learned more.
///
/// The order is not [`PortState`](crate::model::port::PortState)'s, and the
/// difference is in what the words mean here.
/// [`Filtered`](Self::Filtered) is a packet here, an intermediary refusing the
/// protocol in its own words, where a port scan reaches the same word from
/// silence. So it outranks the silent verdict here and sits below it there.
/// The IANA name for a protocol number, where it has one worth printing.
///
/// A short list rather than the whole registry. What a reader needs is to
/// recognise the numbers a scan is likely to find something at, and a table of a
/// hundred and fifty assignments most of which no host has ever answered for
/// would cost more to keep current than it pays back. A number with no name here
/// is rendered as the number, which is what it is.
///
/// Lowercase, matching the registry's own keyword column and
/// [`record::wire`](crate::record::wire)'s convention for a name on the wire.
pub const
// ╔════════════════════════════════════════════╗
// ║ ████████╗███████╗███████╗████████╗███████╗ ║
// ║ ╚══██╔══╝██╔════╝██╔════╝╚══██╔══╝██╔════╝ ║
// ║ ██║ █████╗ ███████╗ ██║ ███████╗ ║
// ║ ██║ ██╔══╝ ╚════██║ ██║ ╚════██║ ║
// ║ ██║ ███████╗███████║ ██║ ███████║ ║
// ║ ╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚══════╝ ║
// ╚════════════════════════════════════════════╝