Wireshark  4.3.0
The Wireshark network protocol analyzer
packet-pn.h
1 /* packet-pn.h
2  * Common functions for other PROFINET protocols like DCP, MRP, ...
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1999 Gerald Combs
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 
11 /*
12  * Cyclic PNIO RTC1 Data Dissection:
13  *
14  * Added new structures to packet-pn.h to transfer the gained data of
15  * packet-pn-dcp.c and packet-dcerpc-pn-io.c to packet-pn-rtc-one.c for
16  * detailed dissection of cyclic PNIO RTC1 dataframes.
17  *
18  */
19 
20 #define FRAME_ID_DCP_HELLO 0xfefc
21 #define FRAME_ID_DCP_GETORSET 0xfefd
22 #define FRAME_ID_DCP_IDENT_REQ 0xfefe
23 #define FRAME_ID_DCP_IDENT_RES 0xfeff
24 
25 
26 /* ---- Structures for pnio_rtc1 ---- */
27 extern int proto_pn_dcp;
28 extern int proto_pn_io_apdu_status;
29 extern int proto_pn_io_time_aware_status;
30 
31 extern bool pnio_ps_selection; /* given by pnio preferences */
32 
33 /* Structure for general station information */
34 typedef struct tagStationInfo {
35  /* general information */
36  gchar *typeofstation;
37  gchar *nameofstation;
38  guint16 u16Vendor_id;
39  guint16 u16Device_id;
40  /* frame structure */
41  guint16 ioDataObjectNr_in;
42  guint16 ioDataObjectNr_out;
43  guint16 iocsNr_in;
44  guint16 iocsNr_out;
45  /* GSDfile station information */
46  gboolean gsdFound;
47  gboolean gsdPathLength;
48  gchar *gsdLocation;
49  /* IOCS object data */
50  wmem_list_t *iocs_data_in;
51  wmem_list_t *iocs_data_out;
52  /* IOData object data */
53  wmem_list_t *ioobject_data_in;
54  wmem_list_t *ioobject_data_out;
55  /* Different ModuleIdentnumber */
56  wmem_list_t *diff_module;
57 } stationInfo;
58 
59 typedef struct tagApduStatusSwitch
60 {
61  gboolean isRedundancyActive;
62  address dl_dst;
63  address dl_src;
65 
66 /* Structure for IOCS Frames */
67 typedef struct tagIocsObject {
68  guint16 slotNr;
69  guint16 subSlotNr;
70  guint16 frameOffset;
71 } iocsObject;
72 
73 /* Structure for IO Data Objects */
74 typedef struct tagIoDataObject {
75  guint16 slotNr;
76  guint16 subSlotNr;
77  guint32 api;
78  guint32 moduleIdentNr;
79  guint32 subModuleIdentNr;
80  guint16 frameOffset;
81  guint16 length;
82  guint16 amountInGSDML;
83  guint32 fParameterIndexNr;
84  guint16 f_par_crc1;
85  guint16 f_src_adr;
86  guint16 f_dest_adr;
87  gboolean f_crc_seed;
88  guint8 f_crc_len;
89  address srcAddr;
90  address dstAddr;
91  gboolean profisafeSupported;
92  gboolean discardIOXS;
93  gchar *moduleNameStr;
94  tvbuff_t *tvb_slot;
95  tvbuff_t *tvb_subslot;
96  /* Status- or Controlbyte data*/
97  guint8 last_sb_cb;
98  guint8 lastToggleBit;
99 } ioDataObject;
100 
101 /* Structure for Modules with different ModuleIdentnumber */
102 typedef struct tagModuleDiffInfo {
103  guint16 slotNr;
104  guint32 modulID;
106 
107 typedef struct tagARUUIDFrame {
108  e_guid_t aruuid;
109  guint32 setupframe;
110  guint32 releaseframe;
111  guint16 outputframe;
112  guint16 inputframe;
113 } ARUUIDFrame;
114 
115 extern wmem_list_t *aruuid_frame_setup_list;
116 
117 extern void init_pn(int proto);
118 extern void init_pn_io_rtc1(int proto);
119 extern void init_pn_rsi(int proto);
120 extern void pn_rsi_reassemble_init(void);
121 
122 extern void init_pnio_rtc1_station(stationInfo *station_info);
123 
124 extern int dissect_pn_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo,
125  proto_tree *tree, int hfindex, guint8 *pdata);
126 
127 extern int dissect_pn_uint16_ret_item(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
128  proto_tree *tree, int hfindex, guint16 *pdata, proto_item ** new_item);
129 extern int dissect_pn_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo,
130  proto_tree *tree, int hfindex, guint16 *pdata);
131 
132 extern int dissect_pn_int16(tvbuff_t *tvb, gint offset, packet_info *pinfo,
133  proto_tree *tree, int hfindex, gint16 *pdata);
134 
135 extern int dissect_pn_oid(tvbuff_t *tvb, int offset, packet_info *pinfo,
136  proto_tree *tree, int hfindex, guint32 *pdata);
137 
138 extern int dissect_pn_mac(tvbuff_t *tvb, int offset, packet_info *pinfo,
139  proto_tree *tree, int hfindex, guint8 *pdata);
140 
141 extern int dissect_pn_ipv4(tvbuff_t *tvb, int offset, packet_info *pinfo,
142  proto_tree *tree, int hfindex, guint32 *pdata);
143 
144 extern int dissect_pn_uuid(tvbuff_t *tvb, int offset, packet_info *pinfo,
145  proto_tree *tree, int hfindex, e_guid_t *uuid);
146 
147 extern int dissect_pn_undecoded(tvbuff_t *tvb, int offset, packet_info *pinfo,
148  proto_tree *tree, guint32 length);
149 
150 extern int dissect_pn_user_data(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
151  proto_tree *tree, guint32 length, const char *text);
152 
153 extern int dissect_pn_pa_profile_data(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
154  proto_tree *tree, guint32 length, const char *text);
155 
156 extern int dissect_blocks(tvbuff_t *tvb, int offset,
157  packet_info *pinfo, proto_tree *tree, guint8 *drep);
158 
159 #define PDU_TYPE_REQ 0x05
160 #define PDU_TYPE_RSP 0x06
161 
162 extern int dissect_rsi_blocks(tvbuff_t* tvb, int offset, packet_info* pinfo, proto_tree* tree, guint8* drep, guint32 u32FOpnumOffsetOpnum, int type);
163 
164 #define SUBST_DATA 1
165 #define FRAG_DATA 2
166 
167 extern int dissect_pn_user_data_bytes(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
168  proto_tree *tree, guint32 length, int iSelect);
169 
170 extern int dissect_pn_malformed(tvbuff_t *tvb, int offset, packet_info *pinfo,
171  proto_tree *tree, guint32 length);
172 
173 extern int dissect_pn_padding(tvbuff_t *tvb, int offset, packet_info *pinfo,
174  proto_tree *tree, int length);
175 
176 extern int dissect_pn_align4(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
177 
178 extern int dissect_PNIO_status(tvbuff_t *tvb, int offset, packet_info *pinfo,
179  proto_tree *tree, guint8 *drep);
180 
181 extern int dissect_PNIO_C_SDU_RTC1(tvbuff_t* tvb, int offset, packet_info* pinfo,
182  proto_tree* tree, guint8* drep _U_, guint16 frameid);
183 
184 extern int dissect_PNIO_RSI(tvbuff_t *tvb, int offset, packet_info *pinfo,
185  proto_tree *tree, guint8 *drep);
186 
187 extern int dissect_PDRsiInstances_block(tvbuff_t *tvb, int offset,
188  packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint8 *drep, guint8 u8BlockVersionHigh, guint8 u8BlockVersionLow);
189 
190 extern void pn_append_info(packet_info *pinfo, proto_item *dcp_item, const char *text);
191 
192 extern void pn_init_append_aruuid_frame_setup_list(e_guid_t aruuid, guint32 setup);
193 
194 extern ARUUIDFrame* pn_find_aruuid_frame_setup(packet_info* pinfo);
195 
196 extern void pn_find_dcp_station_info(stationInfo* station_info, conversation_t* conversation);
197 
198 extern bool dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data);
199 
200 #define MAX_LINE_LENGTH 1024 /* used for fgets() */
201 
202 /* Read a string from an "xml" file, dropping xml comment blocks */
203 #include <stdio.h>
204 extern char *pn_fgets(char *str, int n, FILE *stream, wmem_allocator_t *scope);
Definition: address.h:56
Definition: guid-utils.h:22
Definition: packet_info.h:44
Definition: proto.h:904
Definition: wmem_allocator.h:27
Definition: wmem_list.c:23
Definition: conversation.h:220
Definition: stream.c:41
Definition: packet-pn.h:107
Definition: packet-pn.h:60
Definition: packet-pn.h:74
Definition: packet-pn.h:67
Definition: packet-pn.h:102
Definition: packet-pn.h:34
Definition: tvbuff-int.h:35