HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-cip.h
blob2d485624422d7e8dbfe37982a29db0357ec413ac
1 /* packet-cip.h
2 * Routines for CIP (Common Industrial Protocol) dissection
3 * CIP Home: www.odva.org
5 * Copyright 2004
6 * Magnus Hansson <mah@hms.se>
7 * Joakim Wiberg <jow@hms.se>
9 * Added support for Connection Configuration Object
10 * ryan wamsley * Copyright 2007
12 * $Id$
14 * Wireshark - Network traffic analyzer
15 * By Gerald Combs <gerald@wireshark.org>
16 * Copyright 1998 Gerald Combs
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version 2
21 * of the License, or (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 /* CIP Service Codes */
34 #define SC_GET_ATT_ALL 0x01
35 #define SC_SET_ATT_ALL 0x02
36 #define SC_GET_ATT_LIST 0x03
37 #define SC_SET_ATT_LIST 0x04
38 #define SC_RESET 0x05
39 #define SC_START 0x06
40 #define SC_STOP 0x07
41 #define SC_CREATE 0x08
42 #define SC_DELETE 0x09
43 #define SC_MULT_SERV_PACK 0x0A
44 #define SC_APPLY_ATTRIBUTES 0x0D
45 #define SC_GET_ATT_SINGLE 0x0E
46 #define SC_SET_ATT_SINGLE 0x10
47 #define SC_FIND_NEXT_OBJ_INST 0x11
48 #define SC_RESTOR 0x15
49 #define SC_SAVE 0x16
50 #define SC_NO_OP 0x17
51 #define SC_GET_MEMBER 0x18
52 #define SC_SET_MEMBER 0x19
53 #define SC_INSERT_MEMBER 0x1A
54 #define SC_REMOVE_MEMBER 0x1B
55 #define SC_GROUP_SYNC 0x1C
57 /* Classes that have class-specfic dissectors */
58 #define CI_CLS_MR 0x02 /* Message Router */
59 #define CI_CLS_CM 0x06 /* Connection Manager */
60 #define CI_CLS_MB 0x44 /* Modbus Object */
61 #define CI_CLS_CCO 0xF3 /* Connection Configuration Object */
63 /* Class specific services */
64 /* Connection Manager */
65 #define SC_CM_FWD_CLOSE 0x4E
66 #define SC_CM_UNCON_SEND 0x52
67 #define SC_CM_FWD_OPEN 0x54
68 #define SC_CM_LARGE_FWD_OPEN 0x5B
69 #define SC_CM_GET_CONN_OWNER 0x5A
71 /* Modbus Object services */
72 #define SC_MB_READ_DISCRETE_INPUTS 0x4B
73 #define SC_MB_READ_COILS 0x4C
74 #define SC_MB_READ_INPUT_REGISTERS 0x4D
75 #define SC_MB_READ_HOLDING_REGISTERS 0x4E
76 #define SC_MB_WRITE_COILS 0x4F
77 #define SC_MB_WRITE_HOLDING_REGISTERS 0x50
78 #define SC_MB_PASSTHROUGH 0x51
80 /* Connection Configuration Object services */
81 #define SC_CCO_KICK_TIMER 0x4B
82 #define SC_CCO_OPEN_CONN 0x4C
83 #define SC_CCO_CLOSE_CONN 0x4D
84 #define SC_CCO_STOP_CONN 0x4E
85 #define SC_CCO_CHANGE_START 0x4F
86 #define SC_CCO_GET_STATUS 0x50
87 #define SC_CCO_CHANGE_COMPLETE 0x51
88 #define SC_CCO_AUDIT_CHANGE 0x52
90 /* CIP General status codes */
91 #define CI_GRC_SUCCESS 0x00
92 #define CI_GRC_FAILURE 0x01
93 #define CI_GRC_NO_RESOURCE 0x02
94 #define CI_GRC_BAD_DATA 0x03
95 #define CI_GRC_BAD_PATH 0x04
96 #define CI_GRC_BAD_CLASS_INSTANCE 0x05
97 #define CI_GRC_PARTIAL_DATA 0x06
98 #define CI_GRC_CONN_LOST 0x07
99 #define CI_GRC_BAD_SERVICE 0x08
100 #define CI_GRC_BAD_ATTR_DATA 0x09
101 #define CI_GRC_ATTR_LIST_ERROR 0x0A
102 #define CI_GRC_ALREADY_IN_MODE 0x0B
103 #define CI_GRC_BAD_OBJ_MODE 0x0C
104 #define CI_GRC_OBJ_ALREADY_EXISTS 0x0D
105 #define CI_GRC_ATTR_NOT_SETTABLE 0x0E
106 #define CI_GRC_PERMISSION_DENIED 0x0F
107 #define CI_GRC_DEV_IN_WRONG_STATE 0x10
108 #define CI_GRC_REPLY_DATA_TOO_LARGE 0x11
109 #define CI_GRC_FRAGMENT_PRIMITIVE 0x12
110 #define CI_GRC_CONFIG_TOO_SMALL 0x13
111 #define CI_GRC_UNDEFINED_ATTR 0x14
112 #define CI_GRC_CONFIG_TOO_BIG 0x15
113 #define CI_GRC_OBJ_DOES_NOT_EXIST 0x16
114 #define CI_GRC_NO_FRAGMENTATION 0x17
115 #define CI_GRC_DATA_NOT_SAVED 0x18
116 #define CI_GRC_DATA_WRITE_FAILURE 0x19
117 #define CI_GRC_REQUEST_TOO_LARGE 0x1A
118 #define CI_GRC_RESPONSE_TOO_LARGE 0x1B
119 #define CI_GRC_MISSING_LIST_DATA 0x1C
120 #define CI_GRC_INVALID_LIST_STATUS 0x1D
121 #define CI_GRC_SERVICE_ERROR 0x1E
122 #define CI_GRC_CONN_RELATED_FAILURE 0x1F
123 #define CI_GRC_INVALID_PARAMETER 0x20
124 #define CI_GRC_WRITE_ONCE_FAILURE 0x21
125 #define CI_GRC_INVALID_REPLY 0x22
126 #define CI_GRC_BUFFER_OVERFLOW 0x23
127 #define CI_GRC_MESSAGE_FORMAT 0x24
128 #define CI_GRC_BAD_KEY_IN_PATH 0x25
129 #define CI_GRC_BAD_PATH_SIZE 0x26
130 #define CI_GRC_UNEXPECTED_ATTR 0x27
131 #define CI_GRC_INVALID_MEMBER 0x28
132 #define CI_GRC_MEMBER_NOT_SETTABLE 0x29
133 #define CI_GRC_G2_SERVER_FAILURE 0x2A
134 #define CI_GRC_UNKNOWN_MB_ERROR 0x2B
135 #define CI_GRC_ATTRIBUTE_NOT_GET 0x2C
137 #define CI_GRC_STILL_PROCESSING 0xFF
140 /* IOI Path types */
141 #define CI_SEGMENT_TYPE_MASK 0xE0
143 #define CI_PORT_SEGMENT 0x00
144 #define CI_LOGICAL_SEGMENT 0x20
145 #define CI_NETWORK_SEGMENT 0x40
146 #define CI_SYMBOLIC_SEGMENT 0x60
147 #define CI_DATA_SEGMENT 0x80
149 #define CI_PORT_SEG_EX_LINK_ADDRESS 0x10
150 #define CI_PORT_SEG_PORT_ID_MASK 0x0F
152 #define CI_LOGICAL_SEG_TYPE_MASK 0x1C
153 #define CI_LOGICAL_SEG_CLASS_ID 0x00
154 #define CI_LOGICAL_SEG_INST_ID 0x04
155 #define CI_LOGICAL_SEG_MBR_ID 0x08
156 #define CI_LOGICAL_SEG_CON_POINT 0x0C
157 #define CI_LOGICAL_SEG_ATTR_ID 0x10
158 #define CI_LOGICAL_SEG_SPECIAL 0x14
159 #define CI_LOGICAL_SEG_SERV_ID 0x18
160 #define CI_LOGICAL_SEG_RES_1 0x1C
162 #define CI_LOGICAL_SEG_FORMAT_MASK 0x03
163 #define CI_LOGICAL_SEG_8_BIT 0x00
164 #define CI_LOGICAL_SEG_16_BIT 0x01
165 #define CI_LOGICAL_SEG_32_BIT 0x02
166 #define CI_LOGICAL_SEG_RES_2 0x03
167 #define CI_LOGICAL_SEG_E_KEY 0x00
169 #define CI_E_KEY_FORMAT_VAL 0x04
171 #define CI_DATA_SEG_TYPE_MASK 0x1F
172 #define CI_DATA_SEG_SIMPLE 0x00
173 #define CI_DATA_SEG_SYMBOL 0x11
175 #define CI_NETWORK_SEG_TYPE_MASK 0x1F
176 #define CI_NETWORK_SEG_SCHEDULE 0x01
177 #define CI_NETWORK_SEG_FIXED_TAG 0x02
178 #define CI_NETWORK_SEG_PROD_INHI 0x03
179 #define CI_NETWORK_SEG_SAFETY 0x10
180 #define CI_NETWORK_SEG_EXTENDED 0x1F
182 #define CI_TRANSPORT_CLASS_MASK 0x0F
183 #define CI_PRODUCTION_TRIGGER_MASK 0x70
184 #define CI_PRODUCTION_DIR_MASK 0x80
186 #define CONN_TYPE_NULL 0
187 #define CONN_TYPE_MULTICAST 1
188 #define CONN_TYPE_P2P 2
189 #define CONN_TYPE_RESERVED 3
191 /* Define common services */
192 #define GENERIC_SC_LIST \
193 { SC_GET_ATT_ALL, "Get Attribute All" }, \
194 { SC_SET_ATT_ALL, "Set Attribute All" }, \
195 { SC_GET_ATT_LIST, "Get Attribute List" }, \
196 { SC_SET_ATT_LIST, "Set Attribute List" }, \
197 { SC_RESET, "Reset" }, \
198 { SC_START, "Start" }, \
199 { SC_STOP, "Stop" }, \
200 { SC_CREATE, "Create" }, \
201 { SC_DELETE, "Delete" }, \
202 { SC_MULT_SERV_PACK, "Multiple Service Packet" }, \
203 { SC_APPLY_ATTRIBUTES, "Apply Attributes" }, \
204 { SC_GET_ATT_SINGLE, "Get Attribute Single" }, \
205 { SC_SET_ATT_SINGLE, "Set Attribute Single" }, \
206 { SC_FIND_NEXT_OBJ_INST, "Find Next Object Instance" }, \
207 { SC_RESTOR, "Restore" }, \
208 { SC_SAVE, "Save" }, \
209 { SC_NO_OP, "Nop" }, \
210 { SC_GET_MEMBER, "Get Member" }, \
211 { SC_SET_MEMBER, "Set Member" }, \
212 { SC_INSERT_MEMBER, "Insert Member" }, \
213 { SC_REMOVE_MEMBER, "Remove Member" }, \
214 { SC_GROUP_SYNC, "Group Sync" }, \
216 typedef struct cip_simple_request_info {
217 guint32 iClass;
218 guint32 iInstance;
219 guint32 iAttribute;
220 guint32 iMember;
221 } cip_simple_request_info_t;
223 enum cip_datatype {
224 cip_bool,
225 cip_sint,
226 cip_int,
227 cip_dint,
228 cip_lint,
229 cip_usint,
230 cip_usint_array,
231 cip_uint,
232 cip_uint_array,
233 cip_udint,
234 cip_ulint,
235 cip_real,
236 cip_lreal,
237 cip_itime,
238 cip_time,
239 cip_ftime,
240 cip_ltime,
241 cip_short_string,
242 cip_string,
243 cip_byte,
244 cip_byte_array,
245 cip_word,
246 cip_dword,
247 cip_lword,
248 cip_date,
249 cip_time_of_day,
250 cip_date_and_time,
251 cip_dissector_func,
253 /* Currently not supported */
254 cip_string2,
255 cip_stringN,
256 cip_stringi
259 typedef int attribute_dissector_func(packet_info *pinfo, proto_tree *tree, proto_item *item, tvbuff_t *tvb,
260 int offset, int total_len);
262 typedef struct attribute_info {
263 guint class_id;
264 gboolean class_instance;
265 guint attribute;
266 const char *text;
267 enum cip_datatype datatype;
268 int* phf;
269 attribute_dissector_func* pdissect;
270 } attribute_info_t;
272 typedef struct cip_connID_info {
273 guint32 connID;
274 address ipaddress;
275 guint16 port;
276 guint8 type;
277 } cip_connID_info_t;
279 enum cip_safety_format_type {CIP_SAFETY_BASE_FORMAT, CIP_SAFETY_EXTENDED_FORMAT};
281 typedef struct cip_safety_epath_info {
282 gboolean safety_seg;
283 enum cip_safety_format_type format;
284 } cip_safety_epath_info_t;
286 typedef struct cip_conn_info {
287 guint16 ConnSerialNumber;
288 guint16 VendorID;
289 guint32 DeviceSerialNumber;
290 cip_connID_info_t O2T;
291 cip_connID_info_t T2O;
292 guint8 TransportClass_trigger;
293 cip_safety_epath_info_t safety;
294 gboolean motion;
295 } cip_conn_info_t;
297 typedef struct cip_req_info {
298 dissector_handle_t dissector;
299 guint8 bService;
300 guint IOILen;
301 void *pIOI;
302 void *pData;
303 cip_simple_request_info_t* ciaData;
304 cip_conn_info_t* connInfo;
305 gboolean isUnconnectedSend;
306 } cip_req_info_t;
309 ** Exported functions
311 extern void dissect_epath( tvbuff_t *tvb, packet_info *pinfo, proto_item *epath_item, int offset, int path_length,
312 gboolean generate, gboolean packed, cip_simple_request_info_t* req_data, cip_safety_epath_info_t* safety);
313 extern void dissect_cip_date_and_time(proto_tree *tree, tvbuff_t *tvb, int offset, int hf_datetime);
316 ** Exported variables
318 extern dissector_table_t subdissector_class_table;
319 extern const value_string cip_sc_rr[];
320 extern const value_string cip_reset_type_vals[];
321 extern value_string_ext cip_gs_vals_ext;
322 extern value_string_ext cip_cm_ext_st_vals_ext;
323 extern value_string_ext cip_vendor_vals_ext;
324 extern value_string_ext cip_devtype_vals_ext;
325 extern value_string_ext cip_class_names_vals_ext;
328 * Editor modelines
330 * Local Variables:
331 * c-basic-offset: 3
332 * tab-width: 8
333 * indent-tabs-mode: nil
334 * End:
336 * ex: set shiftwidth=3 tabstop=8 expandtab:
337 * :indentSize=3:tabSize=8:noTabs=true: