Bug Summary

File:builds/wireshark/wireshark/epan/dissectors/packet-rpki-rtr.c
Warning:line 321, column 21
Value stored to 'ti_flags' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name packet-rpki-rtr.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -ffloat16-excess-precision=fast -fbfloat16-excess-precision=fast -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/builds/wireshark/wireshark/build -fcoverage-compilation-dir=/builds/wireshark/wireshark/build -resource-dir /usr/lib/llvm-18/lib/clang/18 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /usr/include/mit-krb5 -isystem /usr/include/libxml2 -isystem /builds/wireshark/wireshark/build/epan/dissectors -isystem /builds/wireshark/wireshark/epan/dissectors -isystem /builds/wireshark/wireshark/epan -D G_DISABLE_DEPRECATED -D G_DISABLE_SINGLE_INCLUDES -D WS_BUILD_DLL -D WS_DEBUG -D WS_DEBUG_UTF_8 -I /builds/wireshark/wireshark/build -I /builds/wireshark/wireshark -I /builds/wireshark/wireshark/include -D _GLIBCXX_ASSERTIONS -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/builds/wireshark/wireshark/= -fmacro-prefix-map=/builds/wireshark/wireshark/build/= -fmacro-prefix-map=../= -Wno-format-truncation -Wno-format-nonliteral -Wno-pointer-sign -std=gnu11 -ferror-limit 19 -fvisibility=hidden -fwrapv -fstrict-flex-arrays=3 -stack-protector 2 -fstack-clash-protection -fcf-protection=full -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fexceptions -fcolor-diagnostics -analyzer-output=html -dwarf-debug-flags /usr/lib/llvm-18/bin/clang -### --analyze -x c -D G_DISABLE_DEPRECATED -D G_DISABLE_SINGLE_INCLUDES -D WS_BUILD_DLL -D WS_DEBUG -D WS_DEBUG_UTF_8 -I /builds/wireshark/wireshark/build -I /builds/wireshark/wireshark -I /builds/wireshark/wireshark/include -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /usr/include/mit-krb5 -isystem /usr/include/libxml2 -isystem /builds/wireshark/wireshark/build/epan/dissectors -isystem /builds/wireshark/wireshark/epan/dissectors -isystem /builds/wireshark/wireshark/epan -fvisibility=hidden -fexcess-precision=fast -fstrict-flex-arrays=3 -fstack-clash-protection -fcf-protection=full -D _GLIBCXX_ASSERTIONS -fstack-protector-strong -fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -fexceptions -Wno-format-truncation -Wno-format-nonliteral -fdiagnostics-color=always -Wno-pointer-sign -fmacro-prefix-map=/builds/wireshark/wireshark/= -fmacro-prefix-map=/builds/wireshark/wireshark/build/= -fmacro-prefix-map=../= -std=gnu11 -fPIC /builds/wireshark/wireshark/epan/dissectors/packet-rpki-rtr.c -o /builds/wireshark/wireshark/sbout/2025-06-26-100304-3847-1 -Xclang -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /builds/wireshark/wireshark/sbout/2025-06-26-100304-3847-1 -x c /builds/wireshark/wireshark/epan/dissectors/packet-rpki-rtr.c
1/* packet-rpki-rtr.c
2 * Routines for RPKI-Router Protocol dissection (RFC6810)
3 * Copyright 2013, Alexis La Goutte <alexis.lagoutte at gmail dot com>
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10
11 * The information used comes from:
12 * RFC6810: The Resource Public Key Infrastructure (RPKI) to Router Protocol
13 */
14
15#include "config.h"
16
17#include <epan/packet.h>
18#include <epan/prefs.h>
19#include "packet-tcp.h"
20#include "packet-tls.h"
21#include <epan/expert.h>
22#include <epan/asn1.h>
23#include <epan/tfs.h>
24#include <wsutil/array.h>
25#include "packet-x509af.h"
26
27void proto_register_rpkirtr(void);
28void proto_reg_handoff_rpkirtr(void);
29
30static int proto_rpkirtr;
31static int hf_rpkirtr_version;
32static int hf_rpkirtr_pdu_type;
33static int hf_rpkirtr_reserved;
34static int hf_rpkirtr_session_id;
35static int hf_rpkirtr_length;
36static int hf_rpkirtr_serial_number;
37static int hf_rpkirtr_flags;
38static int hf_rpkirtr_flags_aw;
39static int hf_rpkirtr_flags_rk;
40static int hf_rpkirtr_flags_ar;
41static int hf_rpkirtr_flags_arafi;
42static int hf_rpkirtr_prefix_length;
43static int hf_rpkirtr_max_length;
44static int hf_rpkirtr_ipv4_prefix;
45static int hf_rpkirtr_ipv6_prefix;
46static int hf_rpkirtr_as_number;
47static int hf_rpkirtr_error_code;
48static int hf_rpkirtr_length_pdu;
49static int hf_rpkirtr_error_pdu;
50static int hf_rpkirtr_length_text;
51static int hf_rpkirtr_error_text;
52static int hf_rpkirtr_refresh_interval;
53static int hf_rpkirtr_retry_interval;
54static int hf_rpkirtr_expire_interval;
55static int hf_rpkirtr_subject_key_identifier;
56static int hf_rpkirtr_subject_public_key_info;
57static int hf_rpkirtr_aspa_customer_asn;
58static int hf_rpkirtr_aspa_provider_asn;
59
60#define RPKI_RTR_TCP_PORT323 323
61#define RPKI_RTR_TLS_PORT324 324
62static unsigned g_port_rpkirtr_tls = RPKI_RTR_TLS_PORT324;
63
64static int ett_rpkirtr;
65static int ett_flags;
66static int ett_flags_nd;
67static int ett_providers;
68
69static expert_field ei_rpkirtr_wrong_version_aspa;
70static expert_field ei_rpkirtr_wrong_version_router_key;
71static expert_field ei_rpkirtr_bad_length;
72
73static dissector_handle_t rpkirtr_handle;
74
75
76/* http://www.iana.org/assignments/rpki/rpki.xml#rpki-rtr-pdu */
77#define RPKI_RTR_SERIAL_NOTIFY_PDU0 0
78#define RPKI_RTR_SERIAL_QUERY_PDU1 1
79#define RPKI_RTR_RESET_QUERY_PDU2 2
80#define RPKI_RTR_CACHE_RESPONSE_PDU3 3
81#define RPKI_RTR_IPV4_PREFIX_PDU4 4
82#define RPKI_RTR_IPV6_PREFIX_PDU6 6
83#define RPKI_RTR_END_OF_DATA_PDU7 7
84#define RPKI_RTR_CACHE_RESET_PDU8 8
85#define RPKI_RTR_ROUTER_KEY9 9
86#define RPKI_RTR_ERROR_REPORT_PDU10 10
87#define RPKI_RTR_ASPA_PDU11 11
88
89static const value_string rtr_pdu_type_vals[] = {
90 { RPKI_RTR_SERIAL_NOTIFY_PDU0, "Serial Notify" },
91 { RPKI_RTR_SERIAL_QUERY_PDU1, "Serial Query" },
92 { RPKI_RTR_RESET_QUERY_PDU2, "Reset Query" },
93 { RPKI_RTR_CACHE_RESPONSE_PDU3, "Cache Response" },
94 { RPKI_RTR_IPV4_PREFIX_PDU4, "IPv4 Prefix" },
95 { RPKI_RTR_IPV6_PREFIX_PDU6, "IPv6 Prefix" },
96 { RPKI_RTR_END_OF_DATA_PDU7, "End of Data" },
97 { RPKI_RTR_CACHE_RESET_PDU8, "Cache Reset" },
98 { RPKI_RTR_ROUTER_KEY9, "Router Key" },
99 { RPKI_RTR_ERROR_REPORT_PDU10, "Error Report" },
100 { RPKI_RTR_ASPA_PDU11, "ASPA" },
101 { 0, NULL((void*)0) }
102};
103
104/* http://www.iana.org/assignments/rpki/rpki.xml#rpki-rtr-error */
105static const value_string rtr_error_code_vals[] = {
106 { 0, "Corrupt Data" },
107 { 1, "Internal Error" },
108 { 2, "No Data Available" },
109 { 3, "Invalid Request" },
110 { 4, "Unsupported Protocol Version" },
111 { 5, "Unsupported PDU Type" },
112 { 6, "Withdrawal of Unknown Record" },
113 { 7, "Duplicate Announcement Received" },
114 { 8, "Unexpected Protocol Version" },
115 { 0, NULL((void*)0) }
116};
117
118static const true_false_string tfs_flag_type_aw = {
119 "Announcement",
120 "Withdrawal"
121};
122
123static const true_false_string tfs_flag_type_rk = {
124 "New Router Key",
125 "Delete Router Key"
126};
127
128static const true_false_string tfs_flag_type_ar = {
129 "New Autonomous System Provider Authorization Record",
130 "Delete Autonomous System Provider Authorization Record"
131};
132
133static const true_false_string tfs_flag_type_afi_ar = {
134 "IPv6",
135 "IPv4",
136};
137
138static unsigned
139get_rpkirtr_pdu_len(packet_info *pinfo _U___attribute__((unused)), tvbuff_t *tvb, int offset, void *data _U___attribute__((unused)))
140{
141 uint32_t plen;
142
143 /*
144 * Get the length of the RPKI-RTR packet.
145 */
146 plen = tvb_get_ntohl(tvb, offset+4);
147
148 return plen;
149}
150
151
152static int dissect_rpkirtr_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U___attribute__((unused)))
153{
154
155 proto_item *ti = NULL((void*)0), *ti_flags, *ti_type;
156 proto_tree *rpkirtr_tree = NULL((void*)0), *flags_tree = NULL((void*)0);
157 int offset = 0;
158 uint8_t pdu_type, version;
159 unsigned length;
160
161 while (tvb_reported_length_remaining(tvb, offset) > 0) {
162
163 ti = proto_tree_add_item(tree, proto_rpkirtr, tvb, 0, -1, ENC_NA0x00000000);
164
165 rpkirtr_tree = proto_item_add_subtree(ti, ett_rpkirtr);
166
167 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_version, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
168 version = tvb_get_uint8(tvb, offset);
169 offset += 1;
170
171 ti_type = proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_pdu_type, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
172 pdu_type = tvb_get_uint8(tvb, offset);
173 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL((void*)0), val_to_str(pdu_type, rtr_pdu_type_vals, "Unknown (%d)"));
174 proto_item_append_text(ti, " (%s)", val_to_str(pdu_type, rtr_pdu_type_vals, "Unknown %d"));
175 offset += 1;
176
177 length = tvb_get_ntohl(tvb, offset);
178
179 switch (pdu_type) {
180 case RPKI_RTR_SERIAL_NOTIFY_PDU0: /* Serial Notify (0) */
181 case RPKI_RTR_SERIAL_QUERY_PDU1: /* Serial Query (1) */
182 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_session_id, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000);
183 offset += 2;
184 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
185 /* TODO: Add check length ? */
186 offset += 4;
187 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_serial_number, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
188 offset += 4;
189 break;
190 case RPKI_RTR_RESET_QUERY_PDU2: /* Reset Query (2) */
191 case RPKI_RTR_CACHE_RESET_PDU8: /* Cache Reset (8) */
192 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 2, ENC_NA0x00000000);
193 offset += 2;
194 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
195 /* TODO: Add check length ? */
196 offset += 4;
197 break;
198 case RPKI_RTR_CACHE_RESPONSE_PDU3: /* Cache Response (3) */
199 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_session_id, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000);
200 offset += 2;
201 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
202 /* TODO: Add check length ? */
203 offset += 4;
204 break;
205 case RPKI_RTR_IPV4_PREFIX_PDU4: /* IPv4 Prefix (4) */
206 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 2, ENC_NA0x00000000);
207 offset += 2;
208 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
209 /* TODO: Add check length ? */
210 offset += 4;
211 ti_flags = proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_flags, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
212 flags_tree = proto_item_add_subtree(ti_flags, ett_flags);
213 proto_tree_add_item(flags_tree, hf_rpkirtr_flags_aw, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
214 offset += 1;
215 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_prefix_length, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
216 offset += 1;
217 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_max_length, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
218 offset += 1;
219 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 1, ENC_NA0x00000000);
220 offset += 1;
221 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_ipv4_prefix, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
222 offset += 4;
223 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_as_number, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
224 offset += 4;
225 break;
226 case RPKI_RTR_IPV6_PREFIX_PDU6: /* IPv6 Prefix (6) */
227 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 2, ENC_NA0x00000000);
228 offset += 2;
229 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
230 /* TODO: Add check length ? */
231 offset += 4;
232 ti_flags = proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_flags, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
233 flags_tree = proto_item_add_subtree(ti_flags, ett_flags);
234 proto_tree_add_item(flags_tree, hf_rpkirtr_flags_aw, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
235 offset += 1;
236 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_prefix_length, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
237 offset += 1;
238 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_max_length, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
239 offset += 1;
240 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 1, ENC_NA0x00000000);
241 offset += 1;
242 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_ipv6_prefix, tvb, offset, 16, ENC_NA0x00000000);
243 offset += 16;
244 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_as_number, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
245 offset += 4;
246 break;
247 case RPKI_RTR_END_OF_DATA_PDU7: /* End Of Data (7) */
248 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_session_id, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000);
249 offset += 2;
250 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
251 /* TODO: Add check length ? */
252 offset += 4;
253 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_serial_number, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
254 offset += 4;
255
256 if (version >= 1){
257 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_refresh_interval, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
258 offset += 4;
259
260 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_retry_interval, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
261 offset += 4;
262
263 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_expire_interval, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
264 offset += 4;
265 }
266 break;
267
268 case RPKI_RTR_ROUTER_KEY9: /* Router Key (9) */
269 if(version < 1){
270 /* Error about wrong version... */
271 expert_add_info(pinfo, ti_type, &ei_rpkirtr_wrong_version_router_key);
272 } else {
273 asn1_ctx_t asn1_ctx;
274
275 ti_flags = proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_flags, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
276 flags_tree = proto_item_add_subtree(ti_flags, ett_flags_nd);
277 proto_tree_add_item(flags_tree, hf_rpkirtr_flags_rk, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
278 offset += 1;
279 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 2, ENC_NA0x00000000);
280 offset += 1;
281 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
282 /* TODO: Add check length ? */
283 offset += 4;
284 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_subject_key_identifier, tvb, offset, 20, ENC_NA0x00000000);
285 offset += 20;
286
287 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_as_number, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
288 offset += 4;
289 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true1, pinfo);
290 offset = dissect_x509af_SubjectPublicKeyInfo(false0, tvb, offset, &asn1_ctx, rpkirtr_tree, hf_rpkirtr_subject_public_key_info);
291
292 }
293 break;
294 case RPKI_RTR_ERROR_REPORT_PDU10: /* Error Report (10) */
295 {
296 uint32_t len_pdu, len_text;
297 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_error_code, tvb, offset, 2, ENC_BIG_ENDIAN0x00000000);
298 offset += 2;
299 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
300 /* TODO: Add check length ? */
301 offset += 4;
302 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length_pdu, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
303 len_pdu = tvb_get_ntohl(tvb, offset);
304 offset += 4;
305 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_error_pdu, tvb, offset, len_pdu, ENC_NA0x00000000);
306 offset += len_pdu;
307 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length_text, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
308 len_text = tvb_get_ntohl(tvb, offset);
309 offset += 4;
310 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_error_text, tvb, offset, len_text, ENC_ASCII0x00000000);
311 offset += len_text;
312 }
313 break;
314 case RPKI_RTR_ASPA_PDU11: /* ASPA (11) */
315 if(version < 2){
316 /* Error about wrong version... */
317 expert_add_info(pinfo, ti_type, &ei_rpkirtr_wrong_version_aspa);
318 } else {
319 // draft-ietf-sidrops-8210bis-21
320 // flags 1B
321 ti_flags = proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_flags, tvb, offset, 1, ENC_BIG_ENDIAN0x00000000);
Value stored to 'ti_flags' is never read
322 offset += 1;
323 // zero 1B
324 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 1, ENC_NA0x00000000);
325 offset += 1;
326 // length 4B
327 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
328 unsigned aspa_length = tvb_get_ntohl(tvb, offset);
329 offset += 4;
330 unsigned cnt_asns = (aspa_length-12)/4;
331 // customer AS (4B)
332 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_aspa_customer_asn, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
333 offset += 4;
334 // provider AS's (4B*cnt_asns)
335 proto_tree *providers_tree = proto_item_add_subtree(rpkirtr_tree, ett_providers);
336 for (unsigned i = 0; i < cnt_asns; i++) {
337 proto_tree_add_item(providers_tree, hf_rpkirtr_aspa_provider_asn, tvb, offset, 4, ENC_BIG_ENDIAN0x00000000);
338 offset += 4;
339 }
340 }
341 break;
342 default:
343 /* No default ? At least sanity check the length*/
344 if (length > tvb_reported_length(tvb)) {
345 expert_add_info(pinfo, ti_type, &ei_rpkirtr_bad_length);
346 return tvb_reported_length(tvb);
347 }
348
349 offset += length;
350 break;
351 }
352 }
353
354 return tvb_reported_length(tvb);
355}
356
357static int
358dissect_rpkirtr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
359{
360 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RPKI-RTR");
361 col_clear(pinfo->cinfo, COL_INFO);
362
363 tcp_dissect_pdus(tvb, pinfo, tree, 1, 8, get_rpkirtr_pdu_len, dissect_rpkirtr_pdu, data);
364 return tvb_reported_length(tvb);
365}
366
367void
368proto_register_rpkirtr(void)
369{
370 module_t *rpkirtr_module;
371
372 static hf_register_info hf[] = {
373 { &hf_rpkirtr_version,
374 { "Version", "rpki-rtr.version",
375 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
376 "Denoting the version of this protocol (currently 0)", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
377 },
378 { &hf_rpkirtr_pdu_type,
379 { "PDU Type", "rpki-rtr.pdu_type",
380 FT_UINT8, BASE_DEC, VALS(rtr_pdu_type_vals)((0 ? (const struct _value_string*)0 : ((rtr_pdu_type_vals)))
)
, 0x0,
381 "Denoting the type of the PDU", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
382 },
383 { &hf_rpkirtr_reserved,
384 { "Reserved", "rpki-rtr.reserved",
385 FT_BYTES, BASE_NONE, NULL((void*)0), 0x0,
386 "Must be zero", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
387 },
388 { &hf_rpkirtr_session_id,
389 { "Session ID", "rpki-rtr.session_id",
390 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
391 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
392 },
393 { &hf_rpkirtr_length,
394 { "Length", "rpki-rtr.length",
395 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
396 "Value the count of the bytes in the entire PDU, including the eight bytes of header that end with the length field", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
397 },
398 { &hf_rpkirtr_serial_number,
399 { "Serial Number", "rpki-rtr.serial_number",
400 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
401 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
402 },
403 { &hf_rpkirtr_flags,
404 { "Flags", "rpki-rtr.flags",
405 FT_UINT8, BASE_HEX, NULL((void*)0), 0x0,
406 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
407 },
408 { &hf_rpkirtr_flags_aw,
409 { "Flag AW", "rpki-rtr.flags.aw",
410 FT_BOOLEAN, 8, TFS(&tfs_flag_type_aw)((0 ? (const struct true_false_string*)0 : ((&tfs_flag_type_aw
))))
, 0x01,
411 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
412 },
413 { &hf_rpkirtr_flags_rk,
414 { "Flag Router Key", "rpki-rtr.flags.rk",
415 FT_BOOLEAN, 8, TFS(&tfs_flag_type_rk)((0 ? (const struct true_false_string*)0 : ((&tfs_flag_type_rk
))))
, 0x01,
416 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
417 },
418 { &hf_rpkirtr_flags_ar,
419 { "Flag ASPA", "rpki-rtr.flags.ar",
420 FT_BOOLEAN, 8, TFS(&tfs_flag_type_ar)((0 ? (const struct true_false_string*)0 : ((&tfs_flag_type_ar
))))
, 0x01,
421 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
422 },
423 { &hf_rpkirtr_flags_arafi,
424 { "ASPA Address Family Flag", "rpki-rtr.flags.arafi",
425 FT_BOOLEAN, 8, TFS(&tfs_flag_type_afi_ar)((0 ? (const struct true_false_string*)0 : ((&tfs_flag_type_afi_ar
))))
, 0x01,
426 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
427 },
428 { &hf_rpkirtr_prefix_length,
429 { "Prefix Length", "rpki-rtr.prefix_length",
430 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
431 "Denoting the shortest prefix allowed for the prefix", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
432 },
433 { &hf_rpkirtr_max_length,
434 { "Max length", "rpki-rtr.max_length",
435 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
436 "Denoting the longest prefix allowed by the prefix. This MUST NOT be less than the Prefix Length element", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
437 },
438 { &hf_rpkirtr_ipv4_prefix,
439 { "IPv4 Prefix", "rpki-rtr.ipv4_prefix",
440 FT_IPv4, BASE_NONE, NULL((void*)0), 0x0,
441 "The IPv4 prefix of the ROA", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
442 },
443 { &hf_rpkirtr_ipv6_prefix,
444 { "IPv6 Prefix", "rpki-rtr.ipv6_prefix",
445 FT_IPv6, BASE_NONE, NULL((void*)0), 0x0,
446 "The IPv6 prefix of the ROA", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
447 },
448 { &hf_rpkirtr_as_number,
449 { "AS Number", "rpki-rtr.as_number",
450 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
451 "Autonomous System Number allowed to announce this prefix", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
452 },
453 { &hf_rpkirtr_error_code,
454 { "Error Code", "rpki-rtr.error_code",
455 FT_UINT16, BASE_DEC, VALS(rtr_error_code_vals)((0 ? (const struct _value_string*)0 : ((rtr_error_code_vals)
)))
, 0x0,
456 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
457 },
458 { &hf_rpkirtr_length_pdu,
459 { "Length of Encapsulated PDU", "rpki-rtr.length_pdu",
460 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
461 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
462 },
463 { &hf_rpkirtr_error_pdu,
464 { "Erroneous PDU", "rpki-rtr.error_pdu",
465 FT_BYTES, BASE_NONE, NULL((void*)0), 0x0,
466 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
467 },
468 { &hf_rpkirtr_length_text,
469 { "Length of text", "rpki-rtr.length_text",
470 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
471 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
472 },
473 { &hf_rpkirtr_error_text,
474 { "Erroneous Text", "rpki-rtr.error_text",
475 FT_STRING, BASE_NONE, NULL((void*)0), 0x0,
476 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
477 },
478 { &hf_rpkirtr_refresh_interval,
479 { "Refresh Interval", "rpki-rtr.refresh_interval",
480 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
481 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
482 },
483 { &hf_rpkirtr_retry_interval,
484 { "Retry Interval", "rpki-rtr.retry_interval",
485 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
486 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
487 },
488 { &hf_rpkirtr_expire_interval,
489 { "Expire Interval", "rpki-rtr.expire_interval",
490 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
491 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
492 },
493 { &hf_rpkirtr_subject_key_identifier,
494 { "Subject Key Identifier", "rpki-rtr.subject_key_identifier",
495 FT_BYTES, BASE_NONE, NULL((void*)0), 0x0,
496 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
497 },
498 { &hf_rpkirtr_subject_public_key_info,
499 { "Subject Public Key Info", "rpki-rtr.subject_public_key_info",
500 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
501 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
502 },
503 { &hf_rpkirtr_aspa_customer_asn,
504 { "ASPA Customer ASN", "rpki-rtr.aspa_customer_asn",
505 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
506 "The Customer Autonomous System Number is the 32-bit Autonomous System Number of the customer which authenticated the ASPA RPKI data", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
507 },
508 { &hf_rpkirtr_aspa_provider_asn,
509 { "ASPA Provider ASN", "rpki-rtr.aspa_provider_asn",
510 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
511 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
512 }
513 };
514
515 static int *ett[] = {
516 &ett_rpkirtr,
517 &ett_flags,
518 &ett_flags_nd,
519 &ett_providers
520 };
521
522 static ei_register_info ei[] = {
523 { &ei_rpkirtr_wrong_version_aspa, { "rpkirtr.aspa.wrong_version", PI_MALFORMED0x07000000, PI_WARN0x00600000, "Wrong version for ASPA type", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},
524 { &ei_rpkirtr_wrong_version_router_key, { "rpkirtr.router_key.wrong_version", PI_MALFORMED0x07000000, PI_WARN0x00600000, "Wrong version for Router Key type", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},
525 { &ei_rpkirtr_bad_length, { "rpkirtr.bad_length", PI_MALFORMED0x07000000, PI_ERROR0x00800000, "Invalid length field", EXPFILL0, ((void*)0), 0, {0, {((void*)0), ((void*)0), FT_NONE, BASE_NONE
, ((void*)0), 0, ((void*)0), -1, 0, HF_REF_TYPE_NONE, -1, ((void
*)0)}}
}},
526 };
527
528 expert_module_t *expert_rpkirtr;
529
530 proto_rpkirtr = proto_register_protocol("RPKI-Router Protocol",
531 "RPKI-Router Protocol", "rpkirtr");
532
533 proto_register_field_array(proto_rpkirtr, hf, array_length(hf)(sizeof (hf) / sizeof (hf)[0]));
534 proto_register_subtree_array(ett, array_length(ett)(sizeof (ett) / sizeof (ett)[0]));
535
536 rpkirtr_module = prefs_register_protocol(proto_rpkirtr,
537 proto_reg_handoff_rpkirtr);
538
539 prefs_register_uint_preference(rpkirtr_module, "tcp.rpkirtr_tls.port", "RPKI-RTR TCP TLS Port",
540 "RPKI-Router Protocol TCP TLS port if other than the default",
541 10, &g_port_rpkirtr_tls);
542
543 expert_rpkirtr = expert_register_protocol(proto_rpkirtr);
544 expert_register_field_array(expert_rpkirtr, ei, array_length(ei)(sizeof (ei) / sizeof (ei)[0]));
545 rpkirtr_handle = register_dissector("rpkirtr", dissect_rpkirtr, proto_rpkirtr);
546}
547
548
549void
550proto_reg_handoff_rpkirtr(void)
551{
552 static bool_Bool initialized = false0;
553 static int rpki_rtr_tls_port;
554
555 if (!initialized) {
556 dissector_add_uint_with_preference("tcp.port", RPKI_RTR_TCP_PORT323, rpkirtr_handle);
557 initialized = true1;
558 } else {
559 ssl_dissector_delete(rpki_rtr_tls_port, rpkirtr_handle);
560 }
561
562 rpki_rtr_tls_port = g_port_rpkirtr_tls;
563 ssl_dissector_add(rpki_rtr_tls_port, rpkirtr_handle);
564}
565
566
567/*
568 * Editor modelines - https://www.wireshark.org/tools/modelines.html
569 *
570 * Local variables:
571 * c-basic-offset: 4
572 * tab-width: 8
573 * indent-tabs-mode: nil
574 * End:
575 *
576 * vi: set shiftwidth=4 tabstop=8 expandtab:
577 * :indentSize=4:tabSize=8:noTabs=true:
578 */