Rename the routines that handle dissector tables with unsigned integer
[obnox/wireshark/wip.git] / epan / dissectors / packet-ptp.c
1 /* packet-ptp.c
2  * Routines for PTP (Precision Time Protocol) dissection
3  * Copyright 2004, Auges Tchouante <tchouante2001@yahoo.fr>
4  * Copyright 2004, Dominic Bechaz <bdo@zhwin.ch> , ZHW/InES
5  * Copyright 2004, Markus Seehofer <mseehofe@nt.hirschmann.de>
6  * Copyright 2006, Christian Schaer <scc@zhwin.ch>
7  * Copyright 2007, Markus Renz <Markus.Renz@hirschmann.de>
8  * Copyright 2010, Torrey Atcitty <torrey.atcitty@harman.com>
9  *                 Dave Olsen <dave.olsen@harman.com>
10  *
11  * Revisions:
12  * - Markus Seehofer 09.08.2005 <mseehofe@nt.hirschmann.de>
13  *   - Included the "startingBoundaryHops" field in
14  *     ptp_management messages.
15  * - Christian Schaer 07.07.2006 <scc@zhwin.ch>
16  *   - Added support for PTP version 2
17  * - Markus Renz 2007-06-01
18  *   - updated support for PTPv2
19  * - Markus Renz added Management for PTPv2, update to Draft 2.2
20  * - Torrey Atcitty & Dave Olsen 05.14.2010
21  *   - Added support for 802.1AS D7.0
22  *
23  * $Id$
24  *
25  * Wireshark - Network traffic analyzer
26  * By Gerald Combs <gerald@wireshark.org>
27  * Copyright 1998 Gerald Combs
28  *
29  * This program is free software; you can redistribute it and/or
30  * modify it under the terms of the GNU General Public License
31  * as published by the Free Software Foundation; either version 2
32  * of the License, or (at your option) any later version.
33  *
34  * This program is distributed in the hope that it will be useful,
35  * but WITHOUT ANY WARRANTY; without even the implied warranty of
36  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37  * GNU General Public License for more details.
38  *
39  * You should have received a copy of the GNU General Public License
40  * along with this program; if not, write to the Free Software
41  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
42  */
43
44 #ifdef HAVE_CONFIG_H
45 # include "config.h"
46 #endif
47
48 #include <stdlib.h>
49 #include <math.h>
50
51
52 #include <glib.h>
53
54 #include <epan/packet.h>
55 #include <epan/etypes.h>
56
57
58 /**********************************************************/
59 /* Port definition's for PTP                              */
60 /**********************************************************/
61 #define EVENT_PORT_PTP      319
62 #define GENERAL_PORT_PTP    320
63
64 /*END Port definition's for PTP*/
65
66 static int proto_ptp = -1;
67
68 /***********************************************************************************/
69 /* Definitions and fields for PTPv1 dissection.                                    */
70 /***********************************************************************************/
71
72
73 /**********************************************************/
74 /* Offsets of fields within a PTPv1 packet.               */
75 /**********************************************************/
76
77 /*Common offsets for all Messages (Synch, Delay_Req, Follow_Up, Delay_Resp ....)*/
78 #define PTP_VERSIONPTP_OFFSET                        0
79 #define PTP_VERSIONNETWORK_OFFSET                    2
80 #define PTP_SUBDOMAIN_OFFSET                         4
81 #define PTP_MESSAGETYPE_OFFSET                      20
82 #define PTP_SOURCECOMMUNICATIONTECHNOLOGY_OFFSET    21
83 #define PTP_SOURCEUUID_OFFSET                       22
84 #define PTP_SOURCEPORTID_OFFSET                     28
85 #define PTP_SEQUENCEID_OFFSET                       30
86 #define PTP_CONTROL_OFFSET                          32
87 #define PTP_FLAGS_OFFSET                            34
88 #define PTP_FLAGS_LI61_OFFSET                       34
89 #define PTP_FLAGS_LI59_OFFSET                       34
90 #define PTP_FLAGS_BOUNDARY_CLOCK_OFFSET             34
91 #define PTP_FLAGS_ASSIST_OFFSET                     34
92 #define PTP_FLAGS_EXT_SYNC_OFFSET                   34
93 #define PTP_FLAGS_PARENT_STATS_OFFSET               34
94 #define PTP_FLAGS_SYNC_BURST_OFFSET                 34
95
96 /*Offsets for PTP_Sync and Delay_Req (=SDR) messages*/
97 #define PTP_SDR_ORIGINTIMESTAMP_OFFSET                       40
98 #define PTP_SDR_ORIGINTIMESTAMP_SECONDS_OFFSET               40
99 #define PTP_SDR_ORIGINTIMESTAMP_NANOSECONDS_OFFSET           44
100 #define PTP_SDR_EPOCHNUMBER_OFFSET                           48
101 #define PTP_SDR_CURRENTUTCOFFSET_OFFSET                      50
102 #define PTP_SDR_GRANDMASTERCOMMUNICATIONTECHNOLOGY_OFFSET    53
103 #define PTP_SDR_GRANDMASTERCLOCKUUID_OFFSET                  54
104 #define PTP_SDR_GRANDMASTERPORTID_OFFSET                     60
105 #define PTP_SDR_GRANDMASTERSEQUENCEID_OFFSET                 62
106 #define PTP_SDR_GRANDMASTERCLOCKSTRATUM_OFFSET               67
107 #define PTP_SDR_GRANDMASTERCLOCKIDENTIFIER_OFFSET            68
108 #define PTP_SDR_GRANDMASTERCLOCKVARIANCE_OFFSET              74
109 #define PTP_SDR_GRANDMASTERPREFERRED_OFFSET                  77
110 #define PTP_SDR_GRANDMASTERISBOUNDARYCLOCK_OFFSET            79
111 #define PTP_SDR_SYNCINTERVAL_OFFSET                          83
112 #define PTP_SDR_LOCALCLOCKVARIANCE_OFFSET                    86
113 #define PTP_SDR_LOCALSTEPSREMOVED_OFFSET                     90
114 #define PTP_SDR_LOCALCLOCKSTRATUM_OFFSET                     95
115 #define PTP_SDR_LOCALCLOCKIDENTIFIER_OFFSET                  96
116 #define PTP_SDR_PARENTCOMMUNICATIONTECHNOLOGY_OFFSET        101
117 #define PTP_SDR_PARENTUUID_OFFSET                           102
118 #define PTP_SDR_PARENTPORTFIELD_OFFSET                      110
119 #define PTP_SDR_ESTIMATEDMASTERVARIANCE_OFFSET              114
120 #define PTP_SDR_ESTIMATEDMASTERDRIFT_OFFSET                 116
121 #define PTP_SDR_UTCREASONABLE_OFFSET                        123
122
123 /*Offsets for Follow_Up (=FU) messages*/
124 #define PTP_FU_ASSOCIATEDSEQUENCEID_OFFSET                   42
125 #define PTP_FU_PRECISEORIGINTIMESTAMP_OFFSET                 44
126 #define PTP_FU_PRECISEORIGINTIMESTAMP_SECONDS_OFFSET         44
127 #define PTP_FU_PRECISEORIGINTIMESTAMP_NANOSECONDS_OFFSET     48
128
129 /*Offsets for Delay_Resp (=DR) messages*/
130 #define PTP_DR_DELAYRECEIPTTIMESTAMP_OFFSET                     40
131 #define PTP_DR_DELAYRECEIPTTIMESTAMP_SECONDS_OFFSET             40
132 #define PTP_DR_DELAYRECEIPTTIMESTAMP_NANOSECONDS_OFFSET         44
133 #define PTP_DR_REQUESTINGSOURCECOMMUNICATIONTECHNOLOGY_OFFSET   49
134 #define PTP_DR_REQUESTINGSOURCEUUID_OFFSET                      50
135 #define PTP_DR_REQUESTINGSOURCEPORTID_OFFSET                    56
136 #define PTP_DR_REQUESTINGSOURCESEQUENCEID_OFFSET                58
137
138 /*Offsets for Management (=MM) messages*/
139 #define PTP_MM_TARGETCOMMUNICATIONTECHNOLOGY_OFFSET             41
140 #define PTP_MM_TARGETUUID_OFFSET                                42
141 #define PTP_MM_TARGETPORTID_OFFSET                              48
142 #define PTP_MM_STARTINGBOUNDARYHOPS_OFFSET                      50
143 #define PTP_MM_BOUNDARYHOPS_OFFSET                              52
144 #define PTP_MM_MANAGEMENTMESSAGEKEY_OFFSET                      55
145 #define PTP_MM_PARAMETERLENGTH_OFFSET                           58
146
147     /*PARAMETERLENGTH > 0*/
148 #define PTP_MM_MESSAGEPARAMETERS_OFFSET                         60
149
150     /*PTP_MM_CLOCK_IDENTITY (PARAMETERLENGTH = 64)*/
151 #define PTP_MM_CLOCK_IDENTITY_CLOCKCOMMUNICATIONTECHNOLOGY_OFFSET    63
152 #define PTP_MM_CLOCK_IDENTITY_CLOCKUUIDFIELD_OFFSET                  64
153 #define PTP_MM_CLOCK_IDENTITY_CLOCKPORTFIELD_OFFSET                  74
154 #define PTP_MM_CLOCK_IDENTITY_MANUFACTURERIDENTITY_OFFSET            76
155
156     /*PTP_MM_INITIALIZE_CLOCK (PARAMETERLENGTH = 4)*/
157 #define PTP_MM_INITIALIZE_CLOCK_INITIALISATIONKEY_OFFSET             62
158
159     /*PTP_MM_SET_SUBDOMAIN (PARAMETERLENGTH = 16)*/
160 #define PTP_MM_SET_SUBDOMAIN_SUBDOMAINNAME_OFFSET                    60
161
162     /*PTP_MM_DEFAULT_DATA_SET (PARAMETERLENGTH = 76)*/
163 #define PTP_MM_DEFAULT_DATA_SET_CLOCKCOMMUNICATIONTECHNOLOGY_OFFSET  63
164 #define PTP_MM_DEFAULT_DATA_SET_CLOCKUUIDFIELD_OFFSET                64
165 #define PTP_MM_DEFAULT_DATA_SET_CLOCKPORTFIELD_OFFSET                74
166 #define PTP_MM_DEFAULT_DATA_SET_CLOCKSTRATUM_OFFSET                  79
167 #define PTP_MM_DEFAULT_DATA_SET_CLOCKIDENTIFIER_OFFSET               80
168 #define PTP_MM_DEFAULT_DATA_SET_CLOCKVARIANCE_OFFSET                 86
169 #define PTP_MM_DEFAULT_DATA_SET_CLOCKFOLLOWUPCAPABLE_OFFSET          89
170 #define PTP_MM_DEFAULT_DATA_SET_PREFERRED_OFFSET                     95
171 #define PTP_MM_DEFAULT_DATA_SET_INITIALIZABLE_OFFSET                 99
172 #define PTP_MM_DEFAULT_DATA_SET_EXTERNALTIMING_OFFSET               103
173 #define PTP_MM_DEFAULT_DATA_SET_ISBOUNDARYCLOCK_OFFSET              107
174 #define PTP_MM_DEFAULT_DATA_SET_SYNCINTERVAL_OFFSET                 111
175 #define PTP_MM_DEFAULT_DATA_SET_SUBDOMAINNAME_OFFSET                112
176 #define PTP_MM_DEFAULT_DATA_SET_NUMBERPORTS_OFFSET                  130
177 #define PTP_MM_DEFAULT_DATA_SET_NUMBERFOREIGNRECORDS_OFFSET         134
178
179     /*PTP_MM_UPDATE_DEFAULT_DATA_SET (PARAMETERLENGTH = 36)*/
180 #define PTP_MM_UPDATE_DEFAULT_DATA_SET_CLOCKSTRATUM_OFFSET           63
181 #define PTP_MM_UPDATE_DEFAULT_DATA_SET_CLOCKIDENTIFIER_OFFSET        64
182 #define PTP_MM_UPDATE_DEFAULT_DATA_SET_CLOCKVARIANCE_OFFSET          70
183 #define PTP_MM_UPDATE_DEFAULT_DATA_SET_PREFERRED_OFFSET              75
184 #define PTP_MM_UPDATE_DEFAULT_DATA_SET_SYNCINTERVAL_OFFSET           79
185 #define PTP_MM_UPDATE_DEFAULT_DATA_SET_SUBDOMAINNAME_OFFSET          80
186
187     /*PTP_MM_CURRENT_DATA_SET (PARAMETERLENGTH = 20)*/
188 #define PTP_MM_CURRENT_DATA_SET_STEPSREMOVED_OFFSET                  62
189 #define PTP_MM_CURRENT_DATA_SET_OFFSETFROMMASTER_OFFSET              64
190 #define PTP_MM_CURRENT_DATA_SET_OFFSETFROMMASTERSECONDS_OFFSET       64
191 #define PTP_MM_CURRENT_DATA_SET_OFFSETFROMMASTERNANOSECONDS_OFFSET   68
192 #define PTP_MM_CURRENT_DATA_SET_ONEWAYDELAY_OFFSET                   72
193 #define PTP_MM_CURRENT_DATA_SET_ONEWAYDELAYSECONDS_OFFSET            72
194 #define PTP_MM_CURRENT_DATA_SET_ONEWAYDELAYNANOSECONDS_OFFSET        76
195
196     /*PTP_MM_PARENT_DATA_SET (PARAMETERLENGTH = 90)*/
197 #define PTP_MM_PARENT_DATA_SET_PARENTCOMMUNICATIONTECHNOLOGY_OFFSET  63
198 #define PTP_MM_PARENT_DATA_SET_PARENTUUID_OFFSET                     64
199 #define PTP_MM_PARENT_DATA_SET_PARENTPORTID_OFFSET                   74
200 #define PTP_MM_PARENT_DATA_SET_PARENTLASTSYNCSEQUENCENUMBER_OFFSET   78
201 #define PTP_MM_PARENT_DATA_SET_PARENTFOLLOWUPCAPABLE_OFFSET          83
202 #define PTP_MM_PARENT_DATA_SET_PARENTEXTERNALTIMING_OFFSET           87
203 #define PTP_MM_PARENT_DATA_SET_PARENTVARIANCE_OFFSET                 90
204 #define PTP_MM_PARENT_DATA_SET_PARENTSTATS_OFFSET                    95
205 #define PTP_MM_PARENT_DATA_SET_OBSERVEDVARIANCE_OFFSET               98
206 #define PTP_MM_PARENT_DATA_SET_OBSERVEDDRIFT_OFFSET                 100
207 #define PTP_MM_PARENT_DATA_SET_UTCREASONABLE_OFFSET                 107
208 #define PTP_MM_PARENT_DATA_SET_GRANDMASTERCOMMUNICATIONTECHNOLOGY_OFFSET    111
209 #define PTP_MM_PARENT_DATA_SET_GRANDMASTERUUIDFIELD_OFFSET          112
210 #define PTP_MM_PARENT_DATA_SET_GRANDMASTERPORTIDFIELD_OFFSET        122
211 #define PTP_MM_PARENT_DATA_SET_GRANDMASTERSTRATUM_OFFSET            127
212 #define PTP_MM_PARENT_DATA_SET_GRANDMASTERIDENTIFIER_OFFSET         128
213 #define PTP_MM_PARENT_DATA_SET_GRANDMASTERVARIANCE_OFFSET           134
214 #define PTP_MM_PARENT_DATA_SET_GRANDMASTERPREFERRED_OFFSET          139
215 #define PTP_MM_PARENT_DATA_SET_GRANDMASTERISBOUNDARYCLOCK_OFFSET    143
216 #define PTP_MM_PARENT_DATA_SET_GRANDMASTERSEQUENCENUMBER_OFFSET     146
217
218     /*PTP_MM_PORT_DATA_SET (PARAMETERLENGTH = 52)*/
219 #define PTP_MM_PORT_DATA_SET_RETURNEDPORTNUMBER_OFFSET               62
220 #define PTP_MM_PORT_DATA_SET_PORTSTATE_OFFSET                        67
221 #define PTP_MM_PORT_DATA_SET_LASTSYNCEVENTSEQUENCENUMBER_OFFSET      70
222 #define PTP_MM_PORT_DATA_SET_LASTGENERALEVENTSEQUENCENUMBER_OFFSET   74
223 #define PTP_MM_PORT_DATA_SET_PORTCOMMUNICATIONTECHNOLOGY_OFFSET      79
224 #define PTP_MM_PORT_DATA_SET_PORTUUIDFIELD_OFFSET                    80
225 #define PTP_MM_PORT_DATA_SET_PORTIDFIELD_OFFSET                      90
226 #define PTP_MM_PORT_DATA_SET_BURSTENABLED_OFFSET                     95
227 #define PTP_MM_PORT_DATA_SET_SUBDOMAINADDRESSOCTETS_OFFSET           97
228 #define PTP_MM_PORT_DATA_SET_EVENTPORTADDRESSOCTETS_OFFSET           98
229 #define PTP_MM_PORT_DATA_SET_GENERALPORTADDRESSOCTETS_OFFSET         99
230 #define PTP_MM_PORT_DATA_SET_SUBDOMAINADDRESS_OFFSET                100
231 #define PTP_MM_PORT_DATA_SET_EVENTPORTADDRESS_OFFSET                106
232 #define PTP_MM_PORT_DATA_SET_GENERALPORTADDRESS_OFFSET              110
233
234     /*PTP_MM_GLOBAL_TIME_DATA_SET (PARAMETERLENGTH = 24)*/
235 #define PTP_MM_GLOBAL_TIME_DATA_SET_LOCALTIME_OFFSET                 60
236 #define PTP_MM_GLOBAL_TIME_DATA_SET_LOCALTIMESECONDS_OFFSET          60
237 #define PTP_MM_GLOBAL_TIME_DATA_SET_LOCALTIMENANOSECONDS_OFFSET      64
238 #define PTP_MM_GLOBAL_TIME_DATA_SET_CURRENTUTCOFFSET_OFFSET          70
239 #define PTP_MM_GLOBAL_TIME_DATA_SET_LEAP59_OFFSET                    75
240 #define PTP_MM_GLOBAL_TIME_DATA_SET_LEAP61_OFFSET                    79
241 #define PTP_MM_GLOBAL_TIME_DATA_SET_EPOCHNUMBER_OFFSET               82
242
243     /*PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES (PARAMETERLENGTH = 16)*/
244 #define PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES_CURRENTUTCOFFSET_OFFSET 62
245 #define PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES_LEAP59_OFFSET           67
246 #define PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES_LEAP61_OFFSET           71
247 #define PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES_EPOCHNUMBER_OFFSET      74
248
249     /*PTP_MM_GET_FOREIGN_DATA_SET (PARAMETERLENGTH = 4)*/
250 #define PTP_MM_GET_FOREIGN_DATA_SET_RECORDKEY_OFFSET                 62
251
252     /*PTP_MM_FOREIGN_DATA_SET (PARAMETERLENGTH = 28)*/
253 #define PTP_MM_FOREIGN_DATA_SET_RETURNEDPORTNUMBER_OFFSET            62
254 #define PTP_MM_FOREIGN_DATA_SET_RETURNEDRECORDNUMBER_OFFSET          66
255 #define PTP_MM_FOREIGN_DATA_SET_FOREIGNMASTERCOMMUNICATIONTECHNOLOGY_OFFSET 71
256 #define PTP_MM_FOREIGN_DATA_SET_FOREIGNMASTERUUIDFIELD_OFFSET        72
257 #define PTP_MM_FOREIGN_DATA_SET_FOREIGNMASTERPORTIDFIELD_OFFSET      82
258 #define PTP_MM_FOREIGN_DATA_SET_FOREIGNMASTERSYNCS_OFFSET            86
259
260     /*PTP_MM_SET_SYNC_INTERVAL (PARAMETERLENGTH = 4)*/
261 #define PTP_MM_SET_SYNC_INTERVAL_SYNCINTERVAL_OFFSET                 62
262
263     /*PTP_MM_SET_TIME (PARAMETERLENGTH = 8)*/
264 #define PTP_MM_SET_TIME_LOCALTIME_OFFSET                             60
265 #define PTP_MM_SET_TIME_LOCALTIMESECONDS_OFFSET                      60
266 #define PTP_MM_SET_TIME_LOCALTIMENANOSECONDS_OFFSET                  64
267
268 /*END Offsets of fields within a PTP packet.*/
269
270 /**********************************************************/
271 /* flag-field-mask-definitions                            */
272 /**********************************************************/
273 #define PTP_FLAGS_LI61_BITMASK              0x01
274 #define PTP_FLAGS_LI59_BITMASK              0x02
275 #define PTP_FLAGS_BOUNDARY_CLOCK_BITMASK    0x04
276 #define PTP_FLAGS_ASSIST_BITMASK            0x08
277 #define PTP_FLAGS_EXT_SYNC_BITMASK          0x10
278 #define PTP_FLAGS_PARENT_STATS_BITMASK      0x20
279 #define PTP_FLAGS_SYNC_BURST_BITMASK        0x40
280
281 /*END flag-field-mask-definitions*/
282
283 /**********************************************************/
284 /* managementMessage definitions                          */
285 /**********************************************************/
286 #define PTP_MM_NULL                               0
287 #define PTP_MM_OBTAIN_IDENTITY                    1
288 #define PTP_MM_CLOCK_IDENTITY                     2
289 #define PTP_MM_INITIALIZE_CLOCK                   3
290 #define PTP_MM_SET_SUBDOMAIN                      4
291 #define PTP_MM_CLEAR_DESIGNATED_PREFERRED_MASTER  5
292 #define PTP_MM_SET_DESIGNATED_PREFERRED_MASTER    6
293 #define PTP_MM_GET_DEFAULT_DATA_SET               7
294 #define PTP_MM_DEFAULT_DATA_SET                   8
295 #define PTP_MM_UPDATE_DEFAULT_DATA_SET            9
296 #define PTP_MM_GET_CURRENT_DATA_SET              10
297 #define PTP_MM_CURRENT_DATA_SET                  11
298 #define PTP_MM_GET_PARENT_DATA_SET               12
299 #define PTP_MM_PARENT_DATA_SET                   13
300 #define PTP_MM_GET_PORT_DATA_SET                 14
301 #define PTP_MM_PORT_DATA_SET                     15
302 #define PTP_MM_GET_GLOBAL_TIME_DATA_SET          16
303 #define PTP_MM_GLOBAL_TIME_DATA_SET              17
304 #define PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES     18
305 #define PTP_MM_GOTO_FAULTY_STATE                 19
306 #define PTP_MM_GET_FOREIGN_DATA_SET              20
307 #define PTP_MM_FOREIGN_DATA_SET                  21
308 #define PTP_MM_SET_SYNC_INTERVAL                 22
309 #define PTP_MM_DISABLE_PORT                      23
310 #define PTP_MM_ENABLE_PORT                       24
311 #define PTP_MM_DISABLE_BURST                     25
312 #define PTP_MM_ENABLE_BURST                      26
313 #define PTP_MM_SET_TIME                          27
314
315 static const value_string ptp_managementMessageKey_vals[] = {
316     {PTP_MM_NULL                              , "PTP_MM_NULL"},
317     {PTP_MM_OBTAIN_IDENTITY                   , "PTP_MM_OBTAIN_IDENTITY"},
318     {PTP_MM_CLOCK_IDENTITY                    , "PTP_MM_CLOCK_IDENTITY"},
319     {PTP_MM_INITIALIZE_CLOCK                  , "PTP_MM_INITIALIZE_CLOCK"},
320     {PTP_MM_SET_SUBDOMAIN                     , "PTP_MM_SET_SUBDOMAIN"},
321     {PTP_MM_CLEAR_DESIGNATED_PREFERRED_MASTER , "PTP_MM_CLEAR_DESIGNATED_PREFERRED_MASTER"},
322     {PTP_MM_SET_DESIGNATED_PREFERRED_MASTER   , "PTP_MM_SET_DESIGNATED_PREFERRED_MASTER"},
323     {PTP_MM_GET_DEFAULT_DATA_SET              , "PTP_MM_GET_DEFAULT_DATA_SET"},
324     {PTP_MM_DEFAULT_DATA_SET                  , "PTP_MM_DEFAULT_DATA_SET"},
325     {PTP_MM_UPDATE_DEFAULT_DATA_SET           , "PTP_MM_UPDATE_DEFAULT_DATA_SET"},
326     {PTP_MM_GET_CURRENT_DATA_SET              , "PTP_MM_GET_CURRENT_DATA_SET"},
327     {PTP_MM_CURRENT_DATA_SET                  , "PTP_MM_CURRENT_DATA_SET"},
328     {PTP_MM_GET_PARENT_DATA_SET               , "PTP_MM_GET_PARENT_DATA_SET"},
329     {PTP_MM_PARENT_DATA_SET                   , "PTP_MM_PARENT_DATA_SET"},
330     {PTP_MM_GET_PORT_DATA_SET                 , "PTP_MM_GET_PORT_DATA_SET"},
331     {PTP_MM_PORT_DATA_SET                     , "PTP_MM_PORT_DATA_SET"},
332     {PTP_MM_GET_GLOBAL_TIME_DATA_SET          , "PTP_MM_GET_GLOBAL_TIME_DATA_SET"},
333     {PTP_MM_GLOBAL_TIME_DATA_SET              , "PTP_MM_GLOBAL_TIME_DATA_SET"},
334     {PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES     , "PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES"},
335     {PTP_MM_GOTO_FAULTY_STATE                 , "PTP_MM_GOTO_FAULTY_STATE"},
336     {PTP_MM_GET_FOREIGN_DATA_SET              , "PTP_MM_GET_FOREIGN_DATA_SET"},
337     {PTP_MM_FOREIGN_DATA_SET                  , "PTP_MM_FOREIGN_DATA_SET"},
338     {PTP_MM_SET_SYNC_INTERVAL                 , "PTP_MM_SET_SYNC_INTERVAL"},
339     {PTP_MM_DISABLE_PORT                      , "PTP_MM_DISABLE_PORT"},
340     {PTP_MM_ENABLE_PORT                       , "PTP_MM_ENABLE_PORT"},
341     {PTP_MM_DISABLE_BURST                     , "PTP_MM_DISABLE_BURST"},
342     {PTP_MM_ENABLE_BURST                      , "PTP_MM_ENABLE_BURST"},
343     {PTP_MM_SET_TIME                          , "PTP_MM_SET_TIME"},
344     {0,              NULL          } };
345
346 /*same again but better readable text for info column*/
347 static const value_string ptp_managementMessageKey_infocolumn_vals[] = {
348     {PTP_MM_NULL                              , "Null"},
349     {PTP_MM_OBTAIN_IDENTITY                   , "Obtain Identity"},
350     {PTP_MM_CLOCK_IDENTITY                    , "Clock Identity"},
351     {PTP_MM_INITIALIZE_CLOCK                  , "Initialize Clock"},
352     {PTP_MM_SET_SUBDOMAIN                     , "Set Subdomain"},
353     {PTP_MM_CLEAR_DESIGNATED_PREFERRED_MASTER , "Clear Designated Preferred Master"},
354     {PTP_MM_SET_DESIGNATED_PREFERRED_MASTER   , "Set Designated Preferred Master"},
355     {PTP_MM_GET_DEFAULT_DATA_SET              , "Get Default Data Set"},
356     {PTP_MM_DEFAULT_DATA_SET                  , "Default Data Set"},
357     {PTP_MM_UPDATE_DEFAULT_DATA_SET           , "Update Default Data Set"},
358     {PTP_MM_GET_CURRENT_DATA_SET              , "Get Current Data Set"},
359     {PTP_MM_CURRENT_DATA_SET                  , "Current Data Set"},
360     {PTP_MM_GET_PARENT_DATA_SET               , "Get Parent Data Set"},
361     {PTP_MM_PARENT_DATA_SET                   , "Parent Data Set"},
362     {PTP_MM_GET_PORT_DATA_SET                 , "Get Port Data Set"},
363     {PTP_MM_PORT_DATA_SET                     , "Port Data Set"},
364     {PTP_MM_GET_GLOBAL_TIME_DATA_SET          , "Get Global Time Data Set"},
365     {PTP_MM_GLOBAL_TIME_DATA_SET              , "Global Time Data Set"},
366     {PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES     , "Update Global Time Properties"},
367     {PTP_MM_GOTO_FAULTY_STATE                 , "Goto Faulty State"},
368     {PTP_MM_GET_FOREIGN_DATA_SET              , "Get Foreign Data Set"},
369     {PTP_MM_FOREIGN_DATA_SET                  , "Foreign Data Set"},
370     {PTP_MM_SET_SYNC_INTERVAL                 , "Set Sync Interval"},
371     {PTP_MM_DISABLE_PORT                      , "Disable Port"},
372     {PTP_MM_ENABLE_PORT                       , "Enable Port"},
373     {PTP_MM_DISABLE_BURST                     , "Disable Burst"},
374     {PTP_MM_ENABLE_BURST                      , "Enable Burst"},
375     {PTP_MM_SET_TIME                          , "Set Time"},
376     {0,              NULL          } };
377
378 /*END managementMessage definitions*/
379
380 /**********************************************************/
381 /* CommunicationId definitions                            */
382 /**********************************************************/
383 #define PTP_CLOSED                0
384 #define PTP_ETHER                 1
385 #define PTP_FFBUS                 4
386 #define PTP_PROFIBUS              5
387 #define PTP_LON                   6
388 #define PTP_DNET                  7
389 #define PTP_SDS                   8
390 #define PTP_CONTROLNET            9
391 #define PTP_CANOPEN              10
392 #define PTP_IEEE1394            243
393 #define PTP_IEEE802_11A         244
394 #define PTP_IEEE_WIRELESS       245
395 #define PTP_INFINIBAND          246
396 #define PTP_BLUETOOTH           247
397 #define PTP_IEEE802_15_1        248
398 #define PTP_IEEE1451_3          249
399 #define PTP_IEEE1451_5          250
400 #define PTP_USB                 251
401 #define PTP_ISA                 252
402 #define PTP_PCI                 253
403 #define PTP_VXI                 254
404 #define PTP_DEFAULT             255
405
406 static const value_string ptp_communicationid_vals[] = {
407     {PTP_CLOSED        , "Closed system outside the scope of this standard."},
408     {PTP_ETHER         , "IEEE 802.3 (Ethernet)"},
409     {PTP_FFBUS         , "FOUNDATION Fieldbus"},
410     {PTP_PROFIBUS      , "PROFIBUS"},
411     {PTP_LON           , "LonTalk"},
412     {PTP_DNET          , "DeviceNet"},
413     {PTP_SDS           , "SmartDistributedSystem"},
414     {PTP_CONTROLNET    , "ControlNet"},
415     {PTP_CANOPEN       , "CANopen"},
416     {PTP_IEEE1394      , "IEEE 1394"},
417     {PTP_IEEE802_11A   , "IEEE 802.11a"},
418     {PTP_IEEE_WIRELESS , "IEEE 802.11b"},
419     {PTP_INFINIBAND    , "InfiniBand"},
420     {PTP_BLUETOOTH     , "Bluetooth wireless"},
421     {PTP_IEEE802_15_1  , "IEEE 802.15.1"},
422     {PTP_IEEE1451_3    , "IEEE 1451.3"},
423     {PTP_IEEE1451_5    , "IEEE 1451.5"},
424     {PTP_USB           , "USB bus"},
425     {PTP_ISA           , "ISA bus"},
426     {PTP_PCI           , "PCI bus"},
427     {PTP_VXI           , "VXI bus"},
428     {PTP_DEFAULT       , "Default value"},
429     {0,              NULL          } };
430
431 /*END CommunicationId definitions*/
432
433 /**********************************************************/
434 /* PTP message types    (PTP_CONTROL field)               */
435 /**********************************************************/
436 #define PTP_SYNC_MESSAGE        0x00
437 #define PTP_DELAY_REQ_MESSAGE   0x01
438 #define PTP_FOLLOWUP_MESSAGE    0x02
439 #define PTP_DELAY_RESP_MESSAGE  0x03
440 #define PTP_MANAGEMENT_MESSAGE  0x04
441 #define PTP_OTHER_MESSAGE       0x05
442
443 static const value_string ptp_control_vals[] = {
444     {PTP_SYNC_MESSAGE       , "Sync Message"},
445     {PTP_DELAY_REQ_MESSAGE  , "Delay_Req Message"},
446     {PTP_FOLLOWUP_MESSAGE   , "Follow_Up Message"},
447     {PTP_DELAY_RESP_MESSAGE , "Delay_Resp Message"},
448     {PTP_MANAGEMENT_MESSAGE , "Management Message"},
449     {PTP_OTHER_MESSAGE      , "Other Message"},
450     {0,                       NULL          } };
451
452 /*END PTP message types*/
453
454 /**********************************************************/
455 /* Channel values for the PTP_MESSAGETYPE field           */
456 /**********************************************************/
457 #define PTP_MESSAGETYPE_EVENT   0x01
458 #define PTP_MESSAGETYPE_GENERAL 0x02
459
460 static const value_string ptp_messagetype_vals[] = {
461     {PTP_MESSAGETYPE_EVENT   , "Event Message"},
462     {PTP_MESSAGETYPE_GENERAL , "General Message"},
463     {0,              NULL          } };
464
465 /*END channel values for the PTP_MESSAGETYPE field*/
466
467 /* Channel values for boolean vals (FLAGS)*/
468
469 static const value_string ptp_bool_vals[] = {
470     {1, "True"},
471     {0, "False"},
472     {0,              NULL          }};
473
474 /**********************************************************/
475 /* Initialize the protocol and registered fields          */
476 /**********************************************************/
477
478 static int hf_ptp_versionptp = -1;
479 static int hf_ptp_versionnetwork = -1;
480 static int hf_ptp_subdomain = -1;
481 static int hf_ptp_messagetype = -1;
482 static int hf_ptp_sourcecommunicationtechnology = -1;
483 static int hf_ptp_sourceuuid = -1;
484 static int hf_ptp_sourceportid = -1;
485 static int hf_ptp_sequenceid = -1;
486 static int hf_ptp_control = -1;
487 static int hf_ptp_flags = -1;
488 static int hf_ptp_flags_li61 = -1;
489 static int hf_ptp_flags_li59 = -1;
490 static int hf_ptp_flags_boundary_clock = -1;
491 static int hf_ptp_flags_assist = -1;
492 static int hf_ptp_flags_ext_sync = -1;
493 static int hf_ptp_flags_parent = -1;
494 static int hf_ptp_flags_sync_burst = -1;
495
496 /*Fields for ptp_sync and delay_req (=sdr) messages*/
497 static int hf_ptp_sdr_origintimestamp = -1; /*Field for seconds & nanoseconds*/
498 static int hf_ptp_sdr_origintimestamp_seconds = -1;
499 static int hf_ptp_sdr_origintimestamp_nanoseconds = -1;
500 static int hf_ptp_sdr_epochnumber = -1;
501 static int hf_ptp_sdr_currentutcoffset = -1;
502 static int hf_ptp_sdr_grandmastercommunicationtechnology = -1;
503 static int hf_ptp_sdr_grandmasterclockuuid = -1;
504 static int hf_ptp_sdr_grandmasterportid = -1;
505 static int hf_ptp_sdr_grandmastersequenceid = -1;
506 static int hf_ptp_sdr_grandmasterclockstratum = -1;
507 static int hf_ptp_sdr_grandmasterclockidentifier = -1;
508 static int hf_ptp_sdr_grandmasterclockvariance = -1;
509 static int hf_ptp_sdr_grandmasterpreferred = -1;
510 static int hf_ptp_sdr_grandmasterisboundaryclock = -1;
511 static int hf_ptp_sdr_syncinterval = -1;
512 static int hf_ptp_sdr_localclockvariance = -1;
513 static int hf_ptp_sdr_localstepsremoved = -1;
514 static int hf_ptp_sdr_localclockstratum = -1;
515 static int hf_ptp_sdr_localclockidentifier = -1;
516 static int hf_ptp_sdr_parentcommunicationtechnology = -1;
517 static int hf_ptp_sdr_parentuuid = -1;
518 static int hf_ptp_sdr_parentportfield = -1;
519 static int hf_ptp_sdr_estimatedmastervariance = -1;
520 static int hf_ptp_sdr_estimatedmasterdrift = -1;
521 static int hf_ptp_sdr_utcreasonable = -1;
522
523 /*Fields for follow_up (=fu) messages*/
524 static int hf_ptp_fu_associatedsequenceid = -1;
525 static int hf_ptp_fu_preciseorigintimestamp = -1;
526 static int hf_ptp_fu_preciseorigintimestamp_seconds = -1;
527 static int hf_ptp_fu_preciseorigintimestamp_nanoseconds = -1;
528
529 /*Fields for delay_resp (=dr) messages*/
530 static int hf_ptp_dr_delayreceipttimestamp = -1;
531 static int hf_ptp_dr_delayreceipttimestamp_seconds = -1;
532 static int hf_ptp_dr_delayreceipttimestamp_nanoseconds = -1;
533 static int hf_ptp_dr_requestingsourcecommunicationtechnology = -1;
534 static int hf_ptp_dr_requestingsourceuuid = -1;
535 static int hf_ptp_dr_requestingsourceportid = -1;
536 static int hf_ptp_dr_requestingsourcesequenceid = -1;
537
538 /*Fields for management (=mm) messages*/
539 static int hf_ptp_mm_targetcommunicationtechnology = -1;
540 static int hf_ptp_mm_targetuuid = -1;
541 static int hf_ptp_mm_targetportid = -1;
542 static int hf_ptp_mm_startingboundaryhops = -1;
543 static int hf_ptp_mm_boundaryhops = -1;
544 static int hf_ptp_mm_managementmessagekey = -1;
545 static int hf_ptp_mm_parameterlength = -1;
546     /*parameterlength > 0*/
547 static int hf_ptp_mm_messageparameters = -1;
548     /*ptp_mm_clock_identity (parameterlength = 64)*/
549 static int hf_ptp_mm_clock_identity_clockcommunicationtechnology = -1;
550 static int hf_ptp_mm_clock_identity_clockuuidfield = -1;
551 static int hf_ptp_mm_clock_identity_clockportfield = -1;
552 static int hf_ptp_mm_clock_identity_manufactureridentity = -1;
553
554     /*ptp_mm_initialize_clock (parameterlength = 4)*/
555 static int hf_ptp_mm_initialize_clock_initialisationkey = -1;
556
557     /*ptp_mm_set_subdomain (parameterlength = 16)*/
558 static int hf_ptp_mm_set_subdomain_subdomainname = -1;
559
560     /*ptp_mm_default_data_set (parameterlength = 76)*/
561 static int hf_ptp_mm_default_data_set_clockcommunicationtechnology = -1;
562 static int hf_ptp_mm_default_data_set_clockuuidfield = -1;
563 static int hf_ptp_mm_default_data_set_clockportfield = -1;
564 static int hf_ptp_mm_default_data_set_clockstratum = -1;
565 static int hf_ptp_mm_default_data_set_clockidentifier = -1;
566 static int hf_ptp_mm_default_data_set_clockvariance = -1;
567 static int hf_ptp_mm_default_data_set_clockfollowupcapable = -1;
568 static int hf_ptp_mm_default_data_set_preferred = -1;
569 static int hf_ptp_mm_default_data_set_initializable = -1;
570 static int hf_ptp_mm_default_data_set_externaltiming = -1;
571 static int hf_ptp_mm_default_data_set_isboundaryclock = -1;
572 static int hf_ptp_mm_default_data_set_syncinterval = -1;
573 static int hf_ptp_mm_default_data_set_subdomainname = -1;
574 static int hf_ptp_mm_default_data_set_numberports = -1;
575 static int hf_ptp_mm_default_data_set_numberforeignrecords = -1;
576
577     /*ptp_mm_update_default_data_set (parameterlength = 36)*/
578 static int hf_ptp_mm_update_default_data_set_clockstratum = -1;
579 static int hf_ptp_mm_update_default_data_set_clockidentifier = -1;
580 static int hf_ptp_mm_update_default_data_set_clockvariance = -1;
581 static int hf_ptp_mm_update_default_data_set_preferred = -1;
582 static int hf_ptp_mm_update_default_data_set_syncinterval = -1;
583 static int hf_ptp_mm_update_default_data_set_subdomainname = -1;
584
585     /*ptp_mm_current_data_set (parameterlength = 20)*/
586 static int hf_ptp_mm_current_data_set_stepsremoved = -1;
587 static int hf_ptp_mm_current_data_set_offsetfrommaster = -1;
588 static int hf_ptp_mm_current_data_set_offsetfrommasterseconds = -1;
589 static int hf_ptp_mm_current_data_set_offsetfrommasternanoseconds = -1;
590 static int hf_ptp_mm_current_data_set_onewaydelay = -1;
591 static int hf_ptp_mm_current_data_set_onewaydelayseconds = -1;
592 static int hf_ptp_mm_current_data_set_onewaydelaynanoseconds = -1;
593
594     /*ptp_mm_parent_data_set (parameterlength = 90)*/
595 static int hf_ptp_mm_parent_data_set_parentcommunicationtechnology = -1;
596 static int hf_ptp_mm_parent_data_set_parentuuid = -1;
597 static int hf_ptp_mm_parent_data_set_parentportid = -1;
598 static int hf_ptp_mm_parent_data_set_parentlastsyncsequencenumber = -1;
599 static int hf_ptp_mm_parent_data_set_parentfollowupcapable = -1;
600 static int hf_ptp_mm_parent_data_set_parentexternaltiming = -1;
601 static int hf_ptp_mm_parent_data_set_parentvariance = -1;
602 static int hf_ptp_mm_parent_data_set_parentstats = -1;
603 static int hf_ptp_mm_parent_data_set_observedvariance = -1;
604 static int hf_ptp_mm_parent_data_set_observeddrift = -1;
605 static int hf_ptp_mm_parent_data_set_utcreasonable = -1;
606 static int hf_ptp_mm_parent_data_set_grandmastercommunicationtechnology = -1;
607 static int hf_ptp_mm_parent_data_set_grandmasteruuidfield = -1;
608 static int hf_ptp_mm_parent_data_set_grandmasterportidfield = -1;
609 static int hf_ptp_mm_parent_data_set_grandmasterstratum = -1;
610 static int hf_ptp_mm_parent_data_set_grandmasteridentifier = -1;
611 static int hf_ptp_mm_parent_data_set_grandmastervariance = -1;
612 static int hf_ptp_mm_parent_data_set_grandmasterpreferred = -1;
613 static int hf_ptp_mm_parent_data_set_grandmasterisboundaryclock = -1;
614 static int hf_ptp_mm_parent_data_set_grandmastersequencenumber = -1;
615
616     /*ptp_mm_port_data_set (parameterlength = 52)*/
617 static int hf_ptp_mm_port_data_set_returnedportnumber = -1;
618 static int hf_ptp_mm_port_data_set_portstate = -1;
619 static int hf_ptp_mm_port_data_set_lastsynceventsequencenumber = -1;
620 static int hf_ptp_mm_port_data_set_lastgeneraleventsequencenumber = -1;
621 static int hf_ptp_mm_port_data_set_portcommunicationtechnology = -1;
622 static int hf_ptp_mm_port_data_set_portuuidfield = -1;
623 static int hf_ptp_mm_port_data_set_portidfield = -1;
624 static int hf_ptp_mm_port_data_set_burstenabled = -1;
625 static int hf_ptp_mm_port_data_set_subdomainaddressoctets = -1;
626 static int hf_ptp_mm_port_data_set_eventportaddressoctets = -1;
627 static int hf_ptp_mm_port_data_set_generalportaddressoctets = -1;
628 static int hf_ptp_mm_port_data_set_subdomainaddress = -1;
629 static int hf_ptp_mm_port_data_set_eventportaddress = -1;
630 static int hf_ptp_mm_port_data_set_generalportaddress = -1;
631
632     /*ptp_mm_global_time_data_set (parameterlength = 24)*/
633 static int hf_ptp_mm_global_time_data_set_localtime = -1;
634 static int hf_ptp_mm_global_time_data_set_localtimeseconds = -1;
635 static int hf_ptp_mm_global_time_data_set_localtimenanoseconds = -1;
636 static int hf_ptp_mm_global_time_data_set_currentutcoffset = -1;
637 static int hf_ptp_mm_global_time_data_set_leap59 = -1;
638 static int hf_ptp_mm_global_time_data_set_leap61 = -1;
639 static int hf_ptp_mm_global_time_data_set_epochnumber = -1;
640
641     /*ptp_mm_update_global_time_properties (parameterlength = 16)*/
642 static int hf_ptp_mm_update_global_time_properties_currentutcoffset = -1;
643 static int hf_ptp_mm_update_global_time_properties_leap59 = -1;
644 static int hf_ptp_mm_update_global_time_properties_leap61 = -1;
645 static int hf_ptp_mm_update_global_time_properties_epochnumber = -1;
646
647     /*ptp_mm_get_foreign_data_set (parameterlength = 4)*/
648 static int hf_ptp_mm_get_foreign_data_set_recordkey = -1;
649
650     /*ptp_mm_foreign_data_set (parameterlength = 28)*/
651 static int hf_ptp_mm_foreign_data_set_returnedportnumber = -1;
652 static int hf_ptp_mm_foreign_data_set_returnedrecordnumber = -1;
653 static int hf_ptp_mm_foreign_data_set_foreignmastercommunicationtechnology = -1;
654 static int hf_ptp_mm_foreign_data_set_foreignmasteruuidfield = -1;
655 static int hf_ptp_mm_foreign_data_set_foreignmasterportidfield = -1;
656 static int hf_ptp_mm_foreign_data_set_foreignmastersyncs = -1;
657
658     /*ptp_mm_set_sync_interval (parameterlength = 4)*/
659 static int hf_ptp_mm_set_sync_interval_syncinterval = -1;
660
661     /*ptp_mm_set_time (parameterlength = 8)*/
662 static int hf_ptp_mm_set_time_localtime = -1;
663 static int hf_ptp_mm_set_time_localtimeseconds = -1;
664 static int hf_ptp_mm_set_time_localtimenanoseconds = -1;
665
666 /*END Initialize the protocol and registered fields */
667
668 /* Initialize the subtree pointers */
669 static gint ett_ptp = -1;
670 static gint ett_ptp_flags = -1;
671 static gint ett_ptp_time = -1;
672 static gint ett_ptp_time2 = -1;
673
674 /* END Definitions and fields for PTPv1 dissection. */
675
676
677
678
679
680 /***********************************************************************************/
681 /* Definitions and fields for PTPv2 dissection.                                    */
682 /***********************************************************************************/
683
684
685 /**********************************************************/
686 /* Offsets of fields within a PTPv2 packet.               */
687 /**********************************************************/
688
689 /*Common offsets for all Messages (Sync, Delay_Req, Follow_Up, Delay_Resp ....)*/
690 #define PTP_V2_TRANSPORT_SPECIFIC_MESSAGE_ID_OFFSET                  0
691 #define PTP_V2_VERSIONPTP_OFFSET                                     1
692 #define PTP_V2_MESSAGE_LENGTH_OFFSET                                 2
693 #define PTP_V2_DOMAIN_NUMBER_OFFSET                                  4
694 #define PTP_V2_FLAGS_OFFSET                                          6
695 #define PTP_V2_CORRECTION_OFFSET                                     8
696 #define PTP_V2_CORRECTIONNS_OFFSET                                   8
697 #define PTP_V2_CORRECTIONSUBNS_OFFSET                               14
698 #define PTP_V2_CLOCKIDENTITY_OFFSET                                 20
699 #define PTP_V2_SOURCEPORTID_OFFSET                                  28
700 #define PTP_V2_SEQUENCEID_OFFSET                                    30
701 #define PTP_V2_CONTROL_OFFSET                                       32
702 #define PTP_V2_LOGMESSAGEPERIOD_OFFSET                              33
703
704
705 /*Offsets for PTP_Announce (=AN) messages*/
706 #define PTP_V2_AN_ORIGINTIMESTAMP_OFFSET                            34
707 #define PTP_V2_AN_ORIGINTIMESTAMPSECONDS_OFFSET                     34
708 #define PTP_V2_AN_ORIGINTIMESTAMPNANOSECONDS_OFFSET                 40
709 #define PTP_V2_AN_ORIGINCURRENTUTCOFFSET_OFFSET                     44
710 #define PTP_V2_AN_PRIORITY_1_OFFSET                                 47
711 #define PTP_V2_AN_GRANDMASTERCLOCKCLASS_OFFSET                      48
712 #define PTP_V2_AN_GRANDMASTERCLOCKACCURACY_OFFSET                   49
713 #define PTP_V2_AN_GRANDMASTERCLOCKVARIANCE_OFFSET                   50
714 #define PTP_V2_AN_PRIORITY_2_OFFSET                                 52
715 #define PTP_V2_AN_GRANDMASTERCLOCKIDENTITY_OFFSET                   53
716 #define PTP_V2_AN_LOCALSTEPSREMOVED_OFFSET                          61
717 #define PTP_V2_AN_TIMESOURCE_OFFSET                                 63
718 #define PTP_V2_AN_TLV_OFFSET                                        64
719
720 /* Announce TLV field offsets */
721 #define PTP_V2_AN_TLV_TYPE_OFFSET                                    0
722 #define PTP_V2_AN_TLV_LENGTHFIELD_OFFSET                             2
723
724 /* PTP_V2_TLV_TYPE_ALTERNATE_TIME_OFFSET_INDICATOR field offsets */
725 #define PTP_V2_AN_TLV_ATOI_KEYFIELD_OFFSET                           4
726 #define PTP_V2_AN_TLV_ATOI_CURRENTOFFSET_OFFSET                      5
727 #define PTP_V2_AN_TLV_ATOI_JUMPSECONDS_OFFSET                        9
728 #define PTP_V2_AN_TLV_ATOI_TIMEOFNEXTJUMP_OFFSET                    13
729 #define PTP_V2_AN_TLV_ATOI_DISPLAYNAME_OFFSET                       19
730
731 /* Undissected TLV field offset */
732 #define PTP_V2_AN_TLV_DATA_OFFSET                                    4
733
734 /* 802.1AS Path Sequence Offset */
735 #define PTP_AS_AN_TLV_PATH_TRACE_OFFSET                              4
736
737 /*Offsets for PTP_Sync AND PTP_DelayRequest (=SDR) messages*/
738 #define PTP_V2_SDR_ORIGINTIMESTAMP_OFFSET                           34
739 #define PTP_V2_SDR_ORIGINTIMESTAMPSECONDS_OFFSET                    34
740 #define PTP_V2_SDR_ORIGINTIMESTAMPNANOSECONDS_OFFSET                40
741
742 /*Offsets for PTP_Follow_Up (=FU) messages*/
743 #define PTP_V2_FU_PRECISEORIGINTIMESTAMP_OFFSET                     34
744 #define PTP_V2_FU_PRECISEORIGINTIMESTAMPSECONDS_OFFSET              34
745 #define PTP_V2_FU_PRECISEORIGINTIMESTAMPNANOSECONDS_OFFSET          40
746
747 /* 802.1AS Follow_Up information TLV */
748 #define PTP_AS_FU_TLV_INFORMATION_OFFSET                            44
749
750 /* 802.1AS Follow_Up TLV field offsets */
751 #define PTP_AS_FU_TLV_TYPE_OFFSET                                    0
752 #define PTP_AS_FU_TLV_LENGTHFIELD_OFFSET                             2
753 #define PTP_AS_FU_TLV_ORGANIZATIONID_OFFSET                          4
754 #define PTP_AS_FU_TLV_ORGANIZATIONSUBTYPE_OFFSET                     7
755 #define PTP_AS_FU_TLV_CUMULATIVESCALEDRATEOFFSET_OFFSET             10
756 #define PTP_AS_FU_TLV_GMTIMEBASEINDICATOR_OFFSET                    14
757 #define PTP_AS_FU_TLV_LASTGMPHASECHANGE_OFFSET                      16
758 #define PTP_AS_FU_TLV_SCALEDLASTGMFREQCHANGE_OFFSET                 28
759
760 /*Offsets for PTP_DelayResponse (=DR) messages*/
761 #define PTP_V2_DR_RECEIVETIMESTAMP_OFFSET                           34
762 #define PTP_V2_DR_RECEIVETIMESTAMPSECONDS_OFFSET                    34
763 #define PTP_V2_DR_RECEIVETIMESTAMPNANOSECONDS_OFFSET                40
764 #define PTP_V2_DR_REQUESTINGPORTIDENTITY_OFFSET                     44
765 #define PTP_V2_DR_REQUESTINGSOURCEPORTID_OFFSET                     52
766
767 /*Offsets for PTP_PDelayRequest (=PDRQ) messages*/
768 #define PTP_V2_PDRQ_ORIGINTIMESTAMP_OFFSET                          34
769 #define PTP_V2_PDRQ_ORIGINTIMESTAMPSECONDS_OFFSET                   34
770 #define PTP_V2_PDRQ_ORIGINTIMESTAMPNANOSECONDS_OFFSET               40
771 #define PTP_V2_PDRQ_RESERVED_OFFSET                                 44
772
773 /*Offsets for PTP_PDelayResponse (=PDRS) messages*/
774 #define PTP_V2_PDRS_REQUESTRECEIPTTIMESTAMP_OFFSET                  34
775 #define PTP_V2_PDRS_REQUESTRECEIPTTIMESTAMPSECONDS_OFFSET           34
776 #define PTP_V2_PDRS_REQUESTRECEIPTTIMESTAMPNANOSECONDS_OFFSET       40
777 #define PTP_V2_PDRS_REQUESTINGPORTIDENTITY_OFFSET                   44 /* ++ */
778 #define PTP_V2_PDRS_REQUESTINGSOURCEPORTID_OFFSET                   52 /* ++ */
779
780
781 /*Offsets for PTP_PDelayResponseFollowUp (=PDFU) messages*/
782 #define PTP_V2_PDFU_RESPONSEORIGINTIMESTAMP_OFFSET                  34
783 #define PTP_V2_PDFU_RESPONSEORIGINTIMESTAMPSECONDS_OFFSET           34
784 #define PTP_V2_PDFU_RESPONSEORIGINTIMESTAMPNANOSECONDS_OFFSET       40
785 #define PTP_V2_PDFU_REQUESTINGPORTIDENTITY_OFFSET                   44 /* ++ */
786 #define PTP_V2_PDFU_REQUESTINGSOURCEPORTID_OFFSET                   52
787
788
789 /*Offsets for PTP_Signalling (=SIG) messages*/
790 #define PTP_V2_SIG_TARGETPORTIDENTITY_OFFSET                        34
791 #define PTP_V2_SIG_TARGETPORTID_OFFSET                              42
792
793 /* 802.1AS Signalling Message Interval Request TLV */
794 #define PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET                44
795
796 /* 802.1AS Signalling TLV field offsets */
797 #define PTP_AS_SIG_TLV_TYPE_OFFSET                                   0
798 #define PTP_AS_SIG_TLV_LENGTHFIELD_OFFSET                            2
799 #define PTP_AS_SIG_TLV_ORGANIZATIONID_OFFSET                         4
800 #define PTP_AS_SIG_TLV_ORGANIZATIONSUBTYPE_OFFSET                    7
801 #define PTP_AS_SIG_TLV_LINKDELAYINTERVAL_OFFSET                     10
802 #define PTP_AS_SIG_TLV_TIMESYNCINTERVAL_OFFSET                      11
803 #define PTP_AS_SIG_TLV_ANNOUNCEINTERVAL_OFFSET                      12
804 #define PTP_AS_SIG_TLV_FLAGS_OFFSET                                 13
805
806 /**********************************************************/
807 /* Message Interval Request flag-field-mask-definitions   */
808 /**********************************************************/
809 #define PTP_AS_FLAGS_COMP_NEIGHBOR_RATE_RATIO_BITMASK           0x0002
810 #define PTP_AS_FLAGS_COMP_NEIGHBOR_PROP_DELAY_BITMASK           0x0004
811
812 /*Offsets for PTP_V2_Management (=MM) messages*/
813 #define PTP_V2_MM_TARGETPORTIDENTITY_OFFSET             34
814 #define PTP_V2_MM_TARGETPORTID_OFFSET                   42
815 #define PTP_V2_MM_STARTINGBOUNDARYHOPS_OFFSET           44
816 #define PTP_V2_MM_BOUNDARYHOPS_OFFSET                   45
817 #define PTP_V2_MM_ACTION_OFFSET                         46
818 #define PTP_V2_MM_RESERVED_OFFSET                       47
819
820 #define PTP_V2_MM_MANAGEMENTTLV_OFFSET                  48
821 /* Management TLV */
822 #define PTP_V2_MM_TLV_TYPE_OFFSET                       48
823 #define PTP_V2_MM_TLV_LENGTHFIELD_OFFSET                50
824 #define PTP_V2_MM_TLV_MANAGEMENTID_OFFSET               52
825 #define PTP_V2_MM_TLV_MANAGEMENTERRORID_OFFSET          52
826 #define PTP_V2_MM_TLV_DATAFIELD_OFFSET                  54
827
828 /* TLV Types */
829 #define PTP_V2_TLV_TYPE_RESERVED                                0x0000
830 #define PTP_V2_TLV_TYPE_MANAGEMENT                              0x0001
831 #define PTP_V2_TLV_TYPE_MANAGEMENT_ERROR_STATUS                 0x0002
832 #define PTP_V2_TLV_TYPE_ORGANIZATION_EXTENSION                  0x0003
833 #define PTP_V2_TLV_TYPE_REQUEST_UNICAST_TRANSMISSION            0x0004
834 #define PTP_V2_TLV_TYPE_GRANT_UNICAST_TRANSMISSION              0x0005
835 #define PTP_V2_TLV_TYPE_CANCEL_UNICAST_TRANSMISSION             0x0006
836 #define PTP_V2_TLV_TYPE_ACKNOWLEDGE_CANCEL_UNICAST_TRANSMISSION 0x0007
837 #define PTP_V2_TLV_TYPE_PATH_TRACE                              0x0008
838 #define PTP_V2_TLV_TYPE_ALTERNATE_TIME_OFFSET_INDICATOR         0x0009
839 #define PTP_V2_TLV_TYPE_AUTHENTICATION                          0x2000
840 #define PTP_V2_TLV_TYPE_AUTHENTICATION_CHALLENGE                0x2001
841 #define PTP_V2_TLV_TYPE_SECURITY_ASSOCIATION_UPDATE             0x2002
842 #define PTP_V2_TLV_TYPE_CUM_FREQ_SCALE_FACTOR_OFFSET            0x2003
843
844 /* Signalling TLV Object IDs */
845 #define PTP_AS_TLV_OID_TYPE_802                               0x0080C2
846
847 /* PTPv2 Management clockType Boolean[16] Bits mask */
848 #define CLOCKTYPE_ORDINARY_CLOCK                                0x8000
849 #define CLOCKTYPE_BOUNDARY_CLOCK                                0x4000
850 #define CLOCKTYPE_P2P_TC                                        0x2000
851 #define CLOCKTYPE_E2E_TC                                        0x1000
852 #define CLOCKTYPE_MANAGEMENT_NODE                               0x0800
853 #define CLOCKTYPE_RESERVED                                      0x07FF
854
855 /* PTPv2 Management IDs */
856 #define PTP_V2_MM_ID_NULL_MANAGEMENT                            0x0000
857 #define PTP_V2_MM_ID_CLOCK_DESCRIPTION                          0x0001
858 #define PTP_V2_MM_ID_USER_DESCRIPTION                           0x0002
859 #define PTP_V2_MM_ID_SAVE_IN_NON_VOLATILE_STORAGE               0x0003
860 #define PTP_V2_MM_ID_RESET_NON_VOLATILE_STORAGE                 0x0004
861 #define PTP_V2_MM_ID_INITIALIZE                                 0x0005
862 #define PTP_V2_MM_ID_FAULT_LOG                                  0x0006
863 #define PTP_V2_MM_ID_FAULT_LOG_RESET                            0x0007
864 #define PTP_V2_MM_ID_DEFAULT_DATA_SET                           0x2000
865 #define PTP_V2_MM_ID_CURRENT_DATA_SET                           0x2001
866 #define PTP_V2_MM_ID_PARENT_DATA_SET                            0x2002
867 #define PTP_V2_MM_ID_TIME_PROPERTIES_DATA_SET                   0x2003
868 #define PTP_V2_MM_ID_PORT_DATA_SET                              0x2004
869 #define PTP_V2_MM_ID_PRIORITY1                                  0x2005
870 #define PTP_V2_MM_ID_PRIORITY2                                  0x2006
871 #define PTP_V2_MM_ID_DOMAIN                                     0x2007
872 #define PTP_V2_MM_ID_SLAVE_ONLY                                 0x2008
873 #define PTP_V2_MM_ID_LOG_ANNOUNCE_INTERVAL                      0x2009
874 #define PTP_V2_MM_ID_ANNOUNCE_RECEIPT_TIMEOUT                   0x200A
875 #define PTP_V2_MM_ID_LOG_SYNC_INTERVAL                          0x200B
876 #define PTP_V2_MM_ID_VERSION_NUMBER                             0x200C
877 #define PTP_V2_MM_ID_ENABLE_PORT                                0x200D
878 #define PTP_V2_MM_ID_DISABLE_PORT                               0x200E
879 #define PTP_V2_MM_ID_TIME                                       0x200F
880 #define PTP_V2_MM_ID_CLOCK_ACCURACY                             0x2010
881 #define PTP_V2_MM_ID_UTC_PROPERTIES                             0x2011
882 #define PTP_V2_MM_ID_TRACEABILITY_PROPERTIES                    0x2012
883 #define PTP_V2_MM_ID_TIMESCALE_PROPERTIES                       0x2013
884 #define PTP_V2_MM_ID_UNICAST_NEGOTIATION_ENABLE                 0x2014
885 #define PTP_V2_MM_ID_PATH_TRACE_LIST                            0x2015
886 #define PTP_V2_MM_ID_PATH_TRACE_ENABLE                          0x2016
887 #define PTP_V2_MM_ID_GRANDMASTER_CLUSTER_TABLE                  0x2017
888 #define PTP_V2_MM_ID_UNICAST_MASTER_TABLE                       0x2018
889 #define PTP_V2_MM_ID_UNICAST_MASTER_MAX_TABLE_SIZE              0x2019
890 #define PTP_V2_MM_ID_ACCEPTABLE_MASTER_TABLE                    0x201A
891 #define PTP_V2_MM_ID_ACCEPTABLE_MASTER_TABLE_ENABLED            0x201B
892 #define PTP_V2_MM_ID_ACCEPTABLE_MASTER_MAX_TABLE_SIZE           0x201C
893 #define PTP_V2_MM_ID_ALTERNATE_MASTER                           0x201D
894 #define PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_ENABLE               0x201E
895 #define PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_NAME                 0x201F
896 #define PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_MAX_KEY              0x2020
897 #define PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_PROPERTIES           0x2021
898 #define PTP_V2_MM_ID_TC_DEFAULT_DATA_SET                        0x4000
899 #define PTP_V2_MM_ID_TC_PORT_DATA_SET                           0x4001
900 #define PTP_V2_MM_ID_PRIMARY_DOMAIN                             0x4002
901 #define PTP_V2_MM_ID_DELAY_MECHANISM                            0x6000
902 #define PTP_V2_MM_ID_LOG_MIN_PDELAY_REQ_INTERVAL                0x6001
903
904 /* Management DataField for DefaultDS */
905 #define PTP_V2_MM_RESERVED1                             PTP_V2_MM_TLV_DATAFIELD_OFFSET + 1
906 #define PTP_V2_MM_NUMBERPORTS                           PTP_V2_MM_TLV_DATAFIELD_OFFSET + 2
907 #define PTP_V2_MM_PRIORITY1                             PTP_V2_MM_TLV_DATAFIELD_OFFSET + 4
908 #define PTP_V2_MM_CLOCKQUALITY                          PTP_V2_MM_TLV_DATAFIELD_OFFSET + 5
909 #define PTP_V2_MM_PRIORITY2                             PTP_V2_MM_TLV_DATAFIELD_OFFSET + 9
910 #define PTP_V2_MM_CLOCKIDENTITY                         PTP_V2_MM_TLV_DATAFIELD_OFFSET + 10
911 #define PTP_V2_MM_DOMAINNUMBER                          PTP_V2_MM_TLV_DATAFIELD_OFFSET + 18
912 #define PTP_V2_MM_RESERVED2                             PTP_V2_MM_TLV_DATAFIELD_OFFSET + 19
913
914 #define PTP_V2_TRANSPORTSPECIFIC_V1COMPATIBILITY_BITMASK              0x10
915
916 #define PTP_V2_TRANSPORTSPECIFIC_ASPACKET_BITMASK                     0x10
917
918
919 /**********************************************************/
920 /* flag-field-mask-definitions                            */
921 /**********************************************************/
922 #define PTP_V2_FLAGS_LI61_BITMASK                                   0x0001
923 #define PTP_V2_FLAGS_LI59_BITMASK                                   0x0002
924 #define PTP_V2_FLAGS_UTC_OFFSET_VALID_BITMASK                       0x0004
925 #define PTP_V2_FLAGS_PTP_TIMESCALE_BITMASK                          0x0008
926 #define PTP_V2_FLAGS_TIME_TRACEABLE_BITMASK                         0x0010
927 #define PTP_V2_FLAGS_FREQUENCY_TRACEABLE_BITMASK                    0x0020
928 #define PTP_V2_FLAGS_ALTERNATE_BITMASK                              0x0100
929 #define PTP_V2_FLAGS_TWO_STEP_BITMASK                               0x0200
930 #define PTP_V2_FLAGS_UNICAST_BITMASK                                0x0400
931 #define PTP_V2_FLAGS_SPECIFIC1_BITMASK                              0x2000
932 #define PTP_V2_FLAGS_SPECIFIC2_BITMASK                              0x4000
933 #define PTP_V2_FLAGS_SECURITY_BITMASK                               0x8000
934
935
936
937 /**********************************************************/
938 /* PTP v2 message ids   (ptp messageid field)             */
939 /**********************************************************/
940 #define PTP_V2_SYNC_MESSAGE                     0x00
941 #define PTP_V2_DELAY_REQ_MESSAGE                0x01
942 #define PTP_V2_PATH_DELAY_REQ_MESSAGE           0x02
943 #define PTP_V2_PATH_DELAY_RESP_MESSAGE          0x03
944 #define PTP_V2_FOLLOWUP_MESSAGE                 0x08
945 #define PTP_V2_DELAY_RESP_MESSAGE               0x09
946 #define PTP_V2_PATH_DELAY_FOLLOWUP_MESSAGE      0x0A
947 #define PTP_V2_ANNOUNCE_MESSAGE                 0x0B
948 #define PTP_V2_SIGNALLING_MESSAGE               0x0C
949 #define PTP_V2_MANAGEMENT_MESSAGE               0x0D
950
951
952 static const value_string ptp_v2_managementID_vals[] = {
953     {PTP_V2_MM_ID_NULL_MANAGEMENT                   ,"NULL_MANAGEMENT"},
954     {PTP_V2_MM_ID_CLOCK_DESCRIPTION                 ,"CLOCK_DESCRIPTION"},
955     {PTP_V2_MM_ID_USER_DESCRIPTION                  ,"USER_DESCRIPTION"},
956     {PTP_V2_MM_ID_SAVE_IN_NON_VOLATILE_STORAGE      ,"SAVE_IN_NON_VOLATILE_STORAGE"},
957     {PTP_V2_MM_ID_RESET_NON_VOLATILE_STORAGE        ,"RESET_NON_VOLATILE_STORAGE"},
958     {PTP_V2_MM_ID_INITIALIZE                        ,"INITIALIZE"},
959     {PTP_V2_MM_ID_FAULT_LOG                         ,"FAULT_LOG"},
960     {PTP_V2_MM_ID_FAULT_LOG_RESET                   ,"FAULT_LOG_RESET"},
961     {PTP_V2_MM_ID_DEFAULT_DATA_SET                  ,"DEFAULT_DATA_SET"},
962     {PTP_V2_MM_ID_CURRENT_DATA_SET                  ,"CURRENT_DATA_SET"},
963     {PTP_V2_MM_ID_PARENT_DATA_SET                   ,"PARENT_DATA_SET"},
964     {PTP_V2_MM_ID_TIME_PROPERTIES_DATA_SET          ,"TIME_PROPERTIES_DATA_SET"},
965     {PTP_V2_MM_ID_PORT_DATA_SET                     ,"PORT_DATA_SET"},
966     {PTP_V2_MM_ID_PRIORITY1                         ,"PRIORITY1"},
967     {PTP_V2_MM_ID_PRIORITY2                         ,"PRIORITY2"},
968     {PTP_V2_MM_ID_DOMAIN                            ,"DOMAIN"},
969     {PTP_V2_MM_ID_SLAVE_ONLY                        ,"SLAVE_ONLY"},
970     {PTP_V2_MM_ID_LOG_ANNOUNCE_INTERVAL             ,"LOG_ANNOUNCE_INTERVAL"},
971     {PTP_V2_MM_ID_ANNOUNCE_RECEIPT_TIMEOUT          ,"ANNOUNCE_RECEIPT_TIMEOUT"},
972     {PTP_V2_MM_ID_LOG_SYNC_INTERVAL                 ,"LOG_SYNC_INTERVAL"},
973     {PTP_V2_MM_ID_VERSION_NUMBER                    ,"VERSION_NUMBER"},
974     {PTP_V2_MM_ID_ENABLE_PORT                       ,"ENABLE_PORT"},
975     {PTP_V2_MM_ID_DISABLE_PORT                      ,"DISABLE_PORT"},
976     {PTP_V2_MM_ID_TIME                              ,"TIME"},
977     {PTP_V2_MM_ID_CLOCK_ACCURACY                    ,"CLOCK_ACCURACY"},
978     {PTP_V2_MM_ID_UTC_PROPERTIES                    ,"UTC_PROPERTIES"},
979     {PTP_V2_MM_ID_TRACEABILITY_PROPERTIES           ,"TRACEABILITY_PROPERTIES"},
980     {PTP_V2_MM_ID_TIMESCALE_PROPERTIES              ,"TIMESCALE_PROPERTIES"},
981     {PTP_V2_MM_ID_UNICAST_NEGOTIATION_ENABLE        ,"UNICAST_NEGOTIATION_ENABLE"},
982     {PTP_V2_MM_ID_PATH_TRACE_LIST                   ,"PATH_TRACE_LIST"},
983     {PTP_V2_MM_ID_PATH_TRACE_ENABLE                 ,"PATH_TRACE_ENABLE"},
984     {PTP_V2_MM_ID_GRANDMASTER_CLUSTER_TABLE         ,"GRANDMASTER_CLUSTER_TABLE"},
985     {PTP_V2_MM_ID_UNICAST_MASTER_TABLE              ,"UNICAST_MASTER_TABLE"},
986     {PTP_V2_MM_ID_UNICAST_MASTER_MAX_TABLE_SIZE     ,"UNICAST_MASTER_MAX_TABLE_SIZE"},
987     {PTP_V2_MM_ID_ACCEPTABLE_MASTER_TABLE           ,"ACCEPTABLE_MASTER_TABLE"},
988     {PTP_V2_MM_ID_ACCEPTABLE_MASTER_TABLE_ENABLED   ,"ACCEPTABLE_MASTER_TABLE_ENABLED"},
989     {PTP_V2_MM_ID_ACCEPTABLE_MASTER_MAX_TABLE_SIZE  ,"ACCEPTABLE_MASTER_MAX_TABLE_SIZE"},
990     {PTP_V2_MM_ID_ALTERNATE_MASTER                  ,"ALTERNATE_MASTER"},
991     {PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_ENABLE      ,"ALTERNATE_TIME_OFFSET_ENABLE"},
992     {PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_NAME        ,"ALTERNATE_TIME_OFFSET_NAME"},
993     {PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_MAX_KEY     ,"ALTERNATE_TIME_OFFSET_MAX_KEY"},
994     {PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_PROPERTIES  ,"ALTERNATE_TIME_OFFSET_PROPERTIES"},
995     {PTP_V2_MM_ID_TC_DEFAULT_DATA_SET               ,"TC_DEFAULT_DATA_SET"},
996     {PTP_V2_MM_ID_TC_PORT_DATA_SET                  ,"TC_PORT_DATA_SET"},
997     {PTP_V2_MM_ID_PRIMARY_DOMAIN                    ,"PRIMARY_DOMAIN"},
998     {PTP_V2_MM_ID_DELAY_MECHANISM                   ,"DELAY_MECHANISM"},
999     {PTP_V2_MM_ID_LOG_MIN_PDELAY_REQ_INTERVAL       ,"LOG_MIN_PDELAY_REQ_INTERVAL"},
1000     {0                                              ,NULL} };
1001
1002 /*same again but better readable text for info column*/
1003 static const value_string ptp_v2_managementID_infocolumn_vals[] = {
1004     {PTP_V2_MM_ID_NULL_MANAGEMENT                   ,"Null management"},
1005     {PTP_V2_MM_ID_CLOCK_DESCRIPTION                 ,"Clock description"},
1006     {PTP_V2_MM_ID_USER_DESCRIPTION                  ,"User description"},
1007     {PTP_V2_MM_ID_SAVE_IN_NON_VOLATILE_STORAGE      ,"Save in non volatile storage"},
1008     {PTP_V2_MM_ID_RESET_NON_VOLATILE_STORAGE        ,"Reset non volatile storage"},
1009     {PTP_V2_MM_ID_INITIALIZE                        ,"Initialize"},
1010     {PTP_V2_MM_ID_FAULT_LOG                         ,"Fault log"},
1011     {PTP_V2_MM_ID_FAULT_LOG_RESET                   ,"Fault log reset"},
1012     {PTP_V2_MM_ID_DEFAULT_DATA_SET                  ,"Default dataset"},
1013     {PTP_V2_MM_ID_CURRENT_DATA_SET                  ,"Current dataset"},
1014     {PTP_V2_MM_ID_PARENT_DATA_SET                   ,"Parent dataset"},
1015     {PTP_V2_MM_ID_TIME_PROPERTIES_DATA_SET          ,"Time properties dataset"},
1016     {PTP_V2_MM_ID_PORT_DATA_SET                     ,"Port dataset"},
1017     {PTP_V2_MM_ID_PRIORITY1                         ,"Priority 1"},
1018     {PTP_V2_MM_ID_PRIORITY2                         ,"Priority 2"},
1019     {PTP_V2_MM_ID_DOMAIN                            ,"Domain"},
1020     {PTP_V2_MM_ID_SLAVE_ONLY                        ,"Slave only"},
1021     {PTP_V2_MM_ID_LOG_ANNOUNCE_INTERVAL             ,"Log announce interval"},
1022     {PTP_V2_MM_ID_ANNOUNCE_RECEIPT_TIMEOUT          ,"Announce receipt timeout"},
1023     {PTP_V2_MM_ID_LOG_SYNC_INTERVAL                 ,"Log sync interval"},
1024     {PTP_V2_MM_ID_VERSION_NUMBER                    ,"Version number"},
1025     {PTP_V2_MM_ID_ENABLE_PORT                       ,"Enable port"},
1026     {PTP_V2_MM_ID_DISABLE_PORT                      ,"Disable port"},
1027     {PTP_V2_MM_ID_TIME                              ,"Time"},
1028     {PTP_V2_MM_ID_CLOCK_ACCURACY                    ,"Clock accuracy"},
1029     {PTP_V2_MM_ID_UTC_PROPERTIES                    ,"UTC properties"},
1030     {PTP_V2_MM_ID_TRACEABILITY_PROPERTIES           ,"Traceability properties"},
1031     {PTP_V2_MM_ID_TIMESCALE_PROPERTIES              ,"Timescale properties"},
1032     {PTP_V2_MM_ID_UNICAST_NEGOTIATION_ENABLE        ,"Unicast negotiation enable"},
1033     {PTP_V2_MM_ID_PATH_TRACE_LIST                   ,"Path trace list"},
1034     {PTP_V2_MM_ID_PATH_TRACE_ENABLE                 ,"Path trace enable"},
1035     {PTP_V2_MM_ID_GRANDMASTER_CLUSTER_TABLE         ,"Grandmaster cluster table"},
1036     {PTP_V2_MM_ID_UNICAST_MASTER_TABLE              ,"Unicast master table"},
1037     {PTP_V2_MM_ID_UNICAST_MASTER_MAX_TABLE_SIZE     ,"Unicast master max table size"},
1038     {PTP_V2_MM_ID_ACCEPTABLE_MASTER_TABLE           ,"Acceptable master table"},
1039     {PTP_V2_MM_ID_ACCEPTABLE_MASTER_TABLE_ENABLED   ,"Acceptable master table enabled"},
1040     {PTP_V2_MM_ID_ACCEPTABLE_MASTER_MAX_TABLE_SIZE  ,"Acceptable master max table size"},
1041     {PTP_V2_MM_ID_ALTERNATE_MASTER                  ,"Alternate master"},
1042     {PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_ENABLE      ,"Alternate time offset enable"},
1043     {PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_NAME        ,"Alternate time offset name"},
1044     {PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_MAX_KEY     ,"Alternate time offset max key"},
1045     {PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_PROPERTIES  ,"Alternate time offset properties"},
1046     {PTP_V2_MM_ID_TC_DEFAULT_DATA_SET               ,"Transparent clock default dataset"},
1047     {PTP_V2_MM_ID_TC_PORT_DATA_SET                  ,"Transparent clock port dataset"},
1048     {PTP_V2_MM_ID_PRIMARY_DOMAIN                    ,"Primary domain"},
1049     {PTP_V2_MM_ID_DELAY_MECHANISM                   ,"Delay mechanism"},
1050     {PTP_V2_MM_ID_LOG_MIN_PDELAY_REQ_INTERVAL       ,"Log min pdelay req. interval"},
1051     {0                                              , NULL} };
1052
1053 static const value_string ptp_v2_TLV_type_vals[] = {
1054     {PTP_V2_TLV_TYPE_RESERVED                       ,"Reserved"},
1055     {PTP_V2_TLV_TYPE_MANAGEMENT                     ,"Management"},
1056     {PTP_V2_TLV_TYPE_MANAGEMENT_ERROR_STATUS        ,"Management error status"},
1057     {PTP_V2_TLV_TYPE_ORGANIZATION_EXTENSION         ,"Organization extension"},
1058     {PTP_V2_TLV_TYPE_REQUEST_UNICAST_TRANSMISSION   ,"Request unicast transmission"},
1059     {PTP_V2_TLV_TYPE_GRANT_UNICAST_TRANSMISSION     ,"Grant unicast transmission"},
1060     {PTP_V2_TLV_TYPE_CANCEL_UNICAST_TRANSMISSION    ,"Cancel unicast transmission"},
1061     {PTP_V2_TLV_TYPE_ACKNOWLEDGE_CANCEL_UNICAST_TRANSMISSION    ,"Acknowledge cancel unicast transmission"},
1062     {PTP_V2_TLV_TYPE_PATH_TRACE                     ,"Path trace"},
1063     {PTP_V2_TLV_TYPE_ALTERNATE_TIME_OFFSET_INDICATOR,"Alternate time offset indicator"},
1064     {PTP_V2_TLV_TYPE_AUTHENTICATION                 ,"Authentication"},
1065     {PTP_V2_TLV_TYPE_AUTHENTICATION_CHALLENGE       ,"Authentication challenge"},
1066     {PTP_V2_TLV_TYPE_SECURITY_ASSOCIATION_UPDATE    ,"Security association update"},
1067     {PTP_V2_TLV_TYPE_CUM_FREQ_SCALE_FACTOR_OFFSET   ,"Cum. freq. scale factor offset"},
1068     {0                                              , NULL} };
1069
1070 static const value_string ptp_as_TLV_oid_vals[] = {
1071     {PTP_AS_TLV_OID_TYPE_802                        ,"IEEE 802"},
1072     {0                                              , NULL} };
1073
1074 static const value_string ptp2_networkProtocol_vals[] = {
1075     {0x0000,  "Reserved"},
1076     {0x0001,  "UDP/IPv4"},
1077     {0x0002,  "UDP/IPv6"},
1078     {0x0003,  "IEEE 802.3"},
1079     {0x0004,  "DeviceNet"},
1080     {0x0005,  "ControlNet"},
1081     {0x0006,  "PROFINET"},
1082     {0x0007,  "Reserved"},
1083     {0xFFFE,  "Unknown Protocol"},
1084     {0xFFFF,  "Reserved"},
1085     {0,              NULL          } };
1086
1087
1088 static const value_string ptp_v2_messageid_vals[] = {
1089     {PTP_V2_SYNC_MESSAGE,               "Sync Message"},
1090     {PTP_V2_DELAY_REQ_MESSAGE,          "Delay_Req Message"},
1091     {PTP_V2_PATH_DELAY_REQ_MESSAGE,     "Path_Delay_Req Message"},
1092     {PTP_V2_PATH_DELAY_RESP_MESSAGE,    "Path_Delay_Resp Message"},
1093     {PTP_V2_FOLLOWUP_MESSAGE,           "Follow_Up Message"},
1094     {PTP_V2_DELAY_RESP_MESSAGE,         "Delay_Resp Message"},
1095     {PTP_V2_PATH_DELAY_FOLLOWUP_MESSAGE,"Path_Delay_Resp_Follow_Up Message"},
1096     {PTP_V2_ANNOUNCE_MESSAGE,           "Announce Message"},
1097     {PTP_V2_SIGNALLING_MESSAGE,         "Signalling Message"},
1098     {PTP_V2_MANAGEMENT_MESSAGE,         "Management Message"},
1099     {0,                                  NULL }
1100 };
1101
1102 static const value_string ptp_v2_clockaccuracy_vals[] = {
1103     {0x20,  "The time is accurate to within 25 ns"},
1104     {0x21,  "The time is accurate to within 100 ns"},
1105     {0x22,  "The time is accurate to within 250 ns"},
1106     {0x23,  "The time is accurate to within 1 us"},
1107     {0x24,  "The time is accurate to within 2,5 us"},
1108     {0x25,  "The time is accurate to within 10 us"},
1109     {0x26,  "The time is accurate to within 25 us"},
1110     {0x27,  "The time is accurate to within 100 us"},
1111     {0x28,  "The time is accurate to within 250 us"},
1112     {0x29,  "The time is accurate to within 1 ms"},
1113     {0x2A,  "The time is accurate to within 2,5 ms"},
1114     {0x2B,  "The time is accurate to within 10 ms"},
1115     {0x2C,  "The time is accurate to within 25 ms"},
1116     {0x2D,  "The time is accurate to within 100 ms"},
1117     {0x2E,  "The time is accurate to within 250 ms"},
1118     {0x2F,  "The time is accurate to within 1 s"},
1119     {0x30,  "The time is accurate to within 10 s"},
1120     {0x31,  "The time is accurate to >10 s"},
1121     {0x32,  "reserved"},
1122     {0x80,  "For use by alternate PTP profiles"},
1123     {0xFE,  "Accuracy Unknown"},
1124     {0xFF,  "reserved"},
1125     {0,              NULL          }
1126 };
1127
1128 static const value_string ptp_v2_timesource_vals[] = {
1129     {0x10,  "ATOMIC_CLOCK"},
1130     {0x20,  "GPS"},
1131     {0x30,  "TERRESTRIAL_RADIO"},
1132     {0x40,  "PTP"},
1133     {0x50,  "NTP"},
1134     {0x60,  "HAND_SET"},
1135     {0x90,  "OTHER"},
1136     {0xA0,  "INTERNAL_OSCILLATOR"},
1137     {0xFF,  "reserved"},
1138     {0,              NULL          }
1139 };
1140
1141 static const value_string ptp_v2_mm_action_vals[] = {
1142     {0x0,  "GET"},
1143     {0x1,  "SET"},
1144     {0x2,  "RESPONSE"},
1145     {0x3,  "COMMAND"},
1146     {0x4,  "ACKNOWLEDGE"},
1147     {0,              NULL          }
1148 };
1149
1150 static const value_string ptp2_severityCode_vals[] = {
1151     {0x00,  "Emergency: system is unusable"},
1152     {0x01,  "Alert: immediate action needed"},
1153     {0x02,  "Critical: critical conditions"},
1154     {0x03,  "Error: error conditions"},
1155     {0x04,  "Warning: warning conditions"},
1156     {0x05,  "Notice: normal but significant condition"},
1157     {0x06,  "Informational: informational messages"},
1158     {0x07,  "Debug: debug-level messages"},
1159     {0x08,  "Reserved"},
1160     {0xFF,  "Reserved"},
1161     {0,      NULL}
1162 };
1163
1164 static const value_string ptp2_portState_vals[] = {
1165     {0x01,  "INITIALIZING"},
1166     {0x02,  "FAULTY"},
1167     {0x03,  "DISABLED"},
1168     {0x04,  "LISTENING"},
1169     {0x05,  "PRE_MASTER"},
1170     {0x06,  "MASTER"},
1171     {0x07,  "PASSIVE"},
1172     {0x08,  "UNCALIBRATED"},
1173     {0x09,  "SLAVE"},
1174     {0,     NULL}
1175 };
1176
1177 static const value_string ptp2_delayMechanism_vals[] = {
1178     {0x01,  "E2E"},
1179     {0x02,  "P2P"},
1180     {0xFE,  "DISABLED"},
1181     {0,     NULL}
1182 };
1183
1184 static const value_string ptp2_managementErrorId_vals[] = {
1185     {0x0000,  "Reserved"},
1186     {0x0001,  "RESPONSE_TOO_BIG"},
1187     {0x0002,  "NO_SUCH_ID"},
1188     {0x0003,  "WRONG_LENGTH"},
1189     {0x0004,  "WRONG_VALUE"},
1190     {0x0005,  "NOT_SETABLE"},
1191     {0x0006,  "NOT_SUPPORTED"},
1192     {0x0007,  "Reserved"},
1193     {0xFFFE,  "GENERAL_ERROR"},
1194     {0xFFFF,  "Reserved"},
1195     {0,     NULL}
1196 };
1197
1198 /**********************************************************/
1199 /* Initialize the protocol and registered fields          */
1200 /**********************************************************/
1201
1202 static int hf_ptp_v2_transportspecific = -1;
1203 static int hf_ptp_v2_transportspecific_v1_compatibility = -1; /* over UDP */
1204 static int hf_ptp_v2_transportspecific_802as_conform = -1; /* over Ethernet */
1205 static int hf_ptp_v2_messageid = -1;
1206 static int hf_ptp_v2_versionptp = -1;
1207 static int hf_ptp_v2_messagelength = -1;
1208 static int hf_ptp_v2_domainnumber = -1;
1209 static int hf_ptp_v2_flags = -1;
1210 static int hf_ptp_v2_flags_alternatemaster = -1;
1211 static int hf_ptp_v2_flags_twostep = -1;
1212 static int hf_ptp_v2_flags_unicast = -1;
1213 static int hf_ptp_v2_flags_specific1 = -1;
1214 static int hf_ptp_v2_flags_specific2 = -1;
1215 static int hf_ptp_v2_flags_security = -1;
1216 static int hf_ptp_v2_flags_li61 = -1;
1217 static int hf_ptp_v2_flags_li59 = -1;
1218 static int hf_ptp_v2_flags_utcoffsetvalid = -1;
1219 static int hf_ptp_v2_flags_ptptimescale = -1;
1220 static int hf_ptp_v2_flags_timetraceable = -1;
1221 static int hf_ptp_v2_flags_frequencytraceable = -1;
1222 static int hf_ptp_v2_correction = -1;
1223 static int hf_ptp_v2_correctionsubns = -1;
1224 static int hf_ptp_v2_clockidentity = -1;
1225 static int hf_ptp_v2_sourceportid = -1;
1226 static int hf_ptp_v2_sequenceid = -1;
1227 static int hf_ptp_v2_control = -1;
1228 static int hf_ptp_v2_logmessageperiod = -1;
1229
1230
1231 /*Fields for PTP_Announce (=an) messages*/
1232 static int hf_ptp_v2_an_origintimestamp = -1;   /*Field for seconds & nanoseconds*/
1233 static int hf_ptp_v2_an_origintimestamp_seconds = -1;
1234 static int hf_ptp_v2_an_origintimestamp_nanoseconds = -1;
1235 static int hf_ptp_v2_an_origincurrentutcoffset = -1;
1236 static int hf_ptp_v2_an_timesource = -1;
1237 static int hf_ptp_v2_an_localstepsremoved = -1;
1238 static int hf_ptp_v2_an_grandmasterclockidentity = -1;
1239 static int hf_ptp_v2_an_grandmasterclockclass = -1;
1240 static int hf_ptp_v2_an_grandmasterclockaccuracy = -1;
1241 static int hf_ptp_v2_an_grandmasterclockvariance = -1;
1242 static int hf_ptp_v2_an_priority1 = -1;
1243 static int hf_ptp_v2_an_priority2 = -1;
1244
1245 /* Fields for PTP_Announce TLVs */
1246 static int hf_ptp_v2_an_tlv_tlvtype = -1;
1247 static int hf_ptp_v2_an_tlv_lengthfield = -1;
1248 /* Fields for the ALTERNATE_TIME_OFFSET_INDICATOR TLV */
1249 static int hf_ptp_v2_atoi_tlv_keyfield = -1;
1250 static int hf_ptp_v2_atoi_tlv_currentoffset = -1;
1251 static int hf_ptp_v2_atoi_tlv_jumpseconds = -1;
1252 static int hf_ptp_v2_atoi_tlv_timeofnextjump = -1;
1253 static int hf_ptp_v2_atoi_tlv_displayname = -1;
1254 static int hf_ptp_v2_atoi_tlv_displayname_length = -1;
1255 /* Field for the PATH TRACE TLV */
1256 static int hf_ptp_v2_an_tlv_pathsequence = -1;
1257
1258 /* Fields for an undissected TLV */
1259 static int hf_ptp_v2_an_tlv_data = -1;
1260
1261 /*Fields for PTP_Sync AND PTP_DelayRequest (=sdr) messages*/
1262 static int hf_ptp_v2_sdr_origintimestamp = -1;  /*Field for seconds & nanoseconds*/
1263 static int hf_ptp_v2_sdr_origintimestamp_seconds = -1;
1264 static int hf_ptp_v2_sdr_origintimestamp_nanoseconds = -1;
1265
1266
1267 /*Fields for PTP_Follow_Up (=fu) messages*/
1268 static int hf_ptp_v2_fu_preciseorigintimestamp = -1;    /*Field for seconds & nanoseconds*/
1269 static int hf_ptp_v2_fu_preciseorigintimestamp_seconds = -1;
1270 static int hf_ptp_v2_fu_preciseorigintimestamp_nanoseconds = -1;
1271 /* Fields for the Follow_Up Information TLV */
1272 static int hf_ptp_as_fu_tlv_tlvtype = -1;
1273 static int hf_ptp_as_fu_tlv_lengthfield = -1;
1274 static int hf_ptp_as_fu_tlv_organization_id = -1;
1275 static int hf_ptp_as_fu_tlv_organization_subtype = -1;
1276 static int hf_ptp_as_fu_tlv_cumulative_offset = -1;
1277 static int hf_ptp_as_fu_tlv_gm_base_indicator = -1;
1278 static int hf_ptp_as_fu_tlv_last_gm_phase_change = -1;
1279 static int hf_ptp_as_fu_tlv_scaled_last_gm_phase_change = -1;
1280
1281 /*Fields for PTP_DelayResponse (=dr) messages*/
1282 static int hf_ptp_v2_dr_receivetimestamp = -1;  /*Field for seconds & nanoseconds*/
1283 static int hf_ptp_v2_dr_receivetimestamp_seconds = -1;
1284 static int hf_ptp_v2_dr_receivetimestamp_nanoseconds = -1;
1285 static int hf_ptp_v2_dr_requestingportidentity = -1;
1286 static int hf_ptp_v2_dr_requestingsourceportid = -1;
1287
1288
1289 /*Fields for PTP_PDelayRequest (=pdrq) messages*/
1290 static int hf_ptp_v2_pdrq_origintimestamp = -1; /*Field for seconds & nanoseconds*/
1291 static int hf_ptp_v2_pdrq_origintimestamp_seconds = -1;
1292 static int hf_ptp_v2_pdrq_origintimestamp_nanoseconds = -1;
1293
1294
1295 /*Fields for PTP_PDelayResponse (=pdrs) messages*/
1296 static int hf_ptp_v2_pdrs_requestreceipttimestamp = -1; /*Field for seconds & nanoseconds*/
1297 static int hf_ptp_v2_pdrs_requestreceipttimestamp_seconds = -1;
1298 static int hf_ptp_v2_pdrs_requestreceipttimestamp_nanoseconds = -1;
1299 static int hf_ptp_v2_pdrs_requestingportidentity = -1;
1300 static int hf_ptp_v2_pdrs_requestingsourceportid = -1;
1301
1302
1303 /*Fields for PTP_PDelayResponseFollowUp (=pdfu) messages*/
1304 static int hf_ptp_v2_pdfu_responseorigintimestamp = -1; /*Field for seconds & nanoseconds*/
1305 static int hf_ptp_v2_pdfu_responseorigintimestamp_seconds = -1;
1306 static int hf_ptp_v2_pdfu_responseorigintimestamp_nanoseconds = -1;
1307 static int hf_ptp_v2_pdfu_requestingportidentity = -1;
1308 static int hf_ptp_v2_pdfu_requestingsourceportid = -1;
1309
1310
1311 /*Fields for PTP_Signalling (=sig) messages*/
1312 static int hf_ptp_v2_sig_targetportidentity = -1;
1313 static int hf_ptp_v2_sig_targetportid = -1;
1314 /* Fields for the Message Interval Request TLV */
1315 static int hf_ptp_as_sig_tlv_tlvtype = -1;
1316 static int hf_ptp_as_sig_tlv_lengthfield = -1;
1317 static int hf_ptp_as_sig_tlv_organization_id = -1;
1318 static int hf_ptp_as_sig_tlv_organization_subtype = -1;
1319 static int hf_ptp_as_sig_tlv_link_delay_interval = -1;
1320 static int hf_ptp_as_sig_tlv_time_sync_interval = -1;
1321 static int hf_ptp_as_sig_tlv_announce_interval = -1;
1322 static int hf_ptp_as_sig_tlv_flags = -1;
1323 static int hf_ptp_as_sig_tlv_flags_comp_rate_ratio = -1;
1324 static int hf_ptp_as_sig_tlv_flags_comp_prop_delay = -1;
1325
1326 /*Fields for PTP_Management (=mm) messages*/
1327 static int hf_ptp_v2_mm_targetportidentity = -1;
1328 static int hf_ptp_v2_mm_targetportid = -1;
1329 static int hf_ptp_v2_mm_startingboundaryhops = -1;
1330 static int hf_ptp_v2_mm_boundaryhops = -1;
1331 static int hf_ptp_v2_mm_action = -1;
1332
1333 /* management TLV */
1334 static int hf_ptp_v2_mm_tlvType = -1;
1335 static int hf_ptp_v2_mm_lengthField = -1;
1336 static int hf_ptp_v2_mm_managementId = -1;
1337 static int hf_ptp_v2_mm_data = -1;
1338 /* Management dataField  */
1339
1340 static int hf_ptp_v2_mm_clockType = -1;
1341 static int hf_ptp_v2_mm_clockType_ordinaryClock = -1;
1342 static int hf_ptp_v2_mm_clockType_boundaryClock = -1;
1343 static int hf_ptp_v2_mm_clockType_p2p_transparentClock = -1;
1344 static int hf_ptp_v2_mm_clockType_e2e_transparentClock = -1;
1345 static int hf_ptp_v2_mm_clockType_managementNode = -1;
1346 static int hf_ptp_v2_mm_clockType_reserved = -1;
1347 static int hf_ptp_v2_mm_physicalLayerProtocol = -1;
1348 static int hf_ptp_v2_mm_physicalLayerProtocol_length = -1;
1349 static int hf_ptp_v2_mm_physicalAddressLength = -1;
1350 static int hf_ptp_v2_mm_physicalAddress = -1;
1351 static int hf_ptp_v2_mm_protocolAddress = -1;
1352 static int hf_ptp_v2_mm_protocolAddress_networkProtocol = -1;
1353 static int hf_ptp_v2_mm_protocolAddress_length = -1;
1354 static int hf_ptp_v2_mm_manufacturerIdentity = -1;
1355
1356 static int hf_ptp_v2_mm_reserved = -1;
1357 static int hf_ptp_v2_mm_productDescription = -1;
1358 static int hf_ptp_v2_mm_productDescription_length = -1;
1359 static int hf_ptp_v2_mm_revisionData = -1;
1360 static int hf_ptp_v2_mm_revisionData_length = -1;
1361 static int hf_ptp_v2_mm_userDescription = -1;
1362 static int hf_ptp_v2_mm_userDescription_length = -1;
1363 static int hf_ptp_v2_mm_profileIdentity = -1;
1364 static int hf_ptp_v2_mm_pad = -1;
1365
1366 static int hf_ptp_v2_mm_numberOfFaultRecords = -1;
1367 static int hf_ptp_v2_mm_faultRecord = -1;
1368
1369 static int hf_ptp_v2_mm_initializationKey = -1;
1370 static int hf_ptp_v2_mm_severityCode = -1;
1371 static int hf_ptp_v2_mm_faultRecordLength = -1;
1372 static int hf_ptp_v2_mm_faultTime = -1;
1373 static int hf_ptp_v2_mm_faultTime_s = -1;
1374 static int hf_ptp_v2_mm_faultTime_ns = -1;
1375 static int hf_ptp_v2_mm_faultValue = -1;
1376 static int hf_ptp_v2_mm_faultName = -1;
1377 static int hf_ptp_v2_mm_faultName_length = -1;
1378 static int hf_ptp_v2_mm_faultValue_length = -1;
1379 static int hf_ptp_v2_mm_faultDescription = -1;
1380 static int hf_ptp_v2_mm_faultDescription_length = -1;
1381 static int hf_ptp_v2_mm_currentTime_s = -1;
1382 static int hf_ptp_v2_mm_currentTime_ns = -1;
1383 static int hf_ptp_v2_mm_clockAccuracy = -1;
1384 static int hf_ptp_v2_mm_priority1 = -1;
1385 static int hf_ptp_v2_mm_priority2 = -1;
1386 static int hf_ptp_v2_mm_dds_SO = -1;
1387 static int hf_ptp_v2_mm_TSC = -1;
1388 static int hf_ptp_v2_mm_numberPorts = -1;
1389 static int hf_ptp_v2_mm_clockclass = -1;
1390 static int hf_ptp_v2_mm_clockaccuracy = -1;
1391 static int hf_ptp_v2_mm_clockvariance = -1;
1392 static int hf_ptp_v2_mm_clockidentity = -1;
1393 static int hf_ptp_v2_mm_domainNumber = -1;
1394 static int hf_ptp_v2_mm_SO = -1;
1395 static int hf_ptp_v2_mm_stepsRemoved = -1;
1396 static int hf_ptp_v2_mm_parentIdentity = -1;
1397 static int hf_ptp_v2_mm_parentPort = -1;
1398 static int hf_ptp_v2_mm_parentStats = -1;
1399 static int hf_ptp_v2_mm_observedParentOffsetScaledLogVariance = -1;
1400 static int hf_ptp_v2_mm_observedParentClockPhaseChangeRate = -1;
1401 static int hf_ptp_v2_mm_grandmasterPriority1 = -1;
1402 static int hf_ptp_v2_mm_grandmasterPriority2 = -1;
1403 static int hf_ptp_v2_mm_grandmasterclockclass = -1;
1404 static int hf_ptp_v2_mm_grandmasterclockaccuracy = -1;
1405 static int hf_ptp_v2_mm_grandmasterclockvariance = -1;
1406 static int hf_ptp_v2_mm_grandmasterIdentity = -1;
1407 static int hf_ptp_v2_mm_currentUtcOffset = -1;
1408 static int hf_ptp_v2_mm_LI_61 = -1;
1409 static int hf_ptp_v2_mm_LI_59 = -1;
1410 static int hf_ptp_v2_mm_UTCV = -1;
1411 static int hf_ptp_v2_mm_PTP = -1;
1412 static int hf_ptp_v2_mm_TTRA = -1;
1413 static int hf_ptp_v2_mm_FTRA = -1;
1414 static int hf_ptp_v2_mm_timesource = -1;
1415 static int hf_ptp_v2_mm_offset_ns = -1;
1416 static int hf_ptp_v2_mm_pathDelay_ns = -1;
1417 static int hf_ptp_v2_mm_offset_subns = -1;
1418 static int hf_ptp_v2_mm_pathDelay_subns = -1;
1419 static int hf_ptp_v2_mm_PortNumber = -1;
1420 static int hf_ptp_v2_mm_portState = -1;
1421 static int hf_ptp_v2_mm_logMinDelayReqInterval = -1;
1422 static int hf_ptp_v2_mm_peerMeanPathDelay_ns = -1;
1423 static int hf_ptp_v2_mm_peerMeanPathDelay_subns = -1;
1424 static int hf_ptp_v2_mm_logAnnounceInterval = -1;
1425 static int hf_ptp_v2_mm_announceReceiptTimeout = -1;
1426 static int hf_ptp_v2_mm_logSyncInterval = -1;
1427 static int hf_ptp_v2_mm_delayMechanism = -1;
1428 static int hf_ptp_v2_mm_logMinPdelayReqInterval = -1;
1429 static int hf_ptp_v2_mm_versionNumber = -1;
1430 static int hf_ptp_v2_mm_primaryDomain = -1;
1431 static int hf_ptp_v2_mm_faultyFlag = -1;
1432 static int hf_ptp_v2_mm_managementErrorId = -1;
1433 static int hf_ptp_v2_mm_displayData = -1;
1434 static int hf_ptp_v2_mm_displayData_length = -1;
1435 static int hf_ptp_v2_mm_ucEN = -1;
1436 static int hf_ptp_v2_mm_ptEN = -1;
1437 static int hf_ptp_v2_mm_atEN = -1;
1438 static int hf_ptp_v2_mm_keyField = -1;
1439 static int hf_ptp_v2_mm_displayName = -1;
1440 static int hf_ptp_v2_mm_displayName_length = -1;
1441 static int hf_ptp_v2_mm_maxKey = -1;
1442 static int hf_ptp_v2_mm_currentOffset = -1;
1443 static int hf_ptp_v2_mm_jumpSeconds = -1;
1444 static int hf_ptp_v2_mm_logAlternateMulticastSyncInterval = -1;
1445 static int hf_ptp_v2_mm_numberOfAlternateMasters = -1;
1446 static int hf_ptp_v2_mm_transmitAlternateMulticastSync = -1;
1447
1448 /* Initialize the subtree pointers */
1449 static gint ett_ptp_v2 = -1;
1450 static gint ett_ptp_v2_flags = -1;
1451 static gint ett_ptp_v2_correction = -1;
1452 static gint ett_ptp_v2_time = -1;
1453 static gint ett_ptp_v2_time2 = -1;
1454 static gint ett_ptp_v2_managementData = -1;
1455 static gint ett_ptp_v2_clockType = -1;
1456 static gint ett_ptp_v2_physicalLayerProtocol = -1;
1457 static gint ett_ptp_v2_protocolAddress = -1;
1458 static gint ett_ptp_v2_faultRecord = -1;
1459 static gint ett_ptp_v2_ptptext = -1;
1460 static gint ett_ptp_v2_timeInterval = -1;
1461 static gint ett_ptp_v2_tlv = -1;
1462 static gint ett_ptp_as_sig_tlv_flags = -1;
1463
1464 /* static gint ett_ptp_v2_timesource = -1;
1465 static gint ett_ptp_v2_priority = -1; */
1466 static gint ett_ptp_v2_transportspecific = -1;
1467
1468 /* For transport specific field  Ethernet or UDP */
1469 static gboolean ptpv2_oE = FALSE;
1470 /* END Definitions and fields for PTPv2 dissection. */
1471
1472
1473 /* forward declaration of local functions for v1 and v2 */
1474
1475 static void
1476 dissect_ptp_oE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
1477
1478 static int
1479 is_ptp_v1(tvbuff_t *tvb);
1480
1481 static void
1482 dissect_ptp_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
1483
1484 static gboolean
1485 is_ptp_v2(tvbuff_t *tvb);
1486
1487 static void
1488 dissect_ptp_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
1489
1490 /**********************************************************/
1491 /* Implementation of the functions                        */
1492 /**********************************************************/
1493
1494
1495 /* Code to dissect the packet */
1496
1497 static void
1498 dissect_ptp_oE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1499 {
1500     ptpv2_oE = TRUE;
1501     /* PTP over Ethernet only available with PTPv2 */
1502     dissect_ptp_v2(tvb, pinfo, tree);
1503 }
1504
1505 static void
1506 dissect_ptp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1507 {
1508     ptpv2_oE = FALSE;
1509     if(is_ptp_v1(tvb))
1510         dissect_ptp_v1(tvb, pinfo, tree);
1511     else if(is_ptp_v2(tvb))
1512         dissect_ptp_v2(tvb, pinfo, tree);
1513 }
1514
1515
1516 /* Code to check if packet is PTPv1 */
1517
1518 static gboolean
1519 is_ptp_v1(tvbuff_t *tvb)
1520 {
1521     guint16 version_ptp;
1522
1523     version_ptp = tvb_get_ntohs(tvb, PTP_VERSIONPTP_OFFSET);
1524
1525     if( version_ptp == 1) return TRUE;
1526     else return FALSE;
1527 }
1528
1529
1530 /* Code to check if packet is PTPv2 */
1531
1532 static gboolean
1533 is_ptp_v2(tvbuff_t *tvb)
1534 {
1535     guint8 version_ptp;
1536
1537     version_ptp = 0x0F & tvb_get_guint8(tvb, PTP_V2_VERSIONPTP_OFFSET);
1538
1539     if( version_ptp == 2) return TRUE;
1540     else return FALSE;
1541 }
1542
1543
1544 /* Code to actually dissect the PTPv1 packets */
1545
1546 static void
1547 dissect_ptp_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1548 {
1549     guint8  ptp_control, ptp_mm_messagekey = 0;
1550     nstime_t ts;    /*time structure with seconds and nanoseconds*/
1551
1552 /* Set up structures needed to add the protocol subtree and manage it */
1553     proto_item *ti, *flags_ti, *time_ti, *time2_ti;
1554     proto_tree *ptp_tree, *ptp_flags_tree, *ptp_time_tree, *ptp_time2_tree;
1555
1556 /* Make entries in Protocol column and Info column on summary display */
1557     col_set_str(pinfo->cinfo, COL_PROTOCOL, "PTPv1");
1558
1559
1560 /* Get control field (what kind of message is this? (Sync, DelayReq, ...) */
1561
1562     ptp_control = tvb_get_guint8 (tvb, PTP_CONTROL_OFFSET);
1563     /* MGMT packet? */
1564     if ( ptp_control == PTP_MANAGEMENT_MESSAGE ){
1565         /* Get the managementMessageKey */
1566         ptp_mm_messagekey = tvb_get_guint8(tvb, PTP_MM_MANAGEMENTMESSAGEKEY_OFFSET);
1567     }
1568
1569 /* Create and set the string for "Info" column */
1570     switch(ptp_control){
1571         case PTP_SYNC_MESSAGE:{
1572             col_set_str(pinfo->cinfo, COL_INFO, "Sync Message");
1573             break;
1574         }
1575         case PTP_DELAY_REQ_MESSAGE:{
1576             col_set_str(pinfo->cinfo, COL_INFO, "Delay_Request Message");
1577             break;
1578         }
1579         case PTP_FOLLOWUP_MESSAGE:{
1580             col_set_str(pinfo->cinfo, COL_INFO, "Follow_Up Message");
1581             break;
1582         }
1583         case PTP_DELAY_RESP_MESSAGE:{
1584             col_set_str(pinfo->cinfo, COL_INFO, "Delay_Response Message");
1585             break;
1586         }
1587         case PTP_MANAGEMENT_MESSAGE:{
1588             if (check_col(pinfo->cinfo, COL_INFO)){
1589                 col_add_fstr(pinfo->cinfo, COL_INFO, "Management Message (%s)",
1590                              val_to_str(ptp_mm_messagekey,
1591                                         ptp_managementMessageKey_infocolumn_vals,
1592                                         "Unknown message key %u"));
1593             }
1594             break;
1595         }
1596         default:{
1597             col_set_str(pinfo->cinfo, COL_INFO, "Unknown Message");
1598             break;
1599         }
1600     }
1601
1602     if (tree) {
1603
1604         /* create display subtree for the protocol */
1605         ti = proto_tree_add_item(tree, proto_ptp, tvb, 0, -1, FALSE);
1606
1607         ptp_tree = proto_item_add_subtree(ti, ett_ptp);
1608
1609         proto_tree_add_item(ptp_tree,
1610             hf_ptp_versionptp, tvb, PTP_VERSIONPTP_OFFSET, 2, FALSE);
1611
1612         proto_tree_add_item(ptp_tree,
1613             hf_ptp_versionnetwork, tvb, PTP_VERSIONNETWORK_OFFSET, 2, FALSE);
1614
1615         proto_tree_add_item(ptp_tree,
1616             hf_ptp_subdomain, tvb, PTP_SUBDOMAIN_OFFSET, 16, FALSE);
1617
1618         proto_tree_add_item(ptp_tree,
1619             hf_ptp_messagetype, tvb, PTP_MESSAGETYPE_OFFSET, 1, FALSE);
1620
1621         proto_tree_add_item(ptp_tree,
1622             hf_ptp_sourcecommunicationtechnology, tvb, PTP_SOURCECOMMUNICATIONTECHNOLOGY_OFFSET, 1, FALSE);
1623
1624         proto_tree_add_item(ptp_tree,
1625             hf_ptp_sourceuuid, tvb, PTP_SOURCEUUID_OFFSET, 6, FALSE);
1626
1627         proto_tree_add_item(ptp_tree,
1628             hf_ptp_sourceportid, tvb, PTP_SOURCEPORTID_OFFSET, 2, FALSE);
1629
1630         proto_tree_add_item(ptp_tree,
1631             hf_ptp_sequenceid, tvb, PTP_SEQUENCEID_OFFSET, 2, FALSE);
1632
1633         proto_tree_add_item(ptp_tree,
1634             hf_ptp_control, tvb, PTP_CONTROL_OFFSET, 1, FALSE);
1635
1636         /*Subtree for the flag-field*/
1637         if(tree){
1638             flags_ti = proto_tree_add_item(ptp_tree,
1639                 hf_ptp_flags, tvb, PTP_FLAGS_OFFSET, 2, FALSE);
1640
1641             ptp_flags_tree = proto_item_add_subtree(flags_ti, ett_ptp_flags);
1642
1643             proto_tree_add_item(ptp_flags_tree,
1644                 hf_ptp_flags_li61, tvb, PTP_FLAGS_LI61_OFFSET, 2, FALSE);
1645
1646             proto_tree_add_item(ptp_flags_tree,
1647                 hf_ptp_flags_li59, tvb, PTP_FLAGS_LI59_OFFSET, 2, FALSE);
1648
1649             proto_tree_add_item(ptp_flags_tree,
1650                 hf_ptp_flags_boundary_clock, tvb, PTP_FLAGS_BOUNDARY_CLOCK_OFFSET, 2, FALSE);
1651
1652             proto_tree_add_item(ptp_flags_tree,
1653                 hf_ptp_flags_assist, tvb, PTP_FLAGS_ASSIST_OFFSET, 2, FALSE);
1654
1655             proto_tree_add_item(ptp_flags_tree,
1656                 hf_ptp_flags_ext_sync, tvb, PTP_FLAGS_EXT_SYNC_OFFSET, 2, FALSE);
1657
1658             proto_tree_add_item(ptp_flags_tree,
1659                 hf_ptp_flags_parent, tvb, PTP_FLAGS_PARENT_STATS_OFFSET, 2, FALSE);
1660
1661             proto_tree_add_item(ptp_flags_tree,
1662                 hf_ptp_flags_sync_burst, tvb, PTP_FLAGS_SYNC_BURST_OFFSET, 2, FALSE);
1663         }
1664
1665         /* The rest of the ptp-dissector depends on the control-field  */
1666
1667         switch(ptp_control){
1668             case PTP_SYNC_MESSAGE:
1669             case PTP_DELAY_REQ_MESSAGE:{
1670
1671                 /*Subtree for the timestamp-field*/
1672                 ts.secs = tvb_get_ntohl(tvb, PTP_SDR_ORIGINTIMESTAMP_SECONDS_OFFSET);
1673                 ts.nsecs =  tvb_get_ntohl(tvb, PTP_SDR_ORIGINTIMESTAMP_NANOSECONDS_OFFSET);
1674                 if(tree){
1675                     time_ti = proto_tree_add_time(ptp_tree,
1676                                       hf_ptp_sdr_origintimestamp, tvb, PTP_SDR_ORIGINTIMESTAMP_OFFSET, 8, &ts);
1677
1678                     ptp_time_tree = proto_item_add_subtree(time_ti, ett_ptp_time);
1679
1680                     proto_tree_add_item(ptp_time_tree,
1681                             hf_ptp_sdr_origintimestamp_seconds, tvb,
1682                             PTP_SDR_ORIGINTIMESTAMP_SECONDS_OFFSET, 4, FALSE);
1683
1684                     proto_tree_add_item(ptp_time_tree, hf_ptp_sdr_origintimestamp_nanoseconds, tvb,
1685                             PTP_SDR_ORIGINTIMESTAMP_NANOSECONDS_OFFSET, 4, FALSE);
1686                 }
1687
1688                 proto_tree_add_item(ptp_tree,
1689                         hf_ptp_sdr_epochnumber, tvb, PTP_SDR_EPOCHNUMBER_OFFSET, 2, FALSE);
1690
1691                 proto_tree_add_item(ptp_tree,
1692                         hf_ptp_sdr_currentutcoffset, tvb, PTP_SDR_CURRENTUTCOFFSET_OFFSET, 2, FALSE);
1693
1694                 proto_tree_add_item(ptp_tree, hf_ptp_sdr_grandmastercommunicationtechnology, tvb,
1695                         PTP_SDR_GRANDMASTERCOMMUNICATIONTECHNOLOGY_OFFSET, 1, FALSE);
1696
1697                 proto_tree_add_item(ptp_tree,
1698                         hf_ptp_sdr_grandmasterclockuuid, tvb, PTP_SDR_GRANDMASTERCLOCKUUID_OFFSET, 6, FALSE);
1699
1700                 proto_tree_add_item(ptp_tree,
1701                         hf_ptp_sdr_grandmasterportid, tvb, PTP_SDR_GRANDMASTERPORTID_OFFSET, 2, FALSE);
1702
1703                 proto_tree_add_item(ptp_tree,
1704                         hf_ptp_sdr_grandmastersequenceid, tvb, PTP_SDR_GRANDMASTERSEQUENCEID_OFFSET, 2, FALSE);
1705
1706                 proto_tree_add_item(ptp_tree,
1707                         hf_ptp_sdr_grandmasterclockstratum, tvb,
1708                         PTP_SDR_GRANDMASTERCLOCKSTRATUM_OFFSET, 1, FALSE);
1709
1710                 proto_tree_add_item(ptp_tree, hf_ptp_sdr_grandmasterclockidentifier, tvb,
1711                         PTP_SDR_GRANDMASTERCLOCKIDENTIFIER_OFFSET, 4, FALSE);
1712
1713                 proto_tree_add_item(ptp_tree,
1714                         hf_ptp_sdr_grandmasterclockvariance, tvb,
1715                         PTP_SDR_GRANDMASTERCLOCKVARIANCE_OFFSET, 2, FALSE);
1716
1717                 proto_tree_add_item(ptp_tree,
1718                         hf_ptp_sdr_grandmasterpreferred, tvb, PTP_SDR_GRANDMASTERPREFERRED_OFFSET, 1, FALSE);
1719
1720                 proto_tree_add_item(ptp_tree, hf_ptp_sdr_grandmasterisboundaryclock, tvb,
1721                         PTP_SDR_GRANDMASTERISBOUNDARYCLOCK_OFFSET, 1, FALSE);
1722
1723                 proto_tree_add_item(ptp_tree,
1724                         hf_ptp_sdr_syncinterval, tvb, PTP_SDR_SYNCINTERVAL_OFFSET, 1, FALSE);
1725
1726                 proto_tree_add_item(ptp_tree,
1727                         hf_ptp_sdr_localclockvariance, tvb, PTP_SDR_LOCALCLOCKVARIANCE_OFFSET, 2, FALSE);
1728
1729                 proto_tree_add_item(ptp_tree,
1730                         hf_ptp_sdr_localstepsremoved, tvb, PTP_SDR_LOCALSTEPSREMOVED_OFFSET, 2, FALSE);
1731
1732                 proto_tree_add_item(ptp_tree,
1733                         hf_ptp_sdr_localclockstratum, tvb, PTP_SDR_LOCALCLOCKSTRATUM_OFFSET, 1, FALSE);
1734
1735                 proto_tree_add_item(ptp_tree,
1736                         hf_ptp_sdr_localclockidentifier, tvb, PTP_SDR_LOCALCLOCKIDENTIFIER_OFFSET, 4, FALSE);
1737
1738                 proto_tree_add_item(ptp_tree, hf_ptp_sdr_parentcommunicationtechnology, tvb,
1739                         PTP_SDR_PARENTCOMMUNICATIONTECHNOLOGY_OFFSET, 1, FALSE);
1740
1741                 proto_tree_add_item(ptp_tree,
1742                         hf_ptp_sdr_parentuuid, tvb, PTP_SDR_PARENTUUID_OFFSET, 6, FALSE);
1743
1744                 proto_tree_add_item(ptp_tree,
1745                         hf_ptp_sdr_parentportfield, tvb, PTP_SDR_PARENTPORTFIELD_OFFSET, 2, FALSE);
1746
1747                 proto_tree_add_item(ptp_tree,
1748                         hf_ptp_sdr_estimatedmastervariance, tvb,
1749                         PTP_SDR_ESTIMATEDMASTERVARIANCE_OFFSET, 2, FALSE);
1750
1751                 proto_tree_add_item(ptp_tree,
1752                         hf_ptp_sdr_estimatedmasterdrift, tvb, PTP_SDR_ESTIMATEDMASTERDRIFT_OFFSET, 4, FALSE);
1753
1754                 proto_tree_add_item(ptp_tree,
1755                         hf_ptp_sdr_utcreasonable, tvb, PTP_SDR_UTCREASONABLE_OFFSET, 1, FALSE);
1756                 break;
1757             }
1758             case PTP_FOLLOWUP_MESSAGE:{
1759                 proto_tree_add_item(ptp_tree,
1760                         hf_ptp_fu_associatedsequenceid, tvb, PTP_FU_ASSOCIATEDSEQUENCEID_OFFSET, 2, FALSE);
1761
1762                 /*Subtree for the timestamp-field*/
1763                 ts.secs = tvb_get_ntohl(tvb, PTP_FU_PRECISEORIGINTIMESTAMP_SECONDS_OFFSET);
1764                 ts.nsecs = tvb_get_ntohl(tvb, PTP_FU_PRECISEORIGINTIMESTAMP_NANOSECONDS_OFFSET);
1765                 if(tree){
1766                     time_ti = proto_tree_add_time(ptp_tree,
1767                             hf_ptp_fu_preciseorigintimestamp, tvb,
1768                             PTP_FU_PRECISEORIGINTIMESTAMP_OFFSET, 8, &ts);
1769
1770                     ptp_time_tree = proto_item_add_subtree(time_ti, ett_ptp_time);
1771
1772                     proto_tree_add_item(ptp_time_tree, hf_ptp_fu_preciseorigintimestamp_seconds, tvb,
1773                             PTP_FU_PRECISEORIGINTIMESTAMP_SECONDS_OFFSET, 4, FALSE);
1774
1775                     proto_tree_add_item(ptp_time_tree, hf_ptp_fu_preciseorigintimestamp_nanoseconds, tvb,
1776                             PTP_FU_PRECISEORIGINTIMESTAMP_NANOSECONDS_OFFSET, 4, FALSE);
1777                 }
1778                 break;
1779             }
1780             case PTP_DELAY_RESP_MESSAGE:{
1781                 /*Subtree for the timestamp-field*/
1782                 ts.secs = tvb_get_ntohl(tvb, PTP_DR_DELAYRECEIPTTIMESTAMP_SECONDS_OFFSET);
1783                 ts.nsecs = tvb_get_ntohl(tvb, PTP_DR_DELAYRECEIPTTIMESTAMP_NANOSECONDS_OFFSET);
1784                 if(tree){
1785                     time_ti = proto_tree_add_time(ptp_tree,
1786                             hf_ptp_dr_delayreceipttimestamp, tvb,
1787                             PTP_DR_DELAYRECEIPTTIMESTAMP_OFFSET, 8, &ts);
1788
1789                     ptp_time_tree = proto_item_add_subtree(time_ti, ett_ptp_time);
1790
1791                     proto_tree_add_item(ptp_time_tree, hf_ptp_dr_delayreceipttimestamp_seconds, tvb,
1792                             PTP_DR_DELAYRECEIPTTIMESTAMP_SECONDS_OFFSET, 4, FALSE);
1793
1794                     proto_tree_add_item(ptp_time_tree, hf_ptp_dr_delayreceipttimestamp_nanoseconds, tvb,
1795                             PTP_DR_DELAYRECEIPTTIMESTAMP_NANOSECONDS_OFFSET, 4, FALSE);
1796                 }
1797
1798                 proto_tree_add_item(ptp_tree, hf_ptp_dr_requestingsourcecommunicationtechnology, tvb,
1799                     PTP_DR_REQUESTINGSOURCECOMMUNICATIONTECHNOLOGY_OFFSET, 1, FALSE);
1800
1801                 proto_tree_add_item(ptp_tree,
1802                         hf_ptp_dr_requestingsourceuuid, tvb, PTP_DR_REQUESTINGSOURCEUUID_OFFSET, 6, FALSE);
1803
1804                 proto_tree_add_item(ptp_tree,
1805                         hf_ptp_dr_requestingsourceportid, tvb, PTP_DR_REQUESTINGSOURCEPORTID_OFFSET, 2, FALSE);
1806
1807                 proto_tree_add_item(ptp_tree,
1808                         hf_ptp_dr_requestingsourcesequenceid, tvb,
1809                         PTP_DR_REQUESTINGSOURCESEQUENCEID_OFFSET, 2, FALSE);
1810                 break;
1811             }
1812             case PTP_MANAGEMENT_MESSAGE:{
1813                 proto_tree_add_item(ptp_tree, hf_ptp_mm_targetcommunicationtechnology, tvb,
1814                         PTP_MM_TARGETCOMMUNICATIONTECHNOLOGY_OFFSET, 1, FALSE);
1815
1816                 proto_tree_add_item(ptp_tree,
1817                         hf_ptp_mm_targetuuid, tvb, PTP_MM_TARGETUUID_OFFSET, 6, FALSE);
1818
1819                 proto_tree_add_item(ptp_tree,
1820                         hf_ptp_mm_targetportid, tvb, PTP_MM_TARGETPORTID_OFFSET, 2, FALSE);
1821
1822                 proto_tree_add_item(ptp_tree,
1823                         hf_ptp_mm_startingboundaryhops, tvb, PTP_MM_STARTINGBOUNDARYHOPS_OFFSET, 2, FALSE);
1824
1825                 proto_tree_add_item(ptp_tree,
1826                         hf_ptp_mm_boundaryhops, tvb, PTP_MM_BOUNDARYHOPS_OFFSET, 2, FALSE);
1827
1828
1829                 proto_tree_add_item(ptp_tree,
1830                         hf_ptp_mm_managementmessagekey, tvb, PTP_MM_MANAGEMENTMESSAGEKEY_OFFSET, 1, FALSE);
1831
1832                 proto_tree_add_item(ptp_tree,
1833                         hf_ptp_mm_parameterlength, tvb, PTP_MM_PARAMETERLENGTH_OFFSET, 2, FALSE);
1834
1835                 switch(ptp_mm_messagekey){
1836                     case PTP_MM_CLOCK_IDENTITY:{
1837                         proto_tree_add_item(ptp_tree,
1838                                 hf_ptp_mm_clock_identity_clockcommunicationtechnology, tvb,
1839                                 PTP_MM_CLOCK_IDENTITY_CLOCKCOMMUNICATIONTECHNOLOGY_OFFSET, 1, FALSE);
1840
1841                         proto_tree_add_item(ptp_tree, hf_ptp_mm_clock_identity_clockuuidfield, tvb,
1842                                 PTP_MM_CLOCK_IDENTITY_CLOCKUUIDFIELD_OFFSET, 6, FALSE);
1843
1844                         proto_tree_add_item(ptp_tree, hf_ptp_mm_clock_identity_clockportfield, tvb,
1845                                 PTP_MM_CLOCK_IDENTITY_CLOCKPORTFIELD_OFFSET, 2, FALSE);
1846
1847                         proto_tree_add_item(ptp_tree, hf_ptp_mm_clock_identity_manufactureridentity, tvb,
1848                                 PTP_MM_CLOCK_IDENTITY_MANUFACTURERIDENTITY_OFFSET, 48, FALSE);
1849                         break;
1850                     }
1851                     case PTP_MM_INITIALIZE_CLOCK:{
1852                         proto_tree_add_item(ptp_tree, hf_ptp_mm_initialize_clock_initialisationkey, tvb,
1853                             PTP_MM_INITIALIZE_CLOCK_INITIALISATIONKEY_OFFSET, 2, FALSE);
1854                         break;
1855                     }
1856                     case PTP_MM_SET_SUBDOMAIN:{
1857                         proto_tree_add_item(ptp_tree, hf_ptp_mm_set_subdomain_subdomainname, tvb,
1858                                 PTP_MM_SET_SUBDOMAIN_SUBDOMAINNAME_OFFSET, 16, FALSE);
1859                         break;
1860                     }
1861                     case PTP_MM_DEFAULT_DATA_SET:{
1862                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_clockcommunicationtechnology,
1863                                 tvb, PTP_MM_DEFAULT_DATA_SET_CLOCKCOMMUNICATIONTECHNOLOGY_OFFSET,
1864                                  1, FALSE);
1865
1866                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_clockuuidfield, tvb,
1867                                 PTP_MM_DEFAULT_DATA_SET_CLOCKUUIDFIELD_OFFSET, 6, FALSE);
1868
1869                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_clockportfield, tvb,
1870                                 PTP_MM_DEFAULT_DATA_SET_CLOCKPORTFIELD_OFFSET, 2, FALSE);
1871
1872                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_clockstratum, tvb,
1873                                 PTP_MM_DEFAULT_DATA_SET_CLOCKSTRATUM_OFFSET, 1, FALSE);
1874
1875                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_clockidentifier, tvb,
1876                                 PTP_MM_DEFAULT_DATA_SET_CLOCKIDENTIFIER_OFFSET, 4, FALSE);
1877
1878                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_clockvariance, tvb,
1879                                 PTP_MM_DEFAULT_DATA_SET_CLOCKVARIANCE_OFFSET, 2, FALSE);
1880
1881                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_clockfollowupcapable, tvb,
1882                                 PTP_MM_DEFAULT_DATA_SET_CLOCKFOLLOWUPCAPABLE_OFFSET, 1, FALSE);
1883
1884                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_preferred, tvb,
1885                                 PTP_MM_DEFAULT_DATA_SET_PREFERRED_OFFSET, 1, FALSE);
1886
1887                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_initializable, tvb,
1888                                 PTP_MM_DEFAULT_DATA_SET_INITIALIZABLE_OFFSET, 1, FALSE);
1889
1890                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_externaltiming, tvb,
1891                                 PTP_MM_DEFAULT_DATA_SET_EXTERNALTIMING_OFFSET, 1, FALSE);
1892
1893                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_isboundaryclock, tvb,
1894                                 PTP_MM_DEFAULT_DATA_SET_ISBOUNDARYCLOCK_OFFSET, 1, FALSE);
1895
1896                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_syncinterval, tvb,
1897                                 PTP_MM_DEFAULT_DATA_SET_SYNCINTERVAL_OFFSET, 1, FALSE);
1898
1899                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_subdomainname, tvb,
1900                                 PTP_MM_DEFAULT_DATA_SET_SUBDOMAINNAME_OFFSET, 16, FALSE);
1901
1902                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_numberports, tvb,
1903                                 PTP_MM_DEFAULT_DATA_SET_NUMBERPORTS_OFFSET, 2, FALSE);
1904
1905                         proto_tree_add_item(ptp_tree, hf_ptp_mm_default_data_set_numberforeignrecords, tvb,
1906                                 PTP_MM_DEFAULT_DATA_SET_NUMBERFOREIGNRECORDS_OFFSET, 2, FALSE);
1907                         break;
1908                     }
1909                     case PTP_MM_UPDATE_DEFAULT_DATA_SET:{
1910                         proto_tree_add_item(ptp_tree, hf_ptp_mm_update_default_data_set_clockstratum, tvb,
1911                                 PTP_MM_UPDATE_DEFAULT_DATA_SET_CLOCKSTRATUM_OFFSET, 1, FALSE);
1912
1913                         proto_tree_add_item(ptp_tree, hf_ptp_mm_update_default_data_set_clockidentifier, tvb,
1914                                 PTP_MM_UPDATE_DEFAULT_DATA_SET_CLOCKIDENTIFIER_OFFSET, 4, FALSE);
1915
1916                         proto_tree_add_item(ptp_tree, hf_ptp_mm_update_default_data_set_clockvariance, tvb,
1917                                 PTP_MM_UPDATE_DEFAULT_DATA_SET_CLOCKVARIANCE_OFFSET, 2, FALSE);
1918
1919                         proto_tree_add_item(ptp_tree, hf_ptp_mm_update_default_data_set_preferred, tvb,
1920                                 PTP_MM_UPDATE_DEFAULT_DATA_SET_PREFERRED_OFFSET, 1, FALSE);
1921
1922                         proto_tree_add_item(ptp_tree, hf_ptp_mm_update_default_data_set_syncinterval, tvb,
1923                                 PTP_MM_UPDATE_DEFAULT_DATA_SET_SYNCINTERVAL_OFFSET, 1, FALSE);
1924
1925                         proto_tree_add_item(ptp_tree, hf_ptp_mm_update_default_data_set_subdomainname, tvb,
1926                                 PTP_MM_UPDATE_DEFAULT_DATA_SET_SUBDOMAINNAME_OFFSET, 16, FALSE);
1927                         break;
1928                     }
1929                     case PTP_MM_CURRENT_DATA_SET:{
1930                         proto_tree_add_item(ptp_tree, hf_ptp_mm_current_data_set_stepsremoved, tvb,
1931                                 PTP_MM_CURRENT_DATA_SET_STEPSREMOVED_OFFSET, 2, FALSE);
1932
1933                         /* Subtree for offset from master*/
1934                         ts.secs = tvb_get_ntohl(tvb, PTP_MM_CURRENT_DATA_SET_OFFSETFROMMASTERSECONDS_OFFSET);
1935
1936                         ts.nsecs = tvb_get_ntohl(tvb,
1937                                 PTP_MM_CURRENT_DATA_SET_OFFSETFROMMASTERNANOSECONDS_OFFSET);
1938
1939                         if (ts.nsecs & 0x80000000) ts.nsecs = ts.nsecs & 0x7FFFFFFF;
1940
1941                         if(tree){
1942                             time_ti = proto_tree_add_time(ptp_tree,
1943                                     hf_ptp_mm_current_data_set_offsetfrommaster, tvb,
1944                                     PTP_MM_CURRENT_DATA_SET_OFFSETFROMMASTER_OFFSET, 8, &ts);
1945
1946                             ptp_time_tree = proto_item_add_subtree(time_ti, ett_ptp_time);
1947
1948                             proto_tree_add_item(ptp_time_tree,
1949                                     hf_ptp_mm_current_data_set_offsetfrommasterseconds, tvb,
1950                                     PTP_MM_CURRENT_DATA_SET_OFFSETFROMMASTERSECONDS_OFFSET, 4, FALSE);
1951
1952                             proto_tree_add_item(ptp_time_tree,
1953                                     hf_ptp_mm_current_data_set_offsetfrommasternanoseconds, tvb,
1954                                     PTP_MM_CURRENT_DATA_SET_OFFSETFROMMASTERNANOSECONDS_OFFSET, 4, FALSE);
1955                         }
1956
1957                         /* Subtree for offset from master*/
1958                         ts.secs = tvb_get_ntohl(tvb, PTP_MM_CURRENT_DATA_SET_ONEWAYDELAYSECONDS_OFFSET);
1959
1960                         ts.nsecs = tvb_get_ntohl(tvb, PTP_MM_CURRENT_DATA_SET_ONEWAYDELAYNANOSECONDS_OFFSET);
1961
1962                         if(tree){
1963                             time2_ti = proto_tree_add_time(ptp_tree,
1964                                     hf_ptp_mm_current_data_set_onewaydelay, tvb,
1965                                     PTP_MM_CURRENT_DATA_SET_ONEWAYDELAY_OFFSET, 8, &ts);
1966
1967                             ptp_time2_tree = proto_item_add_subtree(time2_ti, ett_ptp_time2);
1968
1969                             proto_tree_add_item(ptp_time2_tree, hf_ptp_mm_current_data_set_onewaydelayseconds,
1970                                     tvb, PTP_MM_CURRENT_DATA_SET_ONEWAYDELAYSECONDS_OFFSET, 4, FALSE);
1971
1972                             proto_tree_add_item(ptp_time2_tree,
1973                                     hf_ptp_mm_current_data_set_onewaydelaynanoseconds,
1974                                     tvb, PTP_MM_CURRENT_DATA_SET_ONEWAYDELAYNANOSECONDS_OFFSET, 4, FALSE);
1975                         }
1976                         break;
1977                     }
1978                     case PTP_MM_PARENT_DATA_SET:{
1979                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_parentcommunicationtechnology,
1980                                 tvb, PTP_MM_PARENT_DATA_SET_PARENTCOMMUNICATIONTECHNOLOGY_OFFSET,
1981                                 1, FALSE);
1982
1983                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_parentuuid, tvb,
1984                                 PTP_MM_PARENT_DATA_SET_PARENTUUID_OFFSET, 6, FALSE);
1985
1986                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_parentportid, tvb,
1987                                 PTP_MM_PARENT_DATA_SET_PARENTPORTID_OFFSET, 2, FALSE);
1988
1989                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_parentlastsyncsequencenumber,
1990                                 tvb, PTP_MM_PARENT_DATA_SET_PARENTLASTSYNCSEQUENCENUMBER_OFFSET,
1991                                 2, FALSE);
1992
1993                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_parentfollowupcapable, tvb,
1994                                 PTP_MM_PARENT_DATA_SET_PARENTFOLLOWUPCAPABLE_OFFSET, 1, FALSE);
1995
1996                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_parentexternaltiming, tvb,
1997                                 PTP_MM_PARENT_DATA_SET_PARENTEXTERNALTIMING_OFFSET, 1, FALSE);
1998
1999                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_parentvariance, tvb,
2000                                 PTP_MM_PARENT_DATA_SET_PARENTVARIANCE_OFFSET, 2, FALSE);
2001
2002                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_parentstats, tvb,
2003                                 PTP_MM_PARENT_DATA_SET_PARENTSTATS_OFFSET, 1, FALSE);
2004
2005                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_observedvariance, tvb,
2006                                 PTP_MM_PARENT_DATA_SET_OBSERVEDVARIANCE_OFFSET, 2, FALSE);
2007
2008                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_observeddrift, tvb,
2009                                 PTP_MM_PARENT_DATA_SET_OBSERVEDDRIFT_OFFSET, 4, FALSE);
2010
2011                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_utcreasonable, tvb,
2012                                 PTP_MM_PARENT_DATA_SET_UTCREASONABLE_OFFSET, 1, FALSE);
2013
2014                         proto_tree_add_item(ptp_tree,
2015                                 hf_ptp_mm_parent_data_set_grandmastercommunicationtechnology,
2016                                 tvb, PTP_MM_PARENT_DATA_SET_GRANDMASTERCOMMUNICATIONTECHNOLOGY_OFFSET, 1,
2017                                 FALSE);
2018
2019                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_grandmasteruuidfield, tvb,
2020                                 PTP_MM_PARENT_DATA_SET_GRANDMASTERUUIDFIELD_OFFSET, 6, FALSE);
2021
2022                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_grandmasterportidfield, tvb,
2023                                 PTP_MM_PARENT_DATA_SET_GRANDMASTERPORTIDFIELD_OFFSET, 2, FALSE);
2024
2025                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_grandmasterstratum, tvb,
2026                                 PTP_MM_PARENT_DATA_SET_GRANDMASTERSTRATUM_OFFSET, 1, FALSE);
2027
2028                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_grandmasteridentifier, tvb,
2029                                 PTP_MM_PARENT_DATA_SET_GRANDMASTERIDENTIFIER_OFFSET, 4, FALSE);
2030
2031                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_grandmastervariance, tvb,
2032                                 PTP_MM_PARENT_DATA_SET_GRANDMASTERVARIANCE_OFFSET, 2, FALSE);
2033
2034                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_grandmasterpreferred, tvb,
2035                                 PTP_MM_PARENT_DATA_SET_GRANDMASTERPREFERRED_OFFSET, 1, FALSE);
2036
2037                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_grandmasterisboundaryclock, tvb,
2038                                 PTP_MM_PARENT_DATA_SET_GRANDMASTERISBOUNDARYCLOCK_OFFSET, 1, FALSE);
2039
2040                         proto_tree_add_item(ptp_tree, hf_ptp_mm_parent_data_set_grandmastersequencenumber, tvb,
2041                                 PTP_MM_PARENT_DATA_SET_GRANDMASTERSEQUENCENUMBER_OFFSET, 2, FALSE);
2042                         break;
2043                     }
2044                     case PTP_MM_PORT_DATA_SET:{
2045                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_returnedportnumber, tvb,
2046                                 PTP_MM_PORT_DATA_SET_RETURNEDPORTNUMBER_OFFSET, 2, FALSE);
2047
2048                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_portstate, tvb,
2049                                 PTP_MM_PORT_DATA_SET_PORTSTATE_OFFSET, 1, FALSE);
2050
2051                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_lastsynceventsequencenumber, tvb,
2052                                 PTP_MM_PORT_DATA_SET_LASTSYNCEVENTSEQUENCENUMBER_OFFSET, 2, FALSE);
2053
2054                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_lastgeneraleventsequencenumber,
2055                                 tvb, PTP_MM_PORT_DATA_SET_LASTGENERALEVENTSEQUENCENUMBER_OFFSET,
2056                                 2, FALSE);
2057
2058                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_portcommunicationtechnology, tvb,
2059                                 PTP_MM_PORT_DATA_SET_PORTCOMMUNICATIONTECHNOLOGY_OFFSET, 1, FALSE);
2060
2061                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_portuuidfield, tvb,
2062                                 PTP_MM_PORT_DATA_SET_PORTUUIDFIELD_OFFSET, 6, FALSE);
2063
2064                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_portidfield, tvb,
2065                                 PTP_MM_PORT_DATA_SET_PORTIDFIELD_OFFSET, 2, FALSE);
2066
2067                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_burstenabled, tvb,
2068                                 PTP_MM_PORT_DATA_SET_BURSTENABLED_OFFSET, 1, FALSE);
2069
2070                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_subdomainaddressoctets, tvb,
2071                                 PTP_MM_PORT_DATA_SET_SUBDOMAINADDRESSOCTETS_OFFSET, 1, FALSE);
2072
2073                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_eventportaddressoctets, tvb,
2074                                 PTP_MM_PORT_DATA_SET_EVENTPORTADDRESSOCTETS_OFFSET, 1, FALSE);
2075
2076                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_generalportaddressoctets, tvb,
2077                                 PTP_MM_PORT_DATA_SET_GENERALPORTADDRESSOCTETS_OFFSET, 1, FALSE);
2078
2079                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_subdomainaddress, tvb,
2080                                 PTP_MM_PORT_DATA_SET_SUBDOMAINADDRESS_OFFSET, 4, FALSE);
2081
2082                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_eventportaddress, tvb,
2083                                 PTP_MM_PORT_DATA_SET_EVENTPORTADDRESS_OFFSET, 2, FALSE);
2084
2085                         proto_tree_add_item(ptp_tree, hf_ptp_mm_port_data_set_generalportaddress, tvb,
2086                                 PTP_MM_PORT_DATA_SET_GENERALPORTADDRESS_OFFSET, 2, FALSE);
2087                         break;
2088                     }
2089                     case PTP_MM_GLOBAL_TIME_DATA_SET:{
2090                         /* Subtree for local time*/
2091                         ts.secs = tvb_get_ntohl(tvb, PTP_MM_GLOBAL_TIME_DATA_SET_LOCALTIMESECONDS_OFFSET);
2092
2093                         ts.nsecs = tvb_get_ntohl(tvb,
2094                                 PTP_MM_GLOBAL_TIME_DATA_SET_LOCALTIMENANOSECONDS_OFFSET);
2095
2096                         if(tree){
2097                             time_ti = proto_tree_add_time(ptp_tree,
2098                                     hf_ptp_mm_global_time_data_set_localtime, tvb,
2099                                     PTP_MM_GLOBAL_TIME_DATA_SET_LOCALTIME_OFFSET, 8, &ts);
2100
2101                             ptp_time_tree = proto_item_add_subtree(time_ti, ett_ptp_time);
2102
2103                             proto_tree_add_item(ptp_time_tree,
2104                                     hf_ptp_mm_global_time_data_set_localtimeseconds, tvb,
2105                                     PTP_MM_GLOBAL_TIME_DATA_SET_LOCALTIMESECONDS_OFFSET, 4, FALSE);
2106
2107                             proto_tree_add_item(ptp_time_tree,
2108                                     hf_ptp_mm_global_time_data_set_localtimenanoseconds,
2109                                     tvb, PTP_MM_GLOBAL_TIME_DATA_SET_LOCALTIMENANOSECONDS_OFFSET, 4, FALSE);
2110                         }
2111
2112                         proto_tree_add_item(ptp_tree, hf_ptp_mm_global_time_data_set_currentutcoffset, tvb,
2113                                 PTP_MM_GLOBAL_TIME_DATA_SET_CURRENTUTCOFFSET_OFFSET, 2, FALSE);
2114
2115                         proto_tree_add_item(ptp_tree, hf_ptp_mm_global_time_data_set_leap59, tvb,
2116                                 PTP_MM_GLOBAL_TIME_DATA_SET_LEAP59_OFFSET, 1, FALSE);
2117
2118                         proto_tree_add_item(ptp_tree, hf_ptp_mm_global_time_data_set_leap61, tvb,
2119                                 PTP_MM_GLOBAL_TIME_DATA_SET_LEAP61_OFFSET, 1, FALSE);
2120
2121                         proto_tree_add_item(ptp_tree, hf_ptp_mm_global_time_data_set_epochnumber, tvb,
2122                                 PTP_MM_GLOBAL_TIME_DATA_SET_EPOCHNUMBER_OFFSET, 2, FALSE);
2123                         break;
2124                     }
2125                     case PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES:{
2126                         proto_tree_add_item(ptp_tree, hf_ptp_mm_update_global_time_properties_currentutcoffset,
2127                                 tvb, PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES_CURRENTUTCOFFSET_OFFSET,
2128                                 2, FALSE);
2129
2130                         proto_tree_add_item(ptp_tree, hf_ptp_mm_update_global_time_properties_leap59, tvb,
2131                                 PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES_LEAP59_OFFSET, 1, FALSE);
2132
2133                         proto_tree_add_item(ptp_tree, hf_ptp_mm_update_global_time_properties_leap61, tvb,
2134                                 PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES_LEAP61_OFFSET, 1, FALSE);
2135
2136                         proto_tree_add_item(ptp_tree, hf_ptp_mm_get_foreign_data_set_recordkey, tvb,
2137                                 PTP_MM_UPDATE_GLOBAL_TIME_PROPERTIES_EPOCHNUMBER_OFFSET, 2, FALSE);
2138                         break;
2139                     }
2140                     case PTP_MM_GET_FOREIGN_DATA_SET:{
2141                         proto_tree_add_item(ptp_tree, hf_ptp_mm_get_foreign_data_set_recordkey, tvb,
2142                                 PTP_MM_GET_FOREIGN_DATA_SET_RECORDKEY_OFFSET, 2, FALSE);
2143                         break;
2144                     }
2145                     case PTP_MM_FOREIGN_DATA_SET:{
2146                         proto_tree_add_item(ptp_tree, hf_ptp_mm_foreign_data_set_returnedportnumber, tvb,
2147                                 PTP_MM_FOREIGN_DATA_SET_RETURNEDPORTNUMBER_OFFSET, 2, FALSE);
2148
2149                         proto_tree_add_item(ptp_tree, hf_ptp_mm_foreign_data_set_returnedrecordnumber, tvb,
2150                                 PTP_MM_FOREIGN_DATA_SET_RETURNEDRECORDNUMBER_OFFSET, 2, FALSE);
2151
2152                         proto_tree_add_item(ptp_tree,
2153                                 hf_ptp_mm_foreign_data_set_foreignmastercommunicationtechnology,
2154                                 tvb, PTP_MM_FOREIGN_DATA_SET_FOREIGNMASTERCOMMUNICATIONTECHNOLOGY_OFFSET, 1,
2155                                 FALSE);
2156
2157                         proto_tree_add_item(ptp_tree, hf_ptp_mm_foreign_data_set_foreignmasteruuidfield, tvb,
2158                                 PTP_MM_FOREIGN_DATA_SET_FOREIGNMASTERUUIDFIELD_OFFSET, 6, FALSE);
2159
2160                         proto_tree_add_item(ptp_tree, hf_ptp_mm_foreign_data_set_foreignmasterportidfield, tvb,
2161                                 PTP_MM_FOREIGN_DATA_SET_FOREIGNMASTERPORTIDFIELD_OFFSET, 2, FALSE);
2162
2163                         proto_tree_add_item(ptp_tree, hf_ptp_mm_foreign_data_set_foreignmastersyncs, tvb,
2164                                 PTP_MM_FOREIGN_DATA_SET_FOREIGNMASTERSYNCS_OFFSET, 2, FALSE);
2165                         break;
2166                     }
2167                     case PTP_MM_SET_SYNC_INTERVAL:{
2168                         proto_tree_add_item(ptp_tree, hf_ptp_mm_set_sync_interval_syncinterval, tvb,
2169                                 PTP_MM_SET_SYNC_INTERVAL_SYNCINTERVAL_OFFSET, 2, FALSE);
2170                         break;
2171                     }
2172                     case PTP_MM_SET_TIME:{
2173                         /* Subtree for local time*/
2174                         ts.secs = tvb_get_ntohl(tvb, PTP_MM_SET_TIME_LOCALTIMESECONDS_OFFSET);
2175
2176                         ts.nsecs = tvb_get_ntohl(tvb, PTP_MM_SET_TIME_LOCALTIMENANOSECONDS_OFFSET);
2177
2178                         if(tree){
2179                             time_ti = proto_tree_add_time(ptp_tree, hf_ptp_mm_set_time_localtime, tvb,
2180                                     PTP_MM_SET_TIME_LOCALTIME_OFFSET, 8, &ts);
2181
2182                             ptp_time_tree = proto_item_add_subtree(time_ti, ett_ptp_time);
2183
2184                             proto_tree_add_item(ptp_time_tree, hf_ptp_mm_set_time_localtimeseconds, tvb,
2185                                     PTP_MM_SET_TIME_LOCALTIMESECONDS_OFFSET, 4, FALSE);
2186
2187                             proto_tree_add_item(ptp_time_tree, hf_ptp_mm_set_time_localtimenanoseconds,
2188                                     tvb, PTP_MM_SET_TIME_LOCALTIMENANOSECONDS_OFFSET, 4, FALSE);
2189                         }
2190                         break;
2191                     }
2192                     default :{
2193                         /*- don't dissect any further. */
2194                         break;
2195                     }
2196                 }
2197                 break;
2198             }
2199             default :{
2200                 /* Not a valid MessageType - can't dissect. */
2201                 break;
2202             }
2203         }
2204     }
2205 }
2206
2207
2208 /* Code to dissect PTPText */
2209 static void
2210 dissect_ptp_v2_text(tvbuff_t *tvb, guint16 *cur_offset, proto_tree *tree, int hf_ptp_v2_mm_ptptext, int hf_ptp_v2_mm_ptptext_length)
2211 {
2212     guint8  length = 0;
2213     proto_item  *ptptext_ti;
2214     proto_tree  *ptptext_subtree;
2215
2216     length = tvb_get_guint8 (tvb, *cur_offset);
2217
2218     if (tree)
2219     {
2220         ptptext_ti = proto_tree_add_item(tree, hf_ptp_v2_mm_ptptext, tvb,
2221             *cur_offset+1, length, FALSE);
2222
2223         ptptext_subtree = proto_item_add_subtree(ptptext_ti, ett_ptp_v2_ptptext);
2224             /* subtree */
2225             proto_tree_add_item(ptptext_subtree, hf_ptp_v2_mm_ptptext_length, tvb,
2226                 *cur_offset, 1, FALSE);
2227             proto_tree_add_item(ptptext_subtree, hf_ptp_v2_mm_ptptext, tvb,
2228                 *cur_offset+1, length, FALSE);
2229
2230         *cur_offset = *cur_offset + length + 1;
2231     }
2232 }
2233
2234 static void
2235 dissect_ptp_v2_timeInterval(tvbuff_t *tvb, guint16 *cur_offset, proto_tree *tree, const char* name, int hf_ptp_v2_timeInterval_ns, int hf_ptp_v2_timeInterval_subns)
2236 {
2237
2238     double time_double;
2239     gint64 time_ns;
2240     guint16 time_subns;
2241     proto_item  *ptptimeInterval_ti;
2242     proto_tree  *ptptimeInterval_subtree;
2243
2244     time_ns = tvb_get_ntoh64(tvb, *cur_offset);
2245     time_double = (1.0*time_ns) / 65536.0;
2246     time_ns = time_ns >> 16;
2247     time_subns = tvb_get_ntohs(tvb, *cur_offset+6);
2248
2249     ptptimeInterval_ti = proto_tree_add_text(tree, tvb, *cur_offset, 8,
2250         "%s: %f nanoseconds", name, time_double);
2251
2252     ptptimeInterval_subtree = proto_item_add_subtree(ptptimeInterval_ti, ett_ptp_v2_timeInterval);
2253
2254     proto_tree_add_uint64_format_value(ptptimeInterval_subtree,
2255         hf_ptp_v2_timeInterval_ns, tvb, *cur_offset, 6, time_ns, "Ns: %" G_GINT64_MODIFIER "d nanoseconds", time_ns);
2256
2257     proto_tree_add_double_format(ptptimeInterval_subtree,
2258         hf_ptp_v2_timeInterval_subns, tvb, *cur_offset+6, 2, (time_subns/65536.0),
2259         "SubNs: %f nanoseconds", (time_subns/65536.0));
2260
2261     *cur_offset = *cur_offset + 8;
2262 }
2263
2264 /* Code to actually dissect the PTPv2 packets */
2265
2266 static void
2267 dissect_ptp_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2268 {
2269     guint8 ptp_v2_transport_specific = 0;
2270     guint8 ptp_v2_messageid = 0;
2271     guint16 ptp_v2_mm_managementId = 0;
2272     guint8 ptp_v2_management_action = 0;
2273     guint64 timeStamp;
2274     guint16 temp;
2275
2276
2277     /* Set up structures needed to add the protocol subtree and manage it */
2278     proto_item  *ti, *transportspecific_ti, *flags_ti, *managementData_ti, *clockType_ti, *protocolAddress_ti;
2279     proto_tree  *ptp_tree, *ptp_transportspecific_tree, *ptp_flags_tree, *ptp_managementData_tree,
2280                 *ptp_clockType_tree, *ptp_protocolAddress_tree;
2281
2282     /* Make entries in Protocol column and Info column on summary display */
2283     col_set_str(pinfo->cinfo, COL_PROTOCOL, "PTPv2");
2284
2285     /* Get transport specific bit to determine whether this is an AS packet or not */
2286     ptp_v2_transport_specific = 0xF0 & tvb_get_guint8 (tvb, PTP_V2_TRANSPORT_SPECIFIC_MESSAGE_ID_OFFSET);
2287
2288     /* Get control field (what kind of message is this? (Sync, DelayReq, ...) */
2289     ptp_v2_messageid = 0x0F & tvb_get_guint8 (tvb, PTP_V2_TRANSPORT_SPECIFIC_MESSAGE_ID_OFFSET);
2290
2291     /* Extend  Info column with managementId */
2292     if (check_col(pinfo->cinfo, COL_INFO))
2293     {
2294         /* Create and set the string for "Info" column */
2295         if ( ptp_v2_messageid == PTP_V2_MANAGEMENT_MESSAGE )
2296         {
2297             guint16 tlv_type;
2298             /* Get TLV Type */
2299             tlv_type = tvb_get_ntohs (tvb, PTP_V2_MM_TLV_TYPE_OFFSET);
2300             /* For management there are PTP_V2_TLV_TYPE_MANAGEMENT and PTP_V2_TLV_TYPE_MANAGEMENT_ERROR_STATUS TLVs */
2301             switch(tlv_type)
2302             {
2303                 case PTP_V2_TLV_TYPE_MANAGEMENT:
2304                     /* Get the managementId */
2305                     ptp_v2_mm_managementId = tvb_get_ntohs(tvb, PTP_V2_MM_TLV_MANAGEMENTID_OFFSET);
2306                     ptp_v2_management_action = 0x0F & tvb_get_guint8(tvb, PTP_V2_MM_ACTION_OFFSET);
2307                     col_add_fstr(pinfo->cinfo, COL_INFO, "Management (%s) %s",
2308                         val_to_str(ptp_v2_mm_managementId, ptp_v2_managementID_infocolumn_vals, "Unknown management Id %u"),
2309                         val_to_str(ptp_v2_management_action, ptp_v2_mm_action_vals, "Unknown Action %u"));
2310                     break;
2311                 case PTP_V2_TLV_TYPE_MANAGEMENT_ERROR_STATUS:
2312                     /* Get the managementErrorId */
2313                     ptp_v2_mm_managementId = tvb_get_ntohs(tvb, PTP_V2_MM_TLV_MANAGEMENTERRORID_OFFSET);
2314                     col_add_fstr(pinfo->cinfo, COL_INFO, "Management Error Message (%s)", val_to_str(ptp_v2_mm_managementId,
2315                          ptp2_managementErrorId_vals, "Unknown Error Id %u"));
2316                     break;
2317                 default:
2318                     col_add_str(pinfo->cinfo, COL_INFO, val_to_str(ptp_v2_messageid, ptp_v2_messageid_vals, "Unknown PTP Message (%u)"));
2319                     break;
2320             }
2321         }
2322         else
2323         {
2324             col_add_str(pinfo->cinfo, COL_INFO, val_to_str(ptp_v2_messageid, ptp_v2_messageid_vals, "Unknown PTP Message (%u)"));
2325         }
2326     }
2327
2328    if (tree) {
2329
2330         ti = proto_tree_add_item(tree, proto_ptp, tvb, 0, -1, FALSE);
2331
2332         ptp_tree = proto_item_add_subtree(ti, ett_ptp_v2);
2333
2334         transportspecific_ti = proto_tree_add_item(ptp_tree,
2335             hf_ptp_v2_transportspecific, tvb, PTP_V2_TRANSPORT_SPECIFIC_MESSAGE_ID_OFFSET, 1, FALSE);
2336
2337         ptp_transportspecific_tree = proto_item_add_subtree(transportspecific_ti, ett_ptp_v2_transportspecific);
2338
2339         if (ptpv2_oE == TRUE)
2340         {
2341             proto_tree_add_item(ptp_transportspecific_tree,
2342                 hf_ptp_v2_transportspecific_802as_conform, tvb, PTP_V2_TRANSPORT_SPECIFIC_MESSAGE_ID_OFFSET, 1, FALSE);
2343         }
2344         else
2345         {
2346             proto_tree_add_item(ptp_transportspecific_tree,
2347                 hf_ptp_v2_transportspecific_v1_compatibility, tvb, PTP_V2_TRANSPORT_SPECIFIC_MESSAGE_ID_OFFSET, 1, FALSE);
2348         }
2349
2350         proto_tree_add_item(ptp_tree,
2351             hf_ptp_v2_messageid, tvb, PTP_V2_TRANSPORT_SPECIFIC_MESSAGE_ID_OFFSET, 1, FALSE);
2352
2353         proto_tree_add_item(ptp_tree,
2354             hf_ptp_v2_versionptp, tvb, PTP_V2_VERSIONPTP_OFFSET, 1, FALSE);
2355
2356         proto_tree_add_item(ptp_tree,
2357             hf_ptp_v2_messagelength, tvb, PTP_V2_MESSAGE_LENGTH_OFFSET, 2, FALSE);
2358
2359         proto_tree_add_item(ptp_tree,
2360             hf_ptp_v2_domainnumber, tvb, PTP_V2_DOMAIN_NUMBER_OFFSET, 1, FALSE);
2361
2362
2363         flags_ti = proto_tree_add_item(ptp_tree,
2364             hf_ptp_v2_flags, tvb, PTP_V2_FLAGS_OFFSET, 2, FALSE);
2365
2366         ptp_flags_tree = proto_item_add_subtree(flags_ti, ett_ptp_v2_flags);
2367
2368         proto_tree_add_item(ptp_flags_tree,
2369             hf_ptp_v2_flags_security, tvb, PTP_V2_FLAGS_OFFSET, 2, FALSE);
2370
2371         proto_tree_add_item(ptp_flags_tree,
2372             hf_ptp_v2_flags_specific2, tvb, PTP_V2_FLAGS_OFFSET, 2, FALSE);
2373
2374         proto_tree_add_item(ptp_flags_tree,
2375             hf_ptp_v2_flags_specific1, tvb, PTP_V2_FLAGS_OFFSET, 2, FALSE);
2376
2377         proto_tree_add_item(ptp_flags_tree,
2378             hf_ptp_v2_flags_unicast, tvb, PTP_V2_FLAGS_OFFSET, 2, FALSE);
2379
2380         proto_tree_add_item(ptp_flags_tree,
2381             hf_ptp_v2_flags_twostep, tvb, PTP_V2_FLAGS_OFFSET, 2, FALSE);
2382
2383         proto_tree_add_item(ptp_flags_tree,
2384             hf_ptp_v2_flags_alternatemaster, tvb, PTP_V2_FLAGS_OFFSET, 2, FALSE);
2385
2386         proto_tree_add_item(ptp_flags_tree,
2387             hf_ptp_v2_flags_frequencytraceable, tvb, PTP_V2_FLAGS_OFFSET, 2, FALSE);
2388
2389         proto_tree_add_item(ptp_flags_tree,
2390             hf_ptp_v2_flags_timetraceable, tvb, PTP_V2_FLAGS_OFFSET, 2, FALSE);
2391
2392         proto_tree_add_item(ptp_flags_tree,
2393             hf_ptp_v2_flags_ptptimescale, tvb, PTP_V2_FLAGS_OFFSET, 2, FALSE);
2394
2395         proto_tree_add_item(ptp_flags_tree,
2396             hf_ptp_v2_flags_utcoffsetvalid, tvb, PTP_V2_FLAGS_OFFSET, 2, FALSE);
2397
2398         proto_tree_add_item(ptp_flags_tree,
2399             hf_ptp_v2_flags_li59, tvb, PTP_V2_FLAGS_OFFSET, 2, FALSE);
2400
2401         proto_tree_add_item(ptp_flags_tree,
2402             hf_ptp_v2_flags_li61, tvb, PTP_V2_FLAGS_OFFSET, 2, FALSE);
2403
2404         temp = PTP_V2_CORRECTIONNS_OFFSET;
2405
2406         dissect_ptp_v2_timeInterval(tvb, &temp, ptp_tree, "correction", hf_ptp_v2_correction, hf_ptp_v2_correctionsubns);
2407
2408         proto_tree_add_item(ptp_tree,
2409             hf_ptp_v2_clockidentity, tvb, PTP_V2_CLOCKIDENTITY_OFFSET, 8, FALSE);
2410
2411         proto_tree_add_item(ptp_tree,
2412             hf_ptp_v2_sourceportid, tvb, PTP_V2_SOURCEPORTID_OFFSET, 2, FALSE);
2413
2414         proto_tree_add_item(ptp_tree,
2415             hf_ptp_v2_sequenceid, tvb, PTP_V2_SEQUENCEID_OFFSET, 2, FALSE);
2416
2417         proto_tree_add_item(ptp_tree,
2418             hf_ptp_v2_control, tvb, PTP_V2_CONTROL_OFFSET, 1, FALSE);
2419
2420         proto_tree_add_item(ptp_tree,
2421             hf_ptp_v2_logmessageperiod, tvb, PTP_V2_LOGMESSAGEPERIOD_OFFSET, 1, FALSE);
2422
2423         switch(ptp_v2_messageid){
2424             case PTP_V2_ANNOUNCE_MESSAGE:{
2425                 guint16     Offset;
2426                 guint16     tlv_type;
2427                 guint16     tlv_length;
2428                 guint16     tlv_total_length;
2429                 proto_item *tlv_ti;
2430                 proto_tree *ptp_tlv_tree;
2431
2432                 /* In 802.1AS there is no origin timestamp in an Announce Message */
2433                 if(!(ptp_v2_transport_specific & PTP_V2_TRANSPORTSPECIFIC_ASPACKET_BITMASK)){
2434
2435                     timeStamp = tvb_get_ntohl(tvb, PTP_V2_AN_ORIGINTIMESTAMPSECONDS_OFFSET);
2436                     timeStamp = timeStamp << 16;
2437                     timeStamp = timeStamp | tvb_get_ntohs(tvb, PTP_V2_AN_ORIGINTIMESTAMPSECONDS_OFFSET+4);
2438
2439                     proto_tree_add_item(ptp_tree, hf_ptp_v2_an_origintimestamp_seconds, tvb,
2440                         PTP_V2_AN_ORIGINTIMESTAMPSECONDS_OFFSET, 6, FALSE);
2441
2442                     proto_tree_add_item(ptp_tree, hf_ptp_v2_an_origintimestamp_nanoseconds, tvb,
2443                         PTP_V2_AN_ORIGINTIMESTAMPNANOSECONDS_OFFSET, 4, FALSE);
2444                 }
2445
2446                 proto_tree_add_item(ptp_tree, hf_ptp_v2_an_origincurrentutcoffset, tvb,
2447                     PTP_V2_AN_ORIGINCURRENTUTCOFFSET_OFFSET, 2, FALSE);
2448
2449                 proto_tree_add_item(ptp_tree, hf_ptp_v2_an_priority1, tvb,
2450                     PTP_V2_AN_PRIORITY_1_OFFSET, 1, FALSE);
2451
2452                 proto_tree_add_item(ptp_tree, hf_ptp_v2_an_grandmasterclockclass, tvb,
2453                     PTP_V2_AN_GRANDMASTERCLOCKCLASS_OFFSET, 1, FALSE);
2454
2455                 proto_tree_add_item(ptp_tree, hf_ptp_v2_an_grandmasterclockaccuracy, tvb,
2456                     PTP_V2_AN_GRANDMASTERCLOCKACCURACY_OFFSET, 1, FALSE);
2457
2458                 proto_tree_add_item(ptp_tree, hf_ptp_v2_an_grandmasterclockvariance, tvb,
2459                     PTP_V2_AN_GRANDMASTERCLOCKVARIANCE_OFFSET, 2, FALSE);
2460
2461                 proto_tree_add_item(ptp_tree, hf_ptp_v2_an_priority2, tvb,
2462                     PTP_V2_AN_PRIORITY_2_OFFSET, 1, FALSE);
2463
2464                 proto_tree_add_item(ptp_tree, hf_ptp_v2_an_grandmasterclockidentity, tvb,
2465                     PTP_V2_AN_GRANDMASTERCLOCKIDENTITY_OFFSET, 8, FALSE);
2466
2467                 proto_tree_add_item(ptp_tree, hf_ptp_v2_an_localstepsremoved, tvb,
2468                         PTP_V2_AN_LOCALSTEPSREMOVED_OFFSET, 2, FALSE);
2469
2470                 proto_tree_add_item(ptp_tree,
2471                     hf_ptp_v2_an_timesource, tvb, PTP_V2_AN_TIMESOURCE_OFFSET, 1, FALSE);
2472
2473                 tlv_total_length = 0;
2474                 while (tvb_reported_length_remaining(tvb, PTP_V2_AN_TLV_OFFSET + tlv_total_length) >= 2)
2475                 {
2476                     /* There are TLV's to be processed */
2477                     tlv_type = tvb_get_ntohs (tvb, PTP_V2_AN_TLV_OFFSET+tlv_total_length+PTP_V2_AN_TLV_TYPE_OFFSET);
2478                     tlv_length = tvb_get_ntohs (tvb, PTP_V2_AN_TLV_OFFSET+tlv_total_length+PTP_V2_AN_TLV_LENGTHFIELD_OFFSET);
2479
2480                     tlv_ti = proto_tree_add_text(
2481                         ptp_tree,
2482                         tvb,
2483                         PTP_V2_AN_TLV_OFFSET + tlv_total_length,
2484                         tlv_length + PTP_V2_AN_TLV_DATA_OFFSET,
2485                         "%s TLV",
2486                         val_to_str(tlv_type,
2487                                    ptp_v2_TLV_type_vals,
2488                                    "Unknown (%u)"));
2489
2490                     ptp_tlv_tree = proto_item_add_subtree(tlv_ti, ett_ptp_v2_tlv);
2491
2492                     proto_tree_add_item(ptp_tlv_tree,
2493                                         hf_ptp_v2_an_tlv_tlvtype,
2494                                         tvb,
2495                                         PTP_V2_AN_TLV_OFFSET + tlv_total_length + PTP_V2_AN_TLV_TYPE_OFFSET,
2496                                         2,
2497                                         FALSE);
2498
2499                     proto_tree_add_item(ptp_tlv_tree,
2500                                         hf_ptp_v2_an_tlv_lengthfield,
2501                                         tvb,
2502                                         PTP_V2_AN_TLV_OFFSET + tlv_total_length + PTP_V2_AN_TLV_LENGTHFIELD_OFFSET,
2503                                         2,
2504                                         FALSE);
2505
2506                     switch (tlv_type)
2507                     {
2508                         case PTP_V2_TLV_TYPE_ALTERNATE_TIME_OFFSET_INDICATOR:
2509                         {
2510                             proto_tree_add_item(ptp_tlv_tree,
2511                                                 hf_ptp_v2_atoi_tlv_keyfield,
2512                                                 tvb,
2513                                                 PTP_V2_AN_TLV_OFFSET + tlv_total_length + PTP_V2_AN_TLV_ATOI_KEYFIELD_OFFSET,
2514                                                 1,
2515                                                 FALSE);
2516
2517                             proto_tree_add_item(ptp_tlv_tree,
2518                                                 hf_ptp_v2_atoi_tlv_currentoffset,
2519                                                 tvb,
2520                                                 PTP_V2_AN_TLV_OFFSET + tlv_total_length + PTP_V2_AN_TLV_ATOI_CURRENTOFFSET_OFFSET,
2521                                                 4,
2522                                                 FALSE);
2523
2524                             proto_tree_add_item(ptp_tlv_tree,
2525                                                 hf_ptp_v2_atoi_tlv_jumpseconds,
2526                                                 tvb,
2527                                                 PTP_V2_AN_TLV_OFFSET + tlv_total_length + PTP_V2_AN_TLV_ATOI_JUMPSECONDS_OFFSET,
2528                                                 4,
2529                                                 FALSE);
2530
2531                             proto_tree_add_item(ptp_tlv_tree,
2532                                                 hf_ptp_v2_atoi_tlv_timeofnextjump,
2533                                                 tvb,
2534                                                 PTP_V2_AN_TLV_OFFSET + tlv_total_length + PTP_V2_AN_TLV_ATOI_TIMEOFNEXTJUMP_OFFSET,
2535                                                 6,
2536                                                 FALSE);
2537
2538                             Offset = PTP_V2_AN_TLV_OFFSET + tlv_total_length + PTP_V2_AN_TLV_ATOI_DISPLAYNAME_OFFSET;
2539                             dissect_ptp_v2_text(tvb,
2540                                                 &Offset,
2541                                                 ptp_tlv_tree,
2542                                                 hf_ptp_v2_atoi_tlv_displayname,
2543                                                 hf_ptp_v2_atoi_tlv_displayname_length);
2544
2545                             break;
2546                         }
2547                         case PTP_V2_TLV_TYPE_PATH_TRACE:
2548                         {
2549                             guint16 path_seq_total_length;
2550
2551                             for(path_seq_total_length = 0; path_seq_total_length < tlv_length; path_seq_total_length+=8)
2552                             {
2553                                 proto_tree_add_item(ptp_tlv_tree, hf_ptp_v2_an_tlv_pathsequence, tvb,
2554                                                     PTP_V2_AN_TLV_OFFSET + PTP_AS_AN_TLV_PATH_TRACE_OFFSET + path_seq_total_length,
2555                                                     8, FALSE);
2556                             }
2557
2558                             break;
2559                         }
2560                         default:
2561                         {
2562                             proto_tree_add_item(ptp_tlv_tree,
2563                                                 hf_ptp_v2_an_tlv_data,
2564                                                 tvb,
2565                                                 PTP_V2_AN_TLV_OFFSET + tlv_total_length + PTP_V2_AN_TLV_DATA_OFFSET,
2566                                                 tlv_length,
2567                                                 FALSE);
2568                             break;
2569                         }
2570                     }
2571
2572                     tlv_total_length += (tlv_length + PTP_V2_AN_TLV_DATA_OFFSET);
2573                 }
2574
2575                 break;
2576             }
2577
2578             case PTP_V2_SYNC_MESSAGE:
2579             case PTP_V2_DELAY_REQ_MESSAGE:{
2580                 timeStamp = tvb_get_ntohl(tvb, PTP_V2_SDR_ORIGINTIMESTAMPSECONDS_OFFSET);
2581                 timeStamp = timeStamp << 16;
2582                 timeStamp = timeStamp | tvb_get_ntohs(tvb, PTP_V2_SDR_ORIGINTIMESTAMPSECONDS_OFFSET+4);
2583
2584                 proto_tree_add_item(ptp_tree, hf_ptp_v2_sdr_origintimestamp_seconds, tvb,
2585                     PTP_V2_SDR_ORIGINTIMESTAMPSECONDS_OFFSET, 6, FALSE);
2586
2587                 proto_tree_add_item(ptp_tree, hf_ptp_v2_sdr_origintimestamp_nanoseconds, tvb,
2588                     PTP_V2_SDR_ORIGINTIMESTAMPNANOSECONDS_OFFSET, 4, FALSE);
2589
2590                 break;
2591             }
2592
2593             case PTP_V2_FOLLOWUP_MESSAGE:{
2594                 guint16     tlv_type;
2595                 guint16     tlv_length;
2596                 proto_item *tlv_ti;
2597                 proto_tree *ptp_tlv_tree;
2598
2599                 timeStamp = tvb_get_ntohl(tvb, PTP_V2_FU_PRECISEORIGINTIMESTAMPSECONDS_OFFSET);
2600                 timeStamp = timeStamp << 16;
2601                 timeStamp = timeStamp | tvb_get_ntohs(tvb, PTP_V2_FU_PRECISEORIGINTIMESTAMPSECONDS_OFFSET+4);
2602
2603                 proto_tree_add_item(ptp_tree, hf_ptp_v2_fu_preciseorigintimestamp_seconds, tvb,
2604                     PTP_V2_FU_PRECISEORIGINTIMESTAMPSECONDS_OFFSET, 6, FALSE);
2605
2606                 proto_tree_add_item(ptp_tree, hf_ptp_v2_fu_preciseorigintimestamp_nanoseconds, tvb,
2607                     PTP_V2_FU_PRECISEORIGINTIMESTAMPNANOSECONDS_OFFSET, 4, FALSE);
2608
2609                 /* In 802.1AS there is a Follow_UP information TLV in the Follow Up Message */
2610                 if(ptp_v2_transport_specific & PTP_V2_TRANSPORTSPECIFIC_ASPACKET_BITMASK){
2611
2612                     /* There are TLV's to be processed */
2613                     tlv_type = tvb_get_ntohs (tvb, PTP_AS_FU_TLV_INFORMATION_OFFSET + PTP_AS_FU_TLV_TYPE_OFFSET);
2614                     tlv_length = tvb_get_ntohs (tvb, PTP_AS_FU_TLV_INFORMATION_OFFSET + PTP_AS_FU_TLV_LENGTHFIELD_OFFSET);
2615
2616                     tlv_ti = proto_tree_add_text(
2617                         ptp_tree,
2618                         tvb,
2619                         PTP_AS_FU_TLV_INFORMATION_OFFSET,
2620                         tlv_length + PTP_AS_FU_TLV_ORGANIZATIONID_OFFSET,
2621                         "%s TLV",
2622                         "Follow Up information");
2623
2624                     ptp_tlv_tree = proto_item_add_subtree(tlv_ti, ett_ptp_v2_tlv);
2625
2626                     proto_tree_add_item(ptp_tlv_tree,
2627                                         hf_ptp_as_fu_tlv_tlvtype,
2628                                         tvb,
2629                                         PTP_AS_FU_TLV_INFORMATION_OFFSET + PTP_AS_FU_TLV_TYPE_OFFSET,
2630                                         2,
2631                                         FALSE);
2632
2633                     proto_tree_add_item(ptp_tlv_tree,
2634                                         hf_ptp_as_fu_tlv_lengthfield,
2635                                         tvb,
2636                                         PTP_AS_FU_TLV_INFORMATION_OFFSET + PTP_AS_FU_TLV_LENGTHFIELD_OFFSET,
2637                                         2,
2638                                         FALSE);
2639
2640                     proto_tree_add_item(ptp_tlv_tree,
2641                                         hf_ptp_as_fu_tlv_organization_id,
2642                                         tvb,
2643                                         PTP_AS_FU_TLV_INFORMATION_OFFSET + PTP_AS_FU_TLV_ORGANIZATIONID_OFFSET,
2644                                         3,
2645                                         FALSE);
2646
2647                     proto_tree_add_item(ptp_tlv_tree,
2648                                         hf_ptp_as_fu_tlv_organization_subtype,
2649                                         tvb,
2650                                         PTP_AS_FU_TLV_INFORMATION_OFFSET + PTP_AS_FU_TLV_ORGANIZATIONSUBTYPE_OFFSET,
2651                                         3,
2652                                         FALSE);
2653
2654                     proto_tree_add_item(ptp_tlv_tree,
2655                                         hf_ptp_as_fu_tlv_cumulative_offset,
2656                                         tvb,
2657                                         PTP_AS_FU_TLV_INFORMATION_OFFSET + PTP_AS_FU_TLV_CUMULATIVESCALEDRATEOFFSET_OFFSET,
2658                                         4,
2659                                         FALSE);
2660
2661                     proto_tree_add_item(ptp_tlv_tree,
2662                                         hf_ptp_as_fu_tlv_gm_base_indicator,
2663                                         tvb,
2664                                         PTP_AS_FU_TLV_INFORMATION_OFFSET + PTP_AS_FU_TLV_GMTIMEBASEINDICATOR_OFFSET,
2665                                         2,
2666                                         FALSE);
2667
2668                     proto_tree_add_item(ptp_tlv_tree,
2669                                         hf_ptp_as_fu_tlv_last_gm_phase_change,
2670                                         tvb,
2671                                         PTP_AS_FU_TLV_INFORMATION_OFFSET + PTP_AS_FU_TLV_LASTGMPHASECHANGE_OFFSET,
2672                                         12,
2673                                         FALSE);
2674
2675                     proto_tree_add_item(ptp_tlv_tree,
2676                                         hf_ptp_as_fu_tlv_scaled_last_gm_phase_change,
2677                                         tvb,
2678                                         PTP_AS_FU_TLV_INFORMATION_OFFSET + PTP_AS_FU_TLV_SCALEDLASTGMFREQCHANGE_OFFSET,
2679                                         4,
2680                                         FALSE);
2681
2682                 }
2683
2684                 break;
2685             }
2686
2687             case PTP_V2_DELAY_RESP_MESSAGE:{
2688                 timeStamp = tvb_get_ntohl(tvb, PTP_V2_DR_RECEIVETIMESTAMPSECONDS_OFFSET);
2689                 timeStamp = timeStamp << 16;
2690                 timeStamp = timeStamp | tvb_get_ntohs(tvb, PTP_V2_DR_RECEIVETIMESTAMPSECONDS_OFFSET+4);
2691
2692                 proto_tree_add_item(ptp_tree, hf_ptp_v2_dr_receivetimestamp_seconds, tvb,
2693                     PTP_V2_DR_RECEIVETIMESTAMPSECONDS_OFFSET, 6, FALSE);
2694
2695                 proto_tree_add_item(ptp_tree, hf_ptp_v2_dr_receivetimestamp_nanoseconds, tvb,
2696                     PTP_V2_DR_RECEIVETIMESTAMPNANOSECONDS_OFFSET, 4, FALSE);
2697
2698                 proto_tree_add_item(ptp_tree, hf_ptp_v2_dr_requestingportidentity, tvb,
2699                     PTP_V2_DR_REQUESTINGPORTIDENTITY_OFFSET, 8, FALSE);
2700
2701                 proto_tree_add_item(ptp_tree, hf_ptp_v2_dr_requestingsourceportid, tvb,
2702                     PTP_V2_DR_REQUESTINGSOURCEPORTID_OFFSET, 2, FALSE);
2703
2704                 break;
2705             }
2706
2707             case PTP_V2_PATH_DELAY_REQ_MESSAGE:{
2708                 /* In 802.1AS there is no origin timestamp in a Pdelay_Req Message */
2709                 if(!(ptp_v2_transport_specific & PTP_V2_TRANSPORTSPECIFIC_ASPACKET_BITMASK)){
2710
2711                     timeStamp = tvb_get_ntohl(tvb, PTP_V2_PDRQ_ORIGINTIMESTAMPSECONDS_OFFSET);
2712                     timeStamp = timeStamp << 16;
2713                     timeStamp = timeStamp | tvb_get_ntohs(tvb, PTP_V2_PDRQ_ORIGINTIMESTAMPSECONDS_OFFSET+4);
2714
2715                     proto_tree_add_item(ptp_tree, hf_ptp_v2_pdrq_origintimestamp_seconds, tvb,
2716                         PTP_V2_PDRQ_ORIGINTIMESTAMPSECONDS_OFFSET, 6, FALSE);
2717
2718                     proto_tree_add_item(ptp_tree, hf_ptp_v2_pdrq_origintimestamp_nanoseconds, tvb,
2719                         PTP_V2_PDRQ_ORIGINTIMESTAMPNANOSECONDS_OFFSET, 4, FALSE);
2720                 }
2721
2722                 break;
2723             }
2724
2725             case PTP_V2_PATH_DELAY_RESP_MESSAGE:{
2726                 timeStamp = tvb_get_ntohl(tvb, PTP_V2_PDRS_REQUESTRECEIPTTIMESTAMPSECONDS_OFFSET);
2727                 timeStamp = timeStamp << 16;
2728                 timeStamp = timeStamp | tvb_get_ntohs(tvb, PTP_V2_PDRS_REQUESTRECEIPTTIMESTAMPSECONDS_OFFSET+4);
2729
2730                 proto_tree_add_item(ptp_tree, hf_ptp_v2_pdrs_requestreceipttimestamp_seconds, tvb,
2731                     PTP_V2_PDRS_REQUESTRECEIPTTIMESTAMPSECONDS_OFFSET, 6, FALSE);
2732
2733                 proto_tree_add_item(ptp_tree, hf_ptp_v2_pdrs_requestreceipttimestamp_nanoseconds, tvb,
2734                     PTP_V2_PDRS_REQUESTRECEIPTTIMESTAMPNANOSECONDS_OFFSET, 4, FALSE);
2735
2736                 proto_tree_add_item(ptp_tree, hf_ptp_v2_pdrs_requestingportidentity, tvb,
2737                     PTP_V2_PDRS_REQUESTINGPORTIDENTITY_OFFSET, 8, FALSE);
2738
2739                 proto_tree_add_item(ptp_tree, hf_ptp_v2_pdrs_requestingsourceportid, tvb,
2740                     PTP_V2_PDRS_REQUESTINGSOURCEPORTID_OFFSET, 2, FALSE);
2741
2742                 break;
2743             }
2744
2745             case PTP_V2_PATH_DELAY_FOLLOWUP_MESSAGE:{
2746                 timeStamp = tvb_get_ntohl(tvb, PTP_V2_PDFU_RESPONSEORIGINTIMESTAMPSECONDS_OFFSET);
2747                 timeStamp = timeStamp << 16;
2748                 timeStamp = timeStamp | tvb_get_ntohs(tvb, PTP_V2_PDFU_RESPONSEORIGINTIMESTAMPSECONDS_OFFSET+4);
2749
2750                 proto_tree_add_item(ptp_tree, hf_ptp_v2_pdfu_responseorigintimestamp_seconds, tvb,
2751                     PTP_V2_PDFU_RESPONSEORIGINTIMESTAMPSECONDS_OFFSET, 6, FALSE);
2752
2753                 proto_tree_add_item(ptp_tree, hf_ptp_v2_pdfu_responseorigintimestamp_nanoseconds, tvb,
2754                     PTP_V2_PDFU_RESPONSEORIGINTIMESTAMPNANOSECONDS_OFFSET, 4, FALSE);
2755
2756
2757                 proto_tree_add_item(ptp_tree, hf_ptp_v2_pdfu_requestingportidentity, tvb,
2758                     PTP_V2_PDFU_REQUESTINGPORTIDENTITY_OFFSET, 8, FALSE);
2759
2760                 proto_tree_add_item(ptp_tree, hf_ptp_v2_pdfu_requestingsourceportid, tvb,
2761                     PTP_V2_PDFU_REQUESTINGSOURCEPORTID_OFFSET, 2, FALSE);
2762
2763                 break;
2764             }
2765
2766             case PTP_V2_SIGNALLING_MESSAGE:{
2767                 guint16 tlv_type, tlv_length;
2768                 proto_item *tlv_ti, *sig_tlv_flags_ti;
2769                 proto_tree *ptp_tlv_tree, *sig_tlv_flags_tree;
2770
2771                 proto_tree_add_item(ptp_tree, hf_ptp_v2_sig_targetportidentity, tvb,
2772                     PTP_V2_SIG_TARGETPORTIDENTITY_OFFSET, 8, FALSE);
2773
2774                 proto_tree_add_item(ptp_tree, hf_ptp_v2_sig_targetportid, tvb,
2775                     PTP_V2_SIG_TARGETPORTID_OFFSET, 2, FALSE);
2776
2777                 /* In 802.1AS there is a Message Interval Request TLV in the Signalling Message */
2778                 if(ptp_v2_transport_specific & PTP_V2_TRANSPORTSPECIFIC_ASPACKET_BITMASK){
2779
2780                     /* There are TLV's to be processed */
2781                     tlv_type = tvb_get_ntohs (tvb, PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET + PTP_AS_SIG_TLV_TYPE_OFFSET);
2782                     tlv_length = tvb_get_ntohs (tvb, PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET + PTP_AS_SIG_TLV_LENGTHFIELD_OFFSET);
2783
2784                     tlv_ti = proto_tree_add_text(
2785                         ptp_tree,
2786                         tvb,
2787                         PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET,
2788                         tlv_length + PTP_AS_SIG_TLV_ORGANIZATIONID_OFFSET,
2789                         "%s TLV",
2790                         "Message Interval Request");
2791
2792                     ptp_tlv_tree = proto_item_add_subtree(tlv_ti, ett_ptp_v2_tlv);
2793
2794                     proto_tree_add_item(ptp_tlv_tree,
2795                                         hf_ptp_as_sig_tlv_tlvtype,
2796                                         tvb,
2797                                         PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET + PTP_AS_SIG_TLV_TYPE_OFFSET,
2798                                         2,
2799                                         FALSE);
2800
2801                     proto_tree_add_item(ptp_tlv_tree,
2802                                         hf_ptp_as_sig_tlv_lengthfield,
2803                                         tvb,
2804                                         PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET + PTP_AS_SIG_TLV_LENGTHFIELD_OFFSET,
2805                                         2,
2806                                         FALSE);
2807
2808                     proto_tree_add_item(ptp_tlv_tree,
2809                                         hf_ptp_as_sig_tlv_organization_id,
2810                                         tvb,
2811                                         PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET + PTP_AS_SIG_TLV_ORGANIZATIONID_OFFSET,
2812                                         3,
2813                                         FALSE);
2814
2815                     proto_tree_add_item(ptp_tlv_tree,
2816                                         hf_ptp_as_sig_tlv_organization_subtype,
2817                                         tvb,
2818                                         PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET + PTP_AS_SIG_TLV_ORGANIZATIONSUBTYPE_OFFSET,
2819                                         3,
2820                                         FALSE);
2821
2822                     proto_tree_add_item(ptp_tlv_tree,
2823                                         hf_ptp_as_sig_tlv_link_delay_interval,
2824                                         tvb,
2825                                         PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET + PTP_AS_SIG_TLV_LINKDELAYINTERVAL_OFFSET,
2826                                         1,
2827                                         FALSE);
2828
2829                     proto_tree_add_item(ptp_tlv_tree,
2830                                         hf_ptp_as_sig_tlv_time_sync_interval,
2831                                         tvb,
2832                                         PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET + PTP_AS_SIG_TLV_TIMESYNCINTERVAL_OFFSET,
2833                                         1,
2834                                         FALSE);
2835
2836                     proto_tree_add_item(ptp_tlv_tree,
2837                                         hf_ptp_as_sig_tlv_announce_interval,
2838                                         tvb,
2839                                         PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET + PTP_AS_SIG_TLV_ANNOUNCEINTERVAL_OFFSET,
2840                                         1,
2841                                         FALSE);
2842
2843                     sig_tlv_flags_ti = proto_tree_add_item(ptp_tlv_tree,
2844                                                            hf_ptp_as_sig_tlv_flags,
2845                                                           tvb,
2846                                                           PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET + PTP_AS_SIG_TLV_FLAGS_OFFSET,
2847                                                           1,
2848                                                           FALSE);
2849
2850                     sig_tlv_flags_tree = proto_item_add_subtree(sig_tlv_flags_ti, ett_ptp_as_sig_tlv_flags);
2851
2852                     proto_tree_add_item(sig_tlv_flags_tree,
2853                                         hf_ptp_as_sig_tlv_flags_comp_rate_ratio,
2854                                         tvb,
2855                                         PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET + PTP_AS_SIG_TLV_FLAGS_OFFSET,
2856                                         1,
2857                                         FALSE);
2858
2859                     proto_tree_add_item(sig_tlv_flags_tree,
2860                                         hf_ptp_as_sig_tlv_flags_comp_prop_delay,
2861                                         tvb,
2862                                         PTP_AS_SIG_TLV_MESSAGEINTERVALREQUEST_OFFSET + PTP_AS_SIG_TLV_FLAGS_OFFSET,
2863                                         1,
2864                                         FALSE);
2865
2866                 }
2867                 else {
2868
2869                     proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_tlvType, tvb,
2870                         PTP_V2_SIG_TARGETPORTID_OFFSET+2, 2, FALSE);
2871
2872                     proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_lengthField, tvb,
2873                         PTP_V2_SIG_TARGETPORTID_OFFSET+4, 2, FALSE);
2874
2875                     tlv_type = tvb_get_ntohs (tvb, PTP_V2_MM_TLV_TYPE_OFFSET);
2876                     tlv_length = tvb_get_ntohs (tvb, PTP_V2_MM_TLV_LENGTHFIELD_OFFSET);
2877
2878                     if (tlv_length <= 2)
2879                     {
2880                         /* no data */
2881                         break;
2882                     }
2883                     /* ToDO: Add dissector for TLVs and allow multiple TLVs */
2884                     proto_tree_add_text(ptp_tree, tvb, PTP_V2_SIG_TARGETPORTID_OFFSET+6, tlv_length, "Data");
2885                 }
2886                 break;
2887             }
2888
2889             case PTP_V2_MANAGEMENT_MESSAGE:
2890             {
2891                 guint16 tlv_type, tlv_length;
2892
2893                 proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_targetportidentity, tvb,
2894                     PTP_V2_MM_TARGETPORTIDENTITY_OFFSET, 8, FALSE);
2895
2896                 proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_targetportid, tvb,
2897                     PTP_V2_MM_TARGETPORTID_OFFSET, 2, FALSE);
2898
2899                 proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_startingboundaryhops, tvb,
2900                     PTP_V2_MM_STARTINGBOUNDARYHOPS_OFFSET, 1, FALSE);
2901
2902                 proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_boundaryhops, tvb,
2903                     PTP_V2_MM_BOUNDARYHOPS_OFFSET, 1, FALSE);
2904
2905                 proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_action, tvb,
2906                     PTP_V2_MM_ACTION_OFFSET, 1, FALSE);
2907
2908                 /* management TLV */
2909                 proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_tlvType, tvb,
2910                     PTP_V2_MM_TLV_TYPE_OFFSET, 2, FALSE);
2911
2912                 proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_lengthField, tvb,
2913                     PTP_V2_MM_TLV_LENGTHFIELD_OFFSET, 2, FALSE);
2914
2915                 tlv_type = tvb_get_ntohs (tvb, PTP_V2_MM_TLV_TYPE_OFFSET);
2916                 tlv_length = tvb_get_ntohs (tvb, PTP_V2_MM_TLV_LENGTHFIELD_OFFSET);
2917
2918                 /* For management there are PTP_V2_TLV_TYPE_MANAGEMENT and PTP_V2_TLV_TYPE_MANAGEMENT_ERROR_STATUS TLVs */
2919                 switch(tlv_type) {
2920                     case PTP_V2_TLV_TYPE_MANAGEMENT:
2921                     {
2922                         guint16 ptp_v2_managementId;
2923                         guint16 Offset = PTP_V2_MM_TLV_DATAFIELD_OFFSET;
2924
2925                         proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_managementId, tvb,
2926                             PTP_V2_MM_TLV_MANAGEMENTID_OFFSET, 2, FALSE);
2927
2928                         ptp_v2_managementId = tvb_get_ntohs (tvb, PTP_V2_MM_TLV_MANAGEMENTID_OFFSET);
2929
2930                         if (tlv_length <= 2)
2931                         {
2932                             /* no data */
2933                             break;
2934                         }
2935
2936                         managementData_ti = proto_tree_add_text(ptp_tree, tvb, Offset, tlv_length, "Data");
2937
2938                         /* data field of the management message (subtree)*/
2939                         ptp_managementData_tree = proto_item_add_subtree(managementData_ti, ett_ptp_v2_managementData);
2940
2941                         switch(ptp_v2_managementId) {
2942                             case PTP_V2_MM_ID_NULL_MANAGEMENT:
2943                             {
2944                                 /* no data in NULL management */
2945                                 break;
2946                             }
2947                             case PTP_V2_MM_ID_CLOCK_DESCRIPTION:
2948                             {
2949                                 guint16 N = 0, S = 0;
2950                                 clockType_ti = proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_clockType, tvb,
2951                                     Offset, 2, FALSE);
2952
2953                                 ptp_clockType_tree = proto_item_add_subtree(clockType_ti, ett_ptp_v2_clockType);
2954                                     /* ClockType Subtree */
2955                                     proto_tree_add_item(ptp_clockType_tree, hf_ptp_v2_mm_clockType_ordinaryClock, tvb,
2956                                         Offset, 2, FALSE);
2957
2958                                     proto_tree_add_item(ptp_clockType_tree, hf_ptp_v2_mm_clockType_boundaryClock, tvb,
2959                                         Offset, 2, FALSE);
2960
2961                                     proto_tree_add_item(ptp_clockType_tree, hf_ptp_v2_mm_clockType_p2p_transparentClock, tvb,
2962                                         Offset, 2, FALSE);
2963
2964                                     proto_tree_add_item(ptp_clockType_tree, hf_ptp_v2_mm_clockType_e2e_transparentClock, tvb,
2965                                         Offset, 2, FALSE);
2966
2967                                     proto_tree_add_item(ptp_clockType_tree, hf_ptp_v2_mm_clockType_managementNode, tvb,
2968                                         Offset, 2, FALSE);
2969
2970                                     proto_tree_add_item(ptp_clockType_tree, hf_ptp_v2_mm_clockType_reserved, tvb,
2971                                         Offset, 2, FALSE);
2972                                 Offset +=2;
2973
2974                                 dissect_ptp_v2_text (tvb, &Offset, ptp_managementData_tree,
2975                                                      hf_ptp_v2_mm_physicalLayerProtocol, hf_ptp_v2_mm_physicalLayerProtocol_length);
2976
2977                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_physicalAddressLength, tvb,
2978                                     Offset, 2, FALSE);
2979
2980                                 S = tvb_get_ntohs (tvb, Offset);
2981                                 Offset +=2;
2982
2983                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_physicalAddress, tvb,
2984                                     Offset, S, FALSE);
2985                                 Offset += S;
2986
2987                                 N = tvb_get_ntohs (tvb, Offset+2);
2988
2989                                 protocolAddress_ti = proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_protocolAddress, tvb,
2990                                     Offset+4, N, FALSE);
2991
2992                                 ptp_protocolAddress_tree = proto_item_add_subtree(protocolAddress_ti, ett_ptp_v2_protocolAddress);
2993                                     /* physicalLayerProtocol subtree */
2994                                     proto_tree_add_item(ptp_protocolAddress_tree, hf_ptp_v2_mm_protocolAddress_networkProtocol, tvb,
2995                                         Offset, 2, FALSE);
2996
2997                                     proto_tree_add_item(ptp_protocolAddress_tree, hf_ptp_v2_mm_protocolAddress_length, tvb,
2998                                         Offset+2, 2, FALSE);
2999
3000                                     proto_tree_add_item(ptp_protocolAddress_tree, hf_ptp_v2_mm_protocolAddress, tvb,
3001                                         Offset+4, N, FALSE);
3002                                 N = N + 4;
3003                                 Offset += N;
3004
3005                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_manufacturerIdentity, tvb,
3006                                     Offset, 3, FALSE);
3007
3008                                 Offset += 3;
3009
3010                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3011                                     Offset, 1, FALSE);
3012                                 Offset += 1;
3013
3014                                 dissect_ptp_v2_text (tvb, &Offset, ptp_managementData_tree,
3015                                                      hf_ptp_v2_mm_productDescription, hf_ptp_v2_mm_productDescription_length);
3016                                 dissect_ptp_v2_text (tvb, &Offset, ptp_managementData_tree,
3017                                                      hf_ptp_v2_mm_revisionData, hf_ptp_v2_mm_revisionData_length);
3018                                 dissect_ptp_v2_text (tvb, &Offset, ptp_managementData_tree,
3019                                                      hf_ptp_v2_mm_userDescription, hf_ptp_v2_mm_userDescription_length);
3020
3021                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_profileIdentity, tvb,
3022                                     Offset, 6, FALSE);
3023                                 Offset += 6;
3024
3025                                 /* Wenn Offset nicht gerade folgt noch ein pad Bit */
3026                                 if ( (Offset - PTP_V2_MM_TLV_DATAFIELD_OFFSET) % 2 )
3027                                 {
3028                                     proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_pad, tvb,
3029                                     Offset, 1, FALSE);
3030                                 }
3031                                 break;
3032                             }
3033                             case PTP_V2_MM_ID_USER_DESCRIPTION:
3034                             {
3035
3036                                 dissect_ptp_v2_text (tvb, &Offset, ptp_managementData_tree,
3037                                                      hf_ptp_v2_mm_userDescription, hf_ptp_v2_mm_userDescription_length);
3038
3039                                 /* Wenn Offset nicht gerade folgt noch ein pad Bit */
3040                                 if ( (Offset - PTP_V2_MM_TLV_DATAFIELD_OFFSET) % 2 )
3041                                 {
3042                                     proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_pad, tvb,
3043                                     Offset, 1, FALSE);
3044                                 }
3045                                 break;
3046                             }
3047                             case PTP_V2_MM_ID_SAVE_IN_NON_VOLATILE_STORAGE:
3048                             {
3049                                 /* no data */
3050                                 break;
3051                             }
3052                             case PTP_V2_MM_ID_RESET_NON_VOLATILE_STORAGE:
3053                             {
3054                                 /* no data */
3055                                 break;
3056                             }
3057                             case PTP_V2_MM_ID_INITIALIZE:
3058                             {
3059                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_initializationKey, tvb,
3060                                     Offset, 2, FALSE);
3061                                 break;
3062                             }
3063                             case PTP_V2_MM_ID_FAULT_LOG:
3064                             {
3065                                 guint16 i, num = 0;
3066                                 proto_item  *ptpError_ti;
3067                                 proto_tree  *ptpError_subtree;
3068
3069                                 num = tvb_get_ntohs (tvb, Offset);
3070
3071                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_numberOfFaultRecords, tvb,
3072                                     Offset, 2, FALSE);
3073                                 Offset +=2;
3074
3075                                 for (i = 1; i <= num; i++)
3076                                 {
3077                                     ptpError_ti = proto_tree_add_text(ptp_managementData_tree, tvb, Offset, tvb_get_ntohs (tvb, Offset), "Fault record");
3078
3079                                     /*  (subtree)*/
3080                                     ptpError_subtree = proto_item_add_subtree(ptpError_ti, ett_ptp_v2_faultRecord);
3081
3082                                     proto_tree_add_item(ptpError_subtree, hf_ptp_v2_mm_faultRecordLength, tvb,
3083                                         Offset, 2, FALSE);
3084                                     Offset +=2;
3085
3086                                     timeStamp = tvb_get_ntohl(tvb, Offset);
3087                                     timeStamp = timeStamp << 16;
3088                                     timeStamp = timeStamp | tvb_get_ntohs(tvb, Offset+4);
3089
3090                                     proto_tree_add_item(ptpError_subtree, hf_ptp_v2_mm_faultTime_s, tvb,
3091                                                 Offset, 6, FALSE);
3092
3093                                     Offset +=6;
3094                                     proto_tree_add_item(ptpError_subtree, hf_ptp_v2_mm_faultTime_ns, tvb,
3095                                                 Offset, 4, FALSE);
3096                                     Offset +=4;
3097                                     proto_tree_add_item(ptpError_subtree, hf_ptp_v2_mm_severityCode, tvb,
3098                                                 Offset, 1, FALSE);
3099                                     Offset +=1;
3100
3101                                     dissect_ptp_v2_text (tvb, &Offset, ptpError_subtree,
3102                                                          hf_ptp_v2_mm_faultName, hf_ptp_v2_mm_faultName_length);
3103
3104                                     dissect_ptp_v2_text (tvb, &Offset, ptpError_subtree,
3105                                                          hf_ptp_v2_mm_faultValue, hf_ptp_v2_mm_faultValue_length);
3106
3107                                     dissect_ptp_v2_text (tvb, &Offset, ptpError_subtree,
3108                                                          hf_ptp_v2_mm_faultDescription, hf_ptp_v2_mm_faultDescription_length);
3109                                 }
3110
3111                                 /* Wenn Offset nicht gerade folgt noch ein pad Bit */
3112                                 if ( (Offset - PTP_V2_MM_TLV_DATAFIELD_OFFSET) % 2 )
3113                                 {
3114                                     proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_pad, tvb,
3115                                         Offset, 1, FALSE);
3116                                 }
3117                                 break;
3118                             }
3119                             case PTP_V2_MM_ID_FAULT_LOG_RESET:
3120                             {
3121                                 /* no data */
3122                                 break;
3123                             }
3124                             case PTP_V2_MM_ID_DEFAULT_DATA_SET:
3125                             {
3126                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_TSC, tvb,
3127                                     PTP_V2_MM_TLV_DATAFIELD_OFFSET, 1, FALSE);
3128
3129                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_dds_SO, tvb,
3130                                     PTP_V2_MM_TLV_DATAFIELD_OFFSET, 1, FALSE);
3131
3132                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3133                                     PTP_V2_MM_RESERVED1, 1, FALSE);
3134
3135                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_numberPorts, tvb,
3136                                     PTP_V2_MM_NUMBERPORTS, 2, FALSE);
3137
3138                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_priority1, tvb,
3139                                     PTP_V2_MM_PRIORITY1, 1, FALSE);
3140
3141                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_clockclass, tvb,
3142                                     PTP_V2_MM_CLOCKQUALITY, 1, FALSE);
3143
3144                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_clockaccuracy, tvb,
3145                                     PTP_V2_MM_CLOCKQUALITY+1, 1, FALSE);
3146
3147                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_clockvariance, tvb,
3148                                     PTP_V2_MM_CLOCKQUALITY+2, 2, FALSE);
3149
3150                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_priority2, tvb,
3151                                     PTP_V2_MM_PRIORITY2, 1, FALSE);
3152
3153                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_clockidentity, tvb,
3154                                     PTP_V2_MM_CLOCKIDENTITY, 8, FALSE);
3155
3156                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_domainNumber, tvb,
3157                                     PTP_V2_MM_DOMAINNUMBER, 1, FALSE);
3158
3159                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3160                                     PTP_V2_MM_RESERVED2, 1, FALSE);
3161                                 break;
3162                             }
3163                             case PTP_V2_MM_ID_CURRENT_DATA_SET:
3164                             {
3165                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_stepsRemoved, tvb,
3166                                     Offset, 2, FALSE);
3167                                 Offset +=2;
3168
3169                                 dissect_ptp_v2_timeInterval(tvb, &Offset, ptp_managementData_tree,
3170                                     "Offset from Master", hf_ptp_v2_mm_offset_ns, hf_ptp_v2_mm_offset_subns);
3171                                 dissect_ptp_v2_timeInterval(tvb, &Offset, ptp_managementData_tree,
3172                                     "Mean path delay", hf_ptp_v2_mm_pathDelay_ns, hf_ptp_v2_mm_pathDelay_subns);
3173                                 break;
3174                             }
3175                             case PTP_V2_MM_ID_PARENT_DATA_SET:
3176                             {
3177                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_parentIdentity, tvb,
3178                                     Offset, 8, FALSE);
3179
3180                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_parentPort, tvb,
3181                                     Offset+8, 2, FALSE);
3182                                 Offset +=10;
3183
3184                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_parentStats, tvb,
3185                                     Offset, 1, FALSE);
3186                                 Offset +=1;
3187
3188                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3189                                     Offset, 1, FALSE);
3190                                 Offset +=1;
3191
3192                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_observedParentOffsetScaledLogVariance, tvb,
3193                                     Offset, 2, FALSE);
3194                                 Offset +=2;
3195
3196                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_observedParentClockPhaseChangeRate, tvb,
3197                                     Offset, 4, FALSE);
3198                                 Offset +=4;
3199
3200                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_grandmasterPriority1, tvb,
3201                                     Offset, 1, FALSE);
3202                                 Offset +=1;
3203
3204                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_grandmasterclockclass, tvb,
3205                                     Offset, 1, FALSE);
3206
3207                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_grandmasterclockaccuracy, tvb,
3208                                     Offset+1, 1, FALSE);
3209
3210                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_grandmasterclockvariance, tvb,
3211                                     Offset+2, 2, FALSE);
3212                                 Offset += 4;
3213
3214                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_grandmasterPriority2, tvb,
3215                                     Offset, 1, FALSE);
3216                                 Offset +=1;
3217
3218                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_grandmasterIdentity, tvb,
3219                                     Offset, 8, FALSE);
3220
3221                                 break;
3222                             }
3223                             case PTP_V2_MM_ID_TIME_PROPERTIES_DATA_SET:
3224                             {
3225                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_currentUtcOffset, tvb,
3226                                     Offset, 2, FALSE);
3227                                 Offset +=2;
3228
3229                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_LI_61, tvb,
3230                                     Offset, 1, FALSE);
3231                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_LI_59, tvb,
3232                                     Offset, 1, FALSE);
3233                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_UTCV, tvb,
3234                                     Offset, 1, FALSE);
3235                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_PTP, tvb,
3236                                     Offset, 1, FALSE);
3237                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_TTRA, tvb,
3238                                     Offset, 1, FALSE);
3239                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_FTRA, tvb,
3240                                     Offset, 1, FALSE);
3241                                 Offset +=1;
3242
3243                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_timesource, tvb,
3244                                     Offset, 1, FALSE);
3245
3246                                 break;
3247                             }
3248                             case PTP_V2_MM_ID_PORT_DATA_SET:
3249                             {
3250                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_clockidentity, tvb,
3251                                     Offset, 8, FALSE);
3252                                 Offset +=8;
3253
3254                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_PortNumber, tvb,
3255                                     Offset, 2, FALSE);
3256                                 Offset +=2;
3257
3258                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_portState, tvb,
3259                                     Offset, 1, FALSE);
3260                                 Offset +=1;
3261
3262                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_logMinDelayReqInterval, tvb,
3263                                     Offset, 1, FALSE);
3264                                 Offset +=1;
3265
3266                                 dissect_ptp_v2_timeInterval(tvb, &Offset, ptp_managementData_tree,
3267                                     "Peer mean path delay", hf_ptp_v2_mm_peerMeanPathDelay_ns, hf_ptp_v2_mm_peerMeanPathDelay_subns);
3268
3269                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_logAnnounceInterval, tvb,
3270                                     Offset, 1, FALSE);
3271                                 Offset +=1;
3272
3273                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_announceReceiptTimeout, tvb,
3274                                     Offset, 1, FALSE);
3275                                 Offset +=1;
3276
3277                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_logSyncInterval, tvb,
3278                                     Offset, 1, FALSE);
3279                                 Offset +=1;
3280
3281                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_delayMechanism, tvb,
3282                                     Offset, 1, FALSE);
3283                                 Offset +=1;
3284
3285                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_logMinPdelayReqInterval, tvb,
3286                                     Offset, 1, FALSE);
3287                                 Offset +=1;
3288
3289                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_versionNumber, tvb,
3290                                     Offset, 1, FALSE);
3291                                 Offset +=1;
3292
3293                                 break;
3294                             }
3295                             case PTP_V2_MM_ID_PRIORITY1:
3296                             {
3297                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_priority1, tvb,
3298                                     Offset, 1, FALSE);
3299                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3300                                     Offset+1, 1, FALSE);
3301                                 break;
3302                             }
3303                             case PTP_V2_MM_ID_PRIORITY2:
3304                             {
3305                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_priority2, tvb,
3306                                     Offset, 1, FALSE);
3307                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3308                                     Offset+1, 1, FALSE);
3309                                 break;
3310                             }
3311                             case PTP_V2_MM_ID_DOMAIN:
3312                             {
3313                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_domainNumber, tvb,
3314                                     Offset, 1, FALSE);
3315                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3316                                     Offset+1, 1, FALSE);
3317                                 break;
3318                             }
3319                             case PTP_V2_MM_ID_SLAVE_ONLY:
3320                             {
3321                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_SO, tvb,
3322                                     Offset, 1, FALSE);
3323                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3324                                     Offset+1, 1, FALSE);
3325                                 break;
3326                             }
3327                             case PTP_V2_MM_ID_LOG_ANNOUNCE_INTERVAL:
3328                             {
3329                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_logAnnounceInterval, tvb,
3330                                     Offset, 1, FALSE);
3331
3332                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3333                                     Offset+1, 1, FALSE);
3334                                 break;
3335                             }
3336                             case PTP_V2_MM_ID_ANNOUNCE_RECEIPT_TIMEOUT:
3337                             {
3338                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_announceReceiptTimeout, tvb,
3339                                     Offset, 1, FALSE);
3340
3341                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3342                                     Offset+1, 1, FALSE);
3343                                 break;
3344                             }
3345                             case PTP_V2_MM_ID_LOG_SYNC_INTERVAL:
3346                             {
3347                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_logSyncInterval, tvb,
3348                                     Offset, 1, FALSE);
3349
3350                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3351                                     Offset+1, 1, FALSE);
3352                                 break;
3353                             }
3354                             case PTP_V2_MM_ID_VERSION_NUMBER:
3355                             {
3356                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_versionNumber, tvb,
3357                                     Offset, 1, FALSE);
3358
3359                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3360                                     Offset+1, 1, FALSE);
3361                                 break;
3362                             }
3363                             case PTP_V2_MM_ID_ENABLE_PORT:
3364                             {
3365                                 /* no data */
3366                                 break;
3367                             }
3368                             case PTP_V2_MM_ID_DISABLE_PORT:
3369                             {
3370                                 /* no data */
3371                                 break;
3372                             }
3373                             case PTP_V2_MM_ID_TIME:
3374                             {
3375                                 timeStamp = tvb_get_ntohl(tvb, Offset);
3376                                 timeStamp = timeStamp << 16;
3377                                 timeStamp = timeStamp | tvb_get_ntohs(tvb, Offset+4);
3378
3379                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_currentTime_s, tvb,
3380                                             Offset, 6, FALSE);
3381
3382                                 Offset +=6;
3383                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_currentTime_ns, tvb,
3384                                             Offset, 4, FALSE);
3385                                 break;
3386                             }
3387                             case PTP_V2_MM_ID_CLOCK_ACCURACY:
3388                             {
3389                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_clockAccuracy, tvb,
3390                                     Offset, 1, FALSE);
3391                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3392                                     Offset+1, 1, FALSE);
3393                                 break;
3394                             }
3395                             case PTP_V2_MM_ID_UTC_PROPERTIES:
3396                             {
3397                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_currentUtcOffset, tvb,
3398                                     Offset, 2, FALSE);
3399                                 Offset +=2;
3400
3401                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_LI_61, tvb,
3402                                     Offset, 1, FALSE);
3403                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_LI_59, tvb,
3404                                     Offset, 1, FALSE);
3405                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_UTCV, tvb,
3406                                     Offset, 1, FALSE);
3407                                 Offset +=1;
3408
3409                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3410                                     Offset, 1, FALSE);
3411                                 break;
3412                             }
3413                             case PTP_V2_MM_ID_TRACEABILITY_PROPERTIES:
3414                             {
3415                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_TTRA, tvb,
3416                                     Offset, 1, FALSE);
3417                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_FTRA, tvb,
3418                                     Offset, 1, FALSE);
3419                                 Offset +=1;
3420
3421                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3422                                     Offset, 1, FALSE);
3423
3424                                 break;
3425                             }
3426                             case PTP_V2_MM_ID_TIMESCALE_PROPERTIES:
3427                             {
3428                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_PTP, tvb,
3429                                     Offset, 1, FALSE);
3430                                 Offset +=1;
3431
3432                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_timesource, tvb,
3433                                     Offset, 1, FALSE);
3434
3435                                 break;
3436                             }
3437                             case PTP_V2_MM_ID_UNICAST_NEGOTIATION_ENABLE:
3438                             {
3439                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_ucEN, tvb,
3440                                     Offset, 1, FALSE);
3441                                 Offset +=1;
3442
3443                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3444                                     Offset, 1, FALSE);
3445                                 break;
3446                             }
3447                             case PTP_V2_MM_ID_PATH_TRACE_LIST:
3448                             {
3449                                 guint16 i = 0;
3450                                 /* one or more ClockIdentity */
3451                                 for (i = 1; i <= (tlv_length / 8); i++)
3452                                 {
3453                                     proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_clockidentity, tvb,
3454                                         Offset, 8, FALSE);
3455                                 }
3456
3457                                 break;
3458                             }
3459                             case PTP_V2_MM_ID_PATH_TRACE_ENABLE:
3460                             {
3461                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_ptEN, tvb,
3462                                     Offset, 1, FALSE);
3463                                 Offset +=1;
3464
3465                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3466                                     Offset, 1, FALSE);
3467
3468                                 break;
3469                             }
3470                             case PTP_V2_MM_ID_GRANDMASTER_CLUSTER_TABLE:
3471                                 {
3472                                 /* ToDo */
3473                                 break;
3474                                 }
3475                             case PTP_V2_MM_ID_UNICAST_MASTER_TABLE:
3476                                 {
3477                                 /* ToDo */
3478                                 break;
3479                                 }
3480                             case PTP_V2_MM_ID_UNICAST_MASTER_MAX_TABLE_SIZE:
3481                                 {
3482                                 /* ToDo */
3483                                 break;
3484                                 }
3485                             case PTP_V2_MM_ID_ACCEPTABLE_MASTER_TABLE:
3486                                 {
3487                                 /* ToDo */
3488                                 break;
3489                                 }
3490                             case PTP_V2_MM_ID_ACCEPTABLE_MASTER_TABLE_ENABLED:
3491                                 {
3492                                 /* ToDo */
3493                                 break;
3494                                 }
3495                             case PTP_V2_MM_ID_ACCEPTABLE_MASTER_MAX_TABLE_SIZE:
3496                                 {
3497                                 /* ToDo */
3498                                 break;
3499                                 }
3500                             case PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_ENABLE:
3501                             {
3502                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_keyField, tvb,
3503                                     Offset, 1, FALSE);
3504                                 Offset +=1;
3505
3506                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_atEN, tvb,
3507                                     Offset, 1, FALSE);
3508                                 Offset +=1;
3509
3510                                 break;
3511                             }
3512                             case PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_NAME:
3513                             {
3514                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_keyField, tvb,
3515                                     Offset, 1, FALSE);
3516                                 Offset +=1;
3517
3518                                 dissect_ptp_v2_text (tvb, &Offset, ptp_managementData_tree,
3519                                     hf_ptp_v2_mm_displayName, hf_ptp_v2_mm_displayName_length);
3520
3521                                 /* Wenn Offset nicht gerade folgt noch ein pad Bit */
3522                                 if ( (Offset - PTP_V2_MM_TLV_DATAFIELD_OFFSET) % 2 )
3523                                 {
3524                                     proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_pad, tvb,
3525                                         Offset, 1, FALSE);
3526                                 }
3527                                 break;
3528                             }
3529                             case PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_MAX_KEY:
3530                             {
3531                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_maxKey, tvb,
3532                                     Offset, 1, FALSE);
3533                                 Offset +=1;
3534
3535                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3536                                     Offset, 1, FALSE);
3537
3538                                 break;
3539                             }
3540                             case PTP_V2_MM_ID_ALTERNATE_MASTER:
3541                             {
3542                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_transmitAlternateMulticastSync, tvb,
3543                                     Offset, 1, FALSE);
3544                                 Offset +=1;
3545
3546                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_numberOfAlternateMasters, tvb,
3547                                     Offset, 1, FALSE);
3548                                 Offset +=1;
3549
3550                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_logAlternateMulticastSyncInterval, tvb,
3551                                     Offset, 1, FALSE);
3552                                 Offset +=1;
3553
3554                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3555                                     Offset, 1, FALSE);
3556                                 break;
3557                             }
3558                             case PTP_V2_MM_ID_ALTERNATE_TIME_OFFSET_PROPERTIES:
3559                             {
3560                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_keyField, tvb,
3561                                     Offset, 1, FALSE);
3562                                 Offset +=1;
3563
3564                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_currentOffset, tvb,
3565                                     Offset, 4, FALSE);
3566                                 Offset +=4;
3567
3568                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_jumpSeconds, tvb,
3569                                     Offset, 4, FALSE);
3570                                 Offset +=4;
3571
3572                                 timeStamp = tvb_get_ntohl(tvb, Offset);
3573                                 timeStamp = timeStamp << 16;
3574                                 timeStamp = timeStamp | tvb_get_ntohs(tvb, Offset+4);
3575
3576                                 proto_tree_add_text(ptp_managementData_tree, tvb, Offset, 6,
3577                                     "Time of next jump (seconds): %" G_GINT64_MODIFIER "u", timeStamp);
3578                                 Offset +=6;
3579
3580                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3581                                     Offset, 1, FALSE);
3582                                 break;
3583                             }
3584                             case PTP_V2_MM_ID_TC_DEFAULT_DATA_SET:
3585                             {
3586                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_clockidentity, tvb,
3587                                     Offset, 8, FALSE);
3588                                 Offset +=8;
3589
3590                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_numberPorts, tvb,
3591                                     Offset, 2, FALSE);
3592                                 Offset +=2;
3593
3594                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_delayMechanism, tvb,
3595                                     Offset, 1, FALSE);
3596                                 Offset +=1;
3597
3598                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_primaryDomain, tvb,
3599                                     Offset, 1, FALSE);
3600
3601                                 break;
3602                             }
3603                             case PTP_V2_MM_ID_TC_PORT_DATA_SET:
3604                             {
3605                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_clockidentity, tvb,
3606                                     Offset, 8, FALSE);
3607                                 Offset +=8;
3608
3609                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_PortNumber, tvb,
3610                                     Offset, 2, FALSE);
3611                                 Offset +=2;
3612
3613                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_faultyFlag, tvb,
3614                                     Offset, 1, FALSE);
3615                                 Offset +=1;
3616
3617                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_logMinPdelayReqInterval, tvb,
3618                                     Offset, 1, FALSE);
3619                                 Offset +=1;
3620
3621                                 dissect_ptp_v2_timeInterval(tvb, &Offset, ptp_managementData_tree,
3622                                     "Peer mean path delay", hf_ptp_v2_mm_peerMeanPathDelay_ns, hf_ptp_v2_mm_peerMeanPathDelay_subns);
3623                                 break;
3624                             }
3625                             case PTP_V2_MM_ID_PRIMARY_DOMAIN:
3626                             {
3627                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_primaryDomain, tvb,
3628                                     Offset, 1, FALSE);
3629
3630                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3631                                     Offset+1, 1, FALSE);
3632                                 break;
3633                             }
3634                             case PTP_V2_MM_ID_DELAY_MECHANISM:
3635                             {
3636                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_delayMechanism, tvb,
3637                                     Offset, 1, FALSE);
3638
3639                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3640                                     Offset+1, 1, FALSE);
3641                                 break;
3642                             }
3643                             case PTP_V2_MM_ID_LOG_MIN_PDELAY_REQ_INTERVAL:
3644                             {
3645                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_logMinPdelayReqInterval, tvb,
3646                                     Offset, 1, FALSE);
3647
3648                                 proto_tree_add_item(ptp_managementData_tree, hf_ptp_v2_mm_reserved, tvb,
3649                                     Offset+1, 1, FALSE);
3650                                 break;
3651                             }
3652                             default:
3653                             {
3654                                 /* no data */
3655                                 break;
3656                             }
3657                         } /* switch(ptp_v2_managementId) */
3658                         break;
3659                     }
3660                     case PTP_V2_TLV_TYPE_MANAGEMENT_ERROR_STATUS:
3661                     {
3662                         /* there is only one error TLV */
3663                         guint16 Offset = PTP_V2_MM_TLV_MANAGEMENTERRORID_OFFSET;
3664
3665                         proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_managementErrorId, tvb,
3666                             Offset, 2, FALSE);
3667                         Offset +=2;
3668
3669                         proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_managementId, tvb,
3670                             Offset, 2, FALSE);
3671                         Offset +=2;
3672
3673                         proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_reserved, tvb,
3674                             Offset, 4, FALSE);
3675                         Offset +=4;
3676
3677                         /* optional Field! */
3678                         if (Offset - PTP_V2_MM_TLV_MANAGEMENTERRORID_OFFSET + 2 < tlv_length)
3679                         {
3680                             dissect_ptp_v2_text (tvb, &Offset, ptp_tree,
3681                                 hf_ptp_v2_mm_displayData, hf_ptp_v2_mm_displayData_length);
3682                         }
3683
3684                         /* Wenn Offset nicht gerade folgt noch ein pad Bit */
3685                         if ( (Offset - PTP_V2_MM_TLV_MANAGEMENTERRORID_OFFSET) % 2 )
3686                         {
3687                             proto_tree_add_item(ptp_tree, hf_ptp_v2_mm_pad, tvb,
3688                                 Offset, 1, FALSE);
3689                         }
3690                         break;
3691                     }
3692                     default:
3693                     {
3694                         break;
3695                     }
3696                 } /* switch TLV Type */
3697             } /* case Management Message */
3698         } /* switch message ID*/
3699     } /* tree */
3700 }
3701
3702
3703 /* Register the protocol with Wireshark */
3704
3705 void
3706 proto_register_ptp(void)
3707 {
3708     static hf_register_info hf[] = {
3709         /* PTPv1 fields **********************************************************/
3710         /*Common fields for all frames*/
3711         { &hf_ptp_versionptp,
3712           { "versionPTP",           "ptp.versionptp",
3713             FT_UINT16, BASE_DEC, NULL, 0x00,
3714             NULL, HFILL }
3715         },
3716         { &hf_ptp_versionnetwork,
3717           { "versionNetwork",           "ptp.versionnetwork",
3718             FT_UINT16, BASE_DEC, NULL, 0x00,
3719             NULL, HFILL }
3720         },
3721         { &hf_ptp_subdomain,
3722           { "subdomain",           "ptp.subdomain",
3723             FT_STRING, BASE_NONE, NULL, 0x00,
3724             NULL, HFILL }
3725         },
3726         { &hf_ptp_messagetype,
3727           { "messageType",           "ptp.messagetype",
3728             FT_UINT8, BASE_DEC, VALS(ptp_messagetype_vals), 0x00,
3729             NULL, HFILL }
3730         },
3731         { &hf_ptp_sourcecommunicationtechnology,
3732           { "sourceCommunicationTechnology",           "ptp.sourcecommunicationtechnology",
3733             FT_UINT8, BASE_DEC, VALS(ptp_communicationid_vals), 0x00,
3734             NULL, HFILL }
3735         },
3736         { &hf_ptp_sourceuuid,
3737           { "sourceUuid",           "ptp.sourceuuid",
3738             FT_ETHER, BASE_NONE, NULL, 0x00,
3739             NULL, HFILL }
3740         },
3741         { &hf_ptp_sourceportid,
3742           { "sourcePortId",           "ptp.sourceportid",
3743             FT_UINT16, BASE_DEC, NULL, 0x00,
3744             NULL, HFILL }
3745         },
3746         { &hf_ptp_sequenceid,
3747           { "sequenceId",           "ptp.sequenceid",
3748             FT_UINT16, BASE_DEC, NULL, 0x00,
3749             NULL, HFILL }
3750         },
3751         { &hf_ptp_control,
3752           { "control",           "ptp.control",
3753             FT_UINT8, BASE_DEC, VALS(ptp_control_vals), 0x00,
3754             NULL, HFILL }
3755         },
3756         /*THE FLAGS-FIELD*/
3757         { &hf_ptp_flags,
3758           { "flags",           "ptp.flags",
3759             FT_UINT16, BASE_HEX, NULL, 0x00,
3760             NULL, HFILL }
3761         },
3762         { &hf_ptp_flags_li61,
3763           { "PTP_LI61",           "ptp.flags.li61",
3764             FT_UINT16, BASE_DEC, VALS(ptp_bool_vals), PTP_FLAGS_LI61_BITMASK,
3765             NULL, HFILL }
3766         },
3767         { &hf_ptp_flags_li59,
3768           { "PTP_LI59",           "ptp.flags.li59",
3769             FT_UINT16, BASE_DEC, VALS(ptp_bool_vals), PTP_FLAGS_LI59_BITMASK,
3770             NULL, HFILL }
3771         },
3772         { &hf_ptp_flags_boundary_clock,
3773           { "PTP_BOUNDARY_CLOCK",           "ptp.flags.boundary_clock",
3774             FT_UINT16, BASE_DEC, VALS(ptp_bool_vals), PTP_FLAGS_BOUNDARY_CLOCK_BITMASK,
3775             NULL, HFILL }
3776         },
3777         { &hf_ptp_flags_assist,
3778           { "PTP_ASSIST",           "ptp.flags.assist",
3779             FT_UINT16, BASE_DEC, VALS(ptp_bool_vals), PTP_FLAGS_ASSIST_BITMASK,
3780             NULL, HFILL }
3781         },
3782         { &hf_ptp_flags_ext_sync,
3783           { "PTP_EXT_SYNC",           "ptp.flags.ext_sync",
3784             FT_UINT16, BASE_DEC, VALS(ptp_bool_vals), PTP_FLAGS_EXT_SYNC_BITMASK,
3785             NULL, HFILL }
3786         },
3787         { &hf_ptp_flags_parent,
3788           { "PTP_PARENT_STATS",           "ptp.flags.parent_stats",
3789             FT_UINT16, BASE_DEC, VALS(ptp_bool_vals), PTP_FLAGS_PARENT_STATS_BITMASK,
3790             NULL, HFILL }
3791         },
3792         { &hf_ptp_flags_sync_burst,
3793           { "PTP_SYNC_BURST",           "ptp.flags.sync_burst",
3794             FT_UINT16, BASE_DEC, VALS(ptp_bool_vals), PTP_FLAGS_SYNC_BURST_BITMASK,
3795             NULL, HFILL }
3796         },
3797         /*END OF THE FLAG-FIELD*/
3798
3799         /*offsets for ptp_sync and delay_req (=sdr) messages*/
3800         { &hf_ptp_sdr_origintimestamp,
3801           { "originTimestamp",           "ptp.sdr.origintimestamp",
3802             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
3803             NULL, HFILL }
3804         },
3805         { &hf_ptp_sdr_origintimestamp_seconds,
3806           { "originTimestamp (seconds)",           "ptp.sdr.origintimestamp_seconds",
3807             FT_UINT32, BASE_DEC, NULL, 0x00,
3808             NULL, HFILL }
3809         },
3810         { &hf_ptp_sdr_origintimestamp_nanoseconds,
3811           { "originTimestamp (nanoseconds)",           "ptp.sdr.origintimestamp_nanoseconds",
3812             FT_INT32, BASE_DEC, NULL, 0x00,
3813             NULL, HFILL }
3814         },
3815         { &hf_ptp_sdr_epochnumber,
3816           { "epochNumber",           "ptp.sdr.epochnumber",
3817             FT_UINT16, BASE_DEC, NULL, 0x00,
3818             NULL, HFILL }
3819         },
3820         { &hf_ptp_sdr_currentutcoffset,
3821           { "currentUTCOffset",           "ptp.sdr.currentutcoffset",
3822             FT_INT16, BASE_DEC, NULL, 0x00,
3823             NULL, HFILL }
3824         },
3825         { &hf_ptp_sdr_grandmastercommunicationtechnology,
3826           { "grandmasterCommunicationTechnology",           "ptp.sdr.grandmastercommunicationtechnology",
3827             FT_UINT8, BASE_DEC, VALS(ptp_communicationid_vals), 0x00,
3828             NULL, HFILL }
3829         },
3830         { &hf_ptp_sdr_grandmasterclockuuid,
3831           { "grandMasterClockUuid",           "ptp.sdr.grandmasterclockuuid",
3832             FT_ETHER, BASE_NONE, NULL, 0x00,
3833             NULL, HFILL }
3834         },
3835         { &hf_ptp_sdr_grandmasterportid,
3836           { "grandmasterPortId",           "ptp.sdr.grandmasterportid",
3837             FT_UINT16, BASE_DEC, NULL, 0x00,
3838             NULL, HFILL }
3839         },
3840         { &hf_ptp_sdr_grandmastersequenceid,
3841           { "grandmasterSequenceId",           "ptp.sdr.grandmastersequenceid",
3842             FT_UINT16, BASE_DEC, NULL, 0x00,
3843             NULL, HFILL }
3844         },
3845         { &hf_ptp_sdr_grandmasterclockstratum,
3846           { "grandmasterClockStratum",           "ptp.sdr.grandmasterclockstratum",
3847             FT_UINT8, BASE_DEC, NULL, 0x00,
3848             NULL, HFILL }
3849         },
3850         { &hf_ptp_sdr_grandmasterclockidentifier,
3851           { "grandmasterClockIdentifier",           "ptp.sdr.grandmasterclockidentifier",
3852             FT_STRING, BASE_NONE, NULL, 0x00,
3853             NULL, HFILL }
3854         },
3855         { &hf_ptp_sdr_grandmasterclockvariance,
3856           { "grandmasterClockVariance",           "ptp.sdr.grandmasterclockvariance",
3857             FT_INT16, BASE_DEC, NULL, 0x00,
3858             NULL, HFILL }
3859         },
3860         { &hf_ptp_sdr_grandmasterpreferred,
3861           { "grandmasterPreferred",           "ptp.sdr.grandmasterpreferred",
3862             FT_UINT8, BASE_DEC, NULL, 0x00,
3863             NULL, HFILL }
3864         },
3865         { &hf_ptp_sdr_grandmasterisboundaryclock,
3866           { "grandmasterIsBoundaryClock",           "ptp.sdr.grandmasterisboundaryclock",
3867             FT_UINT8, BASE_DEC, NULL, 0x00,
3868             NULL, HFILL }
3869         },
3870         { &hf_ptp_sdr_syncinterval,
3871           { "syncInterval",           "ptp.sdr.syncinterval",
3872             FT_INT8, BASE_DEC, NULL, 0x00,
3873             NULL, HFILL }
3874         },
3875         { &hf_ptp_sdr_localclockvariance,
3876           { "localClockVariance",           "ptp.sdr.localclockvariance",
3877             FT_INT16, BASE_DEC, NULL, 0x00,
3878             NULL, HFILL }
3879         },
3880         { &hf_ptp_sdr_localstepsremoved,
3881           { "localStepsRemoved",           "ptp.sdr.localstepsremoved",
3882             FT_UINT16, BASE_DEC, NULL, 0x00,
3883             NULL, HFILL }
3884         },
3885         { &hf_ptp_sdr_localclockstratum,
3886           { "localClockStratum",           "ptp.sdr.localclockstratum",
3887             FT_UINT8, BASE_DEC, NULL, 0x00,
3888             NULL, HFILL }
3889         },
3890         { &hf_ptp_sdr_localclockidentifier,
3891           { "localClockIdentifier",           "ptp.sdr.localclockidentifier",
3892             FT_STRING, BASE_NONE, NULL, 0x00,
3893             NULL, HFILL }
3894         },
3895         { &hf_ptp_sdr_parentcommunicationtechnology,
3896           { "parentCommunicationTechnology",           "ptp.sdr.parentcommunicationtechnology",
3897             FT_UINT8, BASE_DEC, VALS(ptp_communicationid_vals), 0x00,
3898             NULL, HFILL }
3899         },
3900         { &hf_ptp_sdr_parentuuid,
3901           { "parentUuid",           "ptp.sdr.parentuuid",
3902             FT_ETHER, BASE_NONE, NULL, 0x00,
3903             NULL, HFILL }
3904         },
3905         { &hf_ptp_sdr_parentportfield,
3906           { "parentPortField",           "ptp.sdr.parentportfield",
3907             FT_UINT16, BASE_DEC, NULL, 0x00,
3908             NULL, HFILL }
3909         },
3910         { &hf_ptp_sdr_estimatedmastervariance,
3911           { "estimatedMasterVariance",           "ptp.sdr.estimatedmastervariance",
3912             FT_INT16, BASE_DEC, NULL, 0x00,
3913             NULL, HFILL }
3914         },
3915         { &hf_ptp_sdr_estimatedmasterdrift,
3916           { "estimatedMasterDrift",           "ptp.sdr.estimatedmasterdrift",
3917             FT_INT32, BASE_DEC, NULL, 0x00,
3918             NULL, HFILL }
3919         },
3920         { &hf_ptp_sdr_utcreasonable,
3921           { "utcReasonable",           "ptp.sdr.utcreasonable",
3922             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3923             NULL, HFILL }
3924         },
3925         /*offsets for follow_up (=fu) messages*/
3926         { &hf_ptp_fu_associatedsequenceid,
3927           { "associatedSequenceId",           "ptp.fu.associatedsequenceid",
3928             FT_UINT16, BASE_DEC, NULL, 0x00,
3929             NULL, HFILL }
3930         },
3931         { &hf_ptp_fu_preciseorigintimestamp,
3932           { "preciseOriginTimestamp",    "ptp.fu.hf_ptp_fu_preciseorigintimestamp",
3933             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
3934             NULL, HFILL }
3935         },
3936         { &hf_ptp_fu_preciseorigintimestamp_seconds,
3937           { "preciseOriginTimestamp (seconds)",    "ptp.fu.hf_ptp_fu_preciseorigintimestamp_seconds",
3938             FT_UINT32, BASE_DEC, NULL, 0x00,
3939             NULL, HFILL }
3940         },
3941         { &hf_ptp_fu_preciseorigintimestamp_nanoseconds,
3942           { "preciseOriginTimestamp (nanoseconds)",           "ptp.fu.preciseorigintimestamp_nanoseconds",
3943             FT_INT32, BASE_DEC, NULL, 0x00,
3944             NULL, HFILL }
3945         },
3946         /*offsets for delay_resp (=dr) messages*/
3947         { &hf_ptp_dr_delayreceipttimestamp,
3948           { "delayReceiptTimestamp",           "ptp.dr.delayreceipttimestamp",
3949             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
3950             NULL, HFILL }
3951         },
3952         { &hf_ptp_dr_delayreceipttimestamp_seconds,
3953           { "delayReceiptTimestamp (Seconds)",           "ptp.dr.delayreceipttimestamp_seconds",
3954             FT_UINT32, BASE_DEC, NULL, 0x00,
3955             NULL, HFILL }
3956         },
3957         { &hf_ptp_dr_delayreceipttimestamp_nanoseconds,
3958           { "delayReceiptTimestamp (nanoseconds)",           "ptp.dr.delayreceipttimestamp_nanoseconds",
3959             FT_INT32, BASE_DEC, NULL, 0x00,
3960             NULL, HFILL }
3961         },
3962         { &hf_ptp_dr_requestingsourcecommunicationtechnology,
3963           { "requestingSourceCommunicationTechnology",    "ptp.dr.requestingsourcecommunicationtechnology",
3964             FT_UINT8, BASE_DEC, VALS(ptp_communicationid_vals), 0x00,
3965             NULL, HFILL }
3966         },
3967         { &hf_ptp_dr_requestingsourceuuid,
3968           { "requestingSourceUuid",           "ptp.dr.requestingsourceuuid",
3969             FT_ETHER, BASE_NONE, NULL, 0x00,
3970             NULL, HFILL }
3971         },
3972         { &hf_ptp_dr_requestingsourceportid,
3973           { "requestingSourcePortId",           "ptp.dr.requestingsourceportid",
3974             FT_UINT16, BASE_DEC, NULL, 0x00,
3975             NULL, HFILL }
3976         },
3977         { &hf_ptp_dr_requestingsourcesequenceid,
3978           { "requestingSourceSequenceId",           "ptp.dr.requestingsourcesequenceid",
3979             FT_UINT16, BASE_DEC, NULL, 0x00,
3980             NULL, HFILL }
3981         },
3982         /*offsets for management (=mm) messages*/
3983         { &hf_ptp_mm_targetcommunicationtechnology,
3984           { "targetCommunicationTechnology",           "ptp.mm.targetcommunicationtechnology",
3985             FT_UINT8, BASE_DEC, VALS(ptp_communicationid_vals), 0x00,
3986             NULL, HFILL }
3987         },
3988         { &hf_ptp_mm_targetuuid,
3989           { "targetUuid",           "ptp.mm.targetuuid",
3990             FT_ETHER, BASE_NONE, NULL, 0x00,
3991             NULL, HFILL }
3992         },
3993         { &hf_ptp_mm_targetportid,
3994           { "targetPortId",           "ptp.mm.targetportid",
3995             FT_UINT16, BASE_DEC, NULL, 0x00,
3996             NULL, HFILL }
3997         },
3998         { &hf_ptp_mm_startingboundaryhops,
3999           { "startingBoundaryHops",           "ptp.mm.startingboundaryhops",
4000             FT_INT16, BASE_DEC, NULL, 0x00,
4001             NULL, HFILL }
4002         },
4003         { &hf_ptp_mm_boundaryhops,
4004           { "boundaryHops",           "ptp.mm.boundaryhops",
4005             FT_INT16, BASE_DEC, NULL, 0x00,
4006             NULL, HFILL }
4007         },
4008         { &hf_ptp_mm_managementmessagekey,
4009           { "managementMessageKey",           "ptp.mm.managementmessagekey",
4010             FT_UINT8, BASE_DEC, VALS(ptp_managementMessageKey_vals), 0x00,
4011             NULL, HFILL }
4012         },
4013         { &hf_ptp_mm_parameterlength,
4014           { "parameterLength",           "ptp.mm.parameterlength",
4015             FT_UINT16, BASE_DEC, NULL, 0x00,
4016             NULL, HFILL }
4017         },
4018         /*parameterlength > 0*/
4019         { &hf_ptp_mm_messageparameters,
4020           { "messageParameters",           "ptp.mm.messageparameters",
4021             FT_BYTES, BASE_NONE, NULL, 0x00,
4022             NULL, HFILL }
4023         },
4024         /*ptp_mm_clock_identity (parameterlength = 64)*/
4025         { &hf_ptp_mm_clock_identity_clockcommunicationtechnology,
4026           { "clockCommunicationTechnology",           "ptp.mm.clock.identity.clockcommunicationtechnology",
4027             FT_UINT8, BASE_DEC, VALS(ptp_communicationid_vals), 0x00,
4028             NULL, HFILL }
4029         },
4030         { &hf_ptp_mm_clock_identity_clockuuidfield,
4031           { "clockUuidField",           "ptp.mm.clock.identity.clockuuidfield",
4032             FT_ETHER, BASE_NONE, NULL, 0x00,
4033             NULL, HFILL }
4034         },
4035         { &hf_ptp_mm_clock_identity_clockportfield,
4036           { "clockPortField",           "ptp.mm.clock.identity.clockportfield",
4037             FT_UINT16, BASE_DEC, NULL, 0x00,
4038             NULL, HFILL }
4039         },
4040         { &hf_ptp_mm_clock_identity_manufactureridentity,
4041           { "manufacturerIdentity",           "ptp.mm.clock.identity.manufactureridentity",
4042             FT_BYTES, BASE_NONE, NULL, 0x00,
4043             NULL, HFILL }
4044         },
4045
4046         /*ptp_mm_initialize_clock (parameterlength = 4)*/
4047         { &hf_ptp_mm_initialize_clock_initialisationkey,
4048           { "initialisationKey",           "ptp.mm.initialize.clock.initialisationkey",
4049             FT_UINT16, BASE_DEC, NULL, 0x00,
4050             NULL, HFILL }
4051         },
4052         /*ptp_mm_set_subdomain (parameterlength = 16)*/
4053         { &hf_ptp_mm_set_subdomain_subdomainname,
4054           { "subdomainName",           "ptp.mm.set.subdomain.subdomainname",
4055             FT_STRING, BASE_NONE, NULL, 0x00,
4056             NULL, HFILL }
4057         },
4058         /*ptp_mm_default_data_set (parameterlength = 76)*/
4059         { &hf_ptp_mm_default_data_set_clockcommunicationtechnology,
4060           { "clockCommunicationTechnology",           "ptp.mm.default.data.set.clockcommunicationtechnology",
4061             FT_UINT8, BASE_DEC, VALS(ptp_communicationid_vals), 0x00,
4062             NULL, HFILL }
4063         },
4064         { &hf_ptp_mm_default_data_set_clockuuidfield,
4065           { "clockUuidField",           "ptp.mm.default.data.set.clockuuidfield",
4066             FT_ETHER, BASE_NONE, NULL, 0x00,
4067             NULL, HFILL }
4068         },
4069         { &hf_ptp_mm_default_data_set_clockportfield,
4070           { "clockPortField",           "ptp.mm.default.data.set.clockportfield",
4071             FT_UINT16, BASE_DEC, NULL, 0x00,
4072             NULL, HFILL }
4073         },
4074         { &hf_ptp_mm_default_data_set_clockstratum,
4075           { "clockStratum",           "ptp.mm.default.data.set.clockstratum",
4076             FT_UINT8, BASE_DEC, NULL, 0x00,
4077             NULL, HFILL }
4078         },
4079         { &hf_ptp_mm_default_data_set_clockidentifier,
4080           { "clockIdentifier",           "ptp.mm.default.data.set.clockidentifier",
4081             FT_BYTES, BASE_NONE, NULL, 0x00,
4082             NULL, HFILL }
4083         },
4084         { &hf_ptp_mm_default_data_set_clockvariance,
4085           { "clockVariance",           "ptp.mm.default.data.set.clockvariance",
4086             FT_UINT16, BASE_DEC, NULL, 0x00,
4087             NULL, HFILL }
4088         },
4089         { &hf_ptp_mm_default_data_set_clockfollowupcapable,
4090           { "clockFollowupCapable",           "ptp.mm.default.data.set.clockfollowupcapable",
4091             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4092             NULL, HFILL }
4093         },
4094         { &hf_ptp_mm_default_data_set_preferred,
4095           { "preferred",           "ptp.mm.default.data.set.preferred",
4096             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4097             NULL, HFILL }
4098         },
4099         { &hf_ptp_mm_default_data_set_initializable,
4100           { "initializable",           "ptp.mm.default.data.set.initializable",
4101             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4102             NULL, HFILL }
4103         },
4104         { &hf_ptp_mm_default_data_set_externaltiming,
4105           { "externalTiming",           "ptp.mm.default.data.set.externaltiming",
4106             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4107             NULL, HFILL }
4108         },
4109         { &hf_ptp_mm_default_data_set_isboundaryclock,
4110           { "isBoundaryClock",           "ptp.mm.default.data.set.isboundaryclock",
4111             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4112             NULL, HFILL }
4113         },
4114         { &hf_ptp_mm_default_data_set_syncinterval,
4115           { "syncInterval",           "ptp.mm.default.data.set.syncinterval",
4116             FT_INT8, BASE_DEC, NULL, 0x00,
4117             NULL, HFILL }
4118         },
4119         { &hf_ptp_mm_default_data_set_subdomainname,
4120           { "subDomainName",           "ptp.mm.default.data.set.subdomainname",
4121             FT_STRING, BASE_NONE, NULL, 0x00,
4122             NULL, HFILL }
4123         },
4124         { &hf_ptp_mm_default_data_set_numberports,
4125           { "numberPorts",           "ptp.mm.default.data.set.numberports",
4126             FT_UINT16, BASE_DEC, NULL, 0x00,
4127             NULL, HFILL }
4128         },
4129         { &hf_ptp_mm_default_data_set_numberforeignrecords,
4130           { "numberForeignRecords",           "ptp.mm.default.data.set.numberforeignrecords",
4131             FT_UINT16, BASE_DEC, NULL, 0x00,
4132             NULL, HFILL }
4133         },
4134         /*ptp_mm_update_default_data_set (parameterlength = 36)*/
4135         { &hf_ptp_mm_update_default_data_set_clockstratum,
4136           { "clockStratum",           "ptp.mm.update.default.data.set.clockstratum",
4137             FT_UINT8, BASE_DEC, NULL, 0x00,
4138             NULL, HFILL }
4139         },
4140         { &hf_ptp_mm_update_default_data_set_clockidentifier,
4141           { "clockIdentifier",           "ptp.mm.update.default.data.set.clockidentifier",
4142             FT_BYTES, BASE_NONE, NULL, 0x00,
4143             NULL, HFILL }
4144         },
4145         { &hf_ptp_mm_update_default_data_set_clockvariance,
4146           { "clockVariance",           "ptp.mm.update.default.data.set.clockvariance",
4147             FT_UINT16, BASE_DEC, NULL, 0x00,
4148             NULL, HFILL }
4149         },
4150         { &hf_ptp_mm_update_default_data_set_preferred,
4151           { "preferred",           "ptp.mm.update.default.data.set.preferred",
4152             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4153             NULL, HFILL }
4154         },
4155         { &hf_ptp_mm_update_default_data_set_syncinterval,
4156           { "syncInterval",           "ptp.mm.update.default.data.set.syncinterval",
4157             FT_INT8, BASE_DEC, NULL, 0x00,
4158             NULL, HFILL }
4159         },
4160         { &hf_ptp_mm_update_default_data_set_subdomainname,
4161           { "subdomainName",           "ptp.mm.update.default.data.set.subdomainname",
4162             FT_STRING, BASE_NONE, NULL, 0x00,
4163             NULL, HFILL }
4164         },
4165         /*ptp_mm_current_data_set (parameterlength = 20)*/
4166         { &hf_ptp_mm_current_data_set_stepsremoved,
4167           { "stepsRemoved",           "ptp.mm.current.data.set.stepsremoved",
4168             FT_UINT16, BASE_DEC, NULL, 0x00,
4169             NULL, HFILL }
4170         },
4171         { &hf_ptp_mm_current_data_set_offsetfrommaster,
4172           { "offsetFromMaster",           "ptp.mm.current.data.set.offsetfrommaster",
4173             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
4174             NULL, HFILL }
4175         },
4176         { &hf_ptp_mm_current_data_set_offsetfrommasterseconds,
4177           { "offsetFromMasterSeconds",           "ptp.mm.current.data.set.offsetfrommasterseconds",
4178             FT_UINT32, BASE_DEC, NULL, 0x00,
4179             NULL, HFILL }
4180         },
4181         { &hf_ptp_mm_current_data_set_offsetfrommasternanoseconds,
4182           { "offsetFromMasterNanoseconds",           "ptp.mm.current.data.set.offsetfrommasternanoseconds",
4183             FT_INT32, BASE_DEC, NULL, 0x00,
4184             NULL, HFILL }
4185         },
4186         { &hf_ptp_mm_current_data_set_onewaydelay,
4187           { "oneWayDelay",           "ptp.mm.current.data.set.onewaydelay",
4188             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
4189             NULL, HFILL }
4190         },
4191         { &hf_ptp_mm_current_data_set_onewaydelayseconds,
4192           { "oneWayDelaySeconds",           "ptp.mm.current.data.set.onewaydelayseconds",
4193             FT_UINT32, BASE_DEC, NULL, 0x00,
4194             NULL, HFILL }
4195         },
4196         { &hf_ptp_mm_current_data_set_onewaydelaynanoseconds,
4197           { "oneWayDelayNanoseconds",           "ptp.mm.current.data.set.onewaydelaynanoseconds",
4198             FT_INT32, BASE_DEC, NULL, 0x00,
4199             NULL, HFILL }
4200         },
4201         /*ptp_mm_parent_data_set (parameterlength = 90)*/
4202         { &hf_ptp_mm_parent_data_set_parentcommunicationtechnology,
4203           { "parentCommunicationTechnology",           "ptp.mm.parent.data.set.parentcommunicationtechnology",
4204             FT_UINT8, BASE_DEC, VALS(ptp_communicationid_vals), 0x00,
4205             NULL, HFILL }
4206         },
4207         { &hf_ptp_mm_parent_data_set_parentuuid,
4208           { "parentUuid",           "ptp.mm.parent.data.set.parentuuid",
4209             FT_ETHER, BASE_NONE, NULL, 0x00,
4210             NULL, HFILL }
4211         },
4212         { &hf_ptp_mm_parent_data_set_parentportid,
4213           { "parentPortId",           "ptp.mm.parent.data.set.parentportid",
4214             FT_UINT16, BASE_DEC, NULL, 0x00,
4215             NULL, HFILL }
4216         },
4217         { &hf_ptp_mm_parent_data_set_parentlastsyncsequencenumber,
4218           { "parentLastSyncSequenceNumber",           "ptp.mm.parent.data.set.parentlastsyncsequencenumber",
4219             FT_UINT16, BASE_DEC, NULL, 0x00,
4220             NULL, HFILL }
4221         },
4222         { &hf_ptp_mm_parent_data_set_parentfollowupcapable,
4223           { "parentFollowupCapable",           "ptp.mm.parent.data.set.parentfollowupcapable",
4224             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4225             NULL, HFILL }
4226         },
4227         { &hf_ptp_mm_parent_data_set_parentexternaltiming,
4228           { "parentExternalTiming",           "ptp.mm.parent.data.set.parentexternaltiming",
4229             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4230             NULL, HFILL }
4231         },
4232         { &hf_ptp_mm_parent_data_set_parentvariance,
4233           { "parentVariance",           "ptp.mm.parent.data.set.parentvariance",
4234             FT_UINT16, BASE_DEC, NULL, 0x00,
4235             NULL, HFILL }
4236         },
4237         { &hf_ptp_mm_parent_data_set_parentstats,
4238           { "parentStats",           "ptp.mm.parent.data.set.parentstats",
4239             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4240             NULL, HFILL }
4241         },
4242         { &hf_ptp_mm_parent_data_set_observedvariance,
4243           { "observedVariance",           "ptp.mm.parent.data.set.observedvariance",
4244             FT_INT16, BASE_DEC, NULL, 0x00,
4245             NULL, HFILL }
4246         },
4247         { &hf_ptp_mm_parent_data_set_observeddrift,
4248           { "observedDrift",           "ptp.mm.parent.data.set.observeddrift",
4249             FT_INT32, BASE_DEC, NULL, 0x00,
4250             NULL, HFILL }
4251         },
4252         { &hf_ptp_mm_parent_data_set_utcreasonable,
4253           { "utcReasonable",           "ptp.mm.parent.data.set.utcreasonable",
4254             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4255             NULL, HFILL }
4256         },
4257         { &hf_ptp_mm_parent_data_set_grandmastercommunicationtechnology,
4258           { "grandmasterCommunicationTechnology",    "ptp.mm.parent.data.set.grandmastercommunicationtechnology",
4259             FT_UINT8, BASE_DEC, VALS(ptp_communicationid_vals), 0x00,
4260             NULL, HFILL }
4261         },
4262         { &hf_ptp_mm_parent_data_set_grandmasteruuidfield,
4263           { "grandmasterUuidField",           "ptp.mm.parent.data.set.grandmasteruuidfield",
4264             FT_ETHER, BASE_NONE, NULL, 0x00,
4265             NULL, HFILL }
4266         },
4267         { &hf_ptp_mm_parent_data_set_grandmasterportidfield,
4268           { "grandmasterPortIdField",           "ptp.mm.parent.data.set.grandmasterportidfield",
4269             FT_UINT16, BASE_DEC, NULL, 0x00,
4270             NULL, HFILL }
4271         },
4272         { &hf_ptp_mm_parent_data_set_grandmasterstratum,
4273           { "grandmasterStratum",           "ptp.mm.parent.data.set.grandmasterstratum",
4274             FT_UINT8, BASE_DEC, NULL, 0x00,
4275             NULL, HFILL }
4276         },
4277         { &hf_ptp_mm_parent_data_set_grandmasteridentifier,
4278           { "grandmasterIdentifier",           "ptp.mm.parent.data.set.grandmasteridentifier",
4279             FT_BYTES, BASE_NONE, NULL, 0x00,
4280             NULL, HFILL }
4281         },
4282         { &hf_ptp_mm_parent_data_set_grandmastervariance,
4283           { "grandmasterVariance",           "ptp.mm.parent.data.set.grandmastervariance",
4284             FT_INT16, BASE_DEC, NULL, 0x00,
4285             NULL, HFILL }
4286         },
4287         { &hf_ptp_mm_parent_data_set_grandmasterpreferred,
4288           { "grandmasterPreferred",           "ptp.mm.parent.data.set.grandmasterpreferred",
4289             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4290             NULL, HFILL }
4291         },
4292         { &hf_ptp_mm_parent_data_set_grandmasterisboundaryclock,
4293           { "grandmasterIsBoundaryClock",           "ptp.mm.parent.data.set.grandmasterisboundaryclock",
4294             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4295             NULL, HFILL }
4296         },
4297         { &hf_ptp_mm_parent_data_set_grandmastersequencenumber,
4298           { "grandmasterSequenceNumber",           "ptp.mm.parent.data.set.grandmastersequencenumber",
4299             FT_UINT16, BASE_DEC, NULL, 0x00,
4300             NULL, HFILL }
4301         },
4302         /*ptp_mm_port_data_set (parameterlength = 52)*/
4303         { &hf_ptp_mm_port_data_set_returnedportnumber,
4304           { "returnedPortNumber",           "ptp.mm.port.data.set.returnedportnumber",
4305             FT_UINT16, BASE_DEC, NULL, 0x00,
4306             NULL, HFILL }
4307         },
4308         { &hf_ptp_mm_port_data_set_portstate,
4309           { "portState",           "ptp.mm.port.data.set.portstate",
4310             FT_UINT8, BASE_DEC, NULL, 0x00,
4311             NULL, HFILL }
4312         },
4313         { &hf_ptp_mm_port_data_set_lastsynceventsequencenumber,
4314           { "lastSyncEventSequenceNumber",           "ptp.mm.port.data.set.lastsynceventsequencenumber",
4315             FT_UINT16, BASE_DEC, NULL, 0x00,
4316             NULL, HFILL }
4317         },
4318         { &hf_ptp_mm_port_data_set_lastgeneraleventsequencenumber,
4319           { "lastGeneralEventSequenceNumber",           "ptp.mm.port.data.set.lastgeneraleventsequencenumber",
4320             FT_UINT16, BASE_DEC, NULL, 0x00,
4321             NULL, HFILL }
4322         },
4323         { &hf_ptp_mm_port_data_set_portcommunicationtechnology,
4324           { "portCommunicationTechnology",           "ptp.mm.port.data.set.portcommunicationtechnology",
4325             FT_UINT8, BASE_DEC, VALS(ptp_communicationid_vals), 0x00,
4326             NULL, HFILL }
4327         },
4328         { &hf_ptp_mm_port_data_set_portuuidfield,
4329           { "portUuidField",           "ptp.mm.port.data.set.portuuidfield",
4330             FT_ETHER, BASE_NONE, NULL, 0x00,
4331             NULL, HFILL }
4332         },
4333         { &hf_ptp_mm_port_data_set_portidfield,
4334           { "portIdField",           "ptp.mm.port.data.set.portidfield",
4335             FT_UINT16, BASE_DEC, NULL, 0x00,
4336             NULL, HFILL }
4337         },
4338         { &hf_ptp_mm_port_data_set_burstenabled,
4339           { "burstEnabled",           "ptp.mm.port.data.set.burstenabled",
4340             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4341             NULL, HFILL }
4342         },
4343         { &hf_ptp_mm_port_data_set_subdomainaddressoctets,
4344           { "subdomainAddressOctets",           "ptp.mm.port.data.set.subdomainaddressoctets",
4345             FT_UINT8, BASE_DEC, NULL, 0x00,
4346             NULL, HFILL }
4347         },
4348         { &hf_ptp_mm_port_data_set_eventportaddressoctets,
4349           { "eventPortAddressOctets",           "ptp.mm.port.data.set.eventportaddressoctets",
4350             FT_UINT8, BASE_DEC, NULL, 0x00,
4351             NULL, HFILL }
4352         },
4353         { &hf_ptp_mm_port_data_set_generalportaddressoctets,
4354           { "generalPortAddressOctets",           "ptp.mm.port.data.set.generalportaddressoctets",
4355             FT_UINT8, BASE_DEC, NULL, 0x00,
4356             NULL, HFILL }
4357         },
4358         { &hf_ptp_mm_port_data_set_subdomainaddress,
4359           { "subdomainAddress",           "ptp.mm.port.data.set.subdomainaddress",
4360             FT_BYTES, BASE_NONE, NULL, 0x00,
4361             NULL, HFILL }
4362         },
4363         { &hf_ptp_mm_port_data_set_eventportaddress,
4364           { "eventPortAddress",           "ptp.mm.port.data.set.eventportaddress",
4365             FT_BYTES, BASE_NONE, NULL, 0x00,
4366             NULL, HFILL }
4367         },
4368         { &hf_ptp_mm_port_data_set_generalportaddress,
4369           { "generalPortAddress",           "ptp.mm.port.data.set.generalportaddress",
4370             FT_BYTES, BASE_NONE, NULL, 0x00,
4371             NULL, HFILL }
4372         },
4373         /*ptp_mm_global_time_data_set (parameterlength = 24)*/
4374         { &hf_ptp_mm_global_time_data_set_localtime,
4375           { "localTime",           "ptp.mm.global.time.data.set.localtime",
4376             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
4377             NULL, HFILL }
4378         },
4379         { &hf_ptp_mm_global_time_data_set_localtimeseconds,
4380           { "localTimeSeconds",           "ptp.mm.global.time.data.set.localtimeseconds",
4381             FT_UINT32, BASE_DEC, NULL, 0x00,
4382             NULL, HFILL }
4383         },
4384         { &hf_ptp_mm_global_time_data_set_localtimenanoseconds,
4385           { "localTimeNanoseconds",           "ptp.mm.global.time.data.set.localtimenanoseconds",
4386             FT_INT32, BASE_DEC, NULL, 0x00,
4387             NULL, HFILL }
4388         },
4389         { &hf_ptp_mm_global_time_data_set_currentutcoffset,
4390           { "currentUtcOffset",           "ptp.mm.global.time.data.set.currentutcoffset",
4391             FT_INT16, BASE_DEC, NULL, 0x00,
4392             NULL, HFILL }
4393         },
4394         { &hf_ptp_mm_global_time_data_set_leap59,
4395           { "leap59",           "ptp.mm.global.time.data.set.leap59",
4396             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4397             NULL, HFILL }
4398         },
4399         { &hf_ptp_mm_global_time_data_set_leap61,
4400           { "leap61",           "ptp.mm.global.time.data.set.leap61",
4401             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4402             NULL, HFILL }
4403         },
4404         { &hf_ptp_mm_global_time_data_set_epochnumber,
4405           { "epochNumber",           "ptp.mm.global.time.data.set.epochnumber",
4406             FT_UINT16, BASE_DEC, NULL, 0x00,
4407             NULL, HFILL }
4408         },
4409         /*ptp_mm_update_global_time_properties (parameterlength = 16)*/
4410         { &hf_ptp_mm_update_global_time_properties_currentutcoffset,
4411           { "currentUtcOffset",           "ptp.mm.update.global.time.properties.currentutcoffset",
4412             FT_UINT16, BASE_DEC, NULL, 0x00,
4413             NULL, HFILL }
4414         },
4415         { &hf_ptp_mm_update_global_time_properties_leap59,
4416           { "leap59",           "ptp.mm.update.global.time.properties.leap59",
4417             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4418             NULL, HFILL }
4419         },
4420         { &hf_ptp_mm_update_global_time_properties_leap61,
4421           { "leap61",           "ptp.mm.update.global.time.properties.leap61",
4422             FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4423             NULL, HFILL }
4424         },
4425         { &hf_ptp_mm_update_global_time_properties_epochnumber,
4426           { "epochNumber",           "ptp.mm.update.global.time.properties.epochnumber",
4427             FT_UINT16, BASE_DEC, NULL, 0x00,
4428             NULL, HFILL }
4429         },
4430         /*ptp_mm_get_foreign_data_set (parameterlength = 4)*/
4431         { &hf_ptp_mm_get_foreign_data_set_recordkey,
4432           { "recordKey",           "ptp.mm.get.foreign.data.set.recordkey",
4433             FT_UINT16, BASE_DEC, NULL, 0x00,
4434             NULL, HFILL }
4435         },
4436         /*ptp_mm_foreign_data_set (parameterlength = 28)*/
4437         { &hf_ptp_mm_foreign_data_set_returnedportnumber,
4438           { "returnedPortNumber",           "ptp.mm.foreign.data.set.returnedportnumber",
4439             FT_UINT16, BASE_DEC, NULL, 0x00,
4440             NULL, HFILL }
4441         },
4442         { &hf_ptp_mm_foreign_data_set_returnedrecordnumber,
4443           { "returnedRecordNumber",           "ptp.mm.foreign.data.set.returnedrecordnumber",
4444             FT_UINT16, BASE_DEC, NULL, 0x00,
4445             NULL, HFILL }
4446         },
4447         { &hf_ptp_mm_foreign_data_set_foreignmastercommunicationtechnology,
4448           { "foreignMasterCommunicationTechnology",
4449             "ptp.mm.foreign.data.set.foreignmastercommunicationtechnology",
4450             FT_UINT8, BASE_DEC, VALS(ptp_communicationid_vals), 0x00,
4451             NULL, HFILL }
4452         },
4453         { &hf_ptp_mm_foreign_data_set_foreignmasteruuidfield,
4454           { "foreignMasterUuidField",           "ptp.mm.foreign.data.set.foreignmasteruuidfield",
4455             FT_ETHER, BASE_NONE, NULL, 0x00,
4456             NULL, HFILL }
4457         },
4458         { &hf_ptp_mm_foreign_data_set_foreignmasterportidfield,
4459           { "foreignMasterPortIdField",           "ptp.mm.foreign.data.set.foreignmasterportidfield",
4460             FT_UINT16, BASE_DEC, NULL, 0x00,
4461             NULL, HFILL }
4462         },
4463         { &hf_ptp_mm_foreign_data_set_foreignmastersyncs,
4464           { "foreignMasterSyncs",           "ptp.mm.foreign.data.set.foreignmastersyncs",
4465             FT_UINT16, BASE_DEC, NULL, 0x00,
4466             NULL, HFILL }
4467         },
4468         /*ptp_mm_set_sync_interval (parameterlength = 4)*/
4469         { &hf_ptp_mm_set_sync_interval_syncinterval,
4470           { "syncInterval",           "ptp.mm.set.sync.interval.syncinterval",
4471             FT_UINT16, BASE_DEC, NULL, 0x00,
4472             NULL, HFILL }
4473         },
4474         /*ptp_mm_set_time (parameterlength = 8)*/
4475         { &hf_ptp_mm_set_time_localtime,
4476           { "localtime",           "ptp.mm.set.time.localtime",
4477             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
4478             NULL, HFILL }
4479         },
4480         { &hf_ptp_mm_set_time_localtimeseconds,
4481           { "localtimeSeconds",           "ptp.mm.set.time.localtimeseconds",
4482             FT_UINT32, BASE_DEC, NULL, 0x00,
4483             NULL, HFILL }
4484         },
4485         { &hf_ptp_mm_set_time_localtimenanoseconds,
4486           { "localTimeNanoseconds",           "ptp.mm.set.time.localtimenanoseconds",
4487             FT_INT32, BASE_DEC, NULL, 0x0,
4488             NULL, HFILL }
4489         },
4490
4491
4492
4493
4494         /* PTPv2 fields **********************************************************/
4495         /*Common fields for all frames*/
4496         { &hf_ptp_v2_transportspecific,
4497           { "transportSpecific",           "ptp.v2.transportspecific",
4498             FT_UINT8, BASE_HEX, NULL, 0xF0,
4499             NULL, HFILL }
4500         },
4501         { &hf_ptp_v2_transportspecific_v1_compatibility,
4502           { "V1 Compatibility",           "ptp.v2.transportspecific.v1compatibility",
4503             FT_BOOLEAN, 8, NULL, PTP_V2_TRANSPORTSPECIFIC_V1COMPATIBILITY_BITMASK,
4504             NULL, HFILL }
4505         },
4506         { &hf_ptp_v2_transportspecific_802as_conform,
4507           { "802.1as conform",           "ptp.v2.transportspecific.802.1asconform",
4508             FT_BOOLEAN, 8, NULL, PTP_V2_TRANSPORTSPECIFIC_V1COMPATIBILITY_BITMASK,
4509             NULL, HFILL }
4510         },
4511         { &hf_ptp_v2_messageid,
4512           { "messageId",           "ptp.v2.messageid",
4513             FT_UINT8, BASE_HEX, VALS(ptp_v2_messageid_vals), 0x0F,
4514             NULL, HFILL }
4515         },
4516         { &hf_ptp_v2_versionptp,
4517           { "versionPTP",           "ptp.v2.versionptp",
4518             FT_UINT8, BASE_DEC, NULL, 0x0F,
4519             NULL, HFILL }
4520         },
4521         { &hf_ptp_v2_messagelength,
4522           { "messageLength",           "ptp.v2.messagelength",
4523             FT_UINT16, BASE_DEC, NULL, 0x00,
4524             NULL, HFILL }
4525         },
4526         { &hf_ptp_v2_domainnumber,
4527           { "subdomainNumber",           "ptp.v2.subdomainnumber",
4528             FT_UINT8, BASE_DEC, NULL, 0x00,
4529             NULL, HFILL }
4530         },
4531         { &hf_ptp_v2_flags,
4532           { "flags",           "ptp.v2.flags",
4533             FT_UINT16, BASE_HEX, NULL, 0x00,
4534             NULL, HFILL }
4535         },
4536         { &hf_ptp_v2_flags_alternatemaster,
4537           { "PTP_ALTERNATE_MASTER",     "ptp.v2.flags.alternatemaster",
4538             FT_BOOLEAN, 16, NULL, PTP_V2_FLAGS_ALTERNATE_BITMASK,
4539             NULL, HFILL }
4540         },
4541         { &hf_ptp_v2_flags_twostep,
4542           { "PTP_TWO_STEP",           "ptp.v2.flags.twostep",
4543             FT_BOOLEAN, 16, NULL, PTP_V2_FLAGS_TWO_STEP_BITMASK,
4544             NULL, HFILL }
4545         },
4546         { &hf_ptp_v2_flags_unicast,
4547           { "PTP_UNICAST",           "ptp.v2.flags.unicast",
4548             FT_BOOLEAN, 16, NULL, PTP_V2_FLAGS_UNICAST_BITMASK,
4549             NULL, HFILL }
4550         },
4551         { &hf_ptp_v2_flags_specific1,
4552           { "PTP profile Specific 1",           "ptp.v2.flags.specific1",
4553             FT_BOOLEAN, 16, NULL, PTP_V2_FLAGS_SPECIFIC1_BITMASK,
4554             NULL, HFILL }
4555         },
4556         { &hf_ptp_v2_flags_specific2,
4557           { "PTP profile Specific 2",           "ptp.v2.flags.specific2",
4558             FT_BOOLEAN, 16, NULL, PTP_V2_FLAGS_SPECIFIC2_BITMASK,
4559             NULL, HFILL }
4560         },
4561         { &hf_ptp_v2_flags_security,
4562           { "PTP_SECURITY",           "ptp.v2.flags.security",
4563             FT_BOOLEAN, 16, NULL, PTP_V2_FLAGS_SECURITY_BITMASK,
4564             NULL, HFILL }
4565         },
4566         { &hf_ptp_v2_flags_li61,
4567           { "PTP_LI_61",           "ptp.v2.flags.li61",
4568             FT_BOOLEAN, 16, NULL, PTP_V2_FLAGS_LI61_BITMASK,
4569             NULL, HFILL }
4570         },
4571         { &hf_ptp_v2_flags_li59,
4572           { "PTP_LI_59",           "ptp.v2.flags.li59",
4573             FT_BOOLEAN, 16, NULL, PTP_V2_FLAGS_LI59_BITMASK,
4574             NULL, HFILL }
4575         },
4576         { &hf_ptp_v2_flags_utcoffsetvalid,
4577           { "PTP_UTC_REASONABLE",           "ptp.v2.flags.utcreasonable",
4578             FT_BOOLEAN, 16, NULL, PTP_V2_FLAGS_UTC_OFFSET_VALID_BITMASK,
4579             NULL, HFILL }
4580         },
4581         { &hf_ptp_v2_flags_ptptimescale,
4582           { "PTP_TIMESCALE",           "ptp.v2.flags.timescale",
4583             FT_BOOLEAN, 16, NULL, PTP_V2_FLAGS_PTP_TIMESCALE_BITMASK,
4584             NULL, HFILL }
4585         },
4586         { &hf_ptp_v2_flags_timetraceable,
4587           { "TIME_TRACEABLE",           "ptp.v2.flags.timetraceable",
4588             FT_BOOLEAN, 16, NULL, PTP_V2_FLAGS_TIME_TRACEABLE_BITMASK,
4589             NULL, HFILL }
4590         },
4591         { &hf_ptp_v2_flags_frequencytraceable,
4592           { "FREQUENCY_TRACEABLE",           "ptp.v2.flags.frequencytraceable",
4593             FT_BOOLEAN, 16, NULL, PTP_V2_FLAGS_FREQUENCY_TRACEABLE_BITMASK,
4594             NULL, HFILL }
4595         },
4596         { &hf_ptp_v2_correction,
4597           { "correction",           "ptp.v2.correction.ns",
4598             FT_UINT64, BASE_DEC, NULL, 0x00,
4599             NULL, HFILL }
4600         },
4601         { &hf_ptp_v2_correctionsubns,
4602           { "correctionSubNs",           "ptp.v2.correction.subns",
4603             FT_DOUBLE, BASE_NONE, NULL, 0x00,
4604             NULL, HFILL }
4605         },
4606         { &hf_ptp_v2_clockidentity,
4607           { "ClockIdentity",           "ptp.v2.clockidentity",
4608             FT_UINT64, BASE_HEX, NULL, 0x00,
4609             NULL, HFILL }
4610         },
4611         { &hf_ptp_v2_sourceportid,
4612           { "SourcePortID",           "ptp.v2.sourceportid",
4613             FT_UINT16, BASE_DEC, NULL, 0x00,
4614             NULL, HFILL }
4615         },
4616         { &hf_ptp_v2_sequenceid,
4617           { "sequenceId",           "ptp.v2.sequenceid",
4618             FT_UINT16, BASE_DEC, NULL, 0x00,
4619             NULL, HFILL }
4620         },
4621         { &hf_ptp_v2_control,
4622           { "control",           "ptp.v2.control",
4623             FT_UINT8, BASE_DEC, VALS(ptp_control_vals), 0x00,
4624             NULL, HFILL }
4625         },
4626         { &hf_ptp_v2_logmessageperiod,
4627           { "logMessagePeriod",           "ptp.v2.logmessageperiod",
4628             FT_INT8, BASE_DEC, NULL, 0x00,
4629             NULL, HFILL }
4630         },
4631
4632         /*Fields for PTP_Announce (=an) messages*/
4633         { &hf_ptp_v2_an_origintimestamp,
4634           { "originTimestamp",           "ptp.v2.an.origintimestamp",
4635             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
4636             NULL, HFILL }
4637         },
4638         { &hf_ptp_v2_an_origintimestamp_seconds,
4639           { "originTimestamp (seconds)",           "ptp.v2.an.origintimestamp.seconds",
4640             FT_UINT64, BASE_DEC, NULL, 0x00,
4641             NULL, HFILL }
4642         },
4643         { &hf_ptp_v2_an_origintimestamp_nanoseconds,
4644           { "originTimestamp (nanoseconds)",           "ptp.v2.an.origintimestamp.nanoseconds",
4645             FT_INT32, BASE_DEC, NULL, 0x00,
4646             NULL, HFILL }
4647         },
4648         { &hf_ptp_v2_an_origincurrentutcoffset,
4649           { "originCurrentUTCOffset",           "ptp.v2.an.origincurrentutcoffset",
4650             FT_INT16, BASE_DEC, NULL, 0x00,
4651             NULL, HFILL }
4652         },
4653         { &hf_ptp_v2_an_timesource,
4654           { "TimeSource",           "ptp.v2.timesource",
4655             FT_UINT8, BASE_HEX, VALS(ptp_v2_timesource_vals), 0x00,
4656             NULL, HFILL }
4657         },
4658         { &hf_ptp_v2_an_localstepsremoved,
4659           { "localStepsRemoved",           "ptp.v2.an.localstepsremoved",
4660             FT_UINT16, BASE_DEC, NULL, 0x00,
4661             NULL, HFILL }
4662         },
4663         { &hf_ptp_v2_an_grandmasterclockidentity,
4664           { "grandmasterClockIdentity",           "ptp.v2.an.grandmasterclockidentity",
4665             FT_UINT64, BASE_HEX, NULL, 0x00,
4666             NULL, HFILL }
4667         },
4668         { &hf_ptp_v2_an_grandmasterclockclass,
4669           { "grandmasterClockClass",           "ptp.v2.an.grandmasterclockclass",
4670             FT_UINT8, BASE_DEC, NULL, 0x00,
4671             NULL, HFILL }
4672         },
4673         { &hf_ptp_v2_an_grandmasterclockaccuracy,
4674           { "grandmasterClockAccuracy",           "ptp.v2.an.grandmasterclockaccuracy",
4675             FT_UINT8, BASE_HEX, VALS(ptp_v2_clockaccuracy_vals), 0x00,
4676             NULL, HFILL }
4677         },
4678         { &hf_ptp_v2_an_grandmasterclockvariance,
4679           { "grandmasterClockVariance",           "ptp.v2.an.grandmasterclockvariance",
4680             FT_UINT16, BASE_DEC, NULL, 0x00,
4681             NULL, HFILL }
4682         },
4683         { &hf_ptp_v2_an_priority1,
4684           { "priority1",           "ptp.v2.an.priority1",
4685             FT_UINT8, BASE_DEC, NULL, 0x00,
4686             NULL, HFILL }
4687         },
4688         { &hf_ptp_v2_an_priority2,
4689           { "priority2",           "ptp.v2.an.priority2",
4690             FT_UINT8, BASE_DEC, NULL, 0x00,
4691             NULL, HFILL }
4692         },
4693
4694         /*Fields for PTP_Announce TLVs */
4695         { &hf_ptp_v2_an_tlv_tlvtype,
4696           { "tlvType", "ptp.v2.an.tlvType",
4697             FT_UINT16, BASE_DEC, VALS(ptp_v2_TLV_type_vals), 0x00,
4698             NULL, HFILL }
4699         },
4700         { &hf_ptp_v2_an_tlv_lengthfield,
4701           { "lengthField", "ptp.v2.an.lengthField",
4702             FT_UINT16, BASE_DEC, NULL, 0x00,
4703             NULL, HFILL }
4704         },
4705         /*Fields for ALTERNATE_TIME_OFFSET_INDICATOR TLV */
4706         { &hf_ptp_v2_atoi_tlv_keyfield,
4707           { "keyField", "ptp.v2.an.atoi.keyField",
4708             FT_UINT8, BASE_DEC, NULL, 0x00,
4709             NULL, HFILL }
4710         },
4711         { &hf_ptp_v2_atoi_tlv_currentoffset,
4712           { "currentOffset", "ptp.v2.an.atoi.currentOffset",
4713             FT_INT32, BASE_DEC, NULL, 0x00,
4714             NULL, HFILL }
4715         },
4716         { &hf_ptp_v2_atoi_tlv_jumpseconds,
4717           { "jumpSeconds", "ptp.v2.an.atoi.jumpSeconds",
4718             FT_INT32, BASE_DEC, NULL, 0x00,
4719             NULL, HFILL }
4720         },
4721         { &hf_ptp_v2_atoi_tlv_timeofnextjump,
4722           { "timeOfNextJump", "ptp.v2.an.atoi.timeOfNextJump",
4723             FT_BYTES, BASE_NONE, NULL, 0x00,
4724             NULL, HFILL }
4725         },
4726         { &hf_ptp_v2_atoi_tlv_displayname,
4727           { "displayName", "ptp.v2.an.atoi.dislpayName",
4728             FT_STRING, BASE_NONE, NULL, 0x00,
4729             NULL, HFILL }
4730         },
4731         { &hf_ptp_v2_atoi_tlv_displayname_length,
4732           { "length",           "ptp.v2.an.atoi.dislpayName.length",
4733             FT_UINT8, BASE_DEC, NULL, 0x00,
4734             NULL, HFILL }
4735         },
4736         /* Field for Path Trace TLV */
4737         { &hf_ptp_v2_an_tlv_pathsequence,
4738           { "PathSequence", "ptp.v2.an.pathsequence",
4739             FT_UINT64, BASE_HEX, NULL, 0x00,
4740             NULL, HFILL }
4741         },
4742
4743         /* Fields for undissected TLV */
4744         { &hf_ptp_v2_an_tlv_data,
4745           { "data",           "ptp.v2.an.tlv.data",
4746             FT_BYTES, BASE_NONE, NULL, 0x00,
4747             NULL, HFILL }
4748         },
4749
4750         /*Fields for PTP_Sync AND PTP_DelayRequest (=sdr) messages*/
4751         { &hf_ptp_v2_sdr_origintimestamp,
4752           { "originTimestamp",           "ptp.v2.sdr.origintimestamp",
4753             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
4754             NULL, HFILL }
4755         },
4756         { &hf_ptp_v2_sdr_origintimestamp_seconds,
4757           { "originTimestamp (seconds)",           "ptp.v2.sdr.origintimestamp.seconds",
4758             FT_UINT64, BASE_DEC, NULL, 0x00,
4759             NULL, HFILL }
4760         },
4761         { &hf_ptp_v2_sdr_origintimestamp_nanoseconds,
4762           { "originTimestamp (nanoseconds)",           "ptp.v2.sdr.origintimestamp.nanoseconds",
4763             FT_INT32, BASE_DEC, NULL, 0x00,
4764             NULL, HFILL }
4765         },
4766
4767         /*Fields for PTP_Follow_Up (=fu) messages*/
4768         { &hf_ptp_v2_fu_preciseorigintimestamp,
4769           { "preciseOriginTimestamp",           "ptp.v2.fu.preciseorigintimestamp",
4770             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
4771             NULL, HFILL }
4772         },
4773         { &hf_ptp_v2_fu_preciseorigintimestamp_seconds,
4774           { "preciseOriginTimestamp (seconds)",           "ptp.v2.fu.preciseorigintimestamp.seconds",
4775             FT_UINT64, BASE_DEC, NULL, 0x00,
4776             NULL, HFILL }
4777         },
4778         { &hf_ptp_v2_fu_preciseorigintimestamp_nanoseconds,
4779           { "preciseOriginTimestamp (nanoseconds)",           "ptp.v2.fu.preciseorigintimestamp.nanoseconds",
4780             FT_INT32, BASE_DEC, NULL, 0x00,
4781             NULL, HFILL }
4782         },
4783         /*Fields for PTP_Follow_up TLVs */
4784         { &hf_ptp_as_fu_tlv_tlvtype,
4785           { "tlvType", "ptp.as.fu.tlvType",
4786             FT_UINT16, BASE_DEC, VALS(ptp_v2_TLV_type_vals), 0x00,
4787             NULL, HFILL }
4788         },
4789         { &hf_ptp_as_fu_tlv_lengthfield,
4790           { "lengthField", "ptp.as.fu.lengthField",
4791             FT_UINT16, BASE_DEC, NULL, 0x00,
4792             NULL, HFILL }
4793         },
4794         { &hf_ptp_as_fu_tlv_organization_id,
4795           { "organizationId", "ptp.as.fu.organizationId",
4796             FT_UINT24, BASE_DEC, NULL, 0x00,
4797             NULL, HFILL }
4798         },
4799         { &hf_ptp_as_fu_tlv_organization_subtype,
4800           { "OrganizationSubType", "ptp.as.fu.organizationSubType",
4801             FT_INT24, BASE_DEC, NULL, 0x00,
4802             NULL, HFILL }
4803         },
4804         { &hf_ptp_as_fu_tlv_cumulative_offset,
4805           { "cumulativeScaledRateOffset", "ptp.as.fu.cumulativeScaledRateOffset",
4806             FT_UINT32, BASE_DEC, NULL, 0x00,
4807             NULL, HFILL }
4808         },
4809         { &hf_ptp_as_fu_tlv_gm_base_indicator,
4810           { "gmTimeBaseIndicator", "ptp.as.fu.gmTimeBaseIndicator",
4811             FT_UINT16, BASE_DEC, NULL, 0x00,
4812             NULL, HFILL }
4813         },
4814         { &hf_ptp_as_fu_tlv_last_gm_phase_change,
4815           { "lastGMPhaseChange", "ptp.as.fu.lastGmPhaseChange",
4816             FT_BYTES, BASE_NONE, NULL, 0x00,
4817             NULL, HFILL }
4818         },
4819         { &hf_ptp_as_fu_tlv_scaled_last_gm_phase_change,
4820           { "scaledLastGMPhaseChange", "ptp.as.fu.scaledLastGmPhaseChange",
4821             FT_INT32, BASE_DEC, NULL, 0x00,
4822             NULL, HFILL }
4823         },
4824
4825         /*Fields for PTP_DelayResponse (=dr) messages*/
4826         { &hf_ptp_v2_dr_receivetimestamp,
4827           { "receiveTimestamp",           "ptp.v2.dr.receivetimestamp",
4828             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
4829             NULL, HFILL }
4830         },
4831         { &hf_ptp_v2_dr_receivetimestamp_seconds,
4832           { "receiveTimestamp (seconds)",           "ptp.v2.dr.receivetimestamp.seconds",
4833             FT_UINT64, BASE_DEC, NULL, 0x00,
4834             NULL, HFILL }
4835         },
4836         { &hf_ptp_v2_dr_receivetimestamp_nanoseconds,
4837           { "receiveTimestamp (nanoseconds)",           "ptp.v2.dr.receivetimestamp.nanoseconds",
4838             FT_INT32, BASE_DEC, NULL, 0x00,
4839             NULL, HFILL }
4840         },
4841         { &hf_ptp_v2_dr_requestingportidentity,
4842           { "requestingSourcePortIdentity",           "ptp.v2.dr.requestingsourceportidentity",
4843             FT_UINT64, BASE_HEX, NULL, 0x00,
4844             NULL, HFILL }
4845         },
4846         { &hf_ptp_v2_dr_requestingsourceportid,
4847           { "requestingSourcePortId",           "ptp.v2.dr.requestingsourceportid",
4848             FT_UINT16, BASE_DEC, NULL, 0x00,
4849             NULL, HFILL }
4850         },
4851
4852         /*Fields for PTP_PDelayRequest (=pdrq) messages*/
4853         { &hf_ptp_v2_pdrq_origintimestamp,
4854           { "originTimestamp",           "ptp.v2.pdrq.origintimestamp",
4855             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
4856             NULL, HFILL }
4857         },
4858         { &hf_ptp_v2_pdrq_origintimestamp_seconds,
4859           { "originTimestamp (seconds)",           "ptp.v2.pdrq.origintimestamp.seconds",
4860             FT_UINT64, BASE_DEC, NULL, 0x00,
4861             NULL, HFILL }
4862         },
4863         { &hf_ptp_v2_pdrq_origintimestamp_nanoseconds,
4864           { "originTimestamp (nanoseconds)",           "ptp.v2.pdrq.origintimestamp.nanoseconds",
4865             FT_INT32, BASE_DEC, NULL, 0x00,
4866             NULL, HFILL }
4867         },
4868
4869         /*Fields for PTP_PDelayResponse (=pdrs) messages*/
4870         { &hf_ptp_v2_pdrs_requestreceipttimestamp,
4871           { "requestreceiptTimestamp",           "ptp.v2.pdrs.requestreceipttimestamp",
4872             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
4873             NULL, HFILL }
4874         },
4875         { &hf_ptp_v2_pdrs_requestreceipttimestamp_seconds,
4876           { "requestreceiptTimestamp (seconds)",           "ptp.v2.pdrs.requestreceipttimestamp.seconds",
4877             FT_UINT64, BASE_DEC, NULL, 0x00,
4878             NULL, HFILL }
4879         },
4880         { &hf_ptp_v2_pdrs_requestreceipttimestamp_nanoseconds,
4881           { "requestreceiptTimestamp (nanoseconds)",           "ptp.v2.pdrs.requestreceipttimestamp.nanoseconds",
4882             FT_INT32, BASE_DEC, NULL, 0x00,
4883             NULL, HFILL }
4884         },
4885         { &hf_ptp_v2_pdrs_requestingportidentity,
4886           { "requestingSourcePortIdentity",           "ptp.v2.pdrs.requestingportidentity",
4887             FT_UINT64, BASE_HEX, NULL, 0x00,
4888             NULL, HFILL }
4889         },
4890         { &hf_ptp_v2_pdrs_requestingsourceportid,
4891           { "requestingSourcePortId",           "ptp.v2.pdrs.requestingsourceportid",
4892             FT_UINT16, BASE_DEC, NULL, 0x00,
4893             NULL, HFILL }
4894         },
4895
4896         /*Fields for PTP_PDelayResponseFollowUp (=pdfu) messages*/
4897         { &hf_ptp_v2_pdfu_responseorigintimestamp,
4898           { "responseOriginTimestamp",           "ptp.v2.pdfu.responseorigintimestamp",
4899             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
4900             NULL, HFILL }
4901         },
4902         { &hf_ptp_v2_pdfu_responseorigintimestamp_seconds,
4903           { "responseOriginTimestamp (seconds)",           "ptp.v2.pdfu.responseorigintimestamp.seconds",
4904             FT_UINT64, BASE_DEC, NULL, 0x00,
4905             NULL, HFILL }
4906         },
4907         { &hf_ptp_v2_pdfu_responseorigintimestamp_nanoseconds,
4908           { "responseOriginTimestamp (nanoseconds)",           "ptp.v2.pdfu.responseorigintimestamp.nanoseconds",
4909             FT_INT32, BASE_DEC, NULL, 0x00,
4910             NULL, HFILL }
4911         },
4912         { &hf_ptp_v2_pdfu_requestingportidentity,
4913           { "requestingSourcePortIdentity",           "ptp.v2.pdfu.requestingportidentity",
4914             FT_UINT64, BASE_HEX, NULL, 0x00,
4915             NULL, HFILL }
4916         },
4917         { &hf_ptp_v2_pdfu_requestingsourceportid,
4918           { "requestingSourcePortId",           "ptp.v2.pdfu.requestingsourceportid",
4919             FT_UINT16, BASE_DEC, NULL, 0x00,
4920             NULL, HFILL }
4921         },
4922
4923         /*Fields for PTP_Signalling (=sig) messages*/
4924         { &hf_ptp_v2_sig_targetportidentity,
4925           { "targetPortIdentity",           "ptp.v2.sig.targetportidentity",
4926             FT_UINT64, BASE_HEX, NULL, 0x00,
4927             NULL, HFILL }
4928         },
4929         { &hf_ptp_v2_sig_targetportid,
4930           { "targetPortId",           "ptp.v2.sig.targetportid",
4931             FT_UINT16, BASE_DEC, NULL, 0x00,
4932             NULL, HFILL }
4933         },
4934         /*Fields for PTP_Signalling (=sig) TLVs */
4935         { &hf_ptp_as_sig_tlv_tlvtype,
4936           { "tlvType", "ptp.as.sig.tlvType",
4937             FT_UINT16, BASE_DEC, VALS(ptp_v2_TLV_type_vals), 0x00,
4938             NULL, HFILL }
4939         },
4940         { &hf_ptp_as_sig_tlv_lengthfield,
4941           { "lengthField", "ptp.as.sig.lengthField",
4942             FT_UINT16, BASE_DEC, NULL, 0x00,
4943             NULL, HFILL }
4944         },
4945         { &hf_ptp_as_sig_tlv_organization_id,
4946           { "organizationId", "ptp.as.sig.tlv.organizationId",
4947             FT_UINT24, BASE_HEX, VALS(ptp_as_TLV_oid_vals), 0x00,
4948             NULL, HFILL }
4949         },
4950         { &hf_ptp_as_sig_tlv_organization_subtype,
4951           { "OrganizationSubType", "ptp.as.sig.tlv.organizationSubType",
4952             FT_INT24, BASE_DEC, NULL, 0x00,
4953             NULL, HFILL }
4954         },
4955         { &hf_ptp_as_sig_tlv_link_delay_interval,
4956           { "linkDelayInterval", "ptp.as.sig.tlv.linkdelayinterval",
4957             FT_INT8, BASE_DEC, NULL, 0x00,
4958             NULL, HFILL }
4959         },
4960         { &hf_ptp_as_sig_tlv_time_sync_interval,
4961           { "timeSyncInterval", "ptp.as.sig.tlv.timesyncinterval",
4962             FT_INT8, BASE_DEC, NULL, 0x00,
4963             NULL, HFILL }
4964         },
4965         { &hf_ptp_as_sig_tlv_announce_interval,
4966           { "announceInterval", "ptp.as.sig.tlv.announceinterval",
4967             FT_INT8, BASE_DEC, NULL, 0x00,
4968             NULL, HFILL }
4969         },
4970         { &hf_ptp_as_sig_tlv_flags,
4971           { "flags",           "ptp.as.sig.tvl.flags",
4972             FT_UINT8, BASE_HEX, NULL, 0x00,
4973             NULL, HFILL }
4974         },
4975         { &hf_ptp_as_sig_tlv_flags_comp_rate_ratio,
4976           { "computeNeighborRateRatio", "ptp.as.sig.tlv.flags.rateratio",
4977             FT_BOOLEAN, 8, NULL, PTP_AS_FLAGS_COMP_NEIGHBOR_RATE_RATIO_BITMASK,
4978             NULL, HFILL }
4979         },
4980         { &hf_ptp_as_sig_tlv_flags_comp_prop_delay,
4981           { "computeNeighborPropDelay", "ptp.as.sig.tlv.flags.propdelay",
4982             FT_BOOLEAN, 8, NULL, PTP_AS_FLAGS_COMP_NEIGHBOR_PROP_DELAY_BITMASK,
4983             NULL, HFILL }
4984         },
4985
4986         /*Fields for PTP_Management (=mm) messages*/
4987         { &hf_ptp_v2_mm_targetportidentity,
4988           { "targetPortIdentity",           "ptp.v2.mm.targetportidentity",
4989             FT_UINT64, BASE_HEX, NULL, 0x00,
4990             NULL, HFILL }
4991         },
4992         { &hf_ptp_v2_mm_targetportid,
4993           { "targetPortId",           "ptp.v2.mm.targetportid",
4994             FT_UINT16, BASE_DEC, NULL, 0x00,
4995             NULL, HFILL }
4996         },
4997         { &hf_ptp_v2_mm_startingboundaryhops,
4998           { "startingBoundaryHops",           "ptp.v2.mm.startingboundaryhops",
4999             FT_UINT8, BASE_DEC, NULL, 0x00,
5000             NULL, HFILL }
5001         },
5002         { &hf_ptp_v2_mm_boundaryhops,
5003           { "boundaryHops",           "ptp.v2.mm.boundaryhops",
5004             FT_UINT8, BASE_DEC, NULL, 0x00,
5005             NULL, HFILL }
5006         },
5007         { &hf_ptp_v2_mm_action,
5008           { "action",           "ptp.v2.mm.action",
5009             FT_UINT8, BASE_DEC, VALS(ptp_v2_mm_action_vals), 0x0F,
5010             NULL, HFILL }
5011         },
5012         /* Management TLV */
5013         { &hf_ptp_v2_mm_tlvType,
5014           { "tlvType",           "ptp.v2.mm.tlvType",
5015             FT_UINT16, BASE_DEC, VALS(ptp_v2_TLV_type_vals), 0x00,
5016             NULL, HFILL }
5017         },
5018         { &hf_ptp_v2_mm_lengthField,
5019           { "lengthField",           "ptp.v2.mm.lengthField",
5020             FT_UINT16, BASE_DEC, NULL, 0x00,
5021             NULL, HFILL }
5022         },
5023         { &hf_ptp_v2_mm_managementId,
5024           { "managementId",           "ptp.v2.mm.managementId",
5025             FT_UINT16, BASE_DEC, VALS(ptp_v2_managementID_vals), 0x00,
5026             NULL, HFILL }
5027         },
5028         { &hf_ptp_v2_mm_data,
5029           { "data",           "ptp.v2.mm.data",
5030             FT_BYTES, BASE_NONE, NULL, 0x00,
5031             NULL, HFILL }
5032         },
5033         /* Management TLV dataField */
5034         /* CLOCK_DESCRIPTION */
5035         { &hf_ptp_v2_mm_clockType,
5036           { "clockType",           "ptp.v2.mm.clockType",
5037             FT_UINT16, BASE_HEX, NULL, 0x00,
5038             NULL, HFILL }
5039         },
5040         { &hf_ptp_v2_mm_clockType_ordinaryClock,
5041           { "The node implements an ordinary clock", "ptp.v2.mm.clockType.OC",
5042             FT_BOOLEAN, 16, NULL, CLOCKTYPE_ORDINARY_CLOCK,
5043             NULL, HFILL }
5044         },
5045         { &hf_ptp_v2_mm_clockType_boundaryClock,
5046           { "The node implements a boundary clock", "ptp.v2.mm.clockType.BC",
5047             FT_BOOLEAN, 16, NULL, CLOCKTYPE_BOUNDARY_CLOCK,
5048             NULL, HFILL }
5049         },
5050         { &hf_ptp_v2_mm_clockType_p2p_transparentClock,
5051           { "The node implements a peer-to-peer transparent clock", "ptp.v2.mm.clockType.p2p_TC",
5052             FT_BOOLEAN, 16, NULL, CLOCKTYPE_P2P_TC,
5053             NULL, HFILL }
5054         },
5055         { &hf_ptp_v2_mm_clockType_e2e_transparentClock,
5056           { "The node implements an end-to-end transparent clock", "ptp.v2.mm.clockType.e2e_TC",
5057             FT_BOOLEAN, 16, NULL, CLOCKTYPE_E2E_TC,
5058             NULL, HFILL }
5059         },
5060         { &hf_ptp_v2_mm_clockType_managementNode,
5061           { "The node implements a management node", "ptp.v2.mm.clockType.MM",
5062             FT_BOOLEAN, 16, NULL, CLOCKTYPE_MANAGEMENT_NODE,
5063             NULL, HFILL }
5064         },
5065         { &hf_ptp_v2_mm_clockType_reserved,
5066           { "Reserved", "ptp.v2.mm.clockType.reserved",
5067             FT_BOOLEAN, 16, NULL, CLOCKTYPE_RESERVED,
5068             NULL, HFILL }
5069         },
5070         { &hf_ptp_v2_mm_physicalLayerProtocol,
5071           { "physicalLayerProtocol",           "ptp.v2.mm.physicalLayerProtocol",
5072             FT_STRING, BASE_NONE, NULL, 0x00,
5073             NULL, HFILL }
5074         },
5075         { &hf_ptp_v2_mm_physicalLayerProtocol_length,
5076           { "length",           "ptp.v2.mm.physicalLayerProtocol.length",
5077             FT_UINT8, BASE_DEC, NULL, 0x00,
5078             NULL, HFILL }
5079         },
5080         { &hf_ptp_v2_mm_physicalAddressLength,
5081           { "physical address length",  "ptp.v2.mm.physicalAddressLength",
5082             FT_UINT16, BASE_DEC, NULL, 0x00,
5083             NULL, HFILL }
5084         },
5085         { &hf_ptp_v2_mm_physicalAddress,
5086           { "physical address",  "ptp.v2.mm.physicalAddress",
5087             FT_BYTES, BASE_NONE, NULL, 0x00,
5088             NULL, HFILL }
5089         },
5090         { &hf_ptp_v2_mm_protocolAddress,
5091           { "protocol address",  "ptp.v2.mm.protocolAddress",
5092             FT_BYTES, BASE_NONE, NULL, 0x00,
5093             NULL, HFILL }
5094         },
5095         { &hf_ptp_v2_mm_protocolAddress_networkProtocol,
5096           { "network protocol",           "ptp.v2.mm.networkProtocol",
5097             FT_UINT16, BASE_DEC, VALS(ptp2_networkProtocol_vals), 0x00,
5098             NULL, HFILL }
5099         },
5100         { &hf_ptp_v2_mm_protocolAddress_length,
5101           { "length",  "ptp.v2.mm.protocolAddress.length",
5102             FT_UINT16, BASE_DEC, NULL, 0x00,
5103             NULL, HFILL }
5104         },
5105         { &hf_ptp_v2_mm_manufacturerIdentity,
5106           { "manufacturer identity",  "ptp.v2.mm.manufacturerIdentity",
5107             FT_BYTES, BASE_NONE, NULL, 0x00,
5108             NULL, HFILL }
5109         },
5110         { &hf_ptp_v2_mm_reserved,
5111           { "reserved",  "ptp.v2.mm.reserved",
5112             FT_BYTES, BASE_NONE, NULL, 0x00,
5113             NULL, HFILL }
5114         },
5115         { &hf_ptp_v2_mm_productDescription,
5116           { "product description",  "ptp.v2.mm.productDescription",
5117             FT_STRING, BASE_NONE, NULL, 0x00,
5118             NULL, HFILL }
5119         },
5120         { &hf_ptp_v2_mm_productDescription_length,
5121           { "length",           "ptp.v2.mm.productDescription.length",
5122             FT_UINT8, BASE_DEC, NULL, 0x00,
5123             NULL, HFILL }
5124         },
5125         { &hf_ptp_v2_mm_revisionData,
5126           { "revision data",  "ptp.v2.mm.revisionData",
5127             FT_STRING, BASE_NONE, NULL, 0x00,
5128             NULL, HFILL }
5129         },
5130         { &hf_ptp_v2_mm_revisionData_length,
5131           { "length",           "ptp.v2.mm.revisionData.length",
5132             FT_UINT8, BASE_DEC, NULL, 0x00,
5133             NULL, HFILL }
5134         },
5135         { &hf_ptp_v2_mm_userDescription,
5136           { "user description",  "ptp.v2.mm.userDescription",
5137             FT_STRING, BASE_NONE, NULL, 0x00,
5138             NULL, HFILL }
5139         },
5140         { &hf_ptp_v2_mm_userDescription_length,
5141           { "length",           "ptp.v2.mm.userDescription.length",
5142             FT_UINT8, BASE_DEC, NULL, 0x00,
5143             NULL, HFILL }
5144         },
5145         { &hf_ptp_v2_mm_profileIdentity,
5146           { "profileIdentity",           "ptp.v2.mm.profileIdentity",
5147             FT_BYTES, BASE_NONE, NULL, 0x00,
5148             NULL, HFILL }
5149         },
5150         { &hf_ptp_v2_mm_pad,
5151           { "Pad",           "ptp.v2.mm.pad",
5152             FT_BYTES, BASE_NONE, NULL, 0x0,
5153             NULL, HFILL }
5154         },
5155         { &hf_ptp_v2_mm_initializationKey,
5156           { "initialization key",           "ptp.v2.mm.initializationKey",
5157             FT_UINT16, BASE_DEC, NULL, 0x00,
5158             NULL, HFILL }
5159         },
5160         { &hf_ptp_v2_mm_numberOfFaultRecords,
5161           { "number of fault records",  "ptp.v2.mm.numberOfFaultRecords",
5162             FT_UINT16, BASE_DEC, NULL, 0x00,
5163             NULL, HFILL }
5164         },
5165         { &hf_ptp_v2_mm_faultRecord,
5166           { "fault record",  "ptp.v2.mm.faultRecord",
5167             FT_BYTES, BASE_NONE, NULL, 0x00,
5168             NULL, HFILL }
5169         },
5170         { &hf_ptp_v2_mm_faultRecordLength,
5171           { "fault record length",           "ptp.v2.mm.faultRecordLength",
5172             FT_UINT16, BASE_DEC, NULL, 0x00,
5173             NULL, HFILL }
5174         },
5175         { &hf_ptp_v2_mm_severityCode,
5176           { "severity code",           "ptp.v2.mm.severityCode",
5177             FT_UINT8, BASE_DEC, VALS(ptp2_severityCode_vals), 0x00,
5178             NULL, HFILL }
5179         },
5180         { &hf_ptp_v2_mm_faultName,
5181           { "faultName",  "ptp.v2.mm.faultName",
5182             FT_STRING, BASE_NONE, NULL, 0x00,
5183             NULL, HFILL }
5184         },
5185         { &hf_ptp_v2_mm_faultName_length,
5186           { "length",           "ptp.v2.mm.faultName.length",
5187             FT_UINT8, BASE_DEC, NULL, 0x00,
5188             NULL, HFILL }
5189         },
5190         { &hf_ptp_v2_mm_faultValue,
5191           { "faultValue",  "ptp.v2.mm.faultValue",
5192             FT_STRING, BASE_NONE, NULL, 0x00,
5193             NULL, HFILL }
5194         },
5195         { &hf_ptp_v2_mm_faultValue_length,
5196           { "length",           "ptp.v2.mm.faultValue.length",
5197             FT_UINT8, BASE_DEC, NULL, 0x00,
5198             NULL, HFILL }
5199         },
5200         { &hf_ptp_v2_mm_faultDescription,
5201           { "faultDescription",  "ptp.v2.mm.faultDescription",
5202             FT_STRING, BASE_NONE, NULL, 0x00,
5203             NULL, HFILL }
5204         },
5205         { &hf_ptp_v2_mm_faultDescription_length,
5206           { "length",           "ptp.v2.mm.faultDescription.length",
5207             FT_UINT8, BASE_DEC, NULL, 0x00,
5208             NULL, HFILL }
5209         },
5210         { &hf_ptp_v2_mm_faultTime,
5211           { "Fault time", "ptp.v2.mm.faultTime",
5212             FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
5213             NULL, HFILL }
5214         },
5215         { &hf_ptp_v2_mm_faultTime_s,
5216           { "Fault time (seconds)", "ptp.v2.mm.faultTime.seconds",
5217             FT_UINT64, BASE_DEC, NULL, 0x00,
5218             NULL, HFILL }
5219         },
5220         { &hf_ptp_v2_mm_faultTime_ns,
5221           { "Fault time (nanoseconds)", "ptp.v2.mm.faultTime.nanoseconds",
5222             FT_INT32, BASE_DEC, NULL, 0x00,
5223             NULL, HFILL }
5224         },
5225         { &hf_ptp_v2_mm_currentTime_s,
5226           { "current time (seconds)", "ptp.v2.mm.currentTime.seconds",
5227             FT_UINT64, BASE_DEC, NULL, 0x00,
5228             NULL, HFILL }
5229         },
5230         { &hf_ptp_v2_mm_currentTime_ns,
5231           { "current time (nanoseconds)", "ptp.v2.mm.currentTime.nanoseconds",
5232             FT_INT32, BASE_DEC, NULL, 0x00,
5233             NULL, HFILL }
5234         },
5235         { &hf_ptp_v2_mm_clockAccuracy,
5236           { "Clock accuracy",           "ptp.v2.mm.clockaccuracy",
5237             FT_UINT8, BASE_HEX, VALS(ptp_v2_clockaccuracy_vals), 0x00,
5238             NULL, HFILL }
5239         },
5240
5241         { &hf_ptp_v2_mm_priority1,
5242           { "priority1",           "ptp.v2.mm.priority1",
5243             FT_UINT8, BASE_DEC, NULL, 0x00,
5244             NULL, HFILL }
5245         },
5246         { &hf_ptp_v2_mm_priority2,
5247           { "priority2",           "ptp.v2.mm.priority2",
5248             FT_UINT8, BASE_DEC, NULL, 0x00,
5249             NULL, HFILL }
5250         },
5251         { &hf_ptp_v2_mm_dds_SO,
5252           { "Slave only",           "ptp.v2.mm.SlavOnly",
5253             FT_BOOLEAN, 8, NULL, 0x02,
5254             NULL, HFILL }
5255         },
5256         { &hf_ptp_v2_mm_TSC,
5257           { "Two step",           "ptp.v2.mm.twoStep",
5258             FT_BOOLEAN, 8, NULL, 0x01,
5259             NULL, HFILL }
5260         },
5261         { &hf_ptp_v2_mm_numberPorts,
5262           { "number of ports",  "ptp.v2.mm.numberPorts",
5263             FT_UINT16, BASE_DEC, NULL, 0x00,
5264             NULL, HFILL }
5265         },
5266         { &hf_ptp_v2_mm_clockclass,
5267           { "Clock class",           "ptp.v2.mm.clockclass",
5268             FT_UINT8, BASE_DEC, NULL, 0x00,
5269             NULL, HFILL }
5270         },
5271         { &hf_ptp_v2_mm_clockaccuracy,
5272           { "Clock accuracy",           "ptp.v2.mm.clockaccuracy",
5273             FT_UINT8, BASE_HEX, VALS(ptp_v2_clockaccuracy_vals), 0x00,
5274             NULL, HFILL }
5275         },
5276         { &hf_ptp_v2_mm_clockvariance,
5277           { "Clock variance",           "ptp.v2.mm.clockvariance",
5278             FT_UINT16, BASE_DEC, NULL, 0x00,
5279             NULL, HFILL }
5280         },
5281         { &hf_ptp_v2_mm_clockidentity,
5282           { "Clock identity",           "ptp.v2.mm.clockidentity",
5283             FT_UINT64, BASE_HEX, NULL, 0x00,
5284             NULL, HFILL }
5285         },
5286         { &hf_ptp_v2_mm_domainNumber,
5287           { "domain number",           "ptp.v2.mm.domainNumber",
5288             FT_UINT8, BASE_DEC, NULL , 0x00,
5289             NULL, HFILL }
5290         },
5291         { &hf_ptp_v2_mm_SO,
5292           { "Slave only",           "ptp.v2.mm.SlavOnly",
5293             FT_BOOLEAN, 8, NULL, 0x01,
5294             NULL, HFILL }
5295         },
5296         { &hf_ptp_v2_mm_stepsRemoved,
5297           { "steps removed",           "ptp.v2.mm.stepsRemoved",
5298             FT_INT16, BASE_DEC, NULL, 0x00,
5299             NULL, HFILL }
5300         },
5301         { &hf_ptp_v2_mm_parentIdentity,
5302           { "parent ClockIdentity",           "ptp.v2.mm.parentclockidentity",
5303             FT_UINT64, BASE_HEX, NULL, 0x00,
5304             NULL, HFILL }
5305         },
5306         { &hf_ptp_v2_mm_parentPort,
5307           { "parent SourcePortID",           "ptp.v2.mm.parentsourceportid",
5308             FT_UINT16, BASE_DEC, NULL, 0x00,
5309             NULL, HFILL }
5310         },
5311         { &hf_ptp_v2_mm_parentStats,
5312           { "parent stats",           "ptp.v2.mm.parentstats",
5313             FT_BOOLEAN, 8, NULL, 0x01,
5314             NULL, HFILL }
5315         },
5316         { &hf_ptp_v2_mm_observedParentOffsetScaledLogVariance,
5317           { "observedParentOffsetScaledLogVariance", "ptp.v2.mm.observedParentOffsetScaledLogVariance",
5318             FT_UINT16, BASE_DEC, NULL, 0x00,
5319             NULL, HFILL }
5320         },
5321         { &hf_ptp_v2_mm_observedParentClockPhaseChangeRate,
5322           { "observedParentClockPhaseChangeRate", "ptp.v2.mm.observedParentClockPhaseChangeRate",
5323             FT_INT32, BASE_DEC, NULL, 0x00,
5324             NULL, HFILL }
5325         },
5326         { &hf_ptp_v2_mm_grandmasterPriority1,
5327           { "Grandmaster priority1", "ptp.v2.mm.grandmasterPriority1",
5328             FT_UINT8, BASE_DEC, NULL, 0x00,
5329             NULL, HFILL }
5330         },
5331         { &hf_ptp_v2_mm_grandmasterPriority2,
5332           { "Grandmaster priority2", "ptp.v2.mm.grandmasterPriority2",
5333             FT_UINT8, BASE_DEC, NULL, 0x00,
5334             NULL, HFILL }
5335         },
5336         { &hf_ptp_v2_mm_grandmasterclockclass,
5337           { "Grandmaster clock class", "ptp.v2.mm.grandmasterclockclass",
5338             FT_UINT8, BASE_DEC, NULL, 0x00,
5339             NULL, HFILL }
5340         },
5341         { &hf_ptp_v2_mm_grandmasterclockaccuracy,
5342           { "Grandmaster clock accuracy", "ptp.v2.mm.grandmasterclockaccuracy",
5343             FT_UINT8, BASE_HEX, VALS(ptp_v2_clockaccuracy_vals), 0x00,
5344             NULL, HFILL }
5345         },
5346         { &hf_ptp_v2_mm_grandmasterclockvariance,
5347           { "Grandmaster clock variance", "ptp.v2.mm.grandmasterclockvariance",
5348             FT_UINT16, BASE_DEC, NULL, 0x00,
5349             NULL, HFILL }
5350         },
5351         { &hf_ptp_v2_mm_grandmasterIdentity,
5352           { "Grandmaster clock identity", "ptp.v2.mm.grandmasterclockidentity",
5353             FT_UINT64, BASE_HEX, NULL, 0x00,
5354             NULL, HFILL }
5355         },
5356         { &hf_ptp_v2_mm_currentUtcOffset,
5357           { "CurrentUTCOffset", "ptp.v2.mm.currentutcoffset",
5358             FT_INT16, BASE_DEC, NULL, 0x00,
5359             NULL, HFILL }
5360         },
5361         { &hf_ptp_v2_mm_LI_61,
5362           { "leap 61", "ptp.v2.mm.li61",
5363             FT_BOOLEAN, 8, NULL, 0x01,
5364             NULL, HFILL }
5365         },
5366         { &hf_ptp_v2_mm_LI_59,
5367           { "leap 59", "ptp.v2.mm.li59",
5368             FT_BOOLEAN, 8, NULL, 0x02,
5369             NULL, HFILL }
5370         },
5371         { &hf_ptp_v2_mm_UTCV,
5372           { "CurrentUTCOffset valid", "ptp.v2.mm.CurrentUTCOffsetValid",
5373             FT_BOOLEAN, 8, NULL, 0x04,
5374             NULL, HFILL }
5375         },
5376         { &hf_ptp_v2_mm_PTP,
5377           { "PTP timescale", "ptp.v2.mm.ptptimescale",
5378             FT_BOOLEAN, 8, NULL, 0x08,
5379             NULL, HFILL }
5380         },
5381         { &hf_ptp_v2_mm_TTRA,
5382           { "Time traceable", "ptp.v2.mm.timeTraceable",
5383             FT_BOOLEAN, 8, NULL, 0x10,
5384             NULL, HFILL }
5385         },
5386         { &hf_ptp_v2_mm_FTRA,
5387           { "Frequency traceable", "ptp.v2.mm.frequencyTraceable",
5388             FT_BOOLEAN, 8, NULL, 0x20,
5389             NULL, HFILL }
5390         },
5391         { &hf_ptp_v2_mm_timesource,
5392           { "TimeSource",           "ptp.v2.mm.timesource",
5393             FT_UINT8, BASE_HEX, VALS(ptp_v2_timesource_vals), 0x00,
5394             NULL, HFILL }
5395         },
5396         { &hf_ptp_v2_mm_offset_ns,
5397           { "correction",           "ptp.v2.mm.offset.ns",
5398             FT_UINT64, BASE_DEC, NULL, 0x00,
5399             NULL, HFILL }
5400         },
5401         { &hf_ptp_v2_mm_offset_subns,
5402           { "SubNs",           "ptp.v2.mm.offset.subns",
5403             FT_DOUBLE, BASE_NONE, NULL, 0x00,
5404             NULL, HFILL }
5405         },
5406         { &hf_ptp_v2_mm_pathDelay_ns,
5407           { "ns",           "ptp.v2.mm.pathDelay.ns",
5408             FT_UINT64, BASE_DEC, NULL, 0x00,
5409             NULL, HFILL }
5410         },
5411         { &hf_ptp_v2_mm_pathDelay_subns,
5412           { "SubNs",           "ptp.v2.mm.pathDelay.subns",
5413             FT_DOUBLE, BASE_NONE, NULL, 0x00,
5414             NULL, HFILL }
5415         },
5416         { &hf_ptp_v2_mm_PortNumber,
5417           { "PortNumber",           "ptp.v2.mm.PortNumber",
5418             FT_UINT16, BASE_DEC, NULL, 0x00,
5419             NULL, HFILL }
5420         },
5421         { &hf_ptp_v2_mm_portState,
5422           { "Port state",           "ptp.v2.mm.portState",
5423             FT_UINT8, BASE_DEC, VALS(ptp2_portState_vals), 0x00,
5424             NULL, HFILL }
5425         },
5426         { &hf_ptp_v2_mm_logMinDelayReqInterval,
5427           { "logMinDelayReqInterval",           "ptp.v2.mm.logMinDelayReqInterval",
5428             FT_INT8, BASE_DEC, NULL, 0x00,
5429             NULL, HFILL }
5430         },
5431         { &hf_ptp_v2_mm_peerMeanPathDelay_ns,
5432           { "ns",           "ptp.v2.mm.peerMeanPathDelay.ns",
5433             FT_UINT64, BASE_DEC, NULL, 0x00,
5434             NULL, HFILL }
5435         },
5436         { &hf_ptp_v2_mm_peerMeanPathDelay_subns,
5437           { "SubNs",           "ptp.v2.mm.peerMeanPathDelay.subns",
5438             FT_DOUBLE, BASE_NONE, NULL, 0x00,
5439             NULL, HFILL }
5440         },
5441         { &hf_ptp_v2_mm_logAnnounceInterval,
5442           { "logAnnounceInterval",           "ptp.v2.mm.logAnnounceInterval",
5443             FT_INT8, BASE_DEC, NULL, 0x00,
5444             NULL, HFILL }
5445         },
5446         { &hf_ptp_v2_mm_announceReceiptTimeout,
5447           { "announceReceiptTimeout",           "ptp.v2.mm.announceReceiptTimeout",
5448             FT_UINT8, BASE_DEC, NULL, 0x00,
5449             NULL, HFILL }
5450         },
5451         { &hf_ptp_v2_mm_logSyncInterval,
5452           { "logSyncInterval",           "ptp.v2.mm.logSyncInterval",
5453             FT_INT8, BASE_DEC, NULL, 0x00,
5454             NULL, HFILL }
5455         },
5456         { &hf_ptp_v2_mm_delayMechanism,
5457           { "Delay mechanism",           "ptp.v2.mm.delayMechanism",
5458             FT_UINT8, BASE_DEC, VALS(ptp2_delayMechanism_vals), 0x00,
5459             NULL, HFILL }
5460         },
5461         { &hf_ptp_v2_mm_logMinPdelayReqInterval,
5462           { "logMinPdelayReqInterval",           "ptp.v2.mm.logMinPdelayReqInterval",
5463             FT_INT8, BASE_DEC, NULL, 0x00,
5464             NULL, HFILL }
5465         },
5466         { &hf_ptp_v2_mm_versionNumber,
5467           { "versionNumber",           "ptp.v2.mm.versionNumber",
5468             FT_UINT8, BASE_DEC, NULL, 0x0F,
5469             NULL, HFILL }
5470         },
5471         { &hf_ptp_v2_mm_primaryDomain,
5472           { "Primary domain number",  "ptp.v2.mm.primaryDomain",
5473             FT_UINT8, BASE_DEC, NULL, 0x00,
5474             NULL, HFILL }
5475         },
5476         { &hf_ptp_v2_mm_faultyFlag,
5477           { "Faulty flag", "ptp.v2.mm.faultyFlag",
5478             FT_BOOLEAN, 8, NULL, 0x01,
5479             NULL, HFILL }
5480         },
5481
5482         { &hf_ptp_v2_mm_managementErrorId,
5483           { "managementErrorId",  "ptp.v2.mm.managementErrorId",
5484             FT_UINT16, BASE_DEC, VALS(ptp2_managementErrorId_vals), 0x00,
5485             NULL, HFILL }
5486         },
5487         { &hf_ptp_v2_mm_displayData,
5488           { "Display data",           "ptp.v2.mm.displayData",
5489             FT_STRING, BASE_NONE, NULL, 0x00,
5490             NULL, HFILL }
5491         },
5492         { &hf_ptp_v2_mm_displayData_length,
5493           { "length",           "ptp.v2.mm.displayData.length",
5494             FT_UINT8, BASE_DEC, NULL, 0x00,
5495             NULL, HFILL }
5496         },
5497         { &hf_ptp_v2_mm_ucEN,
5498           { "Enable unicast", "ptp.v2.mm.unicastEnable",
5499             FT_BOOLEAN, 8, NULL, 0x01,
5500             NULL, HFILL }
5501         },
5502         { &hf_ptp_v2_mm_ptEN,
5503           { "Path trace unicast", "ptp.v2.mm.pathTraceEnable",
5504             FT_BOOLEAN, 8, NULL, 0x01,
5505             NULL, HFILL }
5506         },
5507         { &hf_ptp_v2_mm_atEN,
5508           { "Path trace unicast", "ptp.v2.mm.pathTraceEnable",
5509             FT_BOOLEAN, 8, NULL, 0x01,
5510             NULL, HFILL }
5511         },
5512         { &hf_ptp_v2_mm_keyField,
5513           { "Key field", "ptp.v2.mm.keyField",
5514             FT_UINT8, BASE_DEC, NULL, 0x00,
5515             NULL, HFILL }
5516         },
5517         { &hf_ptp_v2_mm_displayName,
5518           { "Display name",           "ptp.v2.mm.displayName",
5519             FT_STRING, BASE_NONE, NULL, 0x00,
5520             NULL, HFILL }
5521         },
5522         { &hf_ptp_v2_mm_displayName_length,
5523           { "length",           "ptp.v2.mm.displayName.length",
5524             FT_UINT8, BASE_DEC, NULL, 0x00,
5525             NULL, HFILL }
5526         },
5527         { &hf_ptp_v2_mm_maxKey,
5528           { "Max key", "ptp.v2.mm.maxKey",
5529             FT_UINT8, BASE_DEC, NULL, 0x00,
5530             NULL, HFILL }
5531         },
5532         { &hf_ptp_v2_mm_currentOffset,
5533           { "Current offset", "ptp.v2.mm.currentOffset",
5534             FT_INT32, BASE_DEC, NULL, 0x00,
5535             NULL, HFILL }
5536         },
5537         { &hf_ptp_v2_mm_jumpSeconds,
5538           { "Jump seconds", "ptp.v2.mm.jumpSeconds",
5539             FT_INT32, BASE_DEC, NULL, 0x00,
5540             NULL, HFILL }
5541         },
5542         { &hf_ptp_v2_mm_numberOfAlternateMasters,
5543           { "Number of alternate masters", "ptp.v2.mm.numberOfAlternateMasters",
5544             FT_UINT8, BASE_DEC, NULL, 0x00,
5545             NULL, HFILL }
5546         },
5547         { &hf_ptp_v2_mm_logAlternateMulticastSyncInterval,
5548           { "Alternate multicast sync interval", "ptp.v2.mm.AlternateMulticastSyncInterval",
5549             FT_INT8, BASE_DEC, NULL, 0x00,
5550             NULL, HFILL }
5551         },
5552         { &hf_ptp_v2_mm_transmitAlternateMulticastSync,
5553           { "Transmit alternate multicast sync", "ptp.v2.mm.transmitAlternateMulticastSync",
5554             FT_BOOLEAN, 8, NULL, 0x01,
5555             NULL, HFILL }
5556         },
5557     };
5558
5559
5560 /* Setup protocol subtree array */
5561     static gint *ett[] = {
5562         &ett_ptp,
5563         &ett_ptp_flags,
5564         &ett_ptp_time,
5565         &ett_ptp_time2,
5566         &ett_ptp_v2,
5567         &ett_ptp_v2_transportspecific,
5568         &ett_ptp_v2_flags,
5569         &ett_ptp_v2_correction,
5570         &ett_ptp_v2_time,
5571         &ett_ptp_v2_time2,
5572         &ett_ptp_v2_managementData,
5573         &ett_ptp_v2_clockType,
5574         &ett_ptp_v2_physicalLayerProtocol,
5575         &ett_ptp_v2_protocolAddress,
5576         &ett_ptp_v2_ptptext,
5577         &ett_ptp_v2_faultRecord,
5578         &ett_ptp_v2_timeInterval,
5579         &ett_ptp_v2_tlv,
5580         &ett_ptp_as_sig_tlv_flags,
5581     };
5582
5583 /* Register the protocol name and description */
5584     proto_ptp = proto_register_protocol("Precision Time Protocol (IEEE1588)",
5585                                         "PTP", "ptp");
5586
5587 /* Required function calls to register the header fields and subtrees used */
5588     proto_register_field_array(proto_ptp, hf, array_length(hf));
5589     proto_register_subtree_array(ett, array_length(ett));
5590 }
5591
5592 void
5593 proto_reg_handoff_ptp(void)
5594 {
5595     dissector_handle_t event_port_ptp_handle;
5596     dissector_handle_t general_port_ptp_handle;
5597     dissector_handle_t ethertype_ptp_handle;
5598
5599     event_port_ptp_handle = create_dissector_handle(dissect_ptp, proto_ptp);
5600     general_port_ptp_handle = create_dissector_handle(dissect_ptp, proto_ptp);
5601     ethertype_ptp_handle = create_dissector_handle(dissect_ptp_oE, proto_ptp);
5602
5603     dissector_add_uint("udp.port", EVENT_PORT_PTP, event_port_ptp_handle);
5604     dissector_add_uint("udp.port", GENERAL_PORT_PTP, general_port_ptp_handle);
5605     dissector_add_uint("ethertype", ETHERTYPE_PTP, ethertype_ptp_handle);
5606 }