epan/dissectors/pidl/ C99 drsuapi
[wireshark-sm.git] / plugins / epan / profinet / packet-pn.h
blobc0370cda27bda6b86ae5ca12883e832238d482df
1 /* packet-pn.h
2 * Common functions for other PROFINET protocols like DCP, MRP, ...
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1999 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
12 * Cyclic PNIO RTC1 Data Dissection:
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.
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
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;
31 extern bool pnio_ps_selection; /* given by pnio preferences */
33 /* Structure for general station information */
34 typedef struct tagStationInfo {
35 /* general information */
36 char *typeofstation;
37 char *nameofstation;
38 uint16_t u16Vendor_id;
39 uint16_t u16Device_id;
40 /* frame structure */
41 uint16_t ioDataObjectNr_in;
42 uint16_t ioDataObjectNr_out;
43 uint16_t iocsNr_in;
44 uint16_t iocsNr_out;
45 /* GSDfile station information */
46 bool gsdFound;
47 bool gsdPathLength;
48 char *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;
59 typedef struct tagApduStatusSwitch
61 bool isRedundancyActive;
62 address dl_dst;
63 address dl_src;
64 }apduStatusSwitch;
66 /* Structure for IOCS Frames */
67 typedef struct tagIocsObject {
68 uint16_t slotNr;
69 uint16_t subSlotNr;
70 uint16_t frameOffset;
71 } iocsObject;
73 /* Structure for IO Data Objects */
74 typedef struct tagIoDataObject {
75 uint16_t slotNr;
76 uint16_t subSlotNr;
77 uint32_t api;
78 uint32_t moduleIdentNr;
79 uint32_t subModuleIdentNr;
80 uint16_t frameOffset;
81 uint16_t length;
82 uint16_t amountInGSDML;
83 uint32_t fParameterIndexNr;
84 uint16_t f_par_crc1;
85 uint16_t f_src_adr;
86 uint16_t f_dest_adr;
87 bool f_crc_seed;
88 uint8_t f_crc_len;
89 address srcAddr;
90 address dstAddr;
91 bool profisafeSupported;
92 bool discardIOXS;
93 char *moduleNameStr;
94 tvbuff_t *tvb_slot;
95 tvbuff_t *tvb_subslot;
96 /* Status- or Controlbyte data*/
97 uint8_t last_sb_cb;
98 uint8_t lastToggleBit;
99 } ioDataObject;
101 /* Structure for Modules with different ModuleIdentnumber */
102 typedef struct tagModuleDiffInfo {
103 uint16_t slotNr;
104 uint32_t modulID;
105 } moduleDiffInfo;
107 typedef struct tagARUUIDFrame {
108 e_guid_t aruuid;
109 uint32_t setupframe;
110 uint32_t releaseframe;
111 uint16_t outputframe;
112 uint16_t inputframe;
113 } ARUUIDFrame;
115 extern wmem_list_t *aruuid_frame_setup_list;
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);
122 extern void init_pnio_rtc1_station(stationInfo *station_info);
124 extern int dissect_pn_uint8(tvbuff_t *tvb, int offset, packet_info *pinfo,
125 proto_tree *tree, int hfindex, uint8_t *pdata);
127 extern int dissect_pn_uint16_ret_item(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
128 proto_tree *tree, int hfindex, uint16_t *pdata, proto_item ** new_item);
129 extern int dissect_pn_uint16(tvbuff_t *tvb, int offset, packet_info *pinfo,
130 proto_tree *tree, int hfindex, uint16_t *pdata);
132 extern int dissect_pn_int16(tvbuff_t *tvb, int offset, packet_info *pinfo,
133 proto_tree *tree, int hfindex, int16_t *pdata);
135 extern int dissect_pn_oid(tvbuff_t *tvb, int offset, packet_info *pinfo,
136 proto_tree *tree, int hfindex, uint32_t *pdata);
138 extern int dissect_pn_mac(tvbuff_t *tvb, int offset, packet_info *pinfo,
139 proto_tree *tree, int hfindex, uint8_t *pdata);
141 extern int dissect_pn_ipv4(tvbuff_t *tvb, int offset, packet_info *pinfo,
142 proto_tree *tree, int hfindex, uint32_t *pdata);
144 extern int dissect_pn_uuid(tvbuff_t *tvb, int offset, packet_info *pinfo,
145 proto_tree *tree, int hfindex, e_guid_t *uuid);
147 extern int dissect_pn_undecoded(tvbuff_t *tvb, int offset, packet_info *pinfo,
148 proto_tree *tree, uint32_t length);
150 extern int dissect_pn_user_data(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
151 proto_tree *tree, uint32_t length, const char *text);
153 extern int dissect_pn_pa_profile_data(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
154 proto_tree *tree, uint32_t length, const char *text);
156 extern int dissect_blocks(tvbuff_t *tvb, int offset,
157 packet_info *pinfo, proto_tree *tree, uint8_t *drep);
159 #define PDU_TYPE_REQ 0x05
160 #define PDU_TYPE_RSP 0x06
162 extern int dissect_rsi_blocks(tvbuff_t* tvb, int offset, packet_info* pinfo, proto_tree* tree, uint8_t* drep, uint32_t u32FOpnumOffsetOpnum, int type);
164 #define SUBST_DATA 1
165 #define FRAG_DATA 2
167 extern int dissect_pn_user_data_bytes(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
168 proto_tree *tree, uint32_t length, int iSelect);
170 extern int dissect_pn_malformed(tvbuff_t *tvb, int offset, packet_info *pinfo,
171 proto_tree *tree, uint32_t length);
173 extern int dissect_pn_padding(tvbuff_t *tvb, int offset, packet_info *pinfo,
174 proto_tree *tree, int length);
176 extern int dissect_pn_align4(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
178 extern int dissect_PNIO_status(tvbuff_t *tvb, int offset, packet_info *pinfo,
179 proto_tree *tree, uint8_t *drep);
181 extern int dissect_PNIO_C_SDU_RTC1(tvbuff_t* tvb, int offset, packet_info* pinfo,
182 proto_tree* tree, uint8_t* drep _U_, uint16_t frameid);
184 extern int dissect_PNIO_RSI(tvbuff_t *tvb, int offset, packet_info *pinfo,
185 proto_tree *tree, uint8_t *drep);
187 extern int dissect_PDRsiInstances_block(tvbuff_t *tvb, int offset,
188 packet_info *pinfo, proto_tree *tree, proto_item *item _U_, uint8_t *drep, uint8_t u8BlockVersionHigh, uint8_t u8BlockVersionLow);
190 extern void pn_append_info(packet_info *pinfo, proto_item *dcp_item, const char *text);
192 extern void pn_init_append_aruuid_frame_setup_list(e_guid_t aruuid, uint32_t setup);
194 extern ARUUIDFrame* pn_find_aruuid_frame_setup(packet_info* pinfo);
196 extern void pn_find_dcp_station_info(stationInfo* station_info, conversation_t* conversation);
198 extern bool dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data);
200 #define MAX_LINE_LENGTH 1024 /* used for fgets() */
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);