2 * Routines for Common Industrial Protocol (CIP) dissection
3 * CIP Home: www.odva.org
6 * Magnus Hansson <mah@hms.se>
7 * Joakim Wiberg <jow@hms.se>
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
40 #include <epan/packet.h>
41 #include <epan/emem.h>
43 #include "packet-tcp.h"
44 #include "packet-cip.h"
46 #define ENIP_CIP_INTERFACE 0
48 /* Initialize the protocol and registered fields */
49 static int proto_cip = -1;
51 static int hf_cip_sc = -1;
52 static int hf_cip_rr = -1;
53 static int hf_cip_epath = -1;
54 static int hf_cip_genstat = -1;
56 static int hf_cip_fwo_comp = -1;
57 static int hf_cip_fwo_mrev = -1;
58 static int hf_cip_fwo_con_size = -1;
59 static int hf_cip_fwo_fixed_var = -1;
60 static int hf_cip_fwo_prio = -1;
61 static int hf_cip_fwo_typ = -1;
62 static int hf_cip_fwo_own = -1;
63 static int hf_cip_fwo_dir = -1;
64 static int hf_cip_fwo_trigg = -1;
65 static int hf_cip_fwo_class = -1;
67 static int hf_cip_vendor = -1;
68 static int hf_cip_devtype = -1;
69 static int hf_cip_port = -1;
70 static int hf_cip_link_address_byte = -1;
71 static int hf_cip_link_address_string = -1;
72 static int hf_cip_class8 = -1;
73 static int hf_cip_class16 = -1;
74 static int hf_cip_class32 = -1;
75 static int hf_cip_instance8 = -1;
76 static int hf_cip_instance16 = -1;
77 static int hf_cip_instance32 = -1;
78 static int hf_cip_attribute8 = -1;
79 static int hf_cip_attribute16 = -1;
80 static int hf_cip_attribute32 = -1;
81 static int hf_cip_conpoint8 = -1;
82 static int hf_cip_conpoint16 = -1;
83 static int hf_cip_conpoint32 = -1;
84 static int hf_cip_symbol = -1;
86 /* Initialize the subtree pointers */
87 static gint ett_cip = -1;
88 static gint ett_ekey_path = -1;
89 static gint ett_cia_path = -1;
90 static gint ett_data_seg = -1;
91 static gint ett_rrsc = -1;
92 static gint ett_mcsc = -1;
93 static gint ett_ncp = -1;
94 static gint ett_lsrcf = -1;
95 static gint ett_mes_req = -1;
96 static gint ett_cmd_data = -1;
97 static gint ett_port_path = -1;
98 static gint ett_mult_ser = -1;
99 static gint ett_path = -1;
100 static gint ett_status_item = -1;
103 /* Translate function to string - CIP Service codes */
104 static const value_string cip_sc_vals[] = {
105 { SC_GET_ATT_ALL, "Get Attribute All" },
106 { SC_SET_ATT_ALL, "Set Attribute All" },
107 { SC_GET_ATT_LIST, "Get Attribute List" },
108 { SC_SET_ATT_LIST, "Set Attribute List" },
109 { SC_RESET, "Reset" },
110 { SC_START, "Start" },
112 { SC_CREATE, "Create" },
113 { SC_DELETE, "Delete" },
114 { SC_APPLY_ATTRIBUTES, "Apply Attributes" },
115 { SC_GET_ATT_SINGLE, "Get Attribute Single" },
116 { SC_SET_ATT_SINGLE, "Set Attribute Single" },
117 { SC_FIND_NEXT_OBJ_INST, "Find Next Object Instance" },
118 { SC_RESTOR, "Restore" },
121 { SC_GET_MEMBER, "Get Member" },
122 { SC_SET_MEMBER, "Set Member" },
123 { SC_MULT_SERV_PACK, "Multiple Service Packet" },
125 /* Some class specific services */
126 { SC_FWD_CLOSE, "Forward Close" },
127 { SC_FWD_OPEN, "Forward Open" },
128 { SC_UNCON_SEND, "Unconnected Send" },
133 /* Translate function to string - CIP Request/Response */
134 static const value_string cip_sc_rr[] = {
141 /* Translate function to string - Compatibility */
142 static const value_string cip_com_bit_vals[] = {
143 { 0, "Bit Cleared" },
149 /* Translate function to string - Connection priority */
150 static const value_string cip_con_prio_vals[] = {
151 { 0, "Low Priority" },
152 { 1, "High Priority" },
159 /* Translate function to string - Connection size fixed or variable */
160 static const value_string cip_con_fw_vals[] = {
167 /* Translate function to string - Connection owner */
168 static const value_string cip_con_owner_vals[] = {
175 /* Translate function to string - Connection direction */
176 static const value_string cip_con_dir_vals[] = {
183 /* Translate function to string - Production trigger */
184 static const value_string cip_con_trigg_vals[] = {
186 { 1, "Change-Of-State" },
187 { 2, "Application Object" },
192 /* Translate function to string - Transport class */
193 static const value_string cip_con_class_vals[] = {
202 /* Translate function to string - Connection type */
203 static const value_string cip_con_type_vals[] = {
206 { 2, "Point to Point" },
212 /* Translate function to string - Timeout Multiplier */
213 static const value_string cip_con_time_mult_vals[] = {
226 /* Translate function to string - CIP General Status codes */
227 static const value_string cip_gs_vals[] = {
228 { CI_GRC_SUCCESS, "Success" },
229 { CI_GRC_FAILURE, "Connection failure" },
230 { CI_GRC_NO_RESOURCE, "Resource unavailable" },
231 { CI_GRC_BAD_DATA, "Invalid parameter value" },
232 { CI_GRC_BAD_PATH, "Path segment error" },
233 { CI_GRC_BAD_CLASS_INSTANCE, "Path destination unknown" },
234 { CI_GRC_PARTIAL_DATA, "Partial transfer" },
235 { CI_GRC_CONN_LOST, "Connection lost" },
236 { CI_GRC_BAD_SERVICE, "Service not supported" },
237 { CI_GRC_BAD_ATTR_DATA, "Invalid attribute value" },
238 { CI_GRC_ATTR_LIST_ERROR, "Attribute list error" },
239 { CI_GRC_ALREADY_IN_MODE, "Already in requested mode/state" },
240 { CI_GRC_BAD_OBJ_MODE, "Object state conflict" },
241 { CI_GRC_OBJ_ALREADY_EXISTS, "Object already exists" },
242 { CI_GRC_ATTR_NOT_SETTABLE, "Attribute not settable" },
243 { CI_GRC_PERMISSION_DENIED, "Privilege violation" },
244 { CI_GRC_DEV_IN_WRONG_STATE, "Device state conflict" },
245 { CI_GRC_REPLY_DATA_TOO_LARGE,"Reply data too large" },
246 { CI_GRC_FRAGMENT_PRIMITIVE, "Fragmentation of a primitive value" },
247 { CI_GRC_CONFIG_TOO_SMALL, "Not enough data" },
248 { CI_GRC_UNDEFINED_ATTR, "Attribute not supported" },
249 { CI_GRC_CONFIG_TOO_BIG, "Too much data" },
250 { CI_GRC_OBJ_DOES_NOT_EXIST, "Object does not exist" },
251 { CI_GRC_NO_FRAGMENTATION, "Service fragmentation sequence not in progress" },
252 { CI_GRC_DATA_NOT_SAVED, "No stored attribute data" },
253 { CI_GRC_DATA_WRITE_FAILURE, "Store operation failure" },
254 { CI_GRC_REQUEST_TOO_LARGE, "Routing failure, request packet too large" },
255 { CI_GRC_RESPONSE_TOO_LARGE, "Routing failure, response packet too large" },
256 { CI_GRC_MISSING_LIST_DATA, "Missing attribute list entry data" },
257 { CI_GRC_INVALID_LIST_STATUS, "Invalid attribute value list" },
258 { CI_GRC_SERVICE_ERROR, "Embedded service error" },
259 { CI_GRC_CONN_RELATED_FAILURE,"Vendor specific error" },
260 { CI_GRC_INVALID_PARAMETER, "Invalid parameter" },
261 { CI_GRC_WRITE_ONCE_FAILURE, "Write-once value or medium already written" },
262 { CI_GRC_INVALID_REPLY, "Invalid Reply Received" },
263 { CI_GRC_BAD_KEY_IN_PATH, "Key Failure in path" },
264 { CI_GRC_BAD_PATH_SIZE, "Path Size Invalid" },
265 { CI_GRC_UNEXPECTED_ATTR, "Unexpected attribute in list" },
266 { CI_GRC_INVALID_MEMBER, "Invalid Member ID" },
267 { CI_GRC_MEMBER_NOT_SETTABLE, "Member not settable" },
272 /* Translate Vendor ID:s */
273 const value_string cip_vendor_vals[] = {
279 /* Translate Device Profile:s */
280 const value_string cip_devtype_vals[] = {
281 { DP_GEN_DEV, "Generic Device" },
282 { DP_AC_DRIVE, "AC Drive" },
283 { DP_MOTOR_OVERLOAD, "Motor Overload" },
284 { DP_LIMIT_SWITCH, "Limit Switch" },
285 { DP_IND_PROX_SWITCH, "Inductive Proximity Switch" },
286 { DP_PHOTO_SENSOR, "Photoelectric Sensor" },
287 { DP_GENP_DISC_IO, "General Purpose Dicrete I/O" },
288 { DP_RESOLVER, "Resolver" },
289 { DP_COM_ADAPTER, "Communications Adapter" },
290 { DP_POS_CNT, "Position Controller", },
291 { DP_DC_DRIVE, "DC Drive" },
292 { DP_CONTACTOR, "Contactor", },
293 { DP_MOTOR_STARTER, "Motor Starter", },
294 { DP_SOFT_START, "Soft Start", },
295 { DP_HMI, "Human-Machine Interface" },
296 { DP_MASS_FLOW_CNT, "Mass Flow Controller" },
297 { DP_PNEUM_VALVE, "Pneumatic Valve" },
298 { DP_VACUUM_PRES_GAUGE, "Vaccuum Pressure Gauge" },
303 /* Translate class names */
304 static const value_string cip_class_names_vals[] = {
305 { 0x01, "Identity Object" },
306 { 0x02, "Message Router" },
307 { 0x03, "DeviceNet Object" },
308 { 0x04, "Assembly Object" },
309 { 0x05, "Connection Object" },
310 { 0x06, "Connection Manager" },
311 { 0x07, "Register Object" },
312 { 0x08, "Discrete Input Point Object" },
313 { 0x09, "Discrete Output Point Object" },
314 { 0x0A, "Analog Input Point Object" },
315 { 0x0B, "Analog Output Point Object" },
316 { 0x0E, "Presence Sensing Object" },
317 { 0x0F, "Parameter Object" },
318 { 0x10, "Parameter Group Object" },
319 { 0x12, "Group Object" },
320 { 0x1D, "Discrete Input Group Object" },
321 { 0x1E, "Discrete Output Group Object" },
322 { 0x1F, "Discrete Group Object" },
323 { 0x20, "Analog Input Group Object" },
324 { 0x21, "Analog Output Group Object" },
325 { 0x22, "Analog Group Object" },
326 { 0x23, "Position Sensor Object" },
327 { 0x24, "Position Controller Supervisor Object" },
328 { 0x25, "Position Controller Object" },
329 { 0x26, "Block Sequencer Object" },
330 { 0x27, "Command Block Object" },
331 { 0x28, "Motor Data Object" },
332 { 0x29, "Control Supervisor Object" },
333 { 0x2A, "AC/DC Drive Object" },
334 { 0x2B, "Acknowledge Handler Object" },
335 { 0x2C, "Overload Object" },
336 { 0x2D, "Softstart Object" },
337 { 0x2E, "Selection Object" },
338 { 0x30, "S-Device Supervisor Object" },
339 { 0x31, "S-Analog Sensor Object" },
340 { 0x32, "S-Analog Actuator Object" },
341 { 0x33, "S-Single Stage Controller Object" },
342 { 0x34, "S-Gas Calibration Object" },
343 { 0x35, "Trip Point Object" },
344 { 0x37, "File Object" },
345 { 0x38, "S-Partial Pressure Object" },
346 { 0xF0, "ControlNet Object" },
347 { 0xF1, "ControlNet Keeper Object" },
348 { 0xF2, "ControlNet Scheduling Object" },
349 { 0xF3, "Connection Configuration Object" },
350 { 0xF4, "Port Object" },
351 { 0xF5, "TCP/IP Interface Object" },
352 { 0xF6, "EtherNet Link Object" },
359 add_byte_array_text_to_proto_tree( proto_tree *tree, tvbuff_t *tvb, gint start, gint length, const char* str )
362 char *tmp2, *tmp2start;
364 int i,tmp_length,tmp2_length;
366 /* At least one version of Apple's C compiler/linker is buggy, causing
367 a complaint from the linker about the "literal C string section"
368 not ending with '\0' if we initialize a 16-element "char" array with
369 a 16-character string, the fact that initializing such an array with
370 such a string is perfectly legitimate ANSI C nonwithstanding, the 17th
371 '\0' byte in the string nonwithstanding. */
372 static const char my_hex_digits[16] =
373 { '0', '1', '2', '3', '4', '5', '6', '7',
374 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
377 if( ( length * 2 ) > 32 )
385 tmp2_length = ( length * 2 ) + 1;
388 tmp = tvb_get_ptr( tvb, start, tmp_length );
389 tmp2 = (char*)ep_alloc( tmp2_length );
393 for( i = 0; i < tmp_length; i++ )
397 *tmp2++ = my_hex_digits[octet&0xF];
399 *tmp2++ = my_hex_digits[octet&0xF];
402 if( tmp_length != length )
411 pi = proto_tree_add_text( tree, tvb, start, length, "%s%s", str, tmp2start );
415 } /* end of add_byte_array_text_to_proto_tree() */
420 dissect_epath( tvbuff_t *tvb, proto_item *epath_item, int offset, int path_length )
422 int pathpos, temp_data, temp_data2, seg_size, i, temp_word;
423 unsigned char segment_type, opt_link_size;
424 proto_tree *path_tree, *port_tree, *net_tree;
425 proto_item *qi, *cia_item, *ds_item;
426 proto_tree *e_key_tree, *cia_tree, *ds_tree;
427 proto_item *mcpi, *port_item, *net_item;
430 /* Create a sub tree for the epath */
431 path_tree = proto_item_add_subtree( epath_item, ett_path );
433 proto_tree_add_item_hidden(path_tree, hf_cip_epath,
434 tvb, offset, path_length, TRUE );
438 while( pathpos < path_length )
440 /* Get segement type */
441 segment_type = tvb_get_guint8( tvb, offset + pathpos );
443 /* Determine the segment type */
445 switch( segment_type & CI_SEGMENT_TYPE_MASK )
447 case CI_PORT_SEGMENT:
449 port_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 0, "Port Segment" );
450 port_tree = proto_item_add_subtree( port_item, ett_port_path );
452 /* Add port number */
453 proto_tree_add_item( port_tree, hf_cip_port, tvb, offset + pathpos, 1, TRUE );
454 proto_item_append_text( epath_item, "Port: %d", ( segment_type & 0x0F ) );
455 proto_item_append_text( port_item, ": Port: %d", ( segment_type & 0x0F ) );
457 if( segment_type & 0x10 )
459 /* Add Extended Link Address flag */
460 proto_tree_add_text( port_tree, tvb, offset+pathpos, 1, "Extended Link Address: TRUE" );
462 /* Add size of extended link address */
463 opt_link_size = tvb_get_guint8( tvb, offset + pathpos + 1 );
464 proto_tree_add_text( port_tree, tvb, offset+pathpos+1, 1, "Link Address Size: %d", opt_link_size );
466 /* Add extended link address */
467 proto_tree_add_item( port_tree, hf_cip_link_address_string, tvb, offset+pathpos+2, opt_link_size, FALSE );
468 proto_item_append_text( epath_item, ", Address: %s", tvb_format_text(tvb, offset+pathpos+2, opt_link_size) );
469 proto_item_append_text( port_item, ", Address: %s", tvb_format_text(tvb, offset+pathpos+2, opt_link_size) );
472 if( opt_link_size % 2 )
474 proto_item_set_len( port_item, 3 + opt_link_size );
475 pathpos = pathpos + 3 + opt_link_size;
479 proto_item_set_len( port_item, 2 + opt_link_size );
480 pathpos = pathpos + 2 + opt_link_size;
485 /* Add Extended Link Address flag */
486 proto_tree_add_text( port_tree, tvb, offset+pathpos, 1, "Extended Link Address: FALSE" );
488 /* Add Link Address */
489 proto_tree_add_item( port_tree, hf_cip_link_address_byte, tvb, offset+pathpos+1, 1, FALSE );
490 proto_item_append_text( epath_item, ", Address: %d",tvb_get_guint8( tvb, offset + pathpos + 1 ) );
491 proto_item_append_text( port_item, ", Address: %d",tvb_get_guint8( tvb, offset + pathpos + 1 ) );
493 proto_item_set_len( port_item, 2 );
499 case CI_LOGICAL_SEGMENT:
501 /* Logical segment, determin the logical type */
503 switch( segment_type & CI_LOGICAL_SEG_TYPE_MASK )
505 case CI_LOGICAL_SEG_CLASS_ID:
507 /* Logical Class ID, do a format check */
509 if( ( segment_type & CI_LOGICAL_SEG_FORMAT_MASK ) == CI_LOGICAL_SEG_8_BIT )
511 temp_data = tvb_get_guint8( tvb, offset + pathpos + 1 );
512 cia_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 2, "8-Bit Logical Class Segment (0x%02X)", segment_type );
514 /* Create a sub tree for the class */
515 cia_tree = proto_item_add_subtree( cia_item, ett_cia_path );
517 /* Display the 8-bit class number */
518 proto_tree_add_item( cia_tree, hf_cip_class8, tvb, offset + pathpos + 1, 1, TRUE );
519 proto_item_append_text( epath_item, "%s", val_to_str( temp_data, cip_class_names_vals , "Class: 0x%02X" ) );
521 /* 2 bytes of path used */
524 else if( ( segment_type & CI_LOGICAL_SEG_FORMAT_MASK ) == CI_LOGICAL_SEG_16_BIT )
526 temp_data = tvb_get_letohs( tvb, offset + pathpos + 2 );
527 cia_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 4, "16-Bit Logical Class Segment (0x%02X)", segment_type );
529 /* Create a sub tree for the class */
530 cia_tree = proto_item_add_subtree( cia_item, ett_cia_path );
532 /* Display the 16-bit class number */
533 proto_tree_add_item( cia_tree, hf_cip_class16, tvb, offset + pathpos + 2, 2, TRUE );
534 proto_item_append_text( epath_item, "%s", val_to_str( temp_data, cip_class_names_vals , "Class: 0x%04X" ) );
536 /* 4 bytes of path used */
539 else if( ( segment_type & CI_LOGICAL_SEG_FORMAT_MASK ) == CI_LOGICAL_SEG_32_BIT )
541 temp_data = tvb_get_letohl( tvb, offset + pathpos + 2 );
542 cia_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 6, "32-Bit Logical Instance Segment (0x%02X)", segment_type );
544 /* Create a sub tree for the class */
545 cia_tree = proto_item_add_subtree( cia_item, ett_cia_path );
547 /* Display the 32-bit class number */
548 proto_tree_add_item( cia_tree, hf_cip_class32, tvb, offset + pathpos + 2, 4, TRUE );
549 proto_item_append_text( epath_item, "%s", val_to_str( temp_data, cip_class_names_vals , "Class: 0x%08X" ) );
551 /* 6 bytes of path used */
556 /* Unsupported logical segment format */
557 proto_tree_add_text( path_tree, tvb, 0, 0, "Unsupported Logical Segment Format" );
563 case CI_LOGICAL_SEG_INST_ID:
565 /* Logical Instance ID, do a format check */
567 if( ( segment_type & CI_LOGICAL_SEG_FORMAT_MASK ) == CI_LOGICAL_SEG_8_BIT )
569 temp_data = tvb_get_guint8( tvb, offset + pathpos + 1 );
570 cia_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 2, "8-Bit Logical Instance Segment (0x%02X)", segment_type );
572 /* Create a sub tree for the instance */
573 cia_tree = proto_item_add_subtree( cia_item, ett_cia_path );
575 /* Display the 8-bit instance number */
576 proto_tree_add_item( cia_tree, hf_cip_instance8, tvb, offset + pathpos + 1, 1, TRUE );
577 proto_item_append_text( epath_item, "Instance: 0x%02X", temp_data );
579 /* 2 bytes of path used */
582 else if( ( segment_type & CI_LOGICAL_SEG_FORMAT_MASK ) == CI_LOGICAL_SEG_16_BIT )
584 temp_data = tvb_get_letohs( tvb, offset + pathpos + 2 );
585 cia_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 4, "16-Bit Logical Instance Segment (0x%02X)", segment_type );
587 /* Create a sub tree for the instance */
588 cia_tree = proto_item_add_subtree( cia_item, ett_cia_path );
590 /* Display the 16-bit instance number */
591 proto_tree_add_item( cia_tree, hf_cip_instance16, tvb, offset + pathpos + 2, 2, TRUE );
592 proto_item_append_text( epath_item, "Instance: 0x%04X", temp_data );
594 /* 4 bytes of path used */
597 else if( ( segment_type & CI_LOGICAL_SEG_FORMAT_MASK ) == CI_LOGICAL_SEG_32_BIT )
599 temp_data = tvb_get_letohl( tvb, offset + pathpos + 2 );
600 cia_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 6, "32-Bit Logical Instance Segment (0x%02X)", segment_type );
602 /* Create a sub tree for the instance */
603 cia_tree = proto_item_add_subtree( cia_item, ett_cia_path );
605 /* Display the 32-bit instance number */
606 proto_tree_add_item( cia_tree, hf_cip_instance32, tvb, offset + pathpos + 2, 4, TRUE );
607 proto_item_append_text( epath_item, "Instance: 0x%08X", temp_data );
610 /* 6 bytes of path used */
615 /* Unsupported logical segment format */
616 proto_tree_add_text( path_tree, tvb, 0, 0, "Unsupported Logical Segment Format" );
622 case CI_LOGICAL_SEG_ATTR_ID:
624 /* Logical Attribute ID, do a format check */
626 if( ( segment_type & CI_LOGICAL_SEG_FORMAT_MASK ) == CI_LOGICAL_SEG_8_BIT )
628 temp_data = tvb_get_guint8( tvb, offset + pathpos + 1 );
629 cia_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 2, "8-Bit Logical Attribute Segment (0x%02X)", segment_type );
631 /* Create a sub tree for the attribute */
632 cia_tree = proto_item_add_subtree( cia_item, ett_cia_path );
634 /* Display the 8-bit attribute number */
635 proto_tree_add_item( cia_tree, hf_cip_attribute8, tvb, offset + pathpos + 1, 1, TRUE );
636 proto_item_append_text( epath_item, "Attribute: 0x%02X", temp_data );
638 /* 2 bytes of path used */
641 else if( ( segment_type & CI_LOGICAL_SEG_FORMAT_MASK ) == CI_LOGICAL_SEG_16_BIT )
643 temp_data = tvb_get_letohs( tvb, offset + pathpos + 2 );
644 cia_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 4, "16-Bit Logical Attribute Segment (0x%02X)", segment_type );
646 /* Create a sub tree for the attribute */
647 cia_tree = proto_item_add_subtree( cia_item, ett_cia_path );
649 /* Display the 16-bit attribute number */
650 proto_tree_add_item( cia_tree, hf_cip_attribute16, tvb, offset + pathpos + 2, 2, TRUE );
651 proto_item_append_text( epath_item, "Attribute: 0x%04X", temp_data );
653 /* 4 bytes of path used */
656 else if( ( segment_type & CI_LOGICAL_SEG_FORMAT_MASK ) == CI_LOGICAL_SEG_32_BIT )
658 temp_data = tvb_get_letohl( tvb, offset + pathpos + 2 );
659 cia_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 6, "32-Bit Logical Attribute Segment (0x%02X)", segment_type );
661 /* Create a sub tree for the attribute */
662 cia_tree = proto_item_add_subtree( cia_item, ett_cia_path );
664 /* Display the 32-bit attribute number */
665 proto_tree_add_item( cia_tree, hf_cip_attribute32, tvb, offset + pathpos + 2, 4, TRUE );
666 proto_item_append_text( epath_item, "Attribute: 0x%08X", temp_data );
668 /* 6 bytes of path used */
673 /* Unsupported logical segment format */
674 proto_tree_add_text( path_tree, tvb, 0, 0, "Unsupported Logical Segment Format" );
680 case CI_LOGICAL_SEG_CON_POINT:
682 /* Logical Connection point , do a format check */
684 if( ( segment_type & CI_LOGICAL_SEG_FORMAT_MASK ) == CI_LOGICAL_SEG_8_BIT )
686 temp_data = tvb_get_guint8( tvb, offset + pathpos + 1 );
687 cia_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 2, "8-Bit Logical Connection Point Segment (0x%02X)", segment_type );
689 /* Create a sub tree for the connection point */
690 cia_tree = proto_item_add_subtree( cia_item, ett_cia_path );
692 /* Display the 8-bit connection point number */
693 proto_tree_add_item( cia_tree, hf_cip_conpoint8, tvb, offset + pathpos + 1, 1, TRUE );
694 proto_item_append_text( epath_item, "Connection Point: 0x%02X", temp_data );
696 /* 2 bytes of path used */
699 else if( ( segment_type & CI_LOGICAL_SEG_FORMAT_MASK ) == CI_LOGICAL_SEG_16_BIT )
701 temp_data = tvb_get_letohs( tvb, offset + pathpos + 2 );
702 cia_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 4, "16-Bit Logical Connection Point Segment (0x%02X)", segment_type );
704 /* Create a sub tree for the connection point */
705 cia_tree = proto_item_add_subtree( cia_item, ett_cia_path );
707 /* Display the 16-bit connection point number */
708 proto_tree_add_item( cia_tree, hf_cip_conpoint16, tvb, offset + pathpos + 2, 2, TRUE );
709 proto_item_append_text( epath_item, "Connection Point: 0x%04X", temp_data );
711 /* 4 bytes of path used */
714 else if( ( segment_type & CI_LOGICAL_SEG_FORMAT_MASK ) == CI_LOGICAL_SEG_32_BIT )
716 temp_data = tvb_get_letohl( tvb, offset + pathpos + 2 );
717 cia_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 6, "32-Bit Logical Connection Point Segment (0x%02X)", segment_type );
719 /* Create a sub tree for the connection point */
720 cia_tree = proto_item_add_subtree( cia_item, ett_cia_path );
722 /* Display the 32-bit connection point number */
723 proto_tree_add_item( cia_tree, hf_cip_conpoint32, tvb, offset + pathpos + 2, 4, TRUE );
724 proto_item_append_text( epath_item, "Connection Point: 0x%08X", temp_data );
726 /* 6 bytes of path used */
731 /* Unsupported logical segment format */
732 proto_tree_add_text( path_tree, tvb, 0, 0, "Unsupported Logical Segment Format" );
738 case CI_LOGICAL_SEG_SPECIAL:
740 /* Logical Special ID, the only logical format sepcifyed is electronic key */
742 if( ( segment_type & CI_LOGICAL_SEG_FORMAT_MASK ) == CI_LOGICAL_SEG_E_KEY )
744 /* Get the Key Format */
745 temp_data = tvb_get_guint8( tvb, offset + pathpos + 1 );
747 if( temp_data == CI_E_KEY_FORMAT_VAL )
749 qi = proto_tree_add_text( path_tree, tvb, offset + pathpos, 10, "Electronic Key Segment (0x%02X): ",segment_type );
751 /* Create a sub tree for the IOI */
752 e_key_tree = proto_item_add_subtree( qi, ett_ekey_path );
754 /* Print the key type */
755 proto_tree_add_text( e_key_tree, tvb, offset + pathpos + 1, 1, "Key Format: 0x%02X", temp_data );
757 /* Get the Vendor ID */
758 temp_data = tvb_get_letohs( tvb, offset + pathpos + 2 );
759 proto_tree_add_item( e_key_tree, hf_cip_vendor, tvb, offset + pathpos + 2, 2, TRUE);
760 proto_item_append_text( qi, "VendorID: 0x%04X", temp_data );
762 /* Get Device Type */
763 temp_data = tvb_get_letohs( tvb, offset + pathpos + 4 );
764 proto_tree_add_item( e_key_tree, hf_cip_devtype, tvb, offset + pathpos + 4, 2, TRUE);
765 proto_item_append_text( qi, ", DevTyp: 0x%04X", temp_data );
768 temp_data = tvb_get_letohs( tvb, offset + pathpos + 6 );
769 proto_tree_add_text( e_key_tree, tvb, offset + pathpos + 6, 2, "Product Code: 0x%04X", temp_data );
771 /* Major revision/Compatibility */
772 temp_data = tvb_get_guint8( tvb, offset + pathpos + 8 );
774 /* Add Major revision/Compatibility tree */
775 mcpi = proto_tree_add_text(e_key_tree, tvb, offset + pathpos + 8, 1, "Compatibility ");
776 mc_tree = proto_item_add_subtree(mcpi, ett_mcsc);
778 /* Add Compatibility bit info */
779 proto_tree_add_item(mc_tree, hf_cip_fwo_comp,
780 tvb, offset + pathpos + 8, 1, TRUE );
782 proto_item_append_text( mcpi, "%s, Major Revision: %d",
783 val_to_str( ( temp_data & 0x80 )>>7, cip_com_bit_vals , "" ),
787 proto_tree_add_item(mc_tree, hf_cip_fwo_mrev,
788 tvb, offset + pathpos + 8, 1, TRUE );
791 temp_data2 = tvb_get_guint8( tvb, offset + pathpos + 9 );
792 proto_tree_add_text( e_key_tree, tvb, offset + pathpos + 9, 1, "Minor Revision: %d", temp_data2 );
794 proto_item_append_text( qi, ", %d.%d", ( temp_data & 0x7F ), temp_data2 );
796 proto_item_append_text(epath_item, "[Key]" );
798 /* Increment the path pointer */
803 /* Unsupported electronic key format */
804 proto_tree_add_text( path_tree, tvb, 0, 0, "Unsupported Electronic Key Format" );
810 /* Unsupported special segment format */
811 proto_tree_add_text( path_tree, tvb, 0, 0, "Unsupported Special Segment Format" );
818 /* Unsupported logical segment type */
819 proto_tree_add_text( path_tree, tvb, 0, 0, "Unsupported Logical Segment Type" );
822 } /* end of switch( segment_type & CI_LOGICAL_SEG_TYPE_MASK ) */
826 case CI_DATA_SEGMENT:
828 /* Data segment, determin the logical type */
830 switch( segment_type )
832 case CI_DATA_SEG_SIMPLE:
834 /* Simple data segment */
835 ds_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 1, "Simple Data Segment (0x%02X)", segment_type );
837 /* Create a sub tree */
838 ds_tree = proto_item_add_subtree( ds_item, ett_data_seg );
841 seg_size = tvb_get_guint8( tvb, offset + pathpos+1 )*2;
842 proto_tree_add_text( ds_tree, tvb, offset + pathpos+1, 1, "Data Size: %d (words)", seg_size/2 );
847 qi = proto_tree_add_text( ds_tree, tvb, offset + pathpos+2, 0, "Data: " );
849 for( i=0; i < seg_size/2; i ++ )
851 temp_word = tvb_get_letohs( tvb, offset + pathpos+2+(i*2) );
852 proto_item_append_text(qi, " 0x%04X", temp_word );
855 proto_item_set_len(qi, seg_size);
858 proto_item_set_len( ds_item, 2 + seg_size );
859 pathpos = pathpos + 2 + seg_size;
861 proto_item_append_text(epath_item, "[Data]" );
865 case CI_DATA_SEG_SYMBOL:
867 /* ANSI extended symbol segment */
868 ds_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 1, "Extended Symbol Segment (0x%02X)", segment_type );
870 /* Create a sub tree */
871 ds_tree = proto_item_add_subtree( ds_item, ett_data_seg );
874 seg_size = tvb_get_guint8( tvb, offset + pathpos+1 );
875 proto_tree_add_text( ds_tree, tvb, offset + pathpos+1, 1, "Data Size: %d", seg_size );
880 qi = proto_tree_add_text( ds_tree, tvb, offset + pathpos + 2, seg_size, "Data: %s",
881 tvb_format_text(tvb, offset + pathpos + 2, seg_size ) );
883 proto_item_append_text(epath_item, "%s", tvb_format_text(tvb, offset + pathpos + 2, seg_size ) );
884 proto_tree_add_item_hidden( ds_tree, hf_cip_symbol, tvb, offset + pathpos + 2, seg_size, FALSE );
888 /* We have a PAD BYTE */
889 proto_tree_add_text( ds_tree, tvb, offset + pathpos + 2 + seg_size, 1, "Pad Byte (0x%02X)",
890 tvb_get_guint8( tvb, offset + pathpos + 2 + seg_size ) );
896 proto_item_set_len( ds_item, 2 + seg_size );
897 pathpos = pathpos + 2 + seg_size;
902 proto_tree_add_text( path_tree, tvb, 0, 0, "Unsupported Sub-Segment Type" );
905 } /* End of switch sub-type */
909 case CI_NETWORK_SEGMENT:
911 /* Network segment -Determine the segment sub-type */
913 switch( segment_type & CI_NETWORK_SEG_TYPE_MASK )
915 case CI_NETWORK_SEG_SCHEDULE:
916 net_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 2, "Network Segment - Schedule" );
917 net_tree = proto_item_add_subtree( net_item, ett_port_path );
919 proto_tree_add_text( net_tree, tvb, offset + pathpos + 1, 1, "Multiplier/Phase: %02X", tvb_get_guint8( tvb, offset + pathpos + 1 ) );
921 /* 2 bytes of path used */
925 case CI_NETWORK_SEG_FIXED_TAG:
926 net_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 2, "Network Segment - Fixed Tag" );
927 net_tree = proto_item_add_subtree( net_item, ett_port_path );
929 proto_tree_add_text( net_tree, tvb, offset + pathpos + 1, 1, "Fixed Tag: %02X", tvb_get_guint8( tvb, offset + pathpos + 1 ) );
931 /* 2 bytes of path used */
935 case CI_NETWORK_SEG_PROD_INHI:
936 net_item = proto_tree_add_text( path_tree, tvb, offset + pathpos, 2, "Network Segment - Production Inhibit" );
937 net_tree = proto_item_add_subtree( net_item, ett_port_path );
939 proto_tree_add_text( net_tree, tvb, offset + pathpos + 1, 1, "Production Inhibit Time: %dms", tvb_get_guint8( tvb, offset + pathpos + 1 ) );
941 /* 2 bytes of path used */
946 proto_tree_add_text( path_tree, tvb, 0, 0, "Unsupported Sub-Segment Type" );
949 } /* End of switch sub-type */
955 /* Unsupported segment type */
956 proto_tree_add_text( path_tree, tvb, 0, 0, "Unsupported Segment Type" );
959 } /* end of switch( segment_type & CI_SEGMENT_TYPE_MASK ) */
961 /* Next path segment */
962 if( pathpos < path_length )
963 proto_item_append_text( epath_item, ", " );
965 } /* end of while( pathpos < path_length ) */
967 } /* end of dissect_epath() */
971 dissect_cip_data( proto_tree *item_tree, tvbuff_t *tvb, int offset, int item_length, packet_info *pinfo )
973 proto_item *pi, *rrsc_item, *ncppi, *ar_item, *temp_item, *temp_item2, *status_item;
974 proto_tree *temp_tree, *rrsc_tree, *ncp_tree, *cmd_data_tree, *status_tree;
975 int req_path_size, conn_path_size, temp_data;
976 unsigned char gen_status;
977 unsigned char add_stat_size;
978 unsigned char temp_byte, route_path_size;
979 unsigned char app_rep_size, i;
980 int msg_req_siz, num_services, serv_offset;
983 /* Add Service code & Request/Response tree */
984 rrsc_item = proto_tree_add_text( item_tree, tvb, offset, 1, "Service: " );
985 rrsc_tree = proto_item_add_subtree( rrsc_item, ett_rrsc );
987 /* Add Request/Response */
988 proto_tree_add_item( rrsc_tree, hf_cip_rr, tvb, offset, 1, TRUE );
990 proto_item_append_text( rrsc_item, "%s (%s)",
991 val_to_str( ( tvb_get_guint8( tvb, offset ) & 0x7F ),
992 cip_sc_vals , "Unknown Service (%x)"),
993 val_to_str( ( tvb_get_guint8( tvb, offset ) & 0x80 )>>7,
996 /* Add Service code */
997 proto_tree_add_item(rrsc_tree, hf_cip_sc, tvb, offset, 1, TRUE );
999 if( tvb_get_guint8( tvb, offset ) & 0x80 )
1001 /* Response message */
1002 status_item = proto_tree_add_text( item_tree, tvb, offset+2, 1, "Status: " );
1003 status_tree = proto_item_add_subtree( status_item, ett_status_item );
1005 /* Add general status */
1006 gen_status = tvb_get_guint8( tvb, offset+2 );
1007 proto_tree_add_item(status_tree, hf_cip_genstat, tvb, offset+2, 1, TRUE );
1008 proto_item_append_text( status_item, "%s", val_to_str( ( tvb_get_guint8( tvb, offset+2 ) ),
1009 cip_gs_vals , "Unknown Response (%x)") );
1011 /* Add reply status to info column */
1012 if(check_col(pinfo->cinfo, COL_INFO))
1014 col_append_fstr( pinfo->cinfo, COL_INFO, "%s",
1015 val_to_str( ( tvb_get_guint8( tvb, offset+2 ) ),
1016 cip_gs_vals , "Unknown Response (%x)") );
1019 /* Add additional status size */
1020 proto_tree_add_text( status_tree, tvb, offset+3, 1, "Additional Status Size: %d (word)",
1021 tvb_get_guint8( tvb, offset+3 ) );
1023 add_stat_size = tvb_get_guint8( tvb, offset+3 ) * 2;
1027 proto_item_append_text( status_item, ", Extended:" );
1029 /* Add additional status */
1030 pi = proto_tree_add_text( status_tree, tvb, offset+4, add_stat_size, "Additional Status:" );
1032 for( i=0; i < add_stat_size/2; i ++ )
1034 proto_item_append_text( pi, " 0x%04X", tvb_get_letohs( tvb, offset+4+(i*2) ) );
1035 proto_item_append_text( status_item, " 0x%04X", tvb_get_letohs( tvb, offset+4+(i*2) ) );
1039 proto_item_set_len( status_item, 2 + add_stat_size );
1041 /* If there is any command specific data create a sub-tree for it */
1042 if( ( item_length-4-add_stat_size ) != 0 )
1044 pi = proto_tree_add_text( item_tree, tvb, offset+4+add_stat_size, item_length-4-add_stat_size, "Command Specific data" );
1045 cmd_data_tree = proto_item_add_subtree( pi, ett_cmd_data );
1047 if( gen_status == CI_GRC_SUCCESS )
1049 /* Success responses */
1051 if( ( tvb_get_guint8( tvb, offset ) & 0x7F ) == SC_FWD_OPEN )
1053 /* Forward open Response (Success) */
1055 /* Display originator to target connection ID */
1056 temp_data = tvb_get_letohl( tvb, offset+4+add_stat_size );
1057 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size, 4, "O->T Network Connection ID: 0x%08X", temp_data );
1059 /* Display target to originator connection ID */
1060 temp_data = tvb_get_letohl( tvb, offset+4+add_stat_size+4 );
1061 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+4, 4, "T->O Network Connection ID: 0x%08X", temp_data );
1063 /* Display connection serial number */
1064 temp_data = tvb_get_letohs( tvb, offset+4+add_stat_size+8 );
1065 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+8, 2, "Connection Serial Number: 0x%04X", temp_data );
1067 /* Display the originator vendor id */
1068 proto_tree_add_item( cmd_data_tree, hf_cip_vendor, tvb, offset+4+add_stat_size+10, 2, TRUE);
1070 /* Display the originator serial number */
1071 temp_data = tvb_get_letohl( tvb, offset+4+add_stat_size+12 );
1072 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+12, 4, "Originator Serial Number: 0x%08X", temp_data );
1074 /* Display originator to target actual packet interval */
1075 temp_data = tvb_get_letohl( tvb, offset+4+add_stat_size+16 );
1076 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+16, 4, "O->T API: %dms (0x%08X)", temp_data / 1000, temp_data );
1078 /* Display originator to target actual packet interval */
1079 temp_data = tvb_get_letohl( tvb, offset+4+add_stat_size+20 );
1080 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+20, 4, "T->O API: %dms (0x%08X)", temp_data / 1000, temp_data );
1082 /* Display the application reply size */
1083 app_rep_size = tvb_get_guint8( tvb, offset+4+add_stat_size+24 ) * 2;
1084 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+24, 1, "Application Reply Size: %d (words)", app_rep_size / 2 );
1086 /* Display the Reserved byte */
1087 temp_byte = tvb_get_guint8( tvb, offset+4+add_stat_size+25 );
1088 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+25, 1, "Reserved: 0x%02X", temp_byte );
1090 if( app_rep_size != 0 )
1092 /* Display application Reply data */
1093 ar_item = proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+26, app_rep_size, "Application Reply:" );
1095 for( i=0; i < app_rep_size; i++ )
1097 temp_byte = tvb_get_guint8( tvb, offset+4+add_stat_size+26+i );
1098 proto_item_append_text(ar_item, " 0x%02X", temp_byte );
1101 } /* End of if reply data */
1103 } /* End of if forward open response */
1104 else if( ( tvb_get_guint8( tvb, offset ) & 0x7F ) == SC_FWD_CLOSE )
1106 /* Forward close response (Success) */
1108 /* Display connection serial number */
1109 temp_data = tvb_get_letohs( tvb, offset+4+add_stat_size );
1110 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size, 2, "Connection Serial Number: 0x%04X", temp_data );
1112 /* Display the originator vendor id */
1113 proto_tree_add_item( cmd_data_tree, hf_cip_vendor, tvb, offset+4+add_stat_size+2, 2, TRUE);
1115 /* Display the originator serial number */
1116 temp_data = tvb_get_letohl( tvb, offset+4+add_stat_size+4 );
1117 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+4, 4, "Originator Serial Number: 0x%08X", temp_data );
1119 /* Display the application reply size */
1120 app_rep_size = tvb_get_guint8( tvb, offset+4+add_stat_size+8 ) * 2;
1121 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+8, 1, "Application Reply Size: %d (words)", app_rep_size / 2 );
1123 /* Display the Reserved byte */
1124 temp_byte = tvb_get_guint8( tvb, offset+4+add_stat_size+9 );
1125 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+9, 1, "Reserved: 0x%02X", temp_byte );
1127 if( app_rep_size != 0 )
1129 /* Display application Reply data */
1130 ar_item = proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+10, app_rep_size, "Application Reply:" );
1132 for( i=0; i < app_rep_size; i ++ )
1134 temp_byte = tvb_get_guint8( tvb, offset+4+add_stat_size+10+i );
1135 proto_item_append_text(ar_item, " 0x%02X", temp_byte );
1138 } /* End of if reply data */
1140 } /* End of if forward close response */
1141 else if( ( tvb_get_guint8( tvb, offset ) & 0x7F ) == SC_UNCON_SEND )
1143 /* Unconnected send response (Success) */
1145 /* Display service response data */
1146 add_byte_array_text_to_proto_tree( cmd_data_tree, tvb, offset+4+add_stat_size, item_length-4-add_stat_size, "Data: " );
1148 else if( ( tvb_get_guint8( tvb, offset ) & 0x7F ) == SC_MULT_SERV_PACK )
1150 /* Multiple Service Reply (Success)*/
1152 /* Add number of replies */
1153 num_services = tvb_get_letohs( tvb, offset+4+add_stat_size );
1154 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size, 2, "Number of Replies: %d", num_services );
1157 temp_item = proto_tree_add_text( cmd_data_tree, tvb, offset+2+add_stat_size+4, num_services*2, "Offsets: " );
1159 for( i=0; i < num_services; i++ )
1163 serv_offset = tvb_get_letohs( tvb, offset+6+add_stat_size+(i*2) );
1165 if( i == (num_services-1) )
1167 /* Last service to add */
1168 proto_item_append_text(temp_item, "%d", serv_offset );
1169 serv_length = item_length-add_stat_size-serv_offset-4;
1173 proto_item_append_text(temp_item, "%d, ", serv_offset );
1174 serv_length = tvb_get_letohs( tvb, offset+6+add_stat_size+((i+1)*2) ) - serv_offset;
1177 temp_item2 = proto_tree_add_text( cmd_data_tree, tvb, offset+serv_offset+4, serv_length, "Service Reply #%d", i+1 );
1178 temp_tree = proto_item_add_subtree( temp_item2, ett_mult_ser );
1181 ** We call our selves again to disect embedded packet
1184 if(check_col(pinfo->cinfo, COL_INFO))
1185 col_append_fstr( pinfo->cinfo, COL_INFO, ", ");
1187 dissect_cip_data( temp_tree, tvb, offset+serv_offset+4, serv_length, pinfo );
1189 } /* End if Multiple service Packet */
1190 else if( ( tvb_get_guint8( tvb, offset ) & 0x7F ) == SC_GET_ATT_LIST )
1192 /* Get Attribute List Reply (Success)*/
1196 /* Add Attribute Count */
1197 att_count = tvb_get_letohs( tvb, offset+4+add_stat_size );
1198 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size, 2, "Attribute Count: %d", att_count );
1201 add_byte_array_text_to_proto_tree( cmd_data_tree, tvb, offset+6+add_stat_size, item_length-6-add_stat_size, "Data: " );
1203 } /* End if Multiple service Packet */
1207 add_byte_array_text_to_proto_tree( cmd_data_tree, tvb, offset+4+add_stat_size, item_length-4-add_stat_size, "Data: " );
1208 } /* end of check service code */
1213 /* Error responses */
1215 if( ( ( tvb_get_guint8( tvb, offset ) & 0x7F ) == SC_FWD_OPEN ) ||
1216 ( ( tvb_get_guint8( tvb, offset ) & 0x7F ) == SC_FWD_CLOSE ) )
1218 /* Forward open and forward close error response look the same */
1220 /* Display connection serial number */
1221 temp_data = tvb_get_letohs( tvb, offset+4+add_stat_size );
1222 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size, 2, "Connection Serial Number: 0x%04X", temp_data );
1224 /* Display the originator vendor id */
1225 proto_tree_add_item( cmd_data_tree, hf_cip_vendor, tvb, offset+4+add_stat_size+2, 2, TRUE);
1227 /* Display the originator serial number */
1228 temp_data = tvb_get_letohl( tvb, offset+4+add_stat_size+4 );
1229 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+4, 4, "Originator Serial Number: 0x%08X", temp_data );
1231 /* Display remaining path size */
1232 temp_data = tvb_get_guint8( tvb, offset+4+add_stat_size+8 );
1233 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+8, 1, "Remaining Path Size: %d", temp_data );
1235 /* Display reserved data */
1236 temp_data = tvb_get_guint8( tvb, offset+4+add_stat_size+9 );
1237 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size+9, 1, "Reserved: 0x%02X", temp_data );
1239 else if( ( tvb_get_guint8( tvb, offset ) & 0x7F ) == SC_UNCON_SEND )
1241 /* Unconnected send response (Unsuccess) */
1243 /* Display remaining path size */
1244 temp_data = tvb_get_guint8( tvb, offset+4+add_stat_size);
1245 proto_tree_add_text( cmd_data_tree, tvb, offset+4+add_stat_size, 1, "Remaining Path Size: %d", temp_data );
1250 add_byte_array_text_to_proto_tree( cmd_data_tree, tvb, offset+4+add_stat_size, item_length-4-add_stat_size, "Data: " );
1253 } /* end of if-else( CI_CRC_SUCCESS ) */
1255 } /* End of if command-specific data present */
1257 } /* End of if reply */
1260 /* Request message */
1262 /* Add service to info column */
1263 if(check_col(pinfo->cinfo, COL_INFO))
1265 col_append_fstr( pinfo->cinfo, COL_INFO, "%s",
1266 val_to_str( ( tvb_get_guint8( tvb, offset ) & 0x7F ),
1267 cip_sc_vals , "Unknown Service (%x)") );
1270 /* Add path size to tree */
1271 req_path_size = tvb_get_guint8( tvb, offset+1 )*2;
1272 proto_tree_add_text( item_tree, tvb, offset+1, 1, "Request Path Size: %d (words)", req_path_size/2 );
1275 pi = proto_tree_add_text(item_tree, tvb, offset+2, req_path_size, "Request Path: ");
1276 dissect_epath( tvb, pi, offset+2, req_path_size );
1278 /* If there is any command specific data creat a sub-tree for it */
1279 if( (item_length-req_path_size-2) != 0 )
1282 pi = proto_tree_add_text( item_tree, tvb, offset+2+req_path_size, item_length-req_path_size-2, "Command Specific Data" );
1283 cmd_data_tree = proto_item_add_subtree( pi, ett_cmd_data );
1285 /* Check what service code that recived */
1287 if( tvb_get_guint8( tvb, offset ) == SC_FWD_OPEN )
1289 /* Forward open Request*/
1291 /* Display the priority/tick timer */
1292 temp_byte = tvb_get_guint8( tvb, offset+2+req_path_size );
1293 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size, 1, "Priority/Time_tick: 0x%02X", temp_byte );
1295 /* Display the time-out ticks */
1296 temp_data = tvb_get_guint8( tvb, offset+2+req_path_size+1 );
1297 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+1, 1, "Time-out_ticks: %d", temp_data );
1299 /* Display the actual time out */
1300 temp_data = ( 1 << ( temp_byte & 0x0F ) ) * temp_data;
1301 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size, 2, "Actual Time Out: %dms", temp_data );
1303 /* Display originator to taget connection ID */
1304 temp_data = tvb_get_letohl( tvb, offset+2+req_path_size+2 );
1305 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+2, 4, "O->T Network Connection ID: 0x%08X", temp_data );
1307 /* Display target to originator connection ID */
1308 temp_data = tvb_get_letohl( tvb, offset+2+req_path_size+6 );
1309 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+6, 4, "T->O Network Connection ID: 0x%08X", temp_data );
1311 /* Display connection serial number */
1312 temp_data = tvb_get_letohs( tvb, offset+2+req_path_size+10 );
1313 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+10, 2, "Connection Serial Number: 0x%04X", temp_data );
1315 /* Display the originator vendor id */
1316 proto_tree_add_item( cmd_data_tree, hf_cip_vendor, tvb, offset+2+req_path_size+12, 2, TRUE);
1318 /* Display the originator serial number */
1319 temp_data = tvb_get_letohl( tvb, offset+2+req_path_size+14 );
1320 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+14, 4, "Originator Serial Number: 0x%08X", temp_data );
1322 /* Display the timeout multiplier */
1323 temp_data = tvb_get_guint8( tvb, offset+2+req_path_size+18 );
1324 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+18, 1, "Connection Timeout Multiplier: %s (%d)", val_to_str( temp_data, cip_con_time_mult_vals , "Reserved" ), temp_data );
1326 /* Put out an indicator for the reserved bytes */
1327 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+19, 3, "Reserved Data" );
1329 /* Display originator to target requested packet interval */
1330 temp_data = tvb_get_letohl( tvb, offset+2+req_path_size+22 );
1331 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+22, 4, "O->T RPI: %dms (0x%08X)", temp_data / 1000, temp_data );
1333 /* Display originator to target network connection patameterts, in a tree */
1334 temp_data = tvb_get_letohs( tvb, offset+2+req_path_size+26 );
1335 ncppi = proto_tree_add_text(cmd_data_tree, tvb, offset+2+req_path_size+26, 2, "O->T Network Connection Parameters: 0x%04X", temp_data );
1336 ncp_tree = proto_item_add_subtree(ncppi, ett_ncp);
1338 /* Add the data to the tree */
1339 proto_tree_add_item(ncp_tree, hf_cip_fwo_own,
1340 tvb, offset+2+req_path_size+26, 2, TRUE );
1341 proto_tree_add_item(ncp_tree, hf_cip_fwo_typ,
1342 tvb, offset+2+req_path_size+26, 2, TRUE );
1343 proto_tree_add_item(ncp_tree, hf_cip_fwo_prio,
1344 tvb, offset+2+req_path_size+26, 2, TRUE );
1345 proto_tree_add_item(ncp_tree, hf_cip_fwo_fixed_var,
1346 tvb, offset+2+req_path_size+26, 2, TRUE );
1347 proto_tree_add_item(ncp_tree, hf_cip_fwo_con_size,
1348 tvb, offset+2+req_path_size+26, 2, TRUE );
1350 /* Display target to originator requested packet interval */
1351 temp_data = tvb_get_letohl( tvb, offset+2+req_path_size+28 );
1352 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+28, 4, "T->O RPI: %dms (0x%08X)", temp_data / 1000, temp_data );
1354 /* Display target to originator network connection patameterts, in a tree */
1355 temp_data = tvb_get_letohs( tvb, offset+2+req_path_size+32 );
1356 ncppi = proto_tree_add_text(cmd_data_tree, tvb, offset+2+req_path_size+32, 2, "T->O Network Connection Parameters: 0x%04X", temp_data );
1357 ncp_tree = proto_item_add_subtree(ncppi, ett_ncp);
1359 /* Add the data to the tree */
1360 proto_tree_add_item(ncp_tree, hf_cip_fwo_own,
1361 tvb, offset+2+req_path_size+32, 2, TRUE );
1362 proto_tree_add_item(ncp_tree, hf_cip_fwo_typ,
1363 tvb, offset+2+req_path_size+32, 2, TRUE );
1364 proto_tree_add_item(ncp_tree, hf_cip_fwo_prio,
1365 tvb, offset+2+req_path_size+32, 2, TRUE );
1366 proto_tree_add_item(ncp_tree, hf_cip_fwo_fixed_var,
1367 tvb, offset+2+req_path_size+32, 2, TRUE );
1368 proto_tree_add_item(ncp_tree, hf_cip_fwo_con_size,
1369 tvb, offset+2+req_path_size+32, 2, TRUE );
1371 /* Transport type/trigger in tree*/
1372 temp_data = tvb_get_guint8( tvb, offset+2+req_path_size+34 );
1374 ncppi = proto_tree_add_text(cmd_data_tree, tvb, offset+2+req_path_size+34, 1, "Transport Type/Trigger: 0x%02X", temp_data );
1375 ncp_tree = proto_item_add_subtree(ncppi, ett_ncp);
1377 /* Add the data to the tree */
1378 proto_tree_add_item(ncp_tree, hf_cip_fwo_dir,
1379 tvb, offset+2+req_path_size+34, 1, TRUE );
1381 proto_tree_add_item(ncp_tree, hf_cip_fwo_trigg,
1382 tvb, offset+2+req_path_size+34, 1, TRUE );
1384 proto_tree_add_item(ncp_tree, hf_cip_fwo_class,
1385 tvb, offset+2+req_path_size+34, 1, TRUE );
1388 conn_path_size = tvb_get_guint8( tvb, offset+2+req_path_size+35 )*2;
1389 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+35, 1, "Connection Path Size: %d (words)", conn_path_size / 2 );
1392 pi = proto_tree_add_text(cmd_data_tree, tvb, offset+2+req_path_size+36, conn_path_size, "Connection Path: ");
1393 dissect_epath( tvb, pi, offset+2+req_path_size+36, conn_path_size );
1395 else if( tvb_get_guint8( tvb, offset ) == SC_FWD_CLOSE )
1397 /* Forward Close Request */
1399 /* Display the priority/tick timer */
1400 temp_byte = tvb_get_guint8( tvb, offset+2+req_path_size );
1401 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size, 1, "Priority/Time_tick: 0x%02X", temp_byte );
1403 /* Display the time-out ticks */
1404 temp_data = tvb_get_guint8( tvb, offset+2+req_path_size+1 );
1405 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+1, 1, "Time-out_ticks: %d", temp_data );
1407 /* Display the actual time out */
1408 temp_data = ( 1 << ( temp_byte & 0x0F ) ) * temp_data;
1409 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size, 2, "Actual Time Out: %dms", temp_data );
1411 /* Display connection serial number */
1412 temp_data = tvb_get_letohs( tvb, offset+2+req_path_size+2 );
1413 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+2, 2, "Connection Serial Number: 0x%04X", temp_data );
1415 /* Display the originator vendor id */
1416 proto_tree_add_item( cmd_data_tree, hf_cip_vendor, tvb, offset+2+req_path_size+4, 2, TRUE);
1418 /* Display the originator serial number */
1419 temp_data = tvb_get_letohl( tvb, offset+2+req_path_size+6 );
1420 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+6, 4, "Originator Serial Number: 0x%08X", temp_data );
1422 /* Add the path size */
1423 conn_path_size = tvb_get_guint8( tvb, offset+2+req_path_size+10 )*2;
1424 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+10, 1, "Connection Path Size: %d (words)", conn_path_size / 2 );
1426 /* Add the reserved byte */
1427 temp_byte = tvb_get_guint8( tvb, offset+2+req_path_size+11 );
1428 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+11, 1, "Reserved: 0x%02X", temp_byte );
1431 pi = proto_tree_add_text(cmd_data_tree, tvb, offset+2+req_path_size+12, conn_path_size, "Connection Path: ");
1432 dissect_epath( tvb, pi, offset+2+req_path_size+12, conn_path_size );
1434 } /* End of forward close */
1435 else if( tvb_get_guint8( tvb, offset ) == SC_UNCON_SEND )
1437 /* Unconnected send */
1439 /* Display the priority/tick timer */
1440 temp_byte = tvb_get_guint8( tvb, offset+2+req_path_size );
1441 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size, 1, "Priority/Time_tick: 0x%02X", temp_byte );
1443 /* Display the time-out ticks */
1444 temp_data = tvb_get_guint8( tvb, offset+2+req_path_size+1 );
1445 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+1, 1, "Time-out_ticks: %d", temp_data );
1447 /* Display the actual time out */
1448 temp_data = ( 1 << ( temp_byte & 0x0F ) ) * temp_data;
1449 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size, 2, "Actual Time Out: %dms", temp_data );
1451 /* Message request size */
1452 msg_req_siz = tvb_get_letohs( tvb, offset+2+req_path_size+2 );
1453 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+2, 2, "Message Request Size: 0x%04X", msg_req_siz );
1455 /* Message Request */
1456 temp_item = proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+4, msg_req_siz, "Message Request" );
1457 temp_tree = proto_item_add_subtree(temp_item, ett_mes_req );
1460 ** We call our selves again to disect embedded packet
1463 if(check_col(pinfo->cinfo, COL_INFO))
1464 col_append_fstr( pinfo->cinfo, COL_INFO, ": ");
1466 dissect_cip_data( temp_tree, tvb, offset+2+req_path_size+4, msg_req_siz, pinfo );
1468 if( msg_req_siz % 2 )
1471 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+4+msg_req_siz, 1, "Pad Byte (0x%02X)",
1472 tvb_get_guint8( tvb, offset+2+req_path_size+4+msg_req_siz ) );
1473 msg_req_siz++; /* include the padding */
1476 /* Route Path Size */
1477 route_path_size = tvb_get_guint8( tvb, offset+2+req_path_size+4+msg_req_siz )*2;
1478 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+4+msg_req_siz, 1, "Route Path Size: %d (words)", route_path_size/2 );
1481 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+5+msg_req_siz, 1, "Reserved (0x%02X)",
1482 tvb_get_guint8( tvb, offset+2+req_path_size+5+msg_req_siz ) );
1485 temp_item = proto_tree_add_text(cmd_data_tree, tvb, offset+2+req_path_size+6+msg_req_siz, route_path_size, "Route Path: ");
1486 dissect_epath( tvb, temp_item, offset+2+req_path_size+6+msg_req_siz, route_path_size );
1488 } /* End if unconnected send */
1489 else if( tvb_get_guint8( tvb, offset ) == SC_MULT_SERV_PACK )
1491 /* Multiple service packet */
1493 /* Add number of services */
1494 num_services = tvb_get_letohs( tvb, offset+2+req_path_size );
1495 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size, 2, "Number of Services: %d", num_services );
1498 temp_item = proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+2, num_services*2, "Offsets: " );
1500 for( i=0; i < num_services; i++ )
1504 serv_offset = tvb_get_letohs( tvb, offset+4+req_path_size+(i*2) );
1506 if( i == (num_services-1) )
1508 /* Last service to add */
1509 serv_length = item_length-2-req_path_size-serv_offset;
1510 proto_item_append_text(temp_item, "%d", serv_offset );
1514 serv_length = tvb_get_letohs( tvb, offset+4+req_path_size+((i+1)*2) ) - serv_offset;
1515 proto_item_append_text(temp_item, "%d, ", serv_offset );
1518 temp_item2 = proto_tree_add_text( cmd_data_tree, tvb, offset+serv_offset+6, serv_length, "Service Packet #%d", i+1 );
1519 temp_tree = proto_item_add_subtree( temp_item2, ett_mult_ser );
1522 ** We call our selves again to disect embedded packet
1525 if(check_col(pinfo->cinfo, COL_INFO))
1526 col_append_fstr( pinfo->cinfo, COL_INFO, ", ");
1528 dissect_cip_data( temp_tree, tvb, offset+serv_offset+6, serv_length, pinfo );
1530 } /* End if Multiple service Packet */
1531 else if( tvb_get_guint8( tvb, offset ) == SC_GET_ATT_LIST )
1533 /* Get attribute list request */
1537 /* Add number of services */
1538 att_count = tvb_get_letohs( tvb, offset+2+req_path_size );
1539 proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size, 2, "Attribute Count: %d", att_count );
1541 /* Add Attribute List */
1542 temp_item = proto_tree_add_text( cmd_data_tree, tvb, offset+2+req_path_size+2, att_count*2, "Attribute List: " );
1544 for( i=0; i < att_count; i++ )
1546 if( i == (att_count-1) )
1547 proto_item_append_text(temp_item, "%d",tvb_get_letohs( tvb, offset+4+req_path_size+(i*2) ) );
1549 proto_item_append_text(temp_item, "%d, ",tvb_get_letohs( tvb, offset+4+req_path_size+(i*2) ) );
1552 } /* End of Get attribute list request */
1556 add_byte_array_text_to_proto_tree( cmd_data_tree, tvb, offset+2+req_path_size, item_length-req_path_size-2, "Data: " );
1557 } /* End of check service code */
1559 } /* End of if command-specific data present */
1561 } /* End of if-else( request ) */
1563 } /* End of dissect_cip_data() */
1567 dissect_cip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1570 proto_tree *cip_tree;
1572 /* Make entries in Protocol column and Info column on summary display */
1573 if( check_col( pinfo->cinfo, COL_PROTOCOL ) )
1574 col_set_str( pinfo->cinfo, COL_PROTOCOL, "CIP" );
1576 if (check_col( pinfo->cinfo, COL_INFO ) )
1577 col_clear( pinfo->cinfo, COL_INFO );
1581 /* Create display subtree for the protocol */
1582 ti = proto_tree_add_item(tree, proto_cip, tvb, 0, -1, FALSE);
1583 cip_tree = proto_item_add_subtree( ti, ett_cip );
1585 dissect_cip_data( cip_tree, tvb, 0, tvb_length(tvb), pinfo );
1588 return tvb_length(tvb);
1593 proto_register_cip(void)
1595 /* Setup list of header fields */
1596 static hf_register_info hf[] = {
1599 { "Request/Response", "cip.rr",
1600 FT_UINT8, BASE_HEX, VALS(cip_sc_rr), 0x80,
1601 "Request or Response message", HFILL }
1604 { "Service", "cip.sc",
1605 FT_UINT8, BASE_HEX, VALS(cip_sc_vals), 0x7F,
1606 "Service Code", HFILL }
1609 { "EPath", "cip.epath",
1610 FT_BYTES, BASE_HEX, NULL, 0,
1614 { "General Status", "cip.genstat",
1615 FT_UINT8, BASE_HEX, VALS(cip_gs_vals), 0,
1616 "General Status", HFILL }
1619 { "Port", "cip.port",
1620 FT_UINT8, BASE_DEC, NULL, 0,
1621 "Port Identifier", HFILL }
1623 { &hf_cip_link_address_byte,
1624 { "Link Address", "cip.linkaddress",
1625 FT_UINT8, BASE_DEC, NULL, 0,
1626 "Link Address", HFILL }
1628 { &hf_cip_link_address_string,
1629 { "Link Address", "cip.linkaddress",
1630 FT_STRING, BASE_NONE, NULL, 0,
1631 "Link Address", HFILL }
1634 { "Class", "cip.class",
1635 FT_UINT8, BASE_HEX, VALS(cip_class_names_vals), 0,
1639 { "Class", "cip.class",
1640 FT_UINT16, BASE_HEX, VALS(cip_class_names_vals), 0,
1644 { "Class", "cip.class",
1645 FT_UINT32, BASE_HEX, VALS(cip_class_names_vals), 0,
1648 { &hf_cip_instance8,
1649 { "Instance", "cip.instance",
1650 FT_UINT8, BASE_HEX, NULL, 0,
1653 { &hf_cip_instance16,
1654 { "Instance", "cip.instance",
1655 FT_UINT16, BASE_HEX, NULL, 0,
1658 { &hf_cip_instance32,
1659 { "Instance", "cip.instance",
1660 FT_UINT32, BASE_HEX, NULL, 0,
1663 { &hf_cip_attribute8,
1664 { "Attribute", "cip.attribute",
1665 FT_UINT8, BASE_HEX, NULL, 0,
1666 "Attribute", HFILL }
1668 { &hf_cip_attribute16,
1669 { "Attribute", "cip.attribute",
1670 FT_UINT16, BASE_HEX, NULL, 0,
1671 "Attribute", HFILL }
1673 { &hf_cip_attribute32,
1674 { "Attribute", "cip.attribute",
1675 FT_UINT32, BASE_HEX, NULL, 0,
1676 "Attribute", HFILL }
1678 { &hf_cip_conpoint8,
1679 { "Connection Point", "cip.connpoint",
1680 FT_UINT8, BASE_HEX, NULL, 0,
1681 "Connection Point", HFILL }
1683 { &hf_cip_conpoint16,
1684 { "Connection Point", "cip.connpoint",
1685 FT_UINT16, BASE_HEX, NULL, 0,
1686 "Connection Point", HFILL }
1688 { &hf_cip_conpoint32,
1689 { "Connection Point", "cip.connpoint",
1690 FT_UINT16, BASE_HEX, NULL, 0,
1691 "Connection Point", HFILL }
1694 { "Symbol", "cip.symbol",
1695 FT_STRING, BASE_NONE, NULL, 0,
1696 "ANSI Extended Symbol Segment", HFILL }
1699 { "Vendor ID", "cip.vendor",
1700 FT_UINT16, BASE_HEX, VALS(cip_vendor_vals), 0,
1701 "Vendor ID", HFILL }
1704 { "Device Type", "cip.devtype",
1705 FT_UINT16, BASE_DEC, VALS(cip_devtype_vals), 0,
1706 "Device Type", HFILL }
1709 { "Compatibility", "cip.fwo.cmp",
1710 FT_UINT8, BASE_HEX, VALS(cip_com_bit_vals), 0x80,
1711 "Fwd Open: Compatibility bit", HFILL }
1714 { "Major Revision", "cip.fwo.major",
1715 FT_UINT8, BASE_DEC, NULL, 0x7F,
1716 "Fwd Open: Major Revision", HFILL }
1718 { &hf_cip_fwo_con_size,
1719 { "Connection Size", "cip.fwo.consize",
1720 FT_UINT16, BASE_DEC, NULL, 0x01FF,
1721 "Fwd Open: Connection size", HFILL }
1723 { &hf_cip_fwo_fixed_var,
1724 { "Connection Size Type", "cip.fwo.f_v",
1725 FT_UINT16, BASE_DEC, VALS(cip_con_fw_vals), 0x0200,
1726 "Fwd Open: Fixed or variable connection size", HFILL }
1729 { "Priority", "cip.fwo.prio",
1730 FT_UINT16, BASE_DEC, VALS(cip_con_prio_vals), 0x0C00,
1731 "Fwd Open: Connection priority", HFILL }
1734 { "Connection Type", "cip.fwo.type",
1735 FT_UINT16, BASE_DEC, VALS(cip_con_type_vals), 0x6000,
1736 "Fwd Open: Connection type", HFILL }
1739 { "Owner", "cip.fwo.owner",
1740 FT_UINT16, BASE_DEC, VALS(cip_con_owner_vals), 0x8000,
1741 "Fwd Open: Redundant owner bit", HFILL }
1744 { "Direction", "cip.fwo.dir",
1745 FT_UINT8, BASE_DEC, VALS(cip_con_dir_vals), 0x80,
1746 "Fwd Open: Direction", HFILL }
1748 { &hf_cip_fwo_trigg,
1749 { "Trigger", "cip.fwo.trigger",
1750 FT_UINT8, BASE_DEC, VALS(cip_con_trigg_vals), 0x70,
1751 "Fwd Open: Production trigger", HFILL }
1753 { &hf_cip_fwo_class,
1754 { "Class", "cip.fwo.transport",
1755 FT_UINT8, BASE_DEC, VALS(cip_con_class_vals), 0x0F,
1756 "Fwd Open: Transport Class", HFILL }
1760 /* Setup protocol subtree array */
1761 static gint *ett[] = {
1779 /* Register the protocol name and description */
1780 proto_cip = proto_register_protocol("Common Industrial Protocol",
1783 /* Required function calls to register the header fields and subtrees used */
1784 proto_register_field_array(proto_cip, hf, array_length(hf));
1785 proto_register_subtree_array(ett, array_length(ett));
1787 } /* end of proto_register_cip() */
1791 proto_reg_handoff_cip(void)
1793 dissector_handle_t cip_handle;
1795 /* Create dissector handles */
1796 cip_handle = new_create_dissector_handle( dissect_cip, proto_cip );
1798 /* Register for UCMM CIP data, using EtherNet/IP SendRRData service*/
1799 dissector_add( "enip.srrd.iface", ENIP_CIP_INTERFACE, cip_handle );
1801 /* Register for Connected CIP data, using EtherNet/IP SendUnitData service*/
1802 dissector_add( "enip.sud.iface", ENIP_CIP_INTERFACE, cip_handle );
1804 } /* end of proto_reg_handoff_cip() */