Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet-lbm.h
1/* packet-lbm.h
2 * Definitions for LBM packet dissection
3 *
4 * Copyright (c) 2005-2014 Informatica Corporation. All Rights Reserved.
5 *
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <[email protected]>
8 * Copyright 1998 Gerald Combs
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
13#ifndef PACKET_LBM_H_INCLUDED
14#define PACKET_LBM_H_INCLUDED
15
16/* A list of the taps etc. made available by these dissectors:
17 Taps:
18 lbm_stream
19 - A packet is queued for each UIM (unicast immediate message) LBMC message (or fragment)
20 - The data associated with each tap entry is described by lbm_uim_stream_tap_info_t
21 - A single packet may generate multiple tap entries (in the case that a single packet
22 contains multiple LBMC messages)
23 - An LBMC message that spans multiple packets will cause a single entry to be queued,
24 corresponding to the last packet spanned
25 lbm_uim
26 - A packet is queued for each complete (possibly reassembled) UIM message
27 - The data associated with each tap entry is described by lbm_uim_stream_info_t
28 - A single packet may generate multiple tap entries (in the case that a single packet
29 contains multiple complete UIM messages)
30 - An complete UIM message that spans multiple packets will cause a single entry to be queued,
31 corresponding to the last packet spanned
32 lbm_lbmr_topic_advertisement
33 - A packet is queued for each LBMR topic advertisement (TIR)
34 - The data associated with each tap entry is described by lbm_lbmr_topic_advertisement_tap_info_t
35 - A single LBMR message (which may span multiple IP frames, reassembled into a single UDP packet)
36 may generate multiple tap entries (in the case that a single LBMR message contains multiple topic
37 advertisements)
38 lbm_lbmr_topic_query
39 - A packet is queued for each LBMR topic query (TQR)
40 - The data associated with each tap entry is described by lbm_lbmr_topic_query_tap_info_t
41 - A single LBMR message (which may span multiple IP frames, reassembled into a single UDP packet)
42 may generate multiple tap entries (in the case that a single LBMR message contains multiple topic
43 queries)
44 lbm_lbmr_pattern_query
45 - A packet is queued for each LBMR pattern query (TQR specifying a pattern)
46 - The data associated with each tap entry is described by lbm_lbmr_pattern_query_tap_info_t
47 - A single LBMR message (which may span multiple IP frames, reassembled into a single UDP packet)
48 may generate multiple tap entries (in the case that a single LBMR message contains multiple pattern
49 queries)
50 lbm_lbmr_queue_advertisement
51 - A packet is queued for each LBMR queue advertisement (QIR)
52 - The data associated with each tap entry is described by lbm_lbmr_queue_advertisement_tap_info_t
53 - A single LBMR message (which may span multiple IP frames, reassembled into a single UDP packet)
54 may generate multiple tap entries (in the case that a single LBMR message contains multiple queue
55 advertisements)
56 lbm_lbmr_queue_query
57 - A packet is queued for each LBMR queue query (QQR)
58 - The data associated with each tap entry is described by lbm_lbmr_queue_query_tap_info_t
59 - A single LBMR message (which may span multiple IP frames, reassembled into a single UDP packet)
60 may generate multiple tap entries (in the case that a single LBMR message contains multiple queue
61 queries)
62 lbm_lbtrm
63 - A packet is queued for each LBTRM transport message
64 - The data associated with each tap entry is described by lbm_lbtrm_tap_info_t
65 - A single LBTRM transport message (which may span multiple IP frames, reassembled into a single UDP
66 packet) will generate a single tap entry
67 lbm_lbtru
68 - A packet is queued for each LBTRU transport message
69 - The data associated with each tap entry is described by lbm_lbtru_tap_info_t
70 - A single LBTRU transport message (which may span multiple IP frames, reassembled into a single UDP
71 packet) will generate a single tap entry
72 Heuristic subdissector tables:
73 lbm_msg_payload
74 - If the LBMC preference "Use heuristic sub-dissectors" is enabled, the dissector will call any dissector
75 registered in this table via heur_dissector_add(). This allows a customer plugin to dissect the
76 actual payload of their messages.
77*/
78
79#include <stddef.h>
80
81#include <epan/tfs.h>
82#include <wsutil/inet_addr.h>
83
84typedef uint8_t lbm_uint8_t;
85typedef uint16_t lbm_uint16_t;
86typedef uint32_t lbm_uint32_t;
87typedef uint64_t lbm_uint64_t;
88#define SIZEOF(TYPE, MEMBER) (int)(sizeof(((TYPE *)0)->MEMBER))
89#define OFFSETOF(TYPE, MEMBER) (int)(offsetof(TYPE, MEMBER))
90#define STRINGIZE(a) #a
91#define MAKESTRING(a) STRINGIZE(a)
92#define LBM_OTID_BLOCK_SZ 32
93#define LBM_CONTEXT_INSTANCE_BLOCK_SZ 8
94#define LBM_HMAC_BLOCK_SZ 20
95
96/* UAT macros for IPV4 fields. */
97#define UAT_IPV4_CB_DEF(basename,field_name,rec_t) \
98 static bool basename ## _ ## field_name ## _chk_cb(void * u1 _U_, const char * strptr, unsigned len _U_, const void * u2 _U_, const void * u3 _U_, char ** err) \
99 { \
100 uint32_t addr; \
101 if (!ws_inet_pton4(strptr, &addr)) \
102 { \
103 *err = g_strdup("invalid address"); \
104 return false; \
105 } \
106 return true; \
107 } \
108 static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* u1 _U_, const void* u2 _U_) \
109 { \
110 uint32_t addr; \
111 char* new_buf = g_strndup(buf,len); \
112 g_free((((rec_t*)rec)->field_name)); \
113 (((rec_t*)rec)->field_name) = new_buf; \
114 ws_inet_pton4(new_buf, &addr); \
115 (((rec_t*)rec)->field_name ## _val_h) = g_ntohl(addr); \
116 } \
117 static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* u1 _U_, const void* u2 _U_) \
118 {\
119 if (((rec_t*)rec)->field_name ) \
120 { \
121 *out_ptr = g_strdup((((rec_t*)rec)->field_name)); \
122 *out_len = (unsigned)strlen((((rec_t*)rec)->field_name)); \
123 } \
124 else \
125 { \
126 *out_ptr = g_strdup(""); \
127 *out_len = 0; \
128 } \
129 }
130
131#define UAT_FLD_IPV4(basename,field_name,title,desc) \
132 {#field_name, title, PT_TXTMOD_STRING,{basename ## _ ## field_name ## _chk_cb,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL}
133
134/* UAT macros for IPV4 Multicast fields. */
135#define UAT_IPV4_MC_CB_DEF(basename,field_name,rec_t) \
136 static bool basename ## _ ## field_name ## _chk_cb(void * u1 _U_, const char * strptr, unsigned len _U_, const void * u2 _U_, const void * u3 _U_, char ** err) \
137 { \
138 uint32_t addr; \
139 if (!ws_inet_pton4(strptr, &addr)) \
140 { \
141 *err = g_strdup("invalid address"); \
142 return false; \
143 } \
144 if (!in4_addr_is_multicast(g_ntohl(addr)) && (g_ntohl(addr) != 0)) \
145 { \
146 *err = g_strdup("invalid multicast address"); \
147 return false; \
148 } \
149 return true; \
150 } \
151 static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* u1 _U_, const void* u2 _U_) \
152 { \
153 uint32_t addr; \
154 char* new_buf = g_strndup(buf,len); \
155 g_free((((rec_t*)rec)->field_name)); \
156 (((rec_t*)rec)->field_name) = new_buf; \
157 ws_inet_pton4(new_buf, &addr); \
158 (((rec_t*)rec)->field_name ## _val_h) = g_ntohl(addr); \
159 } \
160 static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* u1 _U_, const void* u2 _U_) \
161 {\
162 if (((rec_t*)rec)->field_name ) \
163 { \
164 *out_ptr = g_strdup((((rec_t*)rec)->field_name)); \
165 *out_len = (unsigned)strlen((((rec_t*)rec)->field_name)); \
166 } \
167 else \
168 { \
169 *out_ptr = g_strdup(""); \
170 *out_len = 0; \
171 } \
172 }
173
174#define UAT_FLD_IPV4_MC(basename,field_name,title,desc) \
175 {#field_name, title, PT_TXTMOD_STRING,{basename ## _ ## field_name ## _chk_cb,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL}
176
177typedef struct
178{
179 uint32_t domain;
180 address addr;
181 uint16_t port;
183
184typedef struct
185{
186 uint8_t ctxinst[LBM_CONTEXT_INSTANCE_BLOCK_SZ];
188
189typedef enum
190{
191 lbm_uim_instance_stream,
192 lbm_uim_domain_stream
193} lbm_uim_stream_type_t;
194
195typedef struct
196{
197 lbm_uim_stream_type_t type;
198 union
199 {
202 } stream_info;
204
205/* PUBLIC_HEADER: These appear to be used by custom dissectors and should be in the "install" target */
206typedef struct
207{
208 uint64_t channel;
209 uint32_t substream_id;
210 uint32_t bytes;
211 lbm_uim_stream_endpoint_t endpoint_a;
212 lbm_uim_stream_endpoint_t endpoint_b;
214
215typedef struct
216{
217 char * transport;
218 uint8_t type;
219 bool retransmission;
220 uint32_t sqn;
221 uint8_t ncf_reason;
222 uint16_t num_sqns;
223 uint32_t * sqns;
225
226typedef struct
227{
228 char * transport;
229 uint8_t type;
230 bool retransmission;
231 uint32_t sqn;
232 uint8_t ncf_reason;
233 uint16_t num_sqns;
234 uint16_t creq_type;
235 uint16_t rst_type;
236 uint32_t * sqns;
238
239typedef struct
240{
241 uint16_t size;
242 uint8_t topic_length;
243 uint8_t source_length;
244 uint32_t topic_index;
245 char topic[256];
246 char source[256];
248
249typedef struct
250{
251 uint16_t size;
252 uint8_t topic_length;
253 char topic[256];
255
256typedef struct
257{
258 uint16_t size;
259 uint8_t type;
260 uint8_t pattern_length;
261 char pattern[256];
263
264#define LBMR_WILDCARD_PATTERN_TYPE_PCRE 1
265#define LBMR_WILDCARD_PATTERN_TYPE_REGEX 2
266
267typedef struct
268{
269 uint16_t size;
270 uint16_t port;
271 uint8_t queue_length;
272 uint8_t topic_length;
273 char queue[256];
274 char topic[256];
276
277typedef struct
278{
279 uint16_t size;
280 uint8_t queue_length;
281 char queue[256];
283
284#define LBM_TOPIC_OPT_EXFUNC_FFLAG_LJ 0x00000001
285#define LBM_TOPIC_OPT_EXFUNC_FFLAG_UME 0x00000002
286#define LBM_TOPIC_OPT_EXFUNC_FFLAG_UMQ 0x00000004
287#define LBM_TOPIC_OPT_EXFUNC_FFLAG_ULB 0x00000008
288
289/* LBT-RM packet types */
290#define LBTRM_PACKET_TYPE_DATA 0x00
291#define LBTRM_PACKET_TYPE_SM 0x02
292#define LBTRM_PACKET_TYPE_NAK 0x03
293#define LBTRM_PACKET_TYPE_NCF 0x04
294
295/* LBT-RM NCF reason types */
296#define LBTRM_NCF_REASON_NO_RETRY 0x0
297#define LBTRM_NCF_REASON_IGNORED 0x1
298#define LBTRM_NCF_REASON_RX_DELAY 0x2
299#define LBTRM_NCF_REASON_SHED 0x3
300
301/* LBT-RU packet types */
302#define LBTRU_PACKET_TYPE_DATA 0x00
303#define LBTRU_PACKET_TYPE_SM 0x02
304#define LBTRU_PACKET_TYPE_NAK 0x03
305#define LBTRU_PACKET_TYPE_NCF 0x04
306#define LBTRU_PACKET_TYPE_ACK 0x05
307#define LBTRU_PACKET_TYPE_CREQ 0x06
308#define LBTRU_PACKET_TYPE_RST 0x07
309
310/* LBT-RU NCF reason types */
311#define LBTRU_NCF_REASON_NO_RETRY 0x0
312#define LBTRU_NCF_REASON_IGNORED 0x1
313#define LBTRU_NCF_REASON_RX_DELAY 0x2
314#define LBTRU_NCF_REASON_SHED 0x3
315
316/* LBT-RU CREQ types */
317#define LBTRU_CREQ_REQUEST_SYN 0x0
318
319/* LBT-RU RST reasons */
320#define LBTRU_RST_REASON_DEFAULT 0x0
321
322bool lbmc_test_lbmc_header(tvbuff_t * tvb, unsigned offset);
323int lbmc_dissect_lbmc_packet(tvbuff_t * tvb, unsigned offset, packet_info * pinfo, proto_tree * tree, const char * tag_name, uint64_t channel);
324int lbmc_get_minimum_length(void);
325uint16_t lbmc_get_message_length(tvbuff_t * tvb, unsigned offset);
326bool lbmpdm_verify_payload(tvbuff_t * tvb, unsigned offset, int * encoding, uint32_t* length);
327unsigned lbmpdm_dissect_lbmpdm_payload(tvbuff_t * tvb, unsigned offset, packet_info * pinfo, proto_tree * tree, uint64_t channel);
328int lbmpdm_get_minimum_length(void);
329unsigned lbmr_dissect_umq_qmgmt(tvbuff_t * tvb, unsigned offset, packet_info * pinfo, proto_tree * tree);
330
331extern const true_false_string lbm_ignore_flag;
332extern const value_string lbm_wildcard_pattern_type[];
333extern const value_string lbm_wildcard_pattern_type_short[];
334
335/*----------------------------------------------------------------------------*/
336/* Channel interface. */
337/*----------------------------------------------------------------------------*/
338#define LBM_CHANNEL_NO_CHANNEL (~((uint64_t) 0))
339
340#define LBM_CHANNEL_TRANSPORT_LBTTCP 0x00
341#define LBM_CHANNEL_TRANSPORT_LBTRU 0x01
342#define LBM_CHANNEL_TRANSPORT_LBTRM 0x02
343#define LBM_CHANNEL_TRANSPORT_LBTIPC 0x03
344#define LBM_CHANNEL_TRANSPORT_LBTRDMA 0x04
345#define LBM_CHANNEL_TRANSPORT_LBTSMX 0x05
346#define LBM_CHANNEL_STREAM_TCP 0x10
347#define LBM_CHANNEL_TCP 0x20
348
349#define LBM_CHANNEL_VALUE_MASK UINT64_C(0xfffffffffffff000)
350#define LBM_CHANNEL_VALUE_SHIFT_COUNT 12
351
352void lbm_channel_reset(void);
353uint64_t lbm_channel_assign(uint8_t channel_type);
354bool lbm_channel_is_transport(uint64_t channel);
355uint8_t lbm_channel_type(uint64_t channel);
356uint64_t lbm_channel_assign_unknown_transport_source_lbttcp(void);
357uint64_t lbm_channel_assign_unknown_transport_client_lbttcp(void);
358uint64_t lbm_channel_assign_unknown_stream_tcp(void);
359bool lbm_channel_is_unknown_transport_lbttcp(uint64_t channel);
360bool lbm_channel_is_unknown_transport_source_lbttcp(uint64_t channel);
361bool lbm_channel_is_unknown_transport_client_lbttcp(uint64_t channel);
362bool lbm_channel_is_unknown_stream_tcp(uint64_t channel);
363bool lbm_channel_is_known(uint64_t channel);
364
365#define LBM_CHANNEL_ID(ch) ((ch & LBM_CHANNEL_VALUE_MASK) >> LBM_CHANNEL_VALUE_SHIFT_COUNT)
366
367/*----------------------------------------------------------------------------*/
368/* Frame/SQN interface. */
369/*----------------------------------------------------------------------------*/
370typedef struct
371{
372 uint32_t frame;
373 uint8_t type;
374 uint32_t sqn;
375 uint32_t previous_frame;
376 uint32_t previous_type_frame;
377 uint32_t next_frame;
378 uint32_t next_type_frame;
379 bool retransmission;
380 uint32_t sqn_gap;
381 uint32_t ooo_gap;
382 bool duplicate;
384
385typedef struct
386{
387 uint32_t frame;
388 bool retransmission;
390
391typedef struct
392{
393 uint32_t sqn;
394 uint32_t frame_count;
395 wmem_tree_t * frame; /* List of lbm_transport_sqn_frame_t */
397
398lbm_transport_frame_t * lbm_transport_frame_add(wmem_tree_t * list, uint8_t type, uint32_t frame, uint32_t sqn, bool retransmission);
399lbm_transport_sqn_t * lbm_transport_sqn_add(wmem_tree_t * list, lbm_transport_frame_t * frame);
400
401/*----------------------------------------------------------------------------*/
402/* Topic interface. */
403/*----------------------------------------------------------------------------*/
404void lbm_topic_init(void);
405const char * lbm_topic_find(uint64_t channel, uint32_t topic_index);
406void lbm_topic_add(uint64_t channel, uint32_t topic_index, const char * name);
407
408#endif
409
410/*
411 * Editor modelines - https://www.wireshark.org/tools/modelines.html
412 *
413 * Local variables:
414 * c-basic-offset: 4
415 * tab-width: 8
416 * indent-tabs-mode: nil
417 * End:
418 *
419 * vi: set shiftwidth=4 tabstop=8 expandtab:
420 * :indentSize=4:tabSize=8:noTabs=true:
421 */
Definition address.h:58
Definition packet_info.h:43
Definition proto.h:907
Mapping between a 32-bit integer value and its string representation.
Definition value_string.h:33
Internal representation of a wmem balanced tree.
Definition wmem_tree-int.h:81
Definition packet-lbm.h:257
Definition packet-lbm.h:268
Definition packet-lbm.h:278
Definition packet-lbm.h:240
Definition packet-lbm.h:250
Definition packet-lbm.h:216
Definition packet-lbm.h:227
Definition packet-lbm.h:371
Definition packet-lbm.h:386
Definition packet-lbm.h:392
Definition packet-lbm.h:185
Definition packet-lbm.h:178
Definition packet-lbm.h:196
Definition packet-lbm.h:207
Definition tfs.h:27
Definition tvbuff-int.h:36