Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-rpki-rtr.c
blobfc92a2fb806d0f15db9daafd7e1c74dc3cfa936f
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>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
11 * The information used comes from:
12 * RFC6810: The Resource Public Key Infrastructure (RPKI) to Router Protocol
15 #include "config.h"
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"
27 void proto_register_rpkirtr(void);
28 void proto_reg_handoff_rpkirtr(void);
30 static int proto_rpkirtr;
31 static int hf_rpkirtr_version;
32 static int hf_rpkirtr_pdu_type;
33 static int hf_rpkirtr_reserved;
34 static int hf_rpkirtr_session_id;
35 static int hf_rpkirtr_length;
36 static int hf_rpkirtr_serial_number;
37 static int hf_rpkirtr_flags;
38 static int hf_rpkirtr_flags_aw;
39 static int hf_rpkirtr_flags_rk;
40 static int hf_rpkirtr_flags_ar;
41 static int hf_rpkirtr_flags_arafi;
42 static int hf_rpkirtr_prefix_length;
43 static int hf_rpkirtr_max_length;
44 static int hf_rpkirtr_ipv4_prefix;
45 static int hf_rpkirtr_ipv6_prefix;
46 static int hf_rpkirtr_as_number;
47 static int hf_rpkirtr_error_code;
48 static int hf_rpkirtr_length_pdu;
49 static int hf_rpkirtr_error_pdu;
50 static int hf_rpkirtr_length_text;
51 static int hf_rpkirtr_error_text;
52 static int hf_rpkirtr_refresh_interval;
53 static int hf_rpkirtr_retry_interval;
54 static int hf_rpkirtr_expire_interval;
55 static int hf_rpkirtr_subject_key_identifier;
56 static int hf_rpkirtr_subject_public_key_info;
57 static int hf_rpkirtr_aspa_provider_as_count;
58 static int hf_rpkirtr_aspa_customer_asn;
59 static int hf_rpkirtr_aspa_provider_asn;
61 #define RPKI_RTR_TCP_PORT 323
62 #define RPKI_RTR_TLS_PORT 324
63 static unsigned g_port_rpkirtr_tls = RPKI_RTR_TLS_PORT;
65 static int ett_rpkirtr;
66 static int ett_flags;
67 static int ett_flags_nd;
68 static int ett_providers;
70 static expert_field ei_rpkirtr_wrong_version_aspa;
71 static expert_field ei_rpkirtr_wrong_version_router_key;
72 static expert_field ei_rpkirtr_bad_length;
74 static dissector_handle_t rpkirtr_handle;
77 /* http://www.iana.org/assignments/rpki/rpki.xml#rpki-rtr-pdu */
78 #define RPKI_RTR_SERIAL_NOTIFY_PDU 0
79 #define RPKI_RTR_SERIAL_QUERY_PDU 1
80 #define RPKI_RTR_RESET_QUERY_PDU 2
81 #define RPKI_RTR_CACHE_RESPONSE_PDU 3
82 #define RPKI_RTR_IPV4_PREFIX_PDU 4
83 #define RPKI_RTR_IPV6_PREFIX_PDU 6
84 #define RPKI_RTR_END_OF_DATA_PDU 7
85 #define RPKI_RTR_CACHE_RESET_PDU 8
86 #define RPKI_RTR_ROUTER_KEY 9
87 #define RPKI_RTR_ERROR_REPORT_PDU 10
88 #define RPKI_RTR_ASPA_PDU 11
90 static const value_string rtr_pdu_type_vals[] = {
91 { RPKI_RTR_SERIAL_NOTIFY_PDU, "Serial Notify" },
92 { RPKI_RTR_SERIAL_QUERY_PDU, "Serial Query" },
93 { RPKI_RTR_RESET_QUERY_PDU, "Reset Query" },
94 { RPKI_RTR_CACHE_RESPONSE_PDU, "Cache Response" },
95 { RPKI_RTR_IPV4_PREFIX_PDU, "IPv4 Prefix" },
96 { RPKI_RTR_IPV6_PREFIX_PDU, "IPv6 Prefix" },
97 { RPKI_RTR_END_OF_DATA_PDU, "End of Data" },
98 { RPKI_RTR_CACHE_RESET_PDU, "Cache Reset" },
99 { RPKI_RTR_ROUTER_KEY, "Router Key" },
100 { RPKI_RTR_ERROR_REPORT_PDU, "Error Report" },
101 { RPKI_RTR_ASPA_PDU, "ASPA" },
102 { 0, NULL }
105 /* http://www.iana.org/assignments/rpki/rpki.xml#rpki-rtr-error */
106 static const value_string rtr_error_code_vals[] = {
107 { 0, "Corrupt Data" },
108 { 1, "Internal Error" },
109 { 2, "No Data Available" },
110 { 3, "Invalid Request" },
111 { 4, "Unsupported Protocol Version" },
112 { 5, "Unsupported PDU Type" },
113 { 6, "Withdrawal of Unknown Record" },
114 { 7, "Duplicate Announcement Received" },
115 { 8, "Unexpected Protocol Version" },
116 { 0, NULL }
119 static const true_false_string tfs_flag_type_aw = {
120 "Announcement",
121 "Withdrawal"
124 static const true_false_string tfs_flag_type_rk = {
125 "New Router Key",
126 "Delete Router Key"
129 static const true_false_string tfs_flag_type_ar = {
130 "New Autonomous System Provider Authorization Record",
131 "Delete Autonomous System Provider Authorization Record"
134 static const true_false_string tfs_flag_type_afi_ar = {
135 "IPv6",
136 "IPv4",
139 static unsigned
140 get_rpkirtr_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
142 uint32_t plen;
145 * Get the length of the RPKI-RTR packet.
147 plen = tvb_get_ntohl(tvb, offset+4);
149 return plen;
153 static int dissect_rpkirtr_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
156 proto_item *ti = NULL, *ti_flags, *ti_type;
157 proto_tree *rpkirtr_tree = NULL, *flags_tree = NULL;
158 int offset = 0;
159 uint8_t pdu_type, version;
160 unsigned length;
162 while (tvb_reported_length_remaining(tvb, offset) > 0) {
164 ti = proto_tree_add_item(tree, proto_rpkirtr, tvb, 0, -1, ENC_NA);
166 rpkirtr_tree = proto_item_add_subtree(ti, ett_rpkirtr);
168 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_version, tvb, offset, 1, ENC_BIG_ENDIAN);
169 version = tvb_get_uint8(tvb, offset);
170 offset += 1;
172 ti_type = proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_pdu_type, tvb, offset, 1, ENC_BIG_ENDIAN);
173 pdu_type = tvb_get_uint8(tvb, offset);
174 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, val_to_str(pdu_type, rtr_pdu_type_vals, "Unknown (%d)"));
175 proto_item_append_text(ti, " (%s)", val_to_str(pdu_type, rtr_pdu_type_vals, "Unknown %d"));
176 offset += 1;
178 length = tvb_get_ntohl(tvb, offset);
180 switch (pdu_type) {
181 case RPKI_RTR_SERIAL_NOTIFY_PDU: /* Serial Notify (0) */
182 case RPKI_RTR_SERIAL_QUERY_PDU: /* Serial Query (1) */
183 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_session_id, tvb, offset, 2, ENC_BIG_ENDIAN);
184 offset += 2;
185 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN);
186 /* TODO: Add check length ? */
187 offset += 4;
188 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_serial_number, tvb, offset, 4, ENC_BIG_ENDIAN);
189 offset += 4;
190 break;
191 case RPKI_RTR_RESET_QUERY_PDU: /* Reset Query (2) */
192 case RPKI_RTR_CACHE_RESET_PDU: /* Cache Reset (8) */
193 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 2, ENC_NA);
194 offset += 2;
195 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN);
196 /* TODO: Add check length ? */
197 offset += 4;
198 break;
199 case RPKI_RTR_CACHE_RESPONSE_PDU: /* Cache Response (3) */
200 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_session_id, tvb, offset, 2, ENC_BIG_ENDIAN);
201 offset += 2;
202 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN);
203 /* TODO: Add check length ? */
204 offset += 4;
205 break;
206 case RPKI_RTR_IPV4_PREFIX_PDU: /* IPv4 Prefix (4) */
207 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 2, ENC_NA);
208 offset += 2;
209 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN);
210 /* TODO: Add check length ? */
211 offset += 4;
212 ti_flags = proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
213 flags_tree = proto_item_add_subtree(ti_flags, ett_flags);
214 proto_tree_add_item(flags_tree, hf_rpkirtr_flags_aw, tvb, offset, 1, ENC_BIG_ENDIAN);
215 offset += 1;
216 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_prefix_length, tvb, offset, 1, ENC_BIG_ENDIAN);
217 offset += 1;
218 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_max_length, tvb, offset, 1, ENC_BIG_ENDIAN);
219 offset += 1;
220 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 1, ENC_NA);
221 offset += 1;
222 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_ipv4_prefix, tvb, offset, 4, ENC_BIG_ENDIAN);
223 offset += 4;
224 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_as_number, tvb, offset, 4, ENC_BIG_ENDIAN);
225 offset += 4;
226 break;
227 case RPKI_RTR_IPV6_PREFIX_PDU: /* IPv6 Prefix (6) */
228 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 2, ENC_NA);
229 offset += 2;
230 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN);
231 /* TODO: Add check length ? */
232 offset += 4;
233 ti_flags = proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
234 flags_tree = proto_item_add_subtree(ti_flags, ett_flags);
235 proto_tree_add_item(flags_tree, hf_rpkirtr_flags_aw, tvb, offset, 1, ENC_BIG_ENDIAN);
236 offset += 1;
237 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_prefix_length, tvb, offset, 1, ENC_BIG_ENDIAN);
238 offset += 1;
239 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_max_length, tvb, offset, 1, ENC_BIG_ENDIAN);
240 offset += 1;
241 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 1, ENC_NA);
242 offset += 1;
243 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_ipv6_prefix, tvb, offset, 16, ENC_NA);
244 offset += 16;
245 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_as_number, tvb, offset, 4, ENC_BIG_ENDIAN);
246 offset += 4;
247 break;
248 case RPKI_RTR_END_OF_DATA_PDU: /* End Of Data (7) */
249 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_session_id, tvb, offset, 2, ENC_BIG_ENDIAN);
250 offset += 2;
251 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN);
252 /* TODO: Add check length ? */
253 offset += 4;
254 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_serial_number, tvb, offset, 4, ENC_BIG_ENDIAN);
255 offset += 4;
257 if (version >= 1){
258 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_refresh_interval, tvb, offset, 4, ENC_BIG_ENDIAN);
259 offset += 4;
261 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_retry_interval, tvb, offset, 4, ENC_BIG_ENDIAN);
262 offset += 4;
264 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_expire_interval, tvb, offset, 4, ENC_BIG_ENDIAN);
265 offset += 4;
267 break;
269 case RPKI_RTR_ROUTER_KEY: /* Router Key (9) */
270 if(version < 1){
271 /* Error about wrong version... */
272 expert_add_info(pinfo, ti_type, &ei_rpkirtr_wrong_version_router_key);
273 } else {
274 asn1_ctx_t asn1_ctx;
276 ti_flags = proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
277 flags_tree = proto_item_add_subtree(ti_flags, ett_flags_nd);
278 proto_tree_add_item(flags_tree, hf_rpkirtr_flags_rk, tvb, offset, 1, ENC_BIG_ENDIAN);
279 offset += 1;
280 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 2, ENC_NA);
281 offset += 1;
282 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN);
283 /* TODO: Add check length ? */
284 offset += 4;
285 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_subject_key_identifier, tvb, offset, 20, ENC_NA);
286 offset += 20;
288 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_as_number, tvb, offset, 4, ENC_BIG_ENDIAN);
289 offset += 4;
290 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
291 offset = dissect_x509af_SubjectPublicKeyInfo(false, tvb, offset, &asn1_ctx, rpkirtr_tree, hf_rpkirtr_subject_public_key_info);
294 break;
295 case RPKI_RTR_ERROR_REPORT_PDU: /* Error Report (10) */
297 uint32_t len_pdu, len_text;
298 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_error_code, tvb, offset, 2, ENC_BIG_ENDIAN);
299 offset += 2;
300 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN);
301 /* TODO: Add check length ? */
302 offset += 4;
303 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length_pdu, tvb, offset, 4, ENC_BIG_ENDIAN);
304 len_pdu = tvb_get_ntohl(tvb, offset);
305 offset += 4;
306 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_error_pdu, tvb, offset, len_pdu, ENC_NA);
307 offset += len_pdu;
308 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length_text, tvb, offset, 4, ENC_BIG_ENDIAN);
309 len_text = tvb_get_ntohl(tvb, offset);
310 offset += 4;
311 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_error_text, tvb, offset, len_text, ENC_ASCII);
312 offset += len_text;
314 break;
315 case RPKI_RTR_ASPA_PDU: /* ASPA (11) */
316 if(version < 2){
317 /* Error about wrong version... */
318 expert_add_info(pinfo, ti_type, &ei_rpkirtr_wrong_version_aspa);
319 } else {
320 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_reserved, tvb, offset, 2, ENC_NA);
321 offset += 2;
322 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_length, tvb, offset, 4, ENC_BIG_ENDIAN);
323 offset += 4;
324 ti_flags = proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
325 flags_tree = proto_item_add_subtree(ti_flags, ett_flags_nd);
326 proto_tree_add_item(flags_tree, hf_rpkirtr_flags_ar, tvb, offset, 1, ENC_BIG_ENDIAN);
327 offset += 1;
328 ti_flags = proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
329 flags_tree = proto_item_add_subtree(ti_flags, ett_flags_nd);
330 proto_tree_add_item(flags_tree, hf_rpkirtr_flags_arafi, tvb, offset, 1, ENC_BIG_ENDIAN);
331 offset += 1;
333 unsigned cnt_asns;
334 proto_tree_add_item_ret_uint(rpkirtr_tree, hf_rpkirtr_aspa_provider_as_count, tvb, offset, 2, ENC_BIG_ENDIAN, &cnt_asns);
335 offset += 2;
337 proto_tree_add_item(rpkirtr_tree, hf_rpkirtr_aspa_customer_asn, tvb, offset, 4, ENC_BIG_ENDIAN);
338 offset += 4;
340 proto_tree *providers_tree = proto_item_add_subtree(rpkirtr_tree, ett_providers);
341 for (unsigned i = 0; i < cnt_asns; i++) {
342 proto_tree_add_item(providers_tree, hf_rpkirtr_aspa_provider_asn, tvb, offset, 4, ENC_BIG_ENDIAN);
343 offset += 4;
346 break;
347 default:
348 /* No default ? At least sanity check the length*/
349 if (length > tvb_reported_length(tvb)) {
350 expert_add_info(pinfo, ti_type, &ei_rpkirtr_bad_length);
351 return tvb_reported_length(tvb);
354 offset += length;
355 break;
359 return tvb_reported_length(tvb);
362 static int
363 dissect_rpkirtr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
365 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RPKI-RTR");
366 col_clear(pinfo->cinfo, COL_INFO);
368 tcp_dissect_pdus(tvb, pinfo, tree, 1, 8, get_rpkirtr_pdu_len, dissect_rpkirtr_pdu, data);
369 return tvb_reported_length(tvb);
372 void
373 proto_register_rpkirtr(void)
375 module_t *rpkirtr_module;
377 static hf_register_info hf[] = {
378 { &hf_rpkirtr_version,
379 { "Version", "rpki-rtr.version",
380 FT_UINT8, BASE_DEC, NULL, 0x0,
381 "Denoting the version of this protocol (currently 0)", HFILL }
383 { &hf_rpkirtr_pdu_type,
384 { "PDU Type", "rpki-rtr.pdu_type",
385 FT_UINT8, BASE_DEC, VALS(rtr_pdu_type_vals), 0x0,
386 "Denoting the type of the PDU", HFILL }
388 { &hf_rpkirtr_reserved,
389 { "Reserved", "rpki-rtr.reserved",
390 FT_BYTES, BASE_NONE, NULL, 0x0,
391 "Must be zero", HFILL }
393 { &hf_rpkirtr_session_id,
394 { "Session ID", "rpki-rtr.session_id",
395 FT_UINT16, BASE_DEC, NULL, 0x0,
396 NULL, HFILL }
398 { &hf_rpkirtr_length,
399 { "Length", "rpki-rtr.length",
400 FT_UINT32, BASE_DEC, NULL, 0x0,
401 "Value the count of the bytes in the entire PDU, including the eight bytes of header that end with the length field", HFILL }
403 { &hf_rpkirtr_serial_number,
404 { "Serial Number", "rpki-rtr.serial_number",
405 FT_UINT32, BASE_DEC, NULL, 0x0,
406 NULL, HFILL }
408 { &hf_rpkirtr_flags,
409 { "Flags", "rpki-rtr.flags",
410 FT_UINT8, BASE_HEX, NULL, 0x0,
411 NULL, HFILL }
413 { &hf_rpkirtr_flags_aw,
414 { "Flag AW", "rpki-rtr.flags.aw",
415 FT_BOOLEAN, 8, TFS(&tfs_flag_type_aw), 0x01,
416 NULL, HFILL }
418 { &hf_rpkirtr_flags_rk,
419 { "Flag Router Key", "rpki-rtr.flags.rk",
420 FT_BOOLEAN, 8, TFS(&tfs_flag_type_rk), 0x01,
421 NULL, HFILL }
423 { &hf_rpkirtr_flags_ar,
424 { "Flag ASPA", "rpki-rtr.flags.ar",
425 FT_BOOLEAN, 8, TFS(&tfs_flag_type_ar), 0x01,
426 NULL, HFILL }
428 { &hf_rpkirtr_flags_arafi,
429 { "ASPA Address Family Flag", "rpki-rtr.flags.arafi",
430 FT_BOOLEAN, 8, TFS(&tfs_flag_type_afi_ar), 0x01,
431 NULL, HFILL }
433 { &hf_rpkirtr_prefix_length,
434 { "Prefix Length", "rpki-rtr.prefix_length",
435 FT_UINT8, BASE_DEC, NULL, 0x0,
436 "Denoting the shortest prefix allowed for the prefix", HFILL }
438 { &hf_rpkirtr_max_length,
439 { "Max length", "rpki-rtr.max_length",
440 FT_UINT8, BASE_DEC, NULL, 0x0,
441 "Denoting the longest prefix allowed by the prefix. This MUST NOT be less than the Prefix Length element", HFILL }
443 { &hf_rpkirtr_ipv4_prefix,
444 { "IPv4 Prefix", "rpki-rtr.ipv4_prefix",
445 FT_IPv4, BASE_NONE, NULL, 0x0,
446 "The IPv4 prefix of the ROA", HFILL }
448 { &hf_rpkirtr_ipv6_prefix,
449 { "IPv6 Prefix", "rpki-rtr.ipv6_prefix",
450 FT_IPv6, BASE_NONE, NULL, 0x0,
451 "The IPv6 prefix of the ROA", HFILL }
453 { &hf_rpkirtr_as_number,
454 { "AS Number", "rpki-rtr.as_number",
455 FT_UINT32, BASE_DEC, NULL, 0x0,
456 "Autonomous System Number allowed to announce this prefix", HFILL }
458 { &hf_rpkirtr_error_code,
459 { "Error Code", "rpki-rtr.error_code",
460 FT_UINT16, BASE_DEC, VALS(rtr_error_code_vals), 0x0,
461 NULL, HFILL }
463 { &hf_rpkirtr_length_pdu,
464 { "Length of Encapsulated PDU", "rpki-rtr.length_pdu",
465 FT_UINT32, BASE_DEC, NULL, 0x0,
466 NULL, HFILL }
468 { &hf_rpkirtr_error_pdu,
469 { "Erroneous PDU", "rpki-rtr.error_pdu",
470 FT_BYTES, BASE_NONE, NULL, 0x0,
471 NULL, HFILL }
473 { &hf_rpkirtr_length_text,
474 { "Length of text", "rpki-rtr.length_text",
475 FT_UINT32, BASE_DEC, NULL, 0x0,
476 NULL, HFILL }
478 { &hf_rpkirtr_error_text,
479 { "Erroneous Text", "rpki-rtr.error_text",
480 FT_STRING, BASE_NONE, NULL, 0x0,
481 NULL, HFILL }
483 { &hf_rpkirtr_refresh_interval,
484 { "Refresh Interval", "rpki-rtr.refresh_interval",
485 FT_UINT32, BASE_DEC, NULL, 0x0,
486 NULL, HFILL }
488 { &hf_rpkirtr_retry_interval,
489 { "Retry Interval", "rpki-rtr.retry_interval",
490 FT_UINT32, BASE_DEC, NULL, 0x0,
491 NULL, HFILL }
493 { &hf_rpkirtr_expire_interval,
494 { "Expire Interval", "rpki-rtr.expire_interval",
495 FT_UINT32, BASE_DEC, NULL, 0x0,
496 NULL, HFILL }
498 { &hf_rpkirtr_subject_key_identifier,
499 { "Subject Key Identifier", "rpki-rtr.subject_key_identifier",
500 FT_BYTES, BASE_NONE, NULL, 0x0,
501 NULL, HFILL }
503 { &hf_rpkirtr_subject_public_key_info,
504 { "Subject Public Key Info", "rpki-rtr.subject_public_key_info",
505 FT_NONE, BASE_NONE, NULL, 0x0,
506 NULL, HFILL }
508 { &hf_rpkirtr_aspa_provider_as_count,
509 { "ASPA Provider AS Count", "rpki-rtr.aspa_ascount",
510 FT_UINT16, BASE_DEC, NULL, 0x0,
511 "The Provider AS Count is the number of 32-bit Provider Autonomous System Numbers in the PDU", HFILL }
513 { &hf_rpkirtr_aspa_customer_asn,
514 { "ASPA Customer ASN", "rpki-rtr.aspa_customer_asn",
515 FT_UINT32, BASE_DEC, NULL, 0x0,
516 "The Customer Autonomous System Number is the 32-bit Autonomous System Number of the customer which authenticated the ASPA RPKI data", HFILL }
518 { &hf_rpkirtr_aspa_provider_asn,
519 { "ASPA Provider ASN", "rpki-rtr.aspa_provider_asn",
520 FT_UINT32, BASE_DEC, NULL, 0x0,
521 NULL, HFILL }
525 static int *ett[] = {
526 &ett_rpkirtr,
527 &ett_flags,
528 &ett_flags_nd,
529 &ett_providers
532 static ei_register_info ei[] = {
533 { &ei_rpkirtr_wrong_version_aspa, { "rpkirtr.aspa.wrong_version", PI_MALFORMED, PI_WARN, "Wrong version for ASPA type", EXPFILL }},
534 { &ei_rpkirtr_wrong_version_router_key, { "rpkirtr.router_key.wrong_version", PI_MALFORMED, PI_WARN, "Wrong version for Router Key type", EXPFILL }},
535 { &ei_rpkirtr_bad_length, { "rpkirtr.bad_length", PI_MALFORMED, PI_ERROR, "Invalid length field", EXPFILL }},
538 expert_module_t *expert_rpkirtr;
540 proto_rpkirtr = proto_register_protocol("RPKI-Router Protocol",
541 "RPKI-Router Protocol", "rpkirtr");
543 proto_register_field_array(proto_rpkirtr, hf, array_length(hf));
544 proto_register_subtree_array(ett, array_length(ett));
546 rpkirtr_module = prefs_register_protocol(proto_rpkirtr,
547 proto_reg_handoff_rpkirtr);
549 prefs_register_uint_preference(rpkirtr_module, "tcp.rpkirtr_tls.port", "RPKI-RTR TCP TLS Port",
550 "RPKI-Router Protocol TCP TLS port if other than the default",
551 10, &g_port_rpkirtr_tls);
553 expert_rpkirtr = expert_register_protocol(proto_rpkirtr);
554 expert_register_field_array(expert_rpkirtr, ei, array_length(ei));
555 rpkirtr_handle = register_dissector("rpkirtr", dissect_rpkirtr, proto_rpkirtr);
559 void
560 proto_reg_handoff_rpkirtr(void)
562 static bool initialized = false;
563 static int rpki_rtr_tls_port;
565 if (!initialized) {
566 dissector_add_uint_with_preference("tcp.port", RPKI_RTR_TCP_PORT, rpkirtr_handle);
567 initialized = true;
568 } else {
569 ssl_dissector_delete(rpki_rtr_tls_port, rpkirtr_handle);
572 rpki_rtr_tls_port = g_port_rpkirtr_tls;
573 ssl_dissector_add(rpki_rtr_tls_port, rpkirtr_handle);
578 * Editor modelines - https://www.wireshark.org/tools/modelines.html
580 * Local variables:
581 * c-basic-offset: 4
582 * tab-width: 8
583 * indent-tabs-mode: nil
584 * End:
586 * vi: set shiftwidth=4 tabstop=8 expandtab:
587 * :indentSize=4:tabSize=8:noTabs=true: