Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet-trdp-dict.h
1/* packet-trdp-dict.h
2 * Routines for trdp packet dissection, parser for IEC 61375-3-2 XML description
3 *
4 * Copyright Bombardier Transportation Inc. or its subsidiaries and others, 2013. Florian Weispfenning
5 * Copyright Universität Rostock, 2019 (substantial changes leading to GLib-only version). Thorsten Schulz
6 * Copyright Stadler Deutschland GmbH, 2024-2025. Thorsten Schulz
7 *
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <[email protected]>
10 * Copyright 1998 Gerald Combs
11 *
12 * SPDX-License-Identifier: GPL-2.0-or-later
13 */
14
15#ifndef TRDP_CONFIG_HANDLER
16#define TRDP_CONFIG_HANDLER
17
18/*******************************************************************************
19 * INCLUDES
20 */
21#include <epan/packet.h>
22
23 /* packet-trdp-env.h */
24#define TRDP_BITSET8 1
25#define TRDP_CHAR8 2
26#define TRDP_UTF16 3
27#define TRDP_INT8 4
28#define TRDP_INT16 5
29#define TRDP_INT32 6
30#define TRDP_INT64 7
31#define TRDP_UINT8 8
32#define TRDP_UINT16 9
33#define TRDP_UINT32 10
34#define TRDP_UINT64 11
35#define TRDP_REAL32 12
36#define TRDP_REAL64 13
37#define TRDP_TIMEDATE32 14
38#define TRDP_TIMEDATE48 \
39 15
40#define TRDP_TIMEDATE64 16
41#define TRDP_SC32 17
42#define TRDP_UUID 18
44#define TRDP_BITSUBTYPE_BITS 8
45#define TRDP_BITSUBTYPE_BITSET8 0
46#define TRDP_BITSUBTYPE_BOOL8 \
47 1
49#define TRDP_BITSUBTYPE_ANTIVALENT8 \
50 2
52#define TRDP_ENDSUBTYPE_BIG 0
53#define TRDP_ENDSUBTYPE_LIT 1
55#define TRDP_STANDARDTYPE_MAX TRDP_UUID
57#define TRDP_DEFAULT_UDPTCP_MD_PORT \
58 17225
59#define TRDP_DEFAULT_UDP_PD_PORT \
60 17224
61#define TRDP_DEFAULT_STR_PD_PORT "17224"
62#define TRDP_DEFAULT_STR_MD_PORT "17225"
63
64#define TRDP_DEFAULT_SC32_SID 0xFFFFFFFF
65#define TRDP_DEFAULT_STR_SC32_SID "0xFFFFFFFF"
66
67#define TRDP_MAX_DATASET_RECURSION \
68 15
70#define PROTO_TAG_TRDP "TRDP"
71#define PROTO_NAME_TRDP "Train Real Time Data Protocol"
72#define PROTO_DISSECTORNAME_TRDP "TRDP"
73#define PROTO_DISSECTORNAME_TRDPTCP "TRDP.tcp"
74#define PROTO_FILTERNAME_TRDP "trdp"
75#define PROTO_FILTERNAME_TRDP_PDU PROTO_FILTERNAME_TRDP ".pdu"
76
77#define WS_LOG_DOMAIN PROTO_TAG_TRDP
78
79#define TRDP_HEADER_OFFSET_SEQCNT 0
80#define TRDP_HEADER_OFFSET_PROTOVER 4
81#define TRDP_HEADER_OFFSET_TYPE 6
82#define TRDP_HEADER_OFFSET_COMID 8
83#define TRDP_HEADER_OFFSET_ETB_TOPOCNT 12
84#define TRDP_HEADER_OFFSET_OP_TRN_TOPOCNT 16
85#define TRDP_HEADER_OFFSET_DATASETLENGTH 20
86
87#define TRDP_HEADER_PD_OFFSET_RESERVED 24
88#define TRDP_HEADER_PD_OFFSET_REPLY_COMID 28
89#define TRDP_HEADER_PD_OFFSET_REPLY_IPADDR 32
90#define TRDP_HEADER_PD_OFFSET_FCSHEAD 36
91#define TRDP_HEADER_PD_OFFSET_DATA 40
92
93#define TRDP_HEADER_MD_OFFSET_REPLY_STATUS 24
94#define TRDP_HEADER_MD_SESSIONID0 28
95#define TRDP_HEADER_MD_SESSIONID1 32
96#define TRDP_HEADER_MD_SESSIONID2 36
97#define TRDP_HEADER_MD_SESSIONID3 40
98#define TRDP_HEADER_MD_REPLY_TIMEOUT 44
99#define TRDP_HEADER_MD_SRC_URI 48
100#define TRDP_HEADER_MD_DEST_URI 80
101#define TRDP_HEADER_MD_OFFSET_FCSHEAD 112
102#define TRDP_HEADER_MD_OFFSET_DATA 116
103
104#define TRDP_MD_HEADERLENGTH \
105 TRDP_HEADER_MD_OFFSET_DATA
108#define TRDP_FCS_LENGTH \
109 4
112#define TRDP_SC32_LENGTH \
113 4
115int32_t trdp_dissect_width(uint32_t type);
116
117/* end packet-trdp-env.h */
118/*******************************************************************************
119 * CLASS Definition
120 */
121
162/* Assistant type to cater the type duality of a BITSET8 */
163typedef struct ElementType {
164 char name[32];
165 uint32_t id;
166 uint32_t subtype;
168
169typedef struct Bit {
170 char name[32];
171 int hf_id;
172 int ett_id;
173// int position;
174// struct Element *parent;
175} Bit;
176
177typedef struct Element {
178/* R/O */
179 char *name;
180 char *unit;
182/*public:*/
183
186 int32_t array_size;
187 double scale;
188 int32_t offset;
191 int32_t bitindex;
192 int ** bitfields;
193 int bits_ett_id;
194
195 int32_t width;
197 int hf_id;
198 int ett_id;
199 struct Element *next;
200
201} Element;
202
206typedef struct Dataset {
207/* private */
208 int32_t size;
209 char *name;
211/* public */
212 uint32_t datasetId;
213 int ett_id;
215 char *source;
219 struct Dataset *next;
220} Dataset;
221
222
242typedef struct ComId {
243 char *name;
245/* public: */
246 uint32_t comId;
247 uint32_t dataset;
248 int32_t size;
249 int ett_id;
251 char *source;
254 struct ComId *next;
255} ComId;
256
266typedef struct TrdpDict {
267
268/* pub */
271/* pub-R/O */
274 unsigned int knowledge;
275 unsigned int datasets;
277 const char *currentFile;
281} TrdpDict;
282
295extern TrdpDict* TrdpDict_new(const char* baseXmlConfig, const char* customXmlConfig, uint32_t bitset_subtype, uint32_t endian_subtype, GError** error);
296
306extern void TrdpDict_delete ( TrdpDict *self, gint parent_id);
307
319extern const ComId* TrdpDict_lookup_ComId(const TrdpDict *self, uint32_t comId);
320
332extern const char* TrdpDict_lookup_ComId_Name(const TrdpDict *self, uint32_t comId);
333
345extern Dataset* TrdpDict_get_Dataset (const TrdpDict *self, uint32_t datasetId);
346
347/* @fn int32_t TrdpDict_element_size(const Element *element, uint32_t array_size);
348 *
349 * @brief Calculate the size of an element and its subtree if there is one.
350 *
351 * @param self The element to calculate
352 * @param array_size Hand in the dynamic size of the array (kept from the previous element) or set to 1 to use the predefined size from the dictionary.
353 * @return -1 on error, or the type-size multiplied by the array-size. */
354extern int32_t TrdpDict_element_size(const Element *self, uint32_t array_size /* = 1*/);
355
356extern const ElementType ElBasics[];
357
358#endif
Definition packet-trdp-dict.h:169
char name[32]
Definition packet-trdp-dict.h:170
This struct makes a mapping between one comId and one dataset.
Definition packet-trdp-dict.h:242
struct Dataset * linkedDS
Definition packet-trdp-dict.h:253
int duplicates
Definition packet-trdp-dict.h:250
int32_t size
Definition packet-trdp-dict.h:248
char * source
Definition packet-trdp-dict.h:251
int ett_id
Definition packet-trdp-dict.h:249
struct ComId * next
Definition packet-trdp-dict.h:254
uint32_t dataset
Definition packet-trdp-dict.h:247
char * name
Definition packet-trdp-dict.h:243
uint32_t comId
Definition packet-trdp-dict.h:246
Description of one dataset.
Definition packet-trdp-dict.h:206
struct Element * listOfElements
Definition packet-trdp-dict.h:217
struct Dataset * next
Definition packet-trdp-dict.h:219
char * source
Definition packet-trdp-dict.h:215
struct Element * lastOfElements
Definition packet-trdp-dict.h:218
int ett_id
Definition packet-trdp-dict.h:213
uint32_t datasetId
Definition packet-trdp-dict.h:212
int duplicates
Definition packet-trdp-dict.h:214
char * name
Definition packet-trdp-dict.h:209
int32_t size
Definition packet-trdp-dict.h:208
description of one element
Definition packet-trdp-dict.h:177
ElementType type
Definition packet-trdp-dict.h:184
int32_t bitindex
Definition packet-trdp-dict.h:191
int32_t offset
Definition packet-trdp-dict.h:188
char * unit
Definition packet-trdp-dict.h:180
int ** bitfields
Definition packet-trdp-dict.h:192
double scale
Definition packet-trdp-dict.h:187
int32_t width
Definition packet-trdp-dict.h:195
Bit * bits
Definition packet-trdp-dict.h:190
struct Dataset * linkedDS
Definition packet-trdp-dict.h:196
int32_t array_size
Definition packet-trdp-dict.h:186
char * name
Definition packet-trdp-dict.h:179
Definition packet-trdp-dict.h:163
This struct is the root container for the XML type dictionary.
Definition packet-trdp-dict.h:266
uint32_t def_bitset_subtype
Definition packet-trdp-dict.h:279
bool isShippedXml
Definition packet-trdp-dict.h:278
unsigned int datasets
Definition packet-trdp-dict.h:275
struct Dataset * mCyclicDataset
Definition packet-trdp-dict.h:272
const char * currentFile
Definition packet-trdp-dict.h:277
struct Dataset * mTableDataset
Definition packet-trdp-dict.h:269
size_t maxDatasetDepth
Definition packet-trdp-dict.h:273
struct ComId * mTableComId
Definition packet-trdp-dict.h:276
unsigned int knowledge
Definition packet-trdp-dict.h:274
uint32_t def_endian_subtype
Definition packet-trdp-dict.h:280