Wireshark  4.3.0
The Wireshark network protocol analyzer
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 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 block-type-specific data (BTSD) dissectors are registered with the
32  * dissector table "bpv7.block_type" and Administrative Record dissectors
33  * with the table "bpv7.admin_record_type". Both use guint64* table keys.
34  * Both use bp_dissector_data_t* as dissector user data.
35  *
36  * There is a BTSD heuristic dissector table "bpv7.btsd" which uses
37  * bp_dissector_data_t* as dissector user data.
38  *
39  * Payload block (block type 1) dissection is additionally handled based on
40  * bundle flags and destination EID as:
41  * - If the bundle flags mark it as administrative, it is dissected as such.
42  * - If the destination is a well-known SSP, the dissector table
43  * "bpv7.payload.dtn_wkssp" is used with the scheme-specific part.
44  * - If the destination is "dtn" scheme, the dissector table
45  * "bpv7.payload.dtn_serv" is used with the service demux (text string).
46  * There is also Decode As behavior for dtn service demux.
47  * - If the destination is "ipn" scheme, the dissector table
48  * "bpv7.payload.ipn_serv" is used with the service number (uint value).
49  * There is also Decode As behavior for ipn service number.
50  * - Finally, fall through to BTSD heuristic dissection.
51  * All payload dissection uses bp_dissector_data_t* as dissector user data.
52  */
53 
57 typedef enum {
59  BP_CRC_NONE = 0,
61  BP_CRC_16 = 1,
63  BP_CRC_32 = 2,
64 } BundleCrcType;
65 
69 typedef enum {
71  BP_BUNDLE_REQ_DELETION_REPORT = 0x040000,
73  BP_BUNDLE_REQ_DELIVERY_REPORT = 0x020000,
75  BP_BUNDLE_REQ_FORWARDING_REPORT = 0x010000,
77  BP_BUNDLE_REQ_RECEPTION_REPORT = 0x004000,
79  BP_BUNDLE_REQ_STATUS_TIME = 0x000040,
81  BP_BUNDLE_USER_APP_ACK = 0x000020,
83  BP_BUNDLE_NO_FRAGMENT = 0x000004,
85  BP_BUNDLE_PAYLOAD_ADMIN = 0x000002,
87  BP_BUNDLE_IS_FRAGMENT = 0x000001,
88 } BundleProcessingFlag;
89 
93 typedef enum {
95  BP_BLOCK_REMOVE_IF_NO_PROCESS = 0x10,
97  BP_BLOCK_DELETE_IF_NO_PROCESS = 0x04,
99  BP_BLOCK_STATUS_IF_NO_PROCESS = 0x02,
101  BP_BLOCK_REPLICATE_IN_FRAGMENT = 0x01,
102 } BlockProcessingFlag;
103 
107 typedef enum {
108  BP_BLOCKTYPE_INVALID = 0,
110  BP_BLOCKTYPE_PAYLOAD = 1,
112  BP_BLOCKTYPE_PREV_NODE = 6,
114  BP_BLOCKTYPE_BUNDLE_AGE = 7,
116  BP_BLOCKTYPE_HOP_COUNT = 10,
118  BP_BLOCKTYPE_BIB = 11,
120  BP_BLOCKTYPE_BCB = 12,
121 } BlockTypeCode;
122 
126 typedef enum {
128  BP_ADMINTYPE_BUNDLE_STATUS = 1,
129 } AdminRecordTypeCode;
130 
132 typedef struct {
134  guint64 dtntime;
137 } bp_dtn_time_t;
138 
140 typedef struct {
144  guint64 seqno;
146 
149 WS_DLL_PUBLIC
150 gint bp_creation_ts_compare(gconstpointer a, gconstpointer b, gpointer user_data);
151 
154 typedef enum {
155  EID_SCHEME_DTN = 1,
156  EID_SCHEME_IPN = 2,
157 } EidScheme;
158 
160 typedef struct {
162  gint64 scheme;
165 
167  const char *dtn_wkssp;
169  const char *dtn_serv;
171  guint64 *ipn_serv;
172 } bp_eid_t;
173 
176 WS_DLL_PUBLIC
177 bp_eid_t * bp_eid_new(wmem_allocator_t *alloc);
178 
181 WS_DLL_PUBLIC
182 void bp_eid_free(wmem_allocator_t *alloc, bp_eid_t *obj);
183 
186 WS_DLL_PUBLIC
187 gboolean bp_eid_equal(gconstpointer a, gconstpointer b);
188 
190 typedef struct {
196 
198 typedef struct {
201 
204  guint64 flags;
214  guint64 *frag_offset;
216  guint64 *total_len;
218  guint64 crc_type;
221 
222  security_mark_t sec;
224 
227 WS_DLL_PUBLIC
228 bp_block_primary_t * bp_block_primary_new(wmem_allocator_t *alloc);
229 
232 WS_DLL_PUBLIC
233 void bp_block_primary_free(wmem_allocator_t *alloc, bp_block_primary_t *obj);
234 
235 typedef struct {
238  guint64 blk_ix;
241 
243  guint64 *type_code;
245  guint64 *block_number;
247  guint64 flags;
249  guint64 crc_type;
252 
257 
258  security_mark_t sec;
260 
265 WS_DLL_PUBLIC
266 bp_block_canonical_t * bp_block_canonical_new(wmem_allocator_t *alloc, guint64 blk_ix);
267 
268 WS_DLL_PUBLIC
269 void bp_block_canonical_delete(wmem_allocator_t *alloc, bp_block_canonical_t *obj);
270 
272 typedef struct {
278  const guint64 *frag_offset;
280  const guint64 *total_len;
282 
290 WS_DLL_PUBLIC
291 bp_bundle_ident_t * bp_bundle_ident_new(wmem_allocator_t *alloc, const bp_eid_t *src, const bp_creation_ts_t *ts, const guint64 *off, const guint64 *len);
292 
293 WS_DLL_PUBLIC
294 void bp_bundle_ident_free(wmem_allocator_t *alloc, bp_bundle_ident_t *obj);
295 
298 WS_DLL_PUBLIC
299 gboolean bp_bundle_ident_equal(gconstpointer a, gconstpointer b);
300 
303 WS_DLL_PUBLIC
304 guint bp_bundle_ident_hash(gconstpointer key);
305 
307 typedef struct {
309  guint32 frame_num;
311  guint8 layer_num;
326 
328  guint *pyld_start;
330  guint *pyld_len;
331 } bp_bundle_t;
332 
335 WS_DLL_PUBLIC
336 bp_bundle_t * bp_bundle_new(wmem_allocator_t *alloc);
337 
340 WS_DLL_PUBLIC
341 void bp_bundle_free(wmem_allocator_t *alloc, bp_bundle_t *obj);
342 
355 WS_DLL_PUBLIC
356 proto_item * proto_tree_add_cbor_eid(proto_tree *tree, int hfindex, int hfindex_uri, packet_info *pinfo, tvbuff_t *tvb, gint *offset, bp_eid_t *eid);
357 
359 typedef struct {
366 } bp_history_t;
367 
370 typedef struct {
376 
377 #ifdef __cplusplus
378 }
379 #endif
380 
381 #endif /* PACKET_BPV7_H */
Definition: address.h:56
Definition: packet_info.h:44
Definition: proto.h:904
Definition: wmem_allocator.h:27
Definition: wmem_list.c:23
Definition: wmem_map.c:44
Definition: packet-bpv7.h:235
tvbuff_t * data
Type-specific data, unencoded.
Definition: packet-bpv7.h:254
guint64 flags
All flags on this block.
Definition: packet-bpv7.h:247
guint64 * block_number
Unique identifier for this block.
Definition: packet-bpv7.h:245
proto_item * item_block
Display item for the whole block.
Definition: packet-bpv7.h:240
proto_tree * tree_data
Type-specific data tree.
Definition: packet-bpv7.h:256
guint64 blk_ix
Definition: packet-bpv7.h:238
guint64 * type_code
Type of this block.
Definition: packet-bpv7.h:243
tvbuff_t * crc_field
Raw bytes of CRC field.
Definition: packet-bpv7.h:251
guint64 crc_type
CRC type code (assumed zero)
Definition: packet-bpv7.h:249
Metadata extracted from the primary block.
Definition: packet-bpv7.h:198
bp_eid_t * dst_eid
Destination EID.
Definition: packet-bpv7.h:206
tvbuff_t * crc_field
Raw bytes of CRC field.
Definition: packet-bpv7.h:220
bp_eid_t * rep_nodeid
Report-to NID.
Definition: packet-bpv7.h:210
proto_item * item_block
Display item for the whole block.
Definition: packet-bpv7.h:200
guint64 * frag_offset
Optional fragment start offset.
Definition: packet-bpv7.h:214
guint64 flags
Definition: packet-bpv7.h:204
bp_creation_ts_t ts
Creation Timestamp.
Definition: packet-bpv7.h:212
bp_eid_t * src_nodeid
Source NID.
Definition: packet-bpv7.h:208
guint64 crc_type
CRC type code (assumed zero)
Definition: packet-bpv7.h:218
guint64 * total_len
Optional bundle total length.
Definition: packet-bpv7.h:216
Identification of an individual bundle.
Definition: packet-bpv7.h:272
const guint64 * total_len
Pointer to external optional bundle total length.
Definition: packet-bpv7.h:280
bp_creation_ts_t ts
Creation Timestamp.
Definition: packet-bpv7.h:276
const guint64 * frag_offset
Pointer to external optional fragment start offset.
Definition: packet-bpv7.h:278
address src
Normalized EID URI for the Source Node ID.
Definition: packet-bpv7.h:274
Metadata extracted per-bundle.
Definition: packet-bpv7.h:307
wmem_map_t * block_types
Definition: packet-bpv7.h:325
bp_bundle_ident_t * ident
Bundle identity derived from primary data.
Definition: packet-bpv7.h:315
guint * pyld_len
Payload BTSD length.
Definition: packet-bpv7.h:330
guint * pyld_start
Payload BTSD start offset in bundle TVB.
Definition: packet-bpv7.h:328
nstime_t frame_time
Timestamp on the frame (end time if reassembled)
Definition: packet-bpv7.h:313
wmem_map_t * block_nums
Definition: packet-bpv7.h:322
bp_block_primary_t * primary
Required primary block.
Definition: packet-bpv7.h:317
wmem_list_t * blocks
Additional blocks in order (type bp_block_canonical_t)
Definition: packet-bpv7.h:319
guint32 frame_num
Index of the frame.
Definition: packet-bpv7.h:309
guint8 layer_num
Layer within the frame.
Definition: packet-bpv7.h:311
Creation Timestamp used to correlate bundles.
Definition: packet-bpv7.h:140
bp_dtn_time_t abstime
Absolute time.
Definition: packet-bpv7.h:142
guint64 seqno
Sequence number.
Definition: packet-bpv7.h:144
Definition: packet-bpv7.h:370
bp_bundle_t * bundle
The overall bundle being decoded (so far)
Definition: packet-bpv7.h:372
bp_block_canonical_t * block
This block being decoded.
Definition: packet-bpv7.h:374
DTN time with derived UTC time.
Definition: packet-bpv7.h:132
guint64 dtntime
DTN time.
Definition: packet-bpv7.h:134
nstime_t utctime
Converted to UTC.
Definition: packet-bpv7.h:136
Metadata from a Endpoint ID.
Definition: packet-bpv7.h:160
const char * dtn_wkssp
Optional DTN-scheme well-known SSP.
Definition: packet-bpv7.h:167
guint64 * ipn_serv
Optional IPN-scheme service name.
Definition: packet-bpv7.h:171
gint64 scheme
Scheme ID number.
Definition: packet-bpv7.h:162
address uri
Derived URI text as address.
Definition: packet-bpv7.h:164
const char * dtn_serv
Optional DTN-scheme service name.
Definition: packet-bpv7.h:169
Metadata for an entire file.
Definition: packet-bpv7.h:359
wmem_map_t * admin_status
Definition: packet-bpv7.h:365
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:361
Definition: nstime.h:26
Security marking metadata.
Definition: packet-bpv7.h:190
wmem_map_t * data_i
Block numbers marking the data as security integrity protected.
Definition: packet-bpv7.h:192
wmem_map_t * data_c
Block numbers marking the data as security-modified and not decodable.
Definition: packet-bpv7.h:194
Definition: tvbuff-int.h:35