Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-lbm.h
blobdf40d2f16ece54276e3c8475b914acd00d43a6c9
1 /* packet-lbm.h
2 * Definitions for LBM packet dissection
4 * Copyright (c) 2005-2014 Informatica Corporation. All Rights Reserved.
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #ifndef PACKET_LBM_H_INCLUDED
14 #define PACKET_LBM_H_INCLUDED
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.
79 #if defined(__FreeBSD__)
80 #include <sys/types.h>
81 #include <netinet/in.h>
82 #endif
83 #include <stddef.h>
85 #ifdef HAVE_NETINET_IN_H
86 # include <netinet/in.h>
87 #endif
89 #ifdef _WIN32
90 #include <winsock2.h>
91 #endif
93 #include <epan/tfs.h>
95 typedef uint8_t lbm_uint8_t;
96 typedef uint16_t lbm_uint16_t;
97 typedef uint32_t lbm_uint32_t;
98 typedef uint64_t lbm_uint64_t;
99 #define SIZEOF(TYPE, MEMBER) (int)(sizeof(((TYPE *)0)->MEMBER))
100 #define OFFSETOF(TYPE, MEMBER) (int)(offsetof(TYPE, MEMBER))
101 #define STRINGIZE(a) #a
102 #define MAKESTRING(a) STRINGIZE(a)
103 #define LBM_OTID_BLOCK_SZ 32
104 #define LBM_CONTEXT_INSTANCE_BLOCK_SZ 8
105 #define LBM_HMAC_BLOCK_SZ 20
107 /* UAT macros for IPV4 fields. */
108 #define UAT_IPV4_CB_DEF(basename,field_name,rec_t) \
109 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) \
111 uint32_t addr; \
112 if (!ws_inet_pton4(strptr, &addr)) \
114 *err = g_strdup("invalid address"); \
115 return false; \
117 return true; \
119 static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* u1 _U_, const void* u2 _U_) \
121 uint32_t addr; \
122 char* new_buf = g_strndup(buf,len); \
123 g_free((((rec_t*)rec)->field_name)); \
124 (((rec_t*)rec)->field_name) = new_buf; \
125 ws_inet_pton4(new_buf, &addr); \
126 (((rec_t*)rec)->field_name ## _val_h) = g_ntohl(addr); \
128 static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* u1 _U_, const void* u2 _U_) \
130 if (((rec_t*)rec)->field_name ) \
132 *out_ptr = g_strdup((((rec_t*)rec)->field_name)); \
133 *out_len = (unsigned)strlen((((rec_t*)rec)->field_name)); \
135 else \
137 *out_ptr = g_strdup(""); \
138 *out_len = 0; \
142 #define UAT_FLD_IPV4(basename,field_name,title,desc) \
143 {#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}
145 /* UAT macros for IPV4 Multicast fields. */
146 #define UAT_IPV4_MC_CB_DEF(basename,field_name,rec_t) \
147 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) \
149 uint32_t addr; \
150 if (!ws_inet_pton4(strptr, &addr)) \
152 *err = g_strdup("invalid address"); \
153 return false; \
155 if (!IN_MULTICAST(g_ntohl(addr)) && (g_ntohl(addr) != 0)) \
157 *err = g_strdup("invalid multicast address"); \
158 return false; \
160 return true; \
162 static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* u1 _U_, const void* u2 _U_) \
164 uint32_t addr; \
165 char* new_buf = g_strndup(buf,len); \
166 g_free((((rec_t*)rec)->field_name)); \
167 (((rec_t*)rec)->field_name) = new_buf; \
168 ws_inet_pton4(new_buf, &addr); \
169 (((rec_t*)rec)->field_name ## _val_h) = g_ntohl(addr); \
171 static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* u1 _U_, const void* u2 _U_) \
173 if (((rec_t*)rec)->field_name ) \
175 *out_ptr = g_strdup((((rec_t*)rec)->field_name)); \
176 *out_len = (unsigned)strlen((((rec_t*)rec)->field_name)); \
178 else \
180 *out_ptr = g_strdup(""); \
181 *out_len = 0; \
185 #define UAT_FLD_IPV4_MC(basename,field_name,title,desc) \
186 {#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}
188 typedef struct
190 uint32_t domain;
191 address addr;
192 uint16_t port;
193 } lbm_uim_stream_destination_t;
195 typedef struct
197 uint8_t ctxinst[LBM_CONTEXT_INSTANCE_BLOCK_SZ];
198 } lbm_uim_stream_ctxinst_t;
200 typedef enum
202 lbm_uim_instance_stream,
203 lbm_uim_domain_stream
204 } lbm_uim_stream_type_t;
206 typedef struct
208 lbm_uim_stream_type_t type;
209 union
211 lbm_uim_stream_destination_t dest;
212 lbm_uim_stream_ctxinst_t ctxinst;
213 } stream_info;
214 } lbm_uim_stream_endpoint_t;
216 typedef struct
218 uint64_t channel;
219 uint32_t substream_id;
220 uint32_t bytes;
221 lbm_uim_stream_endpoint_t endpoint_a;
222 lbm_uim_stream_endpoint_t endpoint_b;
223 } lbm_uim_stream_tap_info_t;
225 typedef struct
227 char * transport;
228 uint8_t type;
229 bool retransmission;
230 uint32_t sqn;
231 uint8_t ncf_reason;
232 uint16_t num_sqns;
233 uint32_t * sqns;
234 } lbm_lbtrm_tap_info_t;
236 typedef struct
238 char * transport;
239 uint8_t type;
240 bool retransmission;
241 uint32_t sqn;
242 uint8_t ncf_reason;
243 uint16_t num_sqns;
244 uint16_t creq_type;
245 uint16_t rst_type;
246 uint32_t * sqns;
247 } lbm_lbtru_tap_info_t;
249 typedef struct
251 uint16_t size;
252 uint8_t topic_length;
253 uint8_t source_length;
254 uint32_t topic_index;
255 char topic[256];
256 char source[256];
257 } lbm_lbmr_topic_advertisement_tap_info_t;
259 typedef struct
261 uint16_t size;
262 uint8_t topic_length;
263 char topic[256];
264 } lbm_lbmr_topic_query_tap_info_t;
266 typedef struct
268 uint16_t size;
269 uint8_t type;
270 uint8_t pattern_length;
271 char pattern[256];
272 } lbm_lbmr_pattern_query_tap_info_t;
274 #define LBMR_WILDCARD_PATTERN_TYPE_PCRE 1
275 #define LBMR_WILDCARD_PATTERN_TYPE_REGEX 2
277 typedef struct
279 uint16_t size;
280 uint16_t port;
281 uint8_t queue_length;
282 uint8_t topic_length;
283 char queue[256];
284 char topic[256];
285 } lbm_lbmr_queue_advertisement_tap_info_t;
287 typedef struct
289 uint16_t size;
290 uint8_t queue_length;
291 char queue[256];
292 } lbm_lbmr_queue_query_tap_info_t;
294 #define LBM_TOPIC_OPT_EXFUNC_FFLAG_LJ 0x00000001
295 #define LBM_TOPIC_OPT_EXFUNC_FFLAG_UME 0x00000002
296 #define LBM_TOPIC_OPT_EXFUNC_FFLAG_UMQ 0x00000004
297 #define LBM_TOPIC_OPT_EXFUNC_FFLAG_ULB 0x00000008
299 /* LBT-RM packet types */
300 #define LBTRM_PACKET_TYPE_DATA 0x00
301 #define LBTRM_PACKET_TYPE_SM 0x02
302 #define LBTRM_PACKET_TYPE_NAK 0x03
303 #define LBTRM_PACKET_TYPE_NCF 0x04
305 /* LBT-RM NCF reason types */
306 #define LBTRM_NCF_REASON_NO_RETRY 0x0
307 #define LBTRM_NCF_REASON_IGNORED 0x1
308 #define LBTRM_NCF_REASON_RX_DELAY 0x2
309 #define LBTRM_NCF_REASON_SHED 0x3
311 /* LBT-RU packet types */
312 #define LBTRU_PACKET_TYPE_DATA 0x00
313 #define LBTRU_PACKET_TYPE_SM 0x02
314 #define LBTRU_PACKET_TYPE_NAK 0x03
315 #define LBTRU_PACKET_TYPE_NCF 0x04
316 #define LBTRU_PACKET_TYPE_ACK 0x05
317 #define LBTRU_PACKET_TYPE_CREQ 0x06
318 #define LBTRU_PACKET_TYPE_RST 0x07
320 /* LBT-RU NCF reason types */
321 #define LBTRU_NCF_REASON_NO_RETRY 0x0
322 #define LBTRU_NCF_REASON_IGNORED 0x1
323 #define LBTRU_NCF_REASON_RX_DELAY 0x2
324 #define LBTRU_NCF_REASON_SHED 0x3
326 /* LBT-RU CREQ types */
327 #define LBTRU_CREQ_REQUEST_SYN 0x0
329 /* LBT-RU RST reasons */
330 #define LBTRU_RST_REASON_DEFAULT 0x0
332 bool lbmc_test_lbmc_header(tvbuff_t * tvb, int offset);
333 int lbmc_dissect_lbmc_packet(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, const char * tag_name, uint64_t channel);
334 int lbmc_get_minimum_length(void);
335 uint16_t lbmc_get_message_length(tvbuff_t * tvb, int offset);
336 bool lbmpdm_verify_payload(tvbuff_t * tvb, int offset, int * encoding, int * length);
337 int lbmpdm_dissect_lbmpdm_payload(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree, uint64_t channel);
338 int lbmpdm_get_minimum_length(void);
339 int lbmr_dissect_umq_qmgmt(tvbuff_t * tvb, int offset, packet_info * pinfo, proto_tree * tree);
341 extern const true_false_string lbm_ignore_flag;
342 extern const value_string lbm_wildcard_pattern_type[];
343 extern const value_string lbm_wildcard_pattern_type_short[];
345 /*----------------------------------------------------------------------------*/
346 /* Channel interface. */
347 /*----------------------------------------------------------------------------*/
348 #define LBM_CHANNEL_NO_CHANNEL (~((uint64_t) 0))
350 #define LBM_CHANNEL_TRANSPORT_LBTTCP 0x00
351 #define LBM_CHANNEL_TRANSPORT_LBTRU 0x01
352 #define LBM_CHANNEL_TRANSPORT_LBTRM 0x02
353 #define LBM_CHANNEL_TRANSPORT_LBTIPC 0x03
354 #define LBM_CHANNEL_TRANSPORT_LBTRDMA 0x04
355 #define LBM_CHANNEL_TRANSPORT_LBTSMX 0x05
356 #define LBM_CHANNEL_STREAM_TCP 0x10
357 #define LBM_CHANNEL_TCP 0x20
359 #define LBM_CHANNEL_VALUE_MASK UINT64_C(0xfffffffffffff000)
360 #define LBM_CHANNEL_VALUE_SHIFT_COUNT 12
362 void lbm_channel_reset(void);
363 uint64_t lbm_channel_assign(uint8_t channel_type);
364 bool lbm_channel_is_transport(uint64_t channel);
365 uint8_t lbm_channel_type(uint64_t channel);
366 uint64_t lbm_channel_assign_unknown_transport_source_lbttcp(void);
367 uint64_t lbm_channel_assign_unknown_transport_client_lbttcp(void);
368 uint64_t lbm_channel_assign_unknown_stream_tcp(void);
369 bool lbm_channel_is_unknown_transport_lbttcp(uint64_t channel);
370 bool lbm_channel_is_unknown_transport_source_lbttcp(uint64_t channel);
371 bool lbm_channel_is_unknown_transport_client_lbttcp(uint64_t channel);
372 bool lbm_channel_is_unknown_stream_tcp(uint64_t channel);
373 bool lbm_channel_is_known(uint64_t channel);
375 #define LBM_CHANNEL_ID(ch) ((ch & LBM_CHANNEL_VALUE_MASK) >> LBM_CHANNEL_VALUE_SHIFT_COUNT)
377 /*----------------------------------------------------------------------------*/
378 /* Frame/SQN interface. */
379 /*----------------------------------------------------------------------------*/
380 typedef struct
382 uint32_t frame;
383 uint8_t type;
384 uint32_t sqn;
385 uint32_t previous_frame;
386 uint32_t previous_type_frame;
387 uint32_t next_frame;
388 uint32_t next_type_frame;
389 bool retransmission;
390 uint32_t sqn_gap;
391 uint32_t ooo_gap;
392 bool duplicate;
393 } lbm_transport_frame_t;
395 typedef struct
397 uint32_t frame;
398 bool retransmission;
399 } lbm_transport_sqn_frame_t;
401 typedef struct
403 uint32_t sqn;
404 uint32_t frame_count;
405 wmem_tree_t * frame; /* List of lbm_transport_sqn_frame_t */
406 } lbm_transport_sqn_t;
408 lbm_transport_frame_t * lbm_transport_frame_add(wmem_tree_t * list, uint8_t type, uint32_t frame, uint32_t sqn, bool retransmission);
409 lbm_transport_sqn_t * lbm_transport_sqn_add(wmem_tree_t * list, lbm_transport_frame_t * frame);
411 /*----------------------------------------------------------------------------*/
412 /* Topic interface. */
413 /*----------------------------------------------------------------------------*/
414 void lbm_topic_init(void);
415 const char * lbm_topic_find(uint64_t channel, uint32_t topic_index);
416 void lbm_topic_add(uint64_t channel, uint32_t topic_index, const char * name);
418 #endif
421 * Editor modelines - https://www.wireshark.org/tools/modelines.html
423 * Local variables:
424 * c-basic-offset: 4
425 * tab-width: 8
426 * indent-tabs-mode: nil
427 * End:
429 * vi: set shiftwidth=4 tabstop=8 expandtab:
430 * :indentSize=4:tabSize=8:noTabs=true: