More Ethereal -> Wireshark renaming
[obnox/wireshark/wip.git] / plugins / profinet / packet-pn-dcp.c
1 /* packet-pn-dcp.c
2  * Routines for PN-DCP (PROFINET Discovery and basic Configuration Protocol) 
3  * packet dissection.
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1999 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30
31 #ifdef HAVE_SYS_TYPES_H
32 #include <sys/types.h>
33 #endif
34
35 #include <string.h>
36
37 #include <glib.h>
38 #include <epan/packet.h>
39 #include <epan/emem.h>
40 #include <epan/dissectors/packet-dcerpc.h>
41 #include <epan/expert.h>
42
43 static int proto_pn_dcp = -1;
44
45 static int hf_pn_dcp = -1;
46
47 static int hf_pn_dcp_service_id = -1;
48 static int hf_pn_dcp_service_type = -1;
49 static int hf_pn_dcp_xid = -1;
50 static int hf_pn_dcp_reserved8 = -1;
51 static int hf_pn_dcp_reserved16 = -1;
52 static int hf_pn_dcp_response_delay = -1;
53 static int hf_pn_dcp_data_length = -1;
54 static int hf_pn_dcp_block_length = -1;
55
56 static int hf_pn_dcp_block = -1;
57
58 static int hf_pn_dcp_result = -1;
59
60 static int hf_pn_dcp_option = -1;
61 static int hf_pn_dcp_suboption = -1;
62 static int hf_pn_dcp_req_status = -1;
63 static int hf_pn_dcp_res_status = -1;
64
65 static int hf_pn_dcp_suboption_ip = -1;
66 static int hf_pn_dcp_suboption_ip_status = -1;
67 static int hf_pn_dcp_suboption_ip_ip = -1;
68 static int hf_pn_dcp_suboption_ip_subnetmask = -1;
69 static int hf_pn_dcp_suboption_ip_default_router = -1;
70
71 static int hf_pn_dcp_suboption_device = -1;
72 static int hf_pn_dcp_suboption_device_typeofstation = -1;
73 static int hf_pn_dcp_suboption_device_nameofstation = -1;
74 static int hf_pn_dcp_suboption_vendor_id = -1;
75 static int hf_pn_dcp_suboption_device_id = -1;
76 static int hf_pn_dcp_suboption_device_role = -1;
77
78 static int hf_pn_dcp_suboption_dhcp = -1;
79 static int hf_pn_dcp_suboption_dhcp_device_id = -1;
80
81 static int hf_pn_dcp_suboption_lldp = -1;
82
83 static int hf_pn_dcp_suboption_control = -1;
84 static int hf_pn_dcp_suboption_control_status = -1;
85
86 static int hf_pn_dcp_suboption_all = -1;
87
88 static int hf_pn_dcp_suboption_manuf = -1;
89
90 static int hf_pn_dcp_data = -1;
91
92
93 static gint ett_pn_dcp = -1;
94 static gint ett_pn_dcp_block = -1;
95
96 #define FRAME_ID_UC         0xfefd
97 #define FRAME_ID_MC         0xfefe
98 #define FRAME_ID_MC_RESP    0xfeff
99
100
101 #define PNDCP_SERVICE_ID_GET        0x03
102 #define PNDCP_SERVICE_ID_SET        0x04
103 #define PNDCP_SERVICE_ID_IDENTIFY   0x05
104
105 static const value_string pn_dcp_service_id[] = {
106         { 0x00, "reserved" },
107         { 0x01, "Manufacturer specific" },
108         { 0x02, "Manufacturer specific" },
109         { PNDCP_SERVICE_ID_GET, "Get" },
110         { PNDCP_SERVICE_ID_SET, "Set" },
111         { PNDCP_SERVICE_ID_IDENTIFY, "Identify" },
112     /* 0x06 - 0xff reserved */
113     { 0, NULL }
114 };
115
116 #define PNDCP_SERVICE_TYPE_REQUEST              0
117 #define PNDCP_SERVICE_TYPE_RESPONSE_SUCCESS     1
118 #define PNDCP_SERVICE_TYPE_RESPONSE_UNSUPPORTED 5
119
120 static const value_string pn_dcp_service_type[] = {
121         { PNDCP_SERVICE_TYPE_REQUEST,               "Request" },
122         { PNDCP_SERVICE_TYPE_RESPONSE_SUCCESS,      "Response Success" },
123         { PNDCP_SERVICE_TYPE_RESPONSE_UNSUPPORTED,  "Response - Request not supported" },
124     /* all others reserved */
125     { 0, NULL }
126 };
127
128 static const value_string pn_dcp_result[] = {
129         { 0x00, "Ok" },
130         { 0x01, "Option unsupp." },
131         { 0x02, "Suboption unsupp." },
132         { 0x03, "Suboption not set" },
133         { 0x04, "Manufacturer specific" },
134         { 0x05, "Manufacturer specific" },
135         { 0x06, "Ressource Error" },
136     /* all others reserved */
137     { 0, NULL }
138 };
139
140 static const value_string pn_dcp_req_status[] = {
141         { 0x0000, "Don't save data permanent" },
142         { 0x0001, "Save data permanent" },
143     /*0x0002 - 0xffff reserved */
144     { 0, NULL }
145 };
146
147
148 #define PNDCP_OPTION_IP             0x01
149 #define PNDCP_OPTION_DEVICE         0x02
150 #define PNDCP_OPTION_DHCP           0x03
151 #define PNDCP_OPTION_LLDP           0x04
152 #define PNDCP_OPTION_CONTROL        0x05
153 #define PNDCP_OPTION_MANUF_X80      0x80
154 #define PNDCP_OPTION_MANUF_X81      0x81
155 #define PNDCP_OPTION_MANUF_X82      0x82
156 #define PNDCP_OPTION_MANUF_X83      0x83
157 #define PNDCP_OPTION_MANUF_X84      0x84
158 #define PNDCP_OPTION_MANUF_X85      0x85
159 #define PNDCP_OPTION_MANUF_X86      0x86
160 #define PNDCP_OPTION_ALLSELECTOR    0xff
161
162 static const value_string pn_dcp_option[] = {
163         { 0x00, "reserved" },
164         { PNDCP_OPTION_IP,          "IP" },
165         { PNDCP_OPTION_DEVICE,      "Device properties" },
166         { PNDCP_OPTION_DHCP,        "DHCP" },
167         { PNDCP_OPTION_LLDP,        "LLDP" },
168         { PNDCP_OPTION_CONTROL,     "Control" },
169     /*0x06 - 0x7f reserved */
170     /*0x80 - 0xfe manufacturer specific */
171         { PNDCP_OPTION_MANUF_X80,   "Manufacturer specific" },
172         { PNDCP_OPTION_MANUF_X81,   "Manufacturer specific" },
173         { PNDCP_OPTION_MANUF_X82,   "Manufacturer specific" },
174         { PNDCP_OPTION_MANUF_X83,   "Manufacturer specific" },
175         { PNDCP_OPTION_MANUF_X84,   "Manufacturer specific" },
176         { PNDCP_OPTION_MANUF_X85,   "Manufacturer specific" },
177         { PNDCP_OPTION_MANUF_X86,   "Manufacturer specific" },
178         { PNDCP_OPTION_ALLSELECTOR, "All Selector" },
179     { 0, NULL }
180 };
181
182 #define PNDCP_SUBOPTION_IP_MAC  0x01
183 #define PNDCP_SUBOPTION_IP_IP   0x02
184
185 static const value_string pn_dcp_suboption_ip[] = {
186         { 0x00, "Reserved" },
187         { PNDCP_SUBOPTION_IP_MAC,   "MAC address" },
188         { PNDCP_SUBOPTION_IP_IP,    "IP parameter" },
189     /*0x03 - 0xff reserved */
190     { 0, NULL }
191 };
192
193 static const value_string pn_dcp_suboption_ip_status[] = {
194         { 0x0000, "IP not set" },
195         { 0x0001, "IP set" },
196         { 0x0002, "IP set by DHCP" },
197     /*0x0003 - 0xffff reserved */
198     { 0, NULL }
199 };
200
201 #define PNDCP_SUBOPTION_DEVICE_MANUF            0x01
202 #define PNDCP_SUBOPTION_DEVICE_NAMEOFSTATION    0x02
203 #define PNDCP_SUBOPTION_DEVICE_DEV_ID           0x03
204 #define PNDCP_SUBOPTION_DEVICE_DEV_ROLE         0x04
205 #define PNDCP_SUBOPTION_DEVICE_DEV_OPTIONS      0x05
206
207 static const value_string pn_dcp_suboption_device[] = {
208         { 0x00, "Reserved" },
209         { PNDCP_SUBOPTION_DEVICE_MANUF,         "Manufacturer specific (Type of Station)" },
210         { PNDCP_SUBOPTION_DEVICE_NAMEOFSTATION, "Name of Station" },
211         { PNDCP_SUBOPTION_DEVICE_DEV_ID,        "Device ID" },
212         { PNDCP_SUBOPTION_DEVICE_DEV_ROLE,      "Device Role" },
213         { PNDCP_SUBOPTION_DEVICE_DEV_OPTIONS,   "Device Options" },
214     /*0x06 - 0xff reserved */
215     { 0, NULL }
216 };
217
218 #define PNDCP_SUBOPTION_DHCP_CLIENT_ID  61
219
220 static const value_string pn_dcp_suboption_dhcp[] = {
221     {  12, "Host name" },
222     {  43, "Vendor specific" },
223     {  54, "Server identifier" },
224     {  55, "Parameter request list" },
225     {  60, "Class identifier" },
226     {  PNDCP_SUBOPTION_DHCP_CLIENT_ID, "DHCP client identifier" },
227     {  81, "FQDN, Fully Qualified Domain Name" },
228     {  97, "UUID/GUID-based Client" },
229         { 255, "Control DHCP for address resolution" },
230     /*all others reserved */
231     { 0, NULL }
232 };
233
234 static const value_string pn_dcp_suboption_lldp[] = {
235     /* currently unknown */
236     { 0, NULL }
237 };
238
239 #define PNDCP_SUBOPTION_CONTROL_START_TRANS 0x01
240 #define PNDCP_SUBOPTION_CONTROL_END_TRANS   0x02
241 #define PNDCP_SUBOPTION_CONTROL_SIGNAL      0x03
242 #define PNDCP_SUBOPTION_CONTROL_RESPONSE    0x04
243
244 static const value_string pn_dcp_suboption_control[] = {
245         { 0x00, "Reserved" },
246         { PNDCP_SUBOPTION_CONTROL_START_TRANS, "Start Transaction" },
247         { PNDCP_SUBOPTION_CONTROL_END_TRANS, "End Transaction" },
248         { PNDCP_SUBOPTION_CONTROL_SIGNAL, "Signal" },
249         { PNDCP_SUBOPTION_CONTROL_RESPONSE, "Response" },
250     /*0x05 - 0xff reserved */
251     { 0, NULL }
252 };
253
254 static const value_string pn_dcp_suboption_all[] = {
255     { 0xff, "ALL Selector" },
256     /* all other reserved */
257     { 0, NULL }
258 };
259
260 static const value_string pn_dcp_suboption_manuf[] = {
261     /* none known */
262     { 0, NULL }
263 };
264
265
266
267 /* dissect an 8 bit unsigned integer */
268 static int
269 dissect_pn_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
270                   proto_tree *tree, int hfindex, guint8 *pdata)
271 {
272     guint8 data;
273
274     data = tvb_get_guint8 (tvb, offset);
275     if (tree) {
276         proto_tree_add_uint(tree, hfindex, tvb, offset, 1, data);
277     }
278     if (pdata)
279         *pdata = data;
280     return offset + 1;
281 }
282
283 /* dissect a 16 bit unsigned integer */
284 static int
285 dissect_pn_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
286                        proto_tree *tree, int hfindex, guint16 *pdata)
287 {
288     guint16 data;
289
290     data = tvb_get_ntohs (tvb, offset);
291
292     if (tree) {
293         proto_tree_add_uint(tree, hfindex, tvb, offset, 2, data);
294     }
295     if (pdata)
296         *pdata = data;
297     return offset + 2;
298 }
299
300 /* dissect a 32 bit unsigned integer */
301 static int
302 dissect_pn_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
303                        proto_tree *tree, int hfindex, guint32 *pdata)
304 {
305     guint32 data;
306
307     data = tvb_get_ntohl (tvb, offset);
308
309     if (tree) {
310         proto_tree_add_uint(tree, hfindex, tvb, offset, 4, data);
311     }
312     if (pdata)
313         *pdata = data;
314     return offset+4;
315 }
316
317 /* dissect an IPv4 address */
318 static int 
319 dissect_pn_ipv4(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
320                     proto_tree *tree, int hfindex, guint32 *pdata)
321 {
322     guint32 data;
323
324     data = tvb_get_ipv4(tvb, offset);
325     if(tree)
326         proto_tree_add_ipv4(tree, hfindex, tvb, offset, 4, data);
327
328     if (pdata)
329         *pdata = data;
330
331     return offset + 4;
332 }
333
334 /* dissect some padding data (with the given length) */
335 static int 
336 dissect_pn_padding(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
337                     proto_tree *tree, int length)
338 {
339     proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, length, "data", 
340         "Padding: %u byte", length);
341
342     return offset + length;
343 }
344
345 /* append the given info text */
346 static void
347 pn_append_info(packet_info *pinfo, proto_item *dcp_item, const char *text)
348 {
349     if (check_col(pinfo->cinfo, COL_INFO))
350         col_append_fstr(pinfo->cinfo, COL_INFO, text);
351
352     proto_item_append_text(dcp_item, "%s", text);
353 }
354
355
356 /* dissect the option field */
357 static int
358 dissect_PNDCP_Option(tvbuff_t *tvb, int offset, packet_info *pinfo, 
359                              proto_tree *tree, proto_item *block_item, int hfindex, gboolean append_col)
360 {
361     guint8 option;
362     guint8 suboption;
363     const value_string *val_str;
364
365     offset = dissect_pn_uint8 (tvb, offset, pinfo, tree, hfindex, &option);
366     switch(option) {
367     case(PNDCP_OPTION_IP):
368         offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip, &suboption);
369         val_str = pn_dcp_suboption_ip;
370         break;
371     case(PNDCP_OPTION_DEVICE):
372         offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_device, &suboption);
373         val_str = pn_dcp_suboption_device;
374         break;
375     case(PNDCP_OPTION_DHCP):
376         offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_dhcp, &suboption);
377         val_str = pn_dcp_suboption_dhcp;
378         break;
379     case(PNDCP_OPTION_LLDP):
380         offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_lldp, &suboption);
381         val_str = pn_dcp_suboption_lldp;
382         break;
383     case(PNDCP_OPTION_CONTROL):
384         offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_control, &suboption);
385         val_str = pn_dcp_suboption_control;
386         break;
387     case(PNDCP_OPTION_ALLSELECTOR):
388         offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_all, &suboption);
389         val_str = pn_dcp_suboption_all;
390         break;
391     default:
392         offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_manuf, &suboption);
393         val_str = pn_dcp_suboption_manuf;
394     }
395
396     proto_item_append_text(block_item, ", Status from %s - %s", 
397         val_to_str(option, pn_dcp_option, "Unknown"), val_to_str(suboption, val_str, "Unknown"));
398
399     if(append_col) {
400         if (check_col(pinfo->cinfo, COL_INFO))
401             col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", val_to_str(suboption, val_str, "Unknown"));
402     }
403
404     return offset;
405 }
406
407
408 /* dissect the "IP" suboption */
409 static int
410 dissect_PNDCP_Suboption_IP(tvbuff_t *tvb, int offset, packet_info *pinfo, 
411                             proto_tree *tree, proto_item *block_item, proto_item *dcp_item,
412                             gboolean is_response)
413 {
414     guint8 suboption;
415     guint16 block_length;
416     guint16 status;
417     guint16 req_status;
418     guint32 ip;
419     proto_item *item;
420
421     
422     offset = dissect_pn_uint8 (tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip, &suboption);
423     offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
424
425     switch(suboption) {
426     case(PNDCP_SUBOPTION_IP_MAC):
427         pn_append_info(pinfo, dcp_item, ", MAC");
428         proto_item_append_text(block_item, "IP/MAC");
429
430         /* XXX - improve this */
431         proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data", 
432             "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_IP, suboption, block_length);
433         offset += block_length;
434         break;
435     case(PNDCP_SUBOPTION_IP_IP):
436         pn_append_info(pinfo, dcp_item, ", IP");
437         proto_item_append_text(block_item, "IP/IP");
438
439         if(is_response) {
440             offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip_status, &status);
441             proto_item_append_text(block_item, ", Status: %s", val_to_str(status, pn_dcp_suboption_ip_status, "Unknown"));
442         } else {
443             offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_req_status, &req_status);
444             proto_item_append_text(block_item, ", Status: %s", val_to_str(req_status, pn_dcp_req_status, "Unknown"));
445         }
446
447         /* ip address */
448         offset = dissect_pn_ipv4(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip_ip, &ip);
449         proto_item_append_text(block_item, ", IP: %s", ip_to_str((guint8*)&ip));
450
451         /* subnetmask */
452         offset = dissect_pn_ipv4(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip_subnetmask, &ip);
453         proto_item_append_text(block_item, ", Subnet: %s", ip_to_str((guint8*)&ip));
454
455         /* default router */
456         offset = dissect_pn_ipv4(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip_default_router, &ip);
457         proto_item_append_text(block_item, ", Router: %s", ip_to_str((guint8*)&ip));
458         break;
459     default:
460         item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data", 
461             "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_IP, suboption, block_length);
462         expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
463                         "Undecoded suboption %u, %u bytes",
464                         suboption, block_length);
465         offset += block_length;
466     }
467
468     return offset;
469 }
470
471
472 /* dissect the "device" suboption */
473 static int
474 dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo, 
475                                proto_tree *tree, proto_item *block_item, proto_item *dcp_item, 
476                                gboolean is_response)
477 {
478     guint8 suboption;
479     guint16 block_length;
480     gchar *info_str;
481     guint8 device_role;
482     guint16 vendor_id;
483     guint16 device_id;
484     char *typeofstation;
485     char *nameofstation;
486     guint16 status=0;
487     proto_item *item;
488
489     offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_device, &suboption);
490     offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
491     if(is_response) {
492         offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_res_status, &status);
493         block_length -= 2;
494     }
495
496     switch(suboption) {
497     case(PNDCP_SUBOPTION_DEVICE_MANUF):
498         typeofstation = ep_alloc(block_length+1);
499         tvb_memcpy(tvb, (guint8 *) typeofstation, offset, block_length);
500         typeofstation[block_length] = '\0';
501         proto_tree_add_string (tree, hf_pn_dcp_suboption_device_typeofstation, tvb, offset, block_length, typeofstation);
502         pn_append_info(pinfo, dcp_item, ", TypeOfStation");
503         proto_item_append_text(block_item, "Device/Manufacturer specific");
504         if(is_response)
505             proto_item_append_text(block_item, ", Status: %u", status);
506         proto_item_append_text(block_item, ", TypeOfStation: \"%s\"", typeofstation);
507         offset += block_length;
508         break;
509     case(PNDCP_SUBOPTION_DEVICE_NAMEOFSTATION):
510         nameofstation = ep_alloc(block_length+1);
511         tvb_memcpy(tvb, (guint8 *) nameofstation, offset, block_length);
512         nameofstation[block_length] = '\0';
513         proto_tree_add_string (tree, hf_pn_dcp_suboption_device_nameofstation, tvb, offset, block_length, nameofstation);
514         pn_append_info(pinfo, dcp_item, ", NameOfStation");
515         proto_item_append_text(block_item, "Device/NameOfStation");
516         if(is_response)
517             proto_item_append_text(block_item, ", Status: %u", status);
518         proto_item_append_text(block_item, ", \"%s\"", nameofstation);
519         offset += block_length;
520         break;
521     case(PNDCP_SUBOPTION_DEVICE_DEV_ID):
522         offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_vendor_id, &vendor_id);
523         offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_device_id, &device_id);
524         pn_append_info(pinfo, dcp_item, ", Dev-ID");
525         proto_item_append_text(block_item, "Device/Device ID");
526         if(is_response)
527             proto_item_append_text(block_item, ", Status: %u", status);
528         proto_item_append_text(block_item, ", VendorID: 0x%04x / DeviceID: 0x%04x", vendor_id, device_id);
529         break;
530     case(PNDCP_SUBOPTION_DEVICE_DEV_ROLE):
531         offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_device_role, &device_role);
532         offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_reserved8, NULL);
533         pn_append_info(pinfo, dcp_item, ", Dev-Role");
534         proto_item_append_text(block_item, "Device/Device Role");
535         if(is_response)
536             proto_item_append_text(block_item, ", Status: %u", status);
537         if(device_role & 0x01)
538             proto_item_append_text(block_item, ", IO-Device");
539         if(device_role & 0x02)
540             proto_item_append_text(block_item, ", IO-Controller");
541         if(device_role & 0x04)
542             proto_item_append_text(block_item, ", IO-Multidevice");
543         if(device_role & 0x08)
544             proto_item_append_text(block_item, ", PN-Supervisor");
545         break;
546     case(PNDCP_SUBOPTION_DEVICE_DEV_OPTIONS):
547         info_str = ep_strdup_printf(", Dev-Options(%u)", block_length/2);
548         pn_append_info(pinfo, dcp_item, info_str);
549         proto_item_append_text(block_item, "Device/Device Options");
550         if(is_response)
551             proto_item_append_text(block_item, ", Status: %u", status);
552         proto_item_append_text(block_item, ", %u options", block_length/2);
553         for( ; block_length != 0; block_length -= 2) {
554             offset = dissect_PNDCP_Option(tvb, offset, pinfo, tree, NULL /*block_item*/, hf_pn_dcp_option, 
555                 FALSE /* append_col */);
556         }
557         break;
558     default:
559         item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data", 
560             "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_DEVICE, suboption, block_length);
561         expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
562                         "Undecoded suboption %u, %u bytes",
563                         suboption, block_length);
564         offset += block_length;
565     }
566
567     return offset;
568 }
569
570
571 /* dissect the "DHCP" suboption */
572 static int
573 dissect_PNDCP_Suboption_DHCP(tvbuff_t *tvb, int offset, packet_info *pinfo, 
574                                 proto_tree *tree, proto_item *block_item, proto_item *dcp_item, 
575                                                                 gboolean is_response _U_)
576 {
577     guint8 suboption;
578     guint16 block_length;
579     proto_item *item;
580
581
582     offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_dhcp, &suboption);
583     offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
584
585     switch(suboption) {
586         case(PNDCP_SUBOPTION_DHCP_CLIENT_ID):
587         pn_append_info(pinfo, dcp_item, ", DHCP client identifier");
588         proto_item_append_text(block_item, "DHCP/Client-ID");
589         proto_tree_add_item(tree, hf_pn_dcp_suboption_dhcp_device_id, tvb, offset, block_length, FALSE);
590         offset += block_length;
591                 break;
592     default:
593         item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data", 
594             "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_DHCP, suboption, block_length);
595         expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
596                         "Undecoded suboption %u, %u bytes",
597                         suboption, block_length);
598         offset += block_length;
599     }
600
601     return offset;
602 }
603
604
605 /* dissect the "LLDP" suboption */
606 static int
607 dissect_PNDCP_Suboption_LLDP(tvbuff_t *tvb, int offset, packet_info *pinfo, 
608                                 proto_tree *tree, proto_item *block_item _U_, proto_item *dcp_item _U_, 
609                                                                 gboolean is_response _U_)
610 {
611     guint8 suboption;
612     guint16 block_length;
613     proto_item *item;
614
615
616     offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_lldp, &suboption);
617     offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
618
619     /* XXX - improve this */
620     item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data", 
621         "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_LLDP, suboption, block_length);
622     expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
623                 "Undecoded suboption %u", suboption);
624
625     return offset;
626 }
627
628
629 /* dissect the "control" suboption */
630 static int
631 dissect_PNDCP_Suboption_Control(tvbuff_t *tvb, int offset, packet_info *pinfo, 
632                                 proto_tree *tree, proto_item *block_item, proto_item *dcp_item, 
633                                 gboolean is_response _U_)
634 {
635     guint8 result;
636     guint8 suboption;
637     guint16 block_length;
638     gchar *info_str;
639     guint16 status;
640     proto_item *item;
641
642
643     offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_control, &suboption);
644     offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
645
646     switch(suboption) {
647     case(PNDCP_SUBOPTION_CONTROL_START_TRANS):
648         pn_append_info(pinfo, dcp_item, ", Start-Trans");
649         proto_item_append_text(block_item, "Control/Start-Transaction");
650         offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_res_status, &status);
651         break;
652     case(PNDCP_SUBOPTION_CONTROL_END_TRANS):
653         pn_append_info(pinfo, dcp_item, ", End-Trans");
654         proto_item_append_text(block_item, "Control/End-Transaction");
655         offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_res_status, &status);
656         break;
657     case(PNDCP_SUBOPTION_CONTROL_SIGNAL):
658         pn_append_info(pinfo, dcp_item, ", Signal");
659         proto_item_append_text(block_item, "Control/Signal");
660         offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_res_status, &status);
661         block_length -= 2;
662
663         /* XXX - improve this */
664         proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data", 
665             "Block data: %d bytes", block_length);
666         offset += block_length;
667         break;
668     case(PNDCP_SUBOPTION_CONTROL_RESPONSE):
669         proto_item_append_text(block_item, "Control/Response");
670         offset = dissect_PNDCP_Option(tvb, offset, pinfo, tree, block_item, hf_pn_dcp_suboption_control_status, 
671             FALSE /* append_col */);
672         offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_result, &result);
673         info_str = ep_strdup_printf(", Response(%s)", val_to_str(result, pn_dcp_result, "Unknown"));
674         pn_append_info(pinfo, dcp_item, info_str);
675         proto_item_append_text(block_item, ", Result: %s", val_to_str(result, pn_dcp_result, "Unknown"));
676         break;
677     default:
678         item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data", 
679             "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_CONTROL, suboption, block_length);
680         expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
681                         "Undecoded suboption %u, %u bytes",
682                         suboption, block_length);
683         offset += block_length;
684     }
685
686     return offset;
687 }
688
689
690 /* dissect the "all" suboption */
691 static int
692 dissect_PNDCP_Suboption_All(tvbuff_t *tvb, int offset, packet_info *pinfo, 
693                             proto_tree *tree, proto_item *block_item, proto_item *dcp_item,
694                             gboolean is_response _U_)
695 {
696     guint8 suboption;
697     guint16 block_length;
698     proto_item *item;
699
700     offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_all, &suboption);
701     offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
702
703     switch(suboption) {
704     case(255):    /* All */
705         pn_append_info(pinfo, dcp_item, ", All");
706         proto_item_append_text(block_item, "All/All");
707         break;
708     default:
709             item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data", 
710                 "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_ALLSELECTOR, suboption, block_length);
711         expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
712                         "Undecoded suboption %u, %u bytes",
713                         suboption, block_length);
714             offset += block_length;
715     }
716
717     return offset;
718 }
719
720
721 /* dissect the "manufacturer" suboption */
722 static int
723 dissect_PNDCP_Suboption_Manuf(tvbuff_t *tvb, int offset, packet_info *pinfo, 
724                             proto_tree *tree, proto_item *block_item, proto_item *dcp_item,
725                             gboolean is_response _U_)
726 {
727     guint8 suboption;
728     guint16 block_length;
729     proto_item *item;
730
731     offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_manuf, &suboption);
732     offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
733
734     switch(suboption) {
735     default:
736         pn_append_info(pinfo, dcp_item, ", Manufacturer Specific");
737         proto_item_append_text(block_item, "Manufacturer Specific");
738         item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data", 
739             "Block data: %d bytes", block_length);
740         expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
741                         "Undecoded suboption %u, %u bytes",
742                         suboption, block_length);
743         offset += block_length;
744     }
745
746     return offset;
747 }
748
749
750 /* dissect one DCP block */
751 static int
752 dissect_PNDCP_Block(tvbuff_t *tvb, int offset, packet_info *pinfo, 
753                     proto_tree *tree, proto_item *dcp_item, 
754                     gboolean is_response)
755 {
756     guint8 option;
757     proto_item *block_item;
758     proto_tree *block_tree;
759     int ori_offset = offset;
760
761     /* subtree for block */
762         block_item = proto_tree_add_none_format(tree, hf_pn_dcp_block, 
763                 tvb, offset, 0, "Block: ");
764         block_tree = proto_item_add_subtree(block_item, ett_pn_dcp_block);
765
766
767     offset = dissect_pn_uint8(tvb, offset, pinfo, block_tree, hf_pn_dcp_option, &option);
768
769     switch(option) {
770     case(PNDCP_OPTION_IP):
771         offset = dissect_PNDCP_Suboption_IP(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
772         break;
773     case(PNDCP_OPTION_DEVICE):
774         offset = dissect_PNDCP_Suboption_Device(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
775         break;
776     case(PNDCP_OPTION_DHCP):
777         offset = dissect_PNDCP_Suboption_DHCP(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
778         break;
779     case(PNDCP_OPTION_LLDP):
780         offset = dissect_PNDCP_Suboption_LLDP(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
781         break;
782     case(PNDCP_OPTION_CONTROL):
783         offset = dissect_PNDCP_Suboption_Control(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
784         break;
785     case(PNDCP_OPTION_ALLSELECTOR):
786         offset = dissect_PNDCP_Suboption_All(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
787         break;
788     case(PNDCP_OPTION_MANUF_X80):
789     case(PNDCP_OPTION_MANUF_X81):
790     default:
791         offset = dissect_PNDCP_Suboption_Manuf(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
792     }
793
794     proto_item_set_len(block_item, offset-ori_offset);
795
796     if((offset-ori_offset) & 1) {
797         /* we have an odd number of bytes in this block, add a padding byte */
798         offset = dissect_pn_padding(tvb, offset, pinfo, tree, 1);
799     }
800
801     return offset;
802 }
803
804
805 /* dissect a whole DCP PDU */
806 static void
807 dissect_PNDCP_PDU(tvbuff_t *tvb, 
808         packet_info *pinfo, proto_tree *tree, proto_item *dcp_item)
809 {
810     guint8 service_id;
811     guint8 service_type;
812     guint32 xid;
813     guint16 response_delay;
814     guint16 data_length;
815     int offset = 0;
816     gchar *xid_str;
817     gboolean is_response = FALSE;
818     proto_item *item;
819
820
821     offset = dissect_pn_uint8 (tvb, offset, pinfo, tree, hf_pn_dcp_service_id, &service_id);
822     offset = dissect_pn_uint8 (tvb, offset, pinfo, tree, hf_pn_dcp_service_type, &service_type);
823     offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_dcp_xid, &xid);
824     if(service_id == PNDCP_SERVICE_ID_IDENTIFY && service_type == PNDCP_SERVICE_TYPE_REQUEST) {
825         /* multicast header */
826         offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_response_delay, &response_delay);
827     } else {
828         /* unicast header */
829         offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_reserved16, NULL);
830     }
831     offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_data_length, &data_length);
832
833     switch(service_id) {
834     case(PNDCP_SERVICE_ID_GET):
835         pn_append_info(pinfo, dcp_item, "Get");
836         break;
837     case(PNDCP_SERVICE_ID_SET):
838         pn_append_info(pinfo, dcp_item, "Set");
839         break;
840     case(PNDCP_SERVICE_ID_IDENTIFY):
841         pn_append_info(pinfo, dcp_item, "Ident");
842         break;
843     default:
844         item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, tvb_length_remaining(tvb, offset), "data", 
845             "PN-DCP Unknown service ID %u, Data: %d bytes", service_id, tvb_length_remaining(tvb, offset));
846         expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
847                         "Undecoded service ID %u, %u bytes",
848                         service_id, tvb_length_remaining(tvb, offset));
849         return;
850     }
851
852     switch(service_type) {
853     case(PNDCP_SERVICE_TYPE_REQUEST):
854         pn_append_info(pinfo, dcp_item, " Req");
855         break;
856     case(PNDCP_SERVICE_TYPE_RESPONSE_SUCCESS):
857         pn_append_info(pinfo, dcp_item, " Ok ");
858         is_response = TRUE;
859         break;
860     case(PNDCP_SERVICE_TYPE_RESPONSE_UNSUPPORTED):
861         pn_append_info(pinfo, dcp_item, " unsupported");
862         is_response = TRUE;
863         break;
864     default:
865         item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, tvb_length_remaining(tvb, offset), "data", 
866             "PN-DCP Unknown service type %u, Data: %d bytes", service_type, tvb_length_remaining(tvb, offset));
867         expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
868                         "Undecoded service type %u, %u bytes",
869                         service_type, tvb_length_remaining(tvb, offset));
870         return;
871     }
872
873     xid_str = ep_strdup_printf(", Xid:0x%x", xid);
874     pn_append_info(pinfo, dcp_item, xid_str);
875
876     /* dissect a number of blocks (depending on the remaining length) */
877     while(data_length) {
878         int ori_offset = offset;
879
880         if(service_id == PNDCP_SERVICE_ID_GET && service_type == PNDCP_SERVICE_TYPE_REQUEST) {
881             /* Selectors */
882             offset = dissect_PNDCP_Option(tvb, offset, pinfo, 
883                                  tree, dcp_item, hf_pn_dcp_option, TRUE /* append_col */);
884         } else {
885             offset = dissect_PNDCP_Block(tvb, offset, pinfo, tree, dcp_item, is_response);
886         }
887         /* prevent an infinite loop */
888         if(offset <= ori_offset || data_length < (offset - ori_offset)) {
889             THROW(ReportedBoundsError);
890         }
891         data_length -= (offset - ori_offset);
892     }
893 }
894
895
896 /* possibly dissect a PN-RT packet (frame ID must be in the appropriate range) */
897 static gboolean
898 dissect_PNDCP_Data_heur(tvbuff_t *tvb, 
899         packet_info *pinfo, proto_tree *tree)
900 {
901     guint16 u16FrameID;
902     proto_item *item = NULL;
903     proto_tree *dcp_tree = NULL;
904
905
906     /* the tvb will NOT contain the frame_id here, so get it from our private data! */
907     u16FrameID = GPOINTER_TO_UINT(pinfo->private_data);
908
909         /* frame id must be in valid range (acyclic Real-Time, DCP) */
910         if (u16FrameID < FRAME_ID_UC || u16FrameID > FRAME_ID_MC_RESP) {
911         /* we are not interested in this packet */
912         return FALSE;
913     }
914
915         if (check_col(pinfo->cinfo, COL_PROTOCOL))
916             col_add_str(pinfo->cinfo, COL_PROTOCOL, "PN-DCP");
917     if (check_col(pinfo->cinfo, COL_INFO))
918       col_add_str(pinfo->cinfo, COL_INFO, "");
919
920     /* subtree for DCP */
921         item = proto_tree_add_protocol_format(tree, proto_pn_dcp, tvb, 0, tvb_get_ntohs(tvb, 8) + 10,
922                                 "PROFINET DCP, ");
923         dcp_tree = proto_item_add_subtree(item, ett_pn_dcp);
924
925     /* dissect this PDU */
926     dissect_PNDCP_PDU(tvb, pinfo, dcp_tree, item);
927
928     return TRUE;
929 }
930
931
932 void
933 proto_register_pn_dcp (void)
934 {
935         static hf_register_info hf[] = {
936         { &hf_pn_dcp,
937                 { "PROFINET DCP", "pn_dcp", FT_NONE, BASE_NONE, NULL, 0x0, "", HFILL }},
938         { &hf_pn_dcp_service_id,
939                 { "Service-ID", "pn_dcp.service_id", FT_UINT8, BASE_DEC, VALS(pn_dcp_service_id), 0x0, "", HFILL }},
940         { &hf_pn_dcp_service_type,
941                 { "Service-Type", "pn_dcp.service_type", FT_UINT8, BASE_DEC, VALS(pn_dcp_service_type), 0x0, "", HFILL }},
942         { &hf_pn_dcp_xid,
943                 { "xid", "pn_dcp.xid", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
944         { &hf_pn_dcp_reserved8,
945                 { "Reserved", "pn_dcp.reserved8", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
946         { &hf_pn_dcp_reserved16,
947                 { "Reserved", "pn_dcp.reserved16", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
948         { &hf_pn_dcp_response_delay,
949                 { "ResponseDelay", "pn_dcp.response_delay", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
950         { &hf_pn_dcp_data_length,
951                 { "DCPDataLength", "pn_dcp.data_length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
952         { &hf_pn_dcp_block_length,
953                 { "DataBlockLength", "pn_dcp.block_length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
954         { &hf_pn_dcp_option,
955                 { "Option", "pn_dcp.option", FT_UINT8, BASE_DEC, VALS(pn_dcp_option), 0x0, "", HFILL }},
956         { &hf_pn_dcp_suboption,
957                 { "Suboption", "pn_dcp.suboption", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
958         { &hf_pn_dcp_result,
959                 { "Result", "pn_dcp.result", FT_UINT8, BASE_DEC, VALS(pn_dcp_result), 0x0, "", HFILL }},
960         { &hf_pn_dcp_block,
961                 { "Block", "pn_dcp.block", FT_NONE, BASE_NONE, NULL, 0x0, "", HFILL }},
962         { &hf_pn_dcp_req_status,
963                 { "Status", "pn_dcp.req_status", FT_UINT16, BASE_DEC, VALS(pn_dcp_req_status), 0x0, "", HFILL }},
964         { &hf_pn_dcp_res_status,
965                 { "ResponseStatus", "pn_dcp.res_status", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
966     { &hf_pn_dcp_suboption_ip,
967                 { "Suboption", "pn_dcp.suboption_ip", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_ip), 0x0, "", HFILL }},
968     { &hf_pn_dcp_suboption_ip_status,
969                 { "Status", "pn_dcp.suboption_ip_status", FT_UINT16, BASE_DEC, VALS(pn_dcp_suboption_ip_status), 0x0, "", HFILL }},
970         { &hf_pn_dcp_suboption_ip_ip,
971                 { "IPaddress", "pn_dcp.subobtion_ip_ip", FT_IPv4, BASE_NONE, NULL, 0x0, "", HFILL }},
972         { &hf_pn_dcp_suboption_ip_subnetmask,
973                 { "Subnetmask", "pn_dcp.subobtion_ip_subnetmask", FT_IPv4, BASE_NONE, NULL, 0x0, "", HFILL }},
974         { &hf_pn_dcp_suboption_ip_default_router,
975                 { "Default-router", "pn_dcp.subobtion_ip_default_router", FT_IPv4, BASE_NONE, NULL, 0x0, "", HFILL }},
976
977     { &hf_pn_dcp_suboption_device,
978                 { "Suboption", "pn_dcp.suboption_device", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_device), 0x0, "", HFILL }},
979     { &hf_pn_dcp_suboption_device_typeofstation,
980                 { "TypeOfStation", "pn_dcp.suboption_device_typeofstation", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }},
981     { &hf_pn_dcp_suboption_device_nameofstation,
982                 { "NameOfStation", "pn_dcp.suboption_device_nameofstation", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }},
983     { &hf_pn_dcp_suboption_vendor_id,
984                 { "VendorID", "pn_dcp.suboption_vendor_id", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
985     { &hf_pn_dcp_suboption_device_id,
986                 { "DeviceID", "pn_dcp.suboption_device_id", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
987     { &hf_pn_dcp_suboption_device_role,
988                 { "Device-role", "pn_dcp.suboption_device_role", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }},
989
990     { &hf_pn_dcp_suboption_dhcp,
991                 { "Suboption", "pn_dcp.suboption_dhcp", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_dhcp), 0x0, "", HFILL }},
992     { &hf_pn_dcp_suboption_dhcp_device_id,
993                 { "Device ID", "pn_dcp.suboption_dhcp_device_id", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
994
995     { &hf_pn_dcp_suboption_lldp,
996                 { "Suboption", "pn_dcp.suboption_lldp", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_lldp), 0x0, "", HFILL }},
997
998     { &hf_pn_dcp_suboption_control,
999                 { "Suboption", "pn_dcp.suboption_control", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_control), 0x0, "", HFILL }},
1000     { &hf_pn_dcp_suboption_control_status,
1001                 { "ResponseStatus", "pn_dcp.suboption_control_status", FT_UINT8, BASE_DEC, VALS(pn_dcp_option), 0x0, "", HFILL }},
1002
1003     { &hf_pn_dcp_suboption_all,
1004                 { "Suboption", "pn_dcp.suboption_all", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_all), 0x0, "", HFILL }},
1005
1006     { &hf_pn_dcp_suboption_manuf,
1007                 { "Suboption", "pn_dcp.suboption_manuf", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_manuf), 0x0, "", HFILL }},
1008
1009     { &hf_pn_dcp_data,
1010       { "Undecoded Data", "pn_dcp.data", FT_STRING, BASE_DEC, NULL, 0x0, "", HFILL }},
1011         };
1012
1013         static gint *ett[] = {
1014                 &ett_pn_dcp,
1015         &ett_pn_dcp_block
1016     };
1017         proto_pn_dcp = proto_register_protocol ("PROFINET DCP", "PN-DCP", "pn_dcp");
1018         proto_register_field_array (proto_pn_dcp, hf, array_length (hf));
1019         proto_register_subtree_array (ett, array_length (ett));
1020 }
1021
1022 void
1023 proto_reg_handoff_pn_dcp (void)
1024 {
1025     /* register ourself as an heuristic pn-rt payload dissector */
1026         heur_dissector_add("pn_rt", dissect_PNDCP_Data_heur, proto_pn_dcp);
1027 }