| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
packet-bpv7.h
1/* packet-bpv7.h
2 * Definitions for Bundle Protocol Version 7 dissection.
3 * References:
4 * RFC 9171: https://www.rfc-editor.org/rfc/rfc9171.html
5 *
6 * Copyright 2019-2021, Brian Sipos <brian.sipos@gmail.com>
7 *
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
11 *
12 * SPDX-License-Identifier: LGPL-2.1-or-later
13 */
14#ifndef PACKET_BPV7_H
15#define PACKET_BPV7_H
16
17#include <ws_symbol_export.h>
18#include <epan/tvbuff.h>
19#include <epan/proto.h>
20#include <epan/expert.h>
21
22#ifdef __cplusplus
23 extern "C" {
24#endif
25
26/* This dissector defines two layers of protocol:
27 * - The BPv7 bundle format, its endpoint naming and its block types.
28 * - The BPv7 Administrative Record which is a bundle payload as indicated by
29 * a primary block flag.
30 *
31 * BPv7 endpoint identifier (EID) dissectors for the scheme-specific
32 * part (SSP) are registered with the dissector table "bpv7.eid".
33 * This table uses a `uint` key for the scheme number and uses bp_eid_t* as
34 * dissector user data to be populated by the SSP data.
35 * Specifically the bp_eid_t::uri should be populated by the text form
36 * of the EID (as an AT_STRINGZ value).
37 *
38 * BPv7 block-type-specific data (BTSD) dissectors are registered with the
39 * dissector table "bpv7.block_type" and Administrative Record dissectors
40 * with the table "bpv7.admin_record_type". Both use uint64_t* table keys.
41 * Both use bp_dissector_data_t* as dissector user data.
42 *
43 * There is a BTSD heuristic dissector table "bpv7.btsd" which uses
44 * bp_dissector_data_t* as dissector user data.
45 *
46 * Payload block (block type 1) dissection is additionally handled based on
47 * bundle flags and destination EID as:
48 * - If the bundle flags mark it as administrative, it is dissected as such.
49 * - If the destination is a well-known SSP, the dissector table
50 * "bpv7.payload.dtn_wkssp" is used with the scheme-specific part.
51 * - If the destination is "dtn" scheme, the dissector table
52 * "bpv7.payload.dtn_serv" is used with the service demux (text string).
53 * There is also Decode As behavior for dtn service demux.
54 * - If the destination is "ipn" scheme, the dissector table
55 * "bpv7.payload.ipn_serv" is used with the service number (uint value).
56 * There is also Decode As behavior for ipn service number.
57 * - Finally, fall through to BTSD heuristic dissection.
58 * All payload dissection uses bp_dissector_data_t* as dissector user data.
59 */
60
64 typedef enum {
66 BP_CRC_NONE = 0,
68 BP_CRC_16 = 1,
70 BP_CRC_32 = 2,
71} BundleCrcType;
72
76 typedef enum {
78 BP_BUNDLE_REQ_DELETION_REPORT = 0x040000,
80 BP_BUNDLE_REQ_DELIVERY_REPORT = 0x020000,
82 BP_BUNDLE_REQ_FORWARDING_REPORT = 0x010000,
84 BP_BUNDLE_REQ_RECEPTION_REPORT = 0x004000,
86 BP_BUNDLE_REQ_STATUS_TIME = 0x000040,
88 BP_BUNDLE_USER_APP_ACK = 0x000020,
90 BP_BUNDLE_NO_FRAGMENT = 0x000004,
92 BP_BUNDLE_PAYLOAD_ADMIN = 0x000002,
94 BP_BUNDLE_IS_FRAGMENT = 0x000001,
95} BundleProcessingFlag;
96
100 typedef enum {
102 BP_BLOCK_REMOVE_IF_NO_PROCESS = 0x10,
104 BP_BLOCK_DELETE_IF_NO_PROCESS = 0x04,
106 BP_BLOCK_STATUS_IF_NO_PROCESS = 0x02,
108 BP_BLOCK_REPLICATE_IN_FRAGMENT = 0x01,
109} BlockProcessingFlag;
110
114 typedef enum {
115 BP_BLOCKTYPE_INVALID = 0,
117 BP_BLOCKTYPE_PAYLOAD = 1,
119 BP_BLOCKTYPE_PREV_NODE = 6,
121 BP_BLOCKTYPE_BUNDLE_AGE = 7,
123 BP_BLOCKTYPE_HOP_COUNT = 10,
125 BP_BLOCKTYPE_BIB = 11,
127 BP_BLOCKTYPE_BCB = 12,
128} BlockTypeCode;
129
133 typedef enum {
135 BP_ADMINTYPE_BUNDLE_STATUS = 1,
136} AdminRecordTypeCode;
137
139 typedef struct {
141 uint64_t dtntime;
143 nstime_t utctime;
144} bp_dtn_time_t;
145
147 typedef struct {
149 bp_dtn_time_t abstime;
151 uint64_t seqno;
152} bp_creation_ts_t;
153
156WS_DLL_PUBLIC
157 int bp_creation_ts_compare(const void *a, const void *b, void *user_data);
158
161 typedef enum {
162 EID_SCHEME_DTN = 1,
163 EID_SCHEME_IPN = 2,
164} EidScheme;
165
167 typedef struct {
169 wmem_allocator_t *alloc;
171 uint64_t scheme;
173 address uri;
174
176 const char *dtn_wkssp;
178 const char *dtn_serv;
180 uint64_t *ipn_serv;
181} bp_eid_t;
182
185WS_DLL_PUBLIC
186 bp_eid_t * bp_eid_new(wmem_allocator_t *alloc);
187
190WS_DLL_PUBLIC
191 void bp_eid_free(bp_eid_t *obj);
192
195WS_DLL_PUBLIC
196 bool bp_eid_equal(const void *a, const void *b);
197
199 typedef struct {
201 wmem_map_t *data_i;
203 wmem_map_t *data_c;
204} security_mark_t;
205
207 typedef struct {
209 proto_item *item_block;
210
213 uint64_t flags;
215 bp_eid_t *dst_eid;
217 bp_eid_t *src_nodeid;
219 bp_eid_t *rep_nodeid;
221 bp_creation_ts_t ts;
223 uint64_t *frag_offset;
225 uint64_t *total_len;
227 uint64_t crc_type;
229 tvbuff_t *crc_field;
230
231 security_mark_t sec;
232} bp_block_primary_t;
233
236WS_DLL_PUBLIC
237 bp_block_primary_t * bp_block_primary_new(wmem_allocator_t *alloc);
238
241WS_DLL_PUBLIC
242 void bp_block_primary_free(wmem_allocator_t *alloc, bp_block_primary_t *obj);
243
244 typedef struct {
247 uint64_t blk_ix;
249 proto_item *item_block;
250
252 uint64_t *type_code;
254 uint64_t *block_number;
256 uint64_t flags;
258 uint64_t crc_type;
260 tvbuff_t *crc_field;
261
263 int btsd_len;
265 tvbuff_t *data;
267 proto_tree *tree_data;
268
269 security_mark_t sec;
270} bp_block_canonical_t;
271
276WS_DLL_PUBLIC
277 bp_block_canonical_t * bp_block_canonical_new(wmem_allocator_t *alloc, uint64_t blk_ix);
278
279WS_DLL_PUBLIC
280 void bp_block_canonical_delete(wmem_allocator_t *alloc, bp_block_canonical_t *obj);
281
283 typedef struct {
285 address src;
287 bp_creation_ts_t ts;
289 const uint64_t *frag_offset;
291 const uint64_t *total_len;
292} bp_bundle_ident_t;
293
301WS_DLL_PUBLIC
302 bp_bundle_ident_t * bp_bundle_ident_new(wmem_allocator_t *alloc, const bp_eid_t *src, const bp_creation_ts_t *ts, const uint64_t *off, const uint64_t *len);
303
304WS_DLL_PUBLIC
305 void bp_bundle_ident_free(wmem_allocator_t *alloc, bp_bundle_ident_t *obj);
306
309WS_DLL_PUBLIC
310gboolean bp_bundle_ident_equal(const void *a, const void *b);
311
314WS_DLL_PUBLIC
315 unsigned bp_bundle_ident_hash(const void *key);
316
318 typedef struct {
320 uint32_t frame_num;
322 uint8_t layer_num;
324 nstime_t frame_time;
325
327 int pdu_len;
329 bp_bundle_ident_t *ident;
331 bp_block_primary_t *primary;
333 wmem_list_t *blocks;
336 wmem_map_t *block_nums;
339 wmem_map_t *block_types;
340
342 int *pyld_start;
344 int *pyld_len;
345} bp_bundle_t;
346
349WS_DLL_PUBLIC
350 bp_bundle_t * bp_bundle_new(wmem_allocator_t *alloc);
351
354WS_DLL_PUBLIC
355 void bp_bundle_free(wmem_allocator_t *alloc, bp_bundle_t *obj);
356
369WS_DLL_PUBLIC
370 proto_item * proto_tree_add_cbor_eid(proto_tree *tree, int hfindex, int hfindex_uri, packet_info *pinfo, tvbuff_t *tvb, int *offset, bp_eid_t *eid);
371
373 typedef struct {
375 wmem_map_t *bundles;
379 wmem_map_t *admin_status;
380} bp_history_t;
381
384 typedef struct {
386 bp_bundle_t *bundle;
388 bp_block_canonical_t *block;
389} bp_dissector_data_t;
390
391#ifdef __cplusplus
392}
393#endif
394
395#endif /* PACKET_BPV7_H */
expert.h
proto.h
_address
Definition address.h:58
_packet_info
Definition packet_info.h:43
_proto_node
Definition proto.h:907
_wmem_allocator_t
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
_wmem_list_t
Definition wmem_list.c:23
_wmem_map_t
Definition wmem_map.c:60
bp_block_canonical_t
Definition packet-bpv7.h:244
bp_block_canonical_t::data
tvbuff_t * data
BTSD content bytes, which is only valid during dissection.
Definition packet-bpv7.h:265
bp_block_canonical_t::btsd_len
int btsd_len
Length of BTSD clamped to INT_MAX.
Definition packet-bpv7.h:263
bp_block_canonical_t::blk_ix
uint64_t blk_ix
Definition packet-bpv7.h:247
bp_block_canonical_t::item_block
proto_item * item_block
Display item for the whole block.
Definition packet-bpv7.h:249
bp_block_canonical_t::tree_data
proto_tree * tree_data
Type-specific data tree, which is only valid during dissection.
Definition packet-bpv7.h:267
bp_block_canonical_t::type_code
uint64_t * type_code
Type of this block.
Definition packet-bpv7.h:252
bp_block_canonical_t::crc_type
uint64_t crc_type
CRC type code (assumed zero)
Definition packet-bpv7.h:258
bp_block_canonical_t::flags
uint64_t flags
All flags on this block.
Definition packet-bpv7.h:256
bp_block_canonical_t::crc_field
tvbuff_t * crc_field
Raw bytes of CRC field.
Definition packet-bpv7.h:260
bp_block_canonical_t::block_number
uint64_t * block_number
Unique identifier for this block.
Definition packet-bpv7.h:254
bp_block_primary_t
Metadata extracted from the primary block.
Definition packet-bpv7.h:207
bp_block_primary_t::dst_eid
bp_eid_t * dst_eid
Destination EID.
Definition packet-bpv7.h:215
bp_block_primary_t::total_len
uint64_t * total_len
Optional bundle total length.
Definition packet-bpv7.h:225
bp_block_primary_t::crc_field
tvbuff_t * crc_field
Raw bytes of CRC field.
Definition packet-bpv7.h:229
bp_block_primary_t::crc_type
uint64_t crc_type
CRC type code (assumed zero)
Definition packet-bpv7.h:227
bp_block_primary_t::flags
uint64_t flags
Definition packet-bpv7.h:213
bp_block_primary_t::rep_nodeid
bp_eid_t * rep_nodeid
Report-to NID.
Definition packet-bpv7.h:219
bp_block_primary_t::item_block
proto_item * item_block
Display item for the whole block.
Definition packet-bpv7.h:209
bp_block_primary_t::frag_offset
uint64_t * frag_offset
Optional fragment start offset.
Definition packet-bpv7.h:223
bp_block_primary_t::ts
bp_creation_ts_t ts
Creation Timestamp.
Definition packet-bpv7.h:221
bp_block_primary_t::src_nodeid
bp_eid_t * src_nodeid
Source NID.
Definition packet-bpv7.h:217
bp_bundle_ident_t
Identification of an individual bundle.
Definition packet-bpv7.h:283
bp_bundle_ident_t::ts
bp_creation_ts_t ts
Creation Timestamp.
Definition packet-bpv7.h:287
bp_bundle_ident_t::frag_offset
const uint64_t * frag_offset
Pointer to external optional fragment start offset.
Definition packet-bpv7.h:289
bp_bundle_ident_t::src
address src
Normalized EID URI for the Source Node ID.
Definition packet-bpv7.h:285
bp_bundle_ident_t::total_len
const uint64_t * total_len
Pointer to external optional bundle total length.
Definition packet-bpv7.h:291
bp_bundle_t
Metadata extracted per-bundle.
Definition packet-bpv7.h:318
bp_bundle_t::pyld_len
int * pyld_len
Payload BTSD length clamped to INT_MAX.
Definition packet-bpv7.h:344
bp_bundle_t::block_types
wmem_map_t * block_types
Definition packet-bpv7.h:339
bp_bundle_t::frame_num
uint32_t frame_num
Index of the frame.
Definition packet-bpv7.h:320
bp_bundle_t::ident
bp_bundle_ident_t * ident
Bundle identity derived from primary data.
Definition packet-bpv7.h:329
bp_bundle_t::pyld_start
int * pyld_start
Payload BTSD start offset in bundle TVB.
Definition packet-bpv7.h:342
bp_bundle_t::frame_time
nstime_t frame_time
Timestamp on the frame (end time if reassembled)
Definition packet-bpv7.h:324
bp_bundle_t::block_nums
wmem_map_t * block_nums
Definition packet-bpv7.h:336
bp_bundle_t::layer_num
uint8_t layer_num
Layer within the frame.
Definition packet-bpv7.h:322
bp_bundle_t::pdu_len
int pdu_len
Total PDU length clamped to INT_MAX.
Definition packet-bpv7.h:327
bp_bundle_t::primary
bp_block_primary_t * primary
Required primary block.
Definition packet-bpv7.h:331
bp_bundle_t::blocks
wmem_list_t * blocks
Additional blocks in order (type bp_block_canonical_t)
Definition packet-bpv7.h:333
bp_creation_ts_t
Creation Timestamp used to correlate bundles.
Definition packet-bpv7.h:147
bp_creation_ts_t::abstime
bp_dtn_time_t abstime
Absolute time.
Definition packet-bpv7.h:149
bp_creation_ts_t::seqno
uint64_t seqno
Sequence number.
Definition packet-bpv7.h:151
bp_dissector_data_t
Definition packet-bpv7.h:384
bp_dissector_data_t::bundle
bp_bundle_t * bundle
The overall bundle being decoded (so far)
Definition packet-bpv7.h:386
bp_dissector_data_t::block
bp_block_canonical_t * block
This block being decoded.
Definition packet-bpv7.h:388
bp_dtn_time_t
DTN time with derived UTC time.
Definition packet-bpv7.h:139
bp_dtn_time_t::utctime
nstime_t utctime
Converted to UTC.
Definition packet-bpv7.h:143
bp_dtn_time_t::dtntime
uint64_t dtntime
DTN time.
Definition packet-bpv7.h:141
bp_eid_t
Metadata from a Endpoint ID.
Definition packet-bpv7.h:167
bp_eid_t::ipn_serv
uint64_t * ipn_serv
Optional IPN-scheme service name.
Definition packet-bpv7.h:180
bp_eid_t::alloc
wmem_allocator_t * alloc
Allocator for uri text and optional members.
Definition packet-bpv7.h:169
bp_eid_t::dtn_wkssp
const char * dtn_wkssp
Optional DTN-scheme well-known SSP.
Definition packet-bpv7.h:176
bp_eid_t::scheme
uint64_t scheme
Scheme ID number.
Definition packet-bpv7.h:171
bp_eid_t::uri
address uri
Derived URI text as address.
Definition packet-bpv7.h:173
bp_eid_t::dtn_serv
const char * dtn_serv
Optional DTN-scheme service name.
Definition packet-bpv7.h:178
bp_history_t
Metadata for an entire file.
Definition packet-bpv7.h:373
bp_history_t::admin_status
wmem_map_t * admin_status
Definition packet-bpv7.h:379
bp_history_t::bundles
wmem_map_t * bundles
Map from a bundle ID (bp_bundle_ident_t) to wmem_list_t of bundle (bp_bundle_t)
Definition packet-bpv7.h:375
nstime_t
Definition nstime.h:26
security_mark_t
Security marking metadata.
Definition packet-bpv7.h:199
security_mark_t::data_i
wmem_map_t * data_i
Block numbers marking the data as security integrity protected.
Definition packet-bpv7.h:201
security_mark_t::data_c
wmem_map_t * data_c
Block numbers marking the data as security-modified and not decodable.
Definition packet-bpv7.h:203
tvbuff
Definition tvbuff-int.h:36
tvbuff.h