Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-ntp.c
blob4cddceb9329c9680de78e1541e253ccac193ad43
1 /* packet-ntp.c
2 * Routines for NTP packet dissection
3 * Copyright 1999, Nathan Neulinger <nneul@umr.edu>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * Copied from packet-tftp.c
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include "config.h"
16 #include <math.h>
18 #include <epan/packet.h>
19 #include <epan/expert.h>
20 #include <epan/addr_resolv.h>
21 #include <epan/tvbparse.h>
22 #include <epan/conversation.h>
23 #include <epan/tfs.h>
24 #include <wsutil/array.h>
25 #include <wsutil/epochs.h>
27 #include "packet-ntp.h"
28 #include "packet-nts-ke.h"
30 /* Prototypes */
31 void proto_register_ntp(void);
32 void proto_reg_handoff_ntp(void);
33 static int dissect_ntp_ext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ntp_tree, int offset, uint64_t flags);
35 static dissector_handle_t ntp_handle;
38 * Dissecting NTP packets version 3 and 4 (RFC5905, RFC2030, RFC1769, RFC1361,
39 * RFC1305).
41 * Those packets have simple structure:
42 * 1 2 3
43 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
44 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 * |LI | VN |Mode | Stratum | Poll | Precision |
46 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 * | Root Delay |
48 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 * | Root Dispersion |
50 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 * | Reference Identifier |
52 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 * | Reference Timestamp (64) |
54 * | |
55 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 * | Originate Timestamp (64) |
57 * | |
58 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
59 * | Receive Timestamp (64) |
60 * | |
61 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62 * | Transmit Timestamp (64) |
63 * | |
64 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
65 * | Key Identifier (optional) (32) |
66 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
67 * | Message Digest (optional) (128/160) |
68 * | |
69 * | |
70 * | |
71 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72 * NTP timestamps are represented as a 64-bit unsigned fixed-point number,
73 * in seconds relative to 0h on 1 January 1900. The integer part is in the
74 * first 32 bits and the fraction part in the last 32 bits.
77 * NTP Control messages as defined in version 2, 3 and 4 (RFC1119, RFC1305) use
78 * the following structure:
79 * 1 2 3
80 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
81 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
82 * |00 | VN | 110 |R E M| OpCode | Sequence |
83 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
84 * | Status | Association ID |
85 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
86 * | Offset | Count |
87 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
88 * | |
89 * | Data (468 octets max) |
90 * | |
91 * | | Padding (zeros) |
92 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
93 * | Authenticator (optional) (96) |
94 * | |
95 * | |
96 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
98 * Not yet implemented: complete dissection of TPCTRL_OP_SETTRAP,
99 * NTPCTRL_OP_ASYNCMSG, NTPCTRL_OP_UNSETTRAPSETTRAP Control-Messages
103 #define UDP_PORT_NTP 123
104 #define TCP_PORT_NTP 123
106 /* Leap indicator, 2bit field is used to warn of a inserted/deleted
107 * second, or clock unsynchronized indication.
109 #define NTP_LI_MASK 0xC0
111 #define NTP_LI_NONE 0
112 #define NTP_LI_61 1
113 #define NTP_LI_59 2
114 #define NTP_LI_UNKNOWN 3
116 static const value_string li_types[] = {
117 { NTP_LI_NONE, "no warning" },
118 { NTP_LI_61, "last minute of the day has 61 seconds" },
119 { NTP_LI_59, "last minute of the day has 59 seconds" },
120 { NTP_LI_UNKNOWN, "unknown (clock unsynchronized)" },
121 { 0, NULL}
124 /* Version info, 3bit field informs about NTP version used in particular
125 * packet. According to rfc2030, version info could be only 3 or 4, but I
126 * have noticed packets with 1 or even 6 as version numbers. They are
127 * produced as a result of ntptrace command. Are those packets malformed
128 * on purpose? I don't know yet, probably some browsing through ntp sources
129 * would help. My solution is to put them as reserved for now.
131 #define NTP_VN_MASK 0x38
133 static const value_string ver_nums[] = {
134 { 0, "reserved" },
135 { 1, "NTP Version 1" },
136 { 2, "NTP Version 2" },
137 { 3, "NTP Version 3" },
138 { 4, "NTP Version 4" },
139 { 5, "reserved" },
140 { 6, "reserved" },
141 { 7, "reserved" },
142 { 0, NULL}
145 /* Mode, 3bit field representing mode of communication.
147 #define NTP_MODE_MASK 7
149 #define NTP_MODE_RSV 0
150 #define NTP_MODE_SYMACT 1
151 #define NTP_MODE_SYMPAS 2
152 #define NTP_MODE_CLIENT 3
153 #define NTP_MODE_SERVER 4
154 #define NTP_MODE_BCAST 5
155 #define NTP_MODE_CTRL 6
156 #define NTP_MODE_PRIV 7
158 static const value_string mode_types[] = {
159 { NTP_MODE_RSV, "reserved" },
160 { NTP_MODE_SYMACT, "symmetric active" },
161 { NTP_MODE_SYMPAS, "symmetric passive" },
162 { NTP_MODE_CLIENT, "client" },
163 { NTP_MODE_SERVER, "server" },
164 { NTP_MODE_BCAST, "broadcast" },
165 { NTP_MODE_CTRL, "reserved for NTP control message"},
166 { NTP_MODE_PRIV, "reserved for private use" },
167 { 0, NULL}
170 static const value_string info_mode_types[] = {
171 { NTP_MODE_RSV, "reserved" },
172 { NTP_MODE_SYMACT, "symmetric active" },
173 { NTP_MODE_SYMPAS, "symmetric passive" },
174 { NTP_MODE_CLIENT, "client" },
175 { NTP_MODE_SERVER, "server" },
176 { NTP_MODE_BCAST, "broadcast" },
177 { NTP_MODE_CTRL, "control"},
178 { NTP_MODE_PRIV, "private" },
179 { 0, NULL}
182 /* According to rfc, unspecified or invalid (stratum-0) servers should
183 * set their Reference ID (4bytes field) according to following table:
184 * https://www.iana.org/assignments/ntp-parameters/ntp-parameters.xhtml#ntp-parameters-2
186 static const struct {
187 const char *id;
188 const char *data;
189 } kod_messages[] = {
190 /* IANA / RFC 5905 */
191 { "ACST", "The association belongs to a unicast server" },
192 { "AUTH", "Server authentication failed" },
193 { "AUTO", "Autokey sequence failed" },
194 { "BCST", "The association belongs to a broadcast server" },
195 { "CRYP", "Cryptographic authentication or identification failed" },
196 { "DENY", "Access denied by remote server" },
197 { "DROP", "Lost peer in symmetric mode" },
198 { "RSTR", "Access denied due to local policy" },
199 { "INIT", "The association has not yet synchronized for the first time" },
200 { "MCST", "The association belongs to a dynamically discovered server" },
201 { "NKEY", "No key found. Either the key was never installed or is not trusted" },
202 { "NTSN", "Network Time Security (NTS) negative-acknowledgment (NAK)" },
203 { "RATE", "Rate exceeded. The server has temporarily denied access because the client exceeded the rate threshold" },
204 { "RMOT", "Alteration of association from a remote host running ntpdc." },
205 { "STEP", "A step change in system time has occurred, but the association has not yet resynchronized" },
206 { "\0\0\0\0", "NULL" },
207 { NULL, NULL}
210 /* According to rfc 4330, primary (stratum-1) servers should set
211 * their Reference ID (4bytes field) according to following table:
213 static const struct {
214 const char *id;
215 const char *data;
216 } primary_sources[] = {
217 /* Reference Identifier Codes
218 * https://www.iana.org/assignments/ntp-parameters/ntp-parameters.xhtml#ntp-parameters-1
220 { "GOES", "Geostationary Orbit Environment Satellite" },
221 { "GPS\0", "Global Position System" },
222 { "GAL\0", "Galileo Positioning System" },
223 { "PPS\0", "Generic pulse-per-second" },
224 { "IRIG", "Inter-Range Instrumentation Group" },
225 { "WWVB", "LF Radio WWVB Ft. Collins, CO 60 kHz" },
226 { "DCF\0", "LF Radio DCF77 Mainflingen, DE 77.5 kHz" },
227 { "HBG\0", "LF Radio HBG Prangins, HB 75 kHz" },
228 { "MSF\0", "LF Radio MSF Anthorn, UK 60 kHz" },
229 { "JJY\0", "LF Radio JJY Fukushima, JP 40 kHz, Saga, JP 60 kHz" },
230 { "LORC", "MF Radio LORAN C station, 100 kHz" },
231 { "TDF\0", "MF Radio Allouis, FR 162 kHz" },
232 { "CHU\0", "HF Radio CHU Ottawa, Ontario" },
233 { "WWV\0", "HF Radio WWV Ft. Collins, CO" },
234 { "WWVH", "HF Radio WWVH Kauai, HI" },
235 { "NIST", "NIST telephone modem" },
236 { "ACTS", "NIST telephone modem" },
237 { "USNO", "USNO telephone modem" },
238 { "PTB\0", "European telephone modem" },
239 { "DFM\0", "UTC(DFM)"},
241 /* Unofficial codes */
242 { "LCL\0", "uncalibrated local clock" },
243 { "LOCL", "uncalibrated local clock" },
244 { "CESM", "calibrated Cesium clock" },
245 { "RBDM", "calibrated Rubidium clock" },
246 { "OMEG", "OMEGA radionavigation system" },
247 { "DCN\0", "DCN routing protocol" },
248 { "TSP\0", "TSP time protocol" },
249 { "DTS\0", "Digital Time Service" },
250 { "ATOM", "Atomic clock (calibrated)" },
251 { "VLF\0", "VLF radio (OMEGA,, etc.)" },
252 { "DCFa", "DCF77 with amplitude modulation" },
253 { "DCFp", "DCF77 with phase modulation/pseudo random phase modulation" },
254 { "PZF\0", "DCF77 correlation receiver for middle Europe" },
255 { "PZFs", "DCF77 correlation receiver (with shared memory access)" },
256 { "PZFi", "DCF77 correlation receiver (with interrupt based access)" },
257 { "GPSD", "GPSD client driver" },
258 { "GPSs", "GPS (with shared memory access)" },
259 { "GPSi", "GPS (with interrupt based access)" },
260 { "GLNs", "GPS/GLONASS (with shared memory access)" },
261 { "GLNi", "GPS/GLONASS (with interrupt based access)" },
262 { "GNSS", "Global Navigation Satellite System" },
263 { "MRS\0", "Multi Reference System" },
264 { "Nut1", "UT1(NIST)" },
265 { "1PPS", "External 1 PPS input" },
266 { "FREE", "(Internal clock)" },
267 // { "INIT", "(Initialization)" },
268 { "\0\0\0\0", "NULL" },
269 { NULL, NULL}
273 #define NTPCTRL_R_MASK 0x80
275 #define ctrl_r_types ext_r_types
277 #define NTPCTRL_ERROR_MASK 0x40
278 #define NTPCTRL_MORE_MASK 0x20
279 #define NTPCTRL_OP_MASK 0x1f
281 #define NTPCTRL_OP_UNSPEC 0 /* unspecified */
282 #define NTPCTRL_OP_READSTAT 1 /* read status */
283 #define NTPCTRL_OP_READVAR 2 /* read variables */
284 #define NTPCTRL_OP_WRITEVAR 3 /* write variables */
285 #define NTPCTRL_OP_READCLOCK 4 /* read clock variables */
286 #define NTPCTRL_OP_WRITECLOCK 5 /* write clock variables */
287 #define NTPCTRL_OP_SETTRAP 6 /* set trap address */
288 #define NTPCTRL_OP_ASYNCMSG 7 /* asynchronous message */
289 #define NTPCTRL_OP_CONFIGURE 8 /* runtime configuration */
290 #define NTPCTRL_OP_SAVECONFIG 9 /* save config to file */
291 #define NTPCTRL_OP_READ_MRU 10 /* retrieve MRU (mrulist) */
292 #define NTPCTRL_OP_READ_ORDLIST_A 11 /* ordered list req. auth. */
293 #define NTPCTRL_OP_REQ_NONCE 12 /* request a client nonce */
294 #define NTPCTRL_OP_UNSETTRAP 31 /* unset trap */
296 static const value_string ctrl_op_types[] = {
297 { NTPCTRL_OP_UNSPEC, "reserved" },
298 { NTPCTRL_OP_READSTAT, "read status" },
299 { NTPCTRL_OP_READVAR, "read variables" },
300 { NTPCTRL_OP_WRITEVAR, "write variables" },
301 { NTPCTRL_OP_READCLOCK, "read clock variables" },
302 { NTPCTRL_OP_WRITECLOCK, "write clock variables" },
303 { NTPCTRL_OP_SETTRAP, "set trap address/port" },
304 { NTPCTRL_OP_ASYNCMSG, "asynchronous message" },
305 { NTPCTRL_OP_CONFIGURE, "runtime configuration" },
306 { NTPCTRL_OP_SAVECONFIG, "save config to file" },
307 { NTPCTRL_OP_READ_MRU, "retrieve MRU (mrulist)" },
308 { NTPCTRL_OP_READ_ORDLIST_A, "retrieve ordered list" },
309 { NTPCTRL_OP_REQ_NONCE, "request a client nonce" },
310 { NTPCTRL_OP_UNSETTRAP, "unset trap address/port" },
311 { 0, NULL}
314 #define NTPCTRL_SYSSTATUS_LI_MASK 0xC000
315 #define NTPCTRL_SYSSTATUS_CLK_MASK 0x3F00
316 #define NTPCTRL_SYSSTATUS_COUNT_MASK 0x00F0
317 #define NTPCTRL_SYSSTATUS_CODE_MASK 0x000F
319 static const value_string ctrl_sys_status_clksource_types[] = {
320 { 0, "unspecified or unknown" },
321 { 1, "Calibrated atomic clock (e.g. HP 5061)" },
322 { 2, "VLF (band 4) or LF (band 5) radio (e.g. OMEGA, WWVB)" },
323 { 3, "HF (band 7) radio (e.g. CHU, MSF, WWV/H)" },
324 { 4, "UHF (band 9) satellite (e.g. GOES, GPS)" },
325 { 5, "local net (e.g. DCN, TSP, DTS)" },
326 { 6, "UDP/NTP" },
327 { 7, "UDP/TIME" },
328 { 8, "eyeball-and-wristwatch" },
329 { 9, "telephone modem (e.g. NIST)" },
330 { 0, NULL}
333 static const value_string ctrl_sys_status_event_types[] = {
334 { 0, "unspecified" },
335 { 1, "frequency correction (drift) file not available" },
336 { 2, "frequency correction started (frequency stepped)" },
337 { 3, "spike detected and ignored, starting stepout timer" },
338 { 4, "frequency training started" },
339 { 5, "clock synchronized" },
340 { 6, "system restart" },
341 { 7, "panic stop (required step greater than panic threshold)" },
342 { 8, "no system peer" },
343 { 9, "leap second insertion/deletion armed" },
344 { 10, "leap second disarmed" },
345 { 11, "leap second inserted or deleted" },
346 { 12, "clock stepped (stepout timer expired)" },
347 { 13, "kernel loop discipline status changed" },
348 { 14, "leapseconds table loaded from file" },
349 { 15, "leapseconds table outdated, updated file needed" },
350 { 0, NULL}
353 #define NTPCTRL_PEERSTATUS_STATUS_MASK 0xF800
354 #define NTPCTRL_PEERSTATUS_CONFIG_MASK 0x8000
355 #define NTPCTRL_PEERSTATUS_AUTHENABLE_MASK 0x4000
356 #define NTPCTRL_PEERSTATUS_AUTHENTIC_MASK 0x2000
357 #define NTPCTRL_PEERSTATUS_REACH_MASK 0x1000
358 #define NTPCTRL_PEERSTATUS_BCAST_MASK 0x0800
359 #define NTPCTRL_PEERSTATUS_SEL_MASK 0x0700
360 #define NTPCTRL_PEERSTATUS_COUNT_MASK 0x00F0
361 #define NTPCTRL_PEERSTATUS_CODE_MASK 0x000F
363 static const true_false_string tfs_ctrl_peer_status_config = {"configured (peer.config)", "not configured (peer.config)" };
364 static const true_false_string tfs_ctrl_peer_status_authenable = { "authentication enabled (peer.authenable)", "authentication disabled (peer.authenable)" };
365 static const true_false_string tfs_ctrl_peer_status_authentic = { "authentication okay (peer.authentic)", "authentication not okay (peer.authentic)" };
366 static const true_false_string tfs_ctrl_peer_status_reach = {"reachability okay (peer.reach != 0)", "reachability not okay (peer.reach != 0)" };
368 static const value_string ctrl_peer_status_selection_types[] = {
369 { 0, "rejected" },
370 { 1, "passed sanity checks (tests 1 through 8 in Section 3.4.3)" },
371 { 2, "passed correctness checks (intersection algorithm in Section 4.2.1)" },
372 { 3, "passed candidate checks (if limit check implemented)" },
373 { 4, "passed outlier checks (clustering algorithm in Section 4.2.2)" },
374 { 5, "current synchronization source; max distance exceeded (if limit check implemented)" },
375 { 6, "current synchronization source; max distance okay" },
376 { 7, "reserved" },
377 { 0, NULL}
380 static const value_string ctrl_peer_status_event_types[] = {
381 { 0, "unspecified" },
382 { 1, "association mobilized" },
383 { 2, "association demobilized" },
384 { 3, "peer unreachable (peer.reach was nonzero now zero)" },
385 { 4, "peer reachable (peer.reach was zero now nonzero)" },
386 { 5, "association restarted or timed out" },
387 { 6, "no server found (ntpdate mode)" },
388 { 7, "rate exceeded (kiss code RATE)" },
389 { 8, "access denied (kiss code DENY)" },
390 { 9, "leap armed from server LI code" },
391 { 10, "become system peer" },
392 { 11, "reference clock event (see clock status word)" },
393 { 12, "authentication failure" },
394 { 13, "popcorn spike suppressor" },
395 { 14, "entering interleave mode" },
396 { 15, "interleave error (recovered)" },
397 { 0, NULL}
400 #define NTPCTRL_CLKSTATUS_STATUS_MASK 0xFF00
401 #define NTPCTRL_CLKSTATUS_CODE_MASK 0x00FF
403 static const value_string ctrl_clk_status_types[] = {
404 { 0, "clock operating within nominals" },
405 { 1, "reply timeout" },
406 { 2, "bad reply format" },
407 { 3, "hardware or software fault" },
408 { 4, "propagation failure" },
409 { 5, "bad date format or value" },
410 { 6, "bad time format or value" },
411 { 0, NULL}
414 #define NTP_CTRL_ERRSTATUS_CODE_MASK 0xFF00
416 static const value_string ctrl_err_status_types[] = {
417 { 0, "unspecified" },
418 { 1, "authentication failure" },
419 { 2, "invalid message length or format" },
420 { 3, "invalid opcode" },
421 { 4, "unknown association identifier" },
422 { 5, "unknown variable name" },
423 { 6, "invalid variable value" },
424 { 7, "administratively prohibited" },
425 { 0, NULL}
428 static const value_string err_values_types[] = {
429 { 0, "No error" },
430 { 1, "incompatible implementation number"},
431 { 2, "unimplemented request code" },
432 { 3, "format error" },
433 { 4, "no data available" },
434 { 5, "unknown" },
435 { 6, "unknown" },
436 { 7, "authentication failure"},
437 { 0, NULL}
440 #define NTPPRIV_R_MASK 0x80
442 #define NTPPRIV_MORE_MASK 0x40
444 #define NTPPRIV_AUTH_MASK 0x80
445 #define NTPPRIV_SEQ_MASK 0x7f
447 #define XNTPD_OLD 0x02
448 #define XNTPD 0x03
450 static const value_string priv_impl_types[] = {
451 { 0, "UNIV" },
452 { XNTPD_OLD, "XNTPD_OLD (pre-IPv6)" },
453 { XNTPD, "XNTPD" },
454 { 0, NULL}
457 static const value_string priv_mode7_int_action[] = {
458 { 1, "Interface exists" },
459 { 2, "Interface created" },
460 { 3, "Interface deleted" },
461 { 0, NULL}
464 #define PRIV_RC_PEER_LIST 0
465 #define PRIV_RC_PEER_LIST_SUM 1
466 #define PRIV_RC_PEER_INFO 2
467 #define PRIV_RC_PEER_STATS 3
468 #define PRIV_RC_SYS_INFO 4
469 #define PRIV_RC_SYS_STATS 5
470 #define PRIV_RC_IO_STATS 6
471 #define PRIV_RC_MEM_STATS 7
472 #define PRIV_RC_LOOP_INFO 8
473 #define PRIV_RC_TIMER_STATS 9
474 #define PRIV_RC_CONFIG 10
475 #define PRIV_RC_UNCONFIG 11
476 #define PRIV_RC_SET_SYS_FLAG 12
477 #define PRIV_RC_CLR_SYS_FLAG 13
478 #define PRIV_RC_GET_RESTRICT 16
479 #define PRIV_RC_RESADDFLAGS 17
480 #define PRIV_RC_RESSUBFLAGS 18
481 #define PRIV_RC_UNRESTRICT 19
482 #define PRIV_RC_MON_GETLIST 20
483 #define PRIV_RC_RESET_STATS 21
484 #define PRIV_RC_RESET_PEER 22
485 #define PRIV_RC_TRUSTKEY 26
486 #define PRIV_RC_UNTRUSTKEY 27
487 #define PRIV_RC_AUTHINFO 28
488 #define PRIV_RC_TRAPS 29
489 #define PRIV_RC_ADD_TRAP 30
490 #define PRIV_RC_CLR_TRAP 31
491 #define PRIV_RC_REQUEST_KEY 32
492 #define PRIV_RC_CONTROL_KEY 33
493 #define PRIV_RC_CTL_STATS 34
494 #define PRIV_RC_GET_CLOCKINFO 36
495 #define PRIV_RC_SET_CLKFUDGE 37
496 #define PRIV_RC_GET_KERNEL 38
497 #define PRIV_RC_GET_CLKBUGINFO 39
498 #define PRIV_RC_MON_GETLIST_1 42
499 #define PRIV_RC_IF_STATS 44
500 #define PRIV_RC_IF_RELOAD 45
502 static const value_string priv_rc_types[] = {
503 { PRIV_RC_PEER_LIST, "PEER_LIST" },
504 { PRIV_RC_PEER_LIST_SUM, "PEER_LIST_SUM" },
505 { PRIV_RC_PEER_INFO, "PEER_INFO" },
506 { PRIV_RC_PEER_STATS, "PEER_STATS" },
507 { PRIV_RC_SYS_INFO, "SYS_INFO" },
508 { PRIV_RC_SYS_STATS, "SYS_STATS" },
509 { PRIV_RC_IO_STATS, "IO_STATS" },
510 { PRIV_RC_MEM_STATS, "MEM_STATS" },
511 { PRIV_RC_LOOP_INFO, "LOOP_INFO" },
512 { PRIV_RC_TIMER_STATS, "TIMER_STATS" },
513 { PRIV_RC_CONFIG, "CONFIG" },
514 { PRIV_RC_UNCONFIG, "UNCONFIG" },
515 { PRIV_RC_SET_SYS_FLAG, "SET_SYS_FLAG" },
516 { PRIV_RC_CLR_SYS_FLAG, "CLR_SYS_FLAG" },
517 { 14, "MONITOR" },
518 { 15, "NOMONITOR" },
519 { PRIV_RC_GET_RESTRICT, "GET_RESTRICT" },
520 { PRIV_RC_RESADDFLAGS, "RESADDFLAGS" },
521 { PRIV_RC_RESSUBFLAGS, "RESSUBFLAGS" },
522 { PRIV_RC_UNRESTRICT, "UNRESTRICT" },
523 { PRIV_RC_MON_GETLIST, "MON_GETLIST" },
524 { PRIV_RC_RESET_STATS, "RESET_STATS" },
525 { PRIV_RC_RESET_PEER, "RESET_PEER" },
526 { 23, "REREAD_KEYS" },
527 { 24, "DO_DIRTY_HACK" },
528 { 25, "DONT_DIRTY_HACK" },
529 { PRIV_RC_TRUSTKEY, "TRUSTKEY" },
530 { PRIV_RC_UNTRUSTKEY, "UNTRUSTKEY" },
531 { PRIV_RC_AUTHINFO, "AUTHINFO" },
532 { PRIV_RC_TRAPS, "TRAPS" },
533 { PRIV_RC_ADD_TRAP, "ADD_TRAP" },
534 { PRIV_RC_CLR_TRAP, "CLR_TRAP" },
535 { PRIV_RC_REQUEST_KEY, "REQUEST_KEY" },
536 { PRIV_RC_CONTROL_KEY, "CONTROL_KEY" },
537 { PRIV_RC_CTL_STATS, "GET_CTLSTATS" },
538 { 35, "GET_LEAPINFO" },
539 { PRIV_RC_GET_CLOCKINFO, "GET_CLOCKINFO" },
540 { PRIV_RC_SET_CLKFUDGE, "SET_CLKFUDGE" },
541 { PRIV_RC_GET_KERNEL, "GET_KERNEL" },
542 { PRIV_RC_GET_CLKBUGINFO, "GET_CLKBUGINFO" },
543 { 40, "UNASSIGNED" }, /* included to allow direct lookup */
544 { 41, "SET_PRECISION" },
545 { PRIV_RC_MON_GETLIST_1, "MON_GETLIST_1" },
546 { 43, "HOSTNAME_ASSOCID" },
547 { PRIV_RC_IF_STATS, "IF_STATS" },
548 { PRIV_RC_IF_RELOAD, "IF_RELOAD" },
549 { 0, NULL}
551 static value_string_ext priv_rc_types_ext = VALUE_STRING_EXT_INIT(priv_rc_types);
553 #define PRIV_INFO_FLAG_CONFIG 0x1
554 #define PRIV_INFO_FLAG_SYSPEER 0x2
555 #define PRIV_INFO_FLAG_BURST 0x4
556 #define PRIV_INFO_FLAG_REFCLOCK 0x8
557 #define PRIV_INFO_FLAG_PREFER 0x10
558 #define PRIV_INFO_FLAG_AUTHENABLE 0x20
559 #define PRIV_INFO_FLAG_SEL_CANDIDATE 0x40
560 #define PRIV_INFO_FLAG_SHORTLIST 0x80
561 /* XXX PRIV_INFO_FLAG_IBURST is unused, is a field needed? */
562 #define PRIV_INFO_FLAG_IBURST 0x100
564 #define PRIV_CONF_FLAG_AUTHENABLE 0x01
565 #define PRIV_CONF_FLAG_PREFER 0x02
566 #define PRIV_CONF_FLAG_BURST 0x04
567 #define PRIV_CONF_FLAG_IBURST 0x08
568 #define PRIV_CONF_FLAG_NOSELECT 0x10
569 #define PRIV_CONF_FLAG_SKEY 0x20
571 #define PRIV_SYS_FLAG_BCLIENT 0x01
572 #define PRIV_SYS_FLAG_PPS 0x02
573 #define PRIV_SYS_FLAG_NTP 0x04
574 #define PRIV_SYS_FLAG_KERNEL 0x08
575 #define PRIV_SYS_FLAG_MONITOR 0x10
576 #define PRIV_SYS_FLAG_FILEGEN 0x20
577 #define PRIV_SYS_FLAG_AUTH 0x40
578 #define PRIV_SYS_FLAG_CAL 0x80
580 #define PRIV_RESET_FLAG_ALLPEERS 0x00000001
581 #define PRIV_RESET_FLAG_IO 0x00000002
582 #define PRIV_RESET_FLAG_SYS 0x00000004
583 #define PRIV_RESET_FLAG_MEM 0x00000008
584 #define PRIV_RESET_FLAG_TIMER 0x00000010
585 #define PRIV_RESET_FLAG_AUTH 0x00000020
586 #define PRIV_RESET_FLAG_CTL 0x00000040
588 static const range_string stratum_rvals[] = {
589 { 0, 0, "unspecified or invalid" },
590 { 1, 1, "primary reference" },
591 { 2, 15, "secondary reference" },
592 { 16, 16, "unsynchronized" },
593 { 17, 255, "reserved" },
594 { 0, 0, NULL }
597 #define NTP_MD5_ALGO 0
598 #define NTP_SHA_ALGO 1
600 static const value_string authentication_types[] = {
601 { NTP_MD5_ALGO, "MD5" },
602 { NTP_SHA_ALGO, "SHA" },
603 { 0, NULL}
607 * NTP Extension Field Types.
608 * https://www.iana.org/assignments/ntp-parameters/ntp-parameters.xhtml#ntp-parameters-3
610 static const range_string ntp_ext_field_types[] = {
611 { 0x0000, 0x0000, "Crypto-NAK; authentication failure" },
612 { 0x0002, 0x0002, "Reserved for historic reasons" },
613 { 0x0102, 0x0102, "Reserved for historic reasons" },
614 { 0x0104, 0x0104, "Unique Identifier" },
615 { 0x0200, 0x0200, "No-Operation Request" },
616 { 0x0201, 0x0201, "Association Message Request" },
617 { 0x0202, 0x0202, "Certificate Message Request" },
618 { 0x0203, 0x0203, "Cookie Message Request" },
619 { 0x0204, 0x0204, "NTS Cookie or Autokey Message Request" },
620 { 0x0205, 0x0205, "Leapseconds Message Request" },
621 { 0x0206, 0x0206, "Sign Message Request" },
622 { 0x0207, 0x0207, "IFF Identity Message Request" },
623 { 0x0208, 0x0208, "GQ Identity Message Request" },
624 { 0x0209, 0x0209, "MV Identity Message Request" },
625 { 0x0302, 0x0302, "Reserved for historic reasons" },
626 { 0x0304, 0x0304, "NTS Cookie Placeholder" },
627 { 0x0402, 0x0402, "Reserved for historic reasons" },
628 { 0x0404, 0x0404, "NTS Authenticator and Encrypted Extension Fields" },
629 { 0x0502, 0x0502, "Reserved for historic reasons" },
630 { 0x0602, 0x0602, "Reserved for historic reasons" },
631 { 0x0702, 0x0702, "Reserved for historic reasons" },
632 { 0x0802, 0x0802, "Reserved for historic reasons" },
633 { 0x0902, 0x0902, "Reserved for historic reasons" },
634 { 0x2005, 0x2005, "UDP Checksum Complement" },
635 { 0x8002, 0x8002, "Reserved for historic reasons" },
636 { 0x8102, 0x8102, "Reserved for historic reasons" },
637 { 0x8200, 0x8200, "No-Operation Response" },
638 { 0x8201, 0x8201, "Association Message Response" },
639 { 0x8202, 0x8202, "Certificate Message Response" },
640 { 0x8203, 0x8203, "Cookie Message Response" },
641 { 0x8204, 0x8204, "Autokey Message Response" },
642 { 0x8205, 0x8205, "Leapseconds Message Response" },
643 { 0x8206, 0x8206, "Sign Message Response" },
644 { 0x8207, 0x8207, "IFF Identity Message Response" },
645 { 0x8208, 0x8208, "GQ Identity Message Response" },
646 { 0x8209, 0x8209, "MV Identity Message Response" },
647 { 0x8302, 0x8302, "Reserved for historic reasons" },
648 { 0x8402, 0x8402, "Reserved for historic reasons" },
649 { 0x8502, 0x8502, "Reserved for historic reasons" },
650 { 0x8602, 0x8602, "Reserved for historic reasons" },
651 { 0x8702, 0x8702, "Reserved for historic reasons" },
652 { 0x8802, 0x8802, "Reserved for historic reasons" },
653 { 0x8902, 0x8902, "Reserved for historic reasons" },
654 { 0xC002, 0xC002, "Reserved for historic reasons" },
655 { 0xC102, 0xC102, "Reserved for historic reasons" },
656 { 0xC200, 0xC200, "No-Operation Error Response" },
657 { 0xC201, 0xC201, "Association Message Error Response" },
658 { 0xC202, 0xC202, "Certificate Message Error Response" },
659 { 0xC203, 0xC203, "Cookie Message Error Response" },
660 { 0xC204, 0xC204, "Autokey Message Error Response" },
661 { 0xC205, 0xC205, "Leapseconds Message Error Response" },
662 { 0xC206, 0xC206, "Sign Message Error Response" },
663 { 0xC207, 0xC207, "IFF Identity Message Error Response" },
664 { 0xC208, 0xC208, "GQ Identity Message Error Response" },
665 { 0xC209, 0xC209, "MV Identity Message Error Response" },
666 { 0xC302, 0xC302, "Reserved for historic reasons" },
667 { 0xC402, 0xC402, "Reserved for historic reasons" },
668 { 0xC502, 0xC502, "Reserved for historic reasons" },
669 { 0xC602, 0xC602, "Reserved for historic reasons" },
670 { 0xC702, 0xC702, "Reserved for historic reasons" },
671 { 0xC802, 0xC802, "Reserved for historic reasons" },
672 { 0xC902, 0xC902, "Reserved for historic reasons" },
673 { 0xF000, 0xFFFF, "Reserved for Experimental Use" },
674 { 0, 0, NULL }
678 * Deprecated, historic extensions
679 * (https://datatracker.ietf.org/doc/draft-ietf-ntp-update-registries/)
681 static const value_string ntp_ext_field_types_historic[] = {
682 { 0x0002, "No-Operation Request" },
683 { 0x0102, "Association Message Request" },
684 { 0x0302, "Cookie Message Request" },
685 { 0x0402, "Autokey Message Request" },
686 { 0x0502, "Leapseconds Value Message Request" },
687 { 0x0602, "Sign Message Request" },
688 { 0x0702, "IFF Identity Message Request" },
689 { 0x0802, "GQ Identity Message Request" },
690 { 0x0902, "MV Identity Message Request" },
691 { 0x8002, "No-Operation Response" },
692 { 0x8102, "Association Message Response" },
693 { 0x8302, "Cookie Message Response" },
694 { 0x8402, "Autokey Message Response" },
695 { 0x8502, "Leapseconds Value Message Response" },
696 { 0x8602, "Sign Message Response" },
697 { 0x8702, "IFF Identity Message Response" },
698 { 0x8802, "GQ Identity Message Response" },
699 { 0x8902, "MV Identity Message Response" },
700 { 0xC002, "No-Operation Error Response" },
701 { 0xC102, "Association Message Error Response" },
702 { 0xC302, "Cookie Message Error Response" },
703 { 0xC402, "Autokey Message Error Response" },
704 { 0xC502, "Leapseconds Value Message Error Response" },
705 { 0xC602, "Sign Message Error Response" },
706 { 0xC702, "IFF Identity Message Error Response" },
707 { 0xC802, "GQ Identity Message Error Response" },
708 { 0xC902, "MV Identity Message Error Response" },
709 { 0, NULL }
712 typedef struct {
713 uint32_t req_frame;
714 uint32_t resp_frame;
715 nstime_t req_time;
716 uint32_t seq;
717 } ntp_trans_info_t;
719 typedef struct {
720 wmem_tree_t *trans;
721 } ntp_conv_info_t;
724 static int proto_ntp;
726 static int hf_ntp_flags;
727 static int hf_ntp_flags_li;
728 static int hf_ntp_flags_vn;
729 static int hf_ntp_flags_mode;
730 static int hf_ntp_stratum;
731 static int hf_ntp_ppoll;
732 static int hf_ntp_precision;
733 static int hf_ntp_rootdelay;
734 static int hf_ntp_rootdispersion;
735 static int hf_ntp_refid;
736 static int hf_ntp_reftime;
737 static int hf_ntp_org;
738 static int hf_ntp_rec;
739 static int hf_ntp_xmt;
740 static int hf_ntp_keyid;
741 static int hf_ntp_mac;
742 static int hf_ntp_padding;
743 static int hf_ntp_key_type;
744 static int hf_ntp_key_index;
745 static int hf_ntp_key_signature;
746 static int hf_ntp_response_in;
747 static int hf_ntp_request_in;
748 static int hf_ntp_delta_time;
750 static int hf_ntp_ext;
751 static int hf_ntp_ext_type;
752 static int hf_ntp_ext_length;
753 static int hf_ntp_ext_value;
755 static int hf_ntp_ext_nts;
756 static int hf_ntp_nts_nonce_length;
757 static int hf_ntp_nts_ciphertext_length;
758 static int hf_ntp_nts_nonce;
759 static int hf_ntp_nts_ciphertext;
760 static int hf_ntp_nts_cookie_receive_frame;
761 static int hf_ntp_nts_cookie_used_frame;
762 static int hf_ntp_nts_crypto_success;
764 static int hf_ntpctrl_flags2;
765 static int hf_ntpctrl_flags2_r;
766 static int hf_ntpctrl_flags2_error;
767 static int hf_ntpctrl_flags2_more;
768 static int hf_ntpctrl_flags2_opcode;
769 static int hf_ntpctrl_sequence;
770 static int hf_ntpctrl_status;
771 static int hf_ntpctrl_error_status_word;
772 static int hf_ntpctrl_sys_status_li;
773 static int hf_ntpctrl_sys_status_clksrc;
774 static int hf_ntpctrl_sys_status_count;
775 static int hf_ntpctrl_sys_status_code;
776 static int hf_ntpctrl_peer_status_b0;
777 static int hf_ntpctrl_peer_status_b1;
778 static int hf_ntpctrl_peer_status_b2;
779 static int hf_ntpctrl_peer_status_b3;
780 static int hf_ntpctrl_peer_status_b4;
781 static int hf_ntpctrl_peer_status_selection;
782 static int hf_ntpctrl_peer_status_count;
783 static int hf_ntpctrl_peer_status_code;
784 static int hf_ntpctrl_clk_status;
785 static int hf_ntpctrl_clk_status_code;
786 static int hf_ntpctrl_associd;
787 static int hf_ntpctrl_offset;
788 static int hf_ntpctrl_count;
789 static int hf_ntpctrl_data;
790 static int hf_ntpctrl_item;
791 static int hf_ntpctrl_trapmsg;
792 static int hf_ntpctrl_ordlist;
793 static int hf_ntpctrl_configuration;
794 static int hf_ntpctrl_mru;
795 static int hf_ntpctrl_nonce;
797 static int hf_ntppriv_flags_r;
798 static int hf_ntppriv_flags_more;
799 static int hf_ntppriv_auth_seq;
800 static int hf_ntppriv_auth;
801 static int hf_ntppriv_seq;
802 static int hf_ntppriv_impl;
803 static int hf_ntppriv_reqcode;
804 static int hf_ntppriv_errcode;
805 static int hf_ntppriv_numitems;
806 static int hf_ntppriv_mbz;
807 static int hf_ntppriv_mode7_item;
808 static int hf_ntppriv_itemsize;
809 static int hf_ntppriv_avgint;
810 static int hf_ntppriv_lsint;
811 static int hf_ntppriv_count;
812 static int hf_ntppriv_restr;
813 static int hf_ntppriv_addr;
814 static int hf_ntppriv_daddr;
815 static int hf_ntppriv_flags;
816 static int hf_ntppriv_port;
817 static int hf_ntppriv_mode;
818 static int hf_ntppriv_version;
819 static int hf_ntppriv_v6_flag;
820 static int hf_ntppriv_unused;
821 static int hf_ntppriv_addr6;
822 static int hf_ntppriv_daddr6;
823 static int hf_ntppriv_tstamp;
824 static int hf_ntppriv_mode7_addr;
825 static int hf_ntppriv_mode7_mask;
826 static int hf_ntppriv_mode7_bcast;
827 static int hf_ntppriv_mode7_port;
828 static int hf_ntppriv_mode7_hmode;
829 static int hf_ntppriv_mode7_peer_flags;
830 static int hf_ntppriv_mode7_v6_flag;
831 static int hf_ntppriv_mode7_unused;
832 static int hf_ntppriv_mode7_addr6;
833 static int hf_ntppriv_mode7_mask6;
834 static int hf_ntppriv_mode7_bcast6;
835 static int hf_ntppriv_mode7_peer_flags_config;
836 static int hf_ntppriv_mode7_peer_flags_syspeer;
837 static int hf_ntppriv_mode7_peer_flags_burst;
838 static int hf_ntppriv_mode7_peer_flags_refclock;
839 static int hf_ntppriv_mode7_peer_flags_prefer;
840 static int hf_ntppriv_mode7_peer_flags_authenable;
841 static int hf_ntppriv_mode7_peer_flags_sel_candidate;
842 static int hf_ntppriv_mode7_peer_flags_shortlist;
843 static int hf_ntppriv_mode7_dstaddr;
844 static int hf_ntppriv_mode7_srcaddr;
845 static int hf_ntppriv_mode7_srcport;
846 static int hf_ntppriv_mode7_count;
847 static int hf_ntppriv_mode7_hpoll;
848 static int hf_ntppriv_mode7_reach;
849 static int hf_ntppriv_mode7_delay;
850 static int hf_ntppriv_mode7_offset;
851 static int hf_ntppriv_mode7_dispersion;
852 static int hf_ntppriv_mode7_dstaddr6;
853 static int hf_ntppriv_mode7_srcaddr6;
854 static int hf_ntppriv_mode7_leap;
855 static int hf_ntppriv_mode7_pmode;
856 static int hf_ntppriv_mode7_version;
857 static int hf_ntppriv_mode7_unreach;
858 static int hf_ntppriv_mode7_flash;
859 static int hf_ntppriv_mode7_ttl;
860 static int hf_ntppriv_mode7_flash2;
861 static int hf_ntppriv_mode7_associd;
862 static int hf_ntppriv_mode7_pkeyid;
863 static int hf_ntppriv_mode7_timer;
864 static int hf_ntppriv_mode7_filtdelay;
865 static int hf_ntppriv_mode7_filtoffset;
866 static int hf_ntppriv_mode7_order;
867 static int hf_ntppriv_mode7_selectdis;
868 static int hf_ntppriv_mode7_estbdelay;
869 static int hf_ntppriv_mode7_bdelay;
870 static int hf_ntppriv_mode7_authdelay;
871 static int hf_ntppriv_mode7_stability;
872 static int hf_ntppriv_mode7_timeup;
873 static int hf_ntppriv_mode7_timereset;
874 static int hf_ntppriv_mode7_timereceived;
875 static int hf_ntppriv_mode7_timetosend;
876 static int hf_ntppriv_mode7_timereachable;
877 static int hf_ntppriv_mode7_sent;
878 static int hf_ntppriv_mode7_processed;
879 static int hf_ntppriv_mode7_badauth;
880 static int hf_ntppriv_mode7_bogusorg;
881 static int hf_ntppriv_mode7_oldpkt;
882 static int hf_ntppriv_mode7_seldisp;
883 static int hf_ntppriv_mode7_selbroken;
884 static int hf_ntppriv_mode7_candidate;
885 static int hf_ntppriv_mode7_minpoll;
886 static int hf_ntppriv_mode7_maxpoll;
887 static int hf_ntppriv_mode7_config_flags;
888 static int hf_ntppriv_mode7_config_flags_auth;
889 static int hf_ntppriv_mode7_config_flags_prefer;
890 static int hf_ntppriv_mode7_config_flags_burst;
891 static int hf_ntppriv_mode7_config_flags_iburst;
892 static int hf_ntppriv_mode7_config_flags_noselect;
893 static int hf_ntppriv_mode7_config_flags_skey;
894 static int hf_ntppriv_mode7_key_file;
895 static int hf_ntppriv_mode7_sys_flags;
896 static int hf_ntppriv_mode7_sys_flags8;
897 static int hf_ntppriv_mode7_sys_flags_bclient;
898 static int hf_ntppriv_mode7_sys_flags_pps;
899 static int hf_ntppriv_mode7_sys_flags_ntp;
900 static int hf_ntppriv_mode7_sys_flags_kernel;
901 static int hf_ntppriv_mode7_sys_flags_monitor;
902 static int hf_ntppriv_mode7_sys_flags_filegen;
903 static int hf_ntppriv_mode7_sys_flags_auth;
904 static int hf_ntppriv_mode7_sys_flags_cal;
905 static int hf_ntppriv_mode7_reset_stats_flags;
906 static int hf_ntppriv_mode7_reset_stats_flags_allpeers;
907 static int hf_ntppriv_mode7_reset_stats_flags_io;
908 static int hf_ntppriv_mode7_reset_stats_flags_sys;
909 static int hf_ntppriv_mode7_reset_stats_flags_mem;
910 static int hf_ntppriv_mode7_reset_stats_flags_timer;
911 static int hf_ntppriv_mode7_reset_stats_flags_auth;
912 static int hf_ntppriv_mode7_reset_stats_flags_ctl;
913 static int hf_ntppriv_mode7_req;
914 static int hf_ntppriv_mode7_badpkts;
915 static int hf_ntppriv_mode7_responses;
916 static int hf_ntppriv_mode7_frags;
917 static int hf_ntppriv_mode7_errors;
918 static int hf_ntppriv_mode7_tooshort;
919 static int hf_ntppriv_mode7_inputresp;
920 static int hf_ntppriv_mode7_inputfrag;
921 static int hf_ntppriv_mode7_inputerr;
922 static int hf_ntppriv_mode7_badoffset;
923 static int hf_ntppriv_mode7_badversion;
924 static int hf_ntppriv_mode7_datatooshort;
925 static int hf_ntppriv_mode7_badop;
926 static int hf_ntppriv_mode7_asyncmsgs;
927 static int hf_ntppriv_mode7_type;
928 static int hf_ntppriv_mode7_clock_flags;
929 static int hf_ntppriv_mode7_lastevent;
930 static int hf_ntppriv_mode7_currentstatus;
931 static int hf_ntppriv_mode7_polls;
932 static int hf_ntppriv_mode7_noresponse;
933 static int hf_ntppriv_mode7_badformat;
934 static int hf_ntppriv_mode7_baddata;
935 static int hf_ntppriv_mode7_timestarted;
936 static int hf_ntppriv_mode7_fudgetime1;
937 static int hf_ntppriv_mode7_fudgetime2;
938 static int hf_ntppriv_mode7_fudgeval1;
939 static int hf_ntppriv_mode7_fudgeval2;
940 static int hf_ntppriv_mode7_kernel_offset;
941 static int hf_ntppriv_mode7_freq;
942 static int hf_ntppriv_mode7_maxerror;
943 static int hf_ntppriv_mode7_esterror;
944 static int hf_ntppriv_mode7_status;
945 static int hf_ntppriv_mode7_shift;
946 static int hf_ntppriv_mode7_constant;
947 static int hf_ntppriv_mode7_precision;
948 static int hf_ntppriv_mode7_tolerance;
949 static int hf_ntppriv_mode7_ppsfreq;
950 static int hf_ntppriv_mode7_jitter;
951 static int hf_ntppriv_mode7_stabil;
952 static int hf_ntppriv_mode7_jitcnt;
953 static int hf_ntppriv_mode7_calcnt;
954 static int hf_ntppriv_mode7_errcnt;
955 static int hf_ntppriv_mode7_stbcnt;
956 static int hf_ntppriv_mode7_key;
957 static int hf_ntppriv_mode7_numkeys;
958 static int hf_ntppriv_mode7_numfreekeys;
959 static int hf_ntppriv_mode7_keylookups;
960 static int hf_ntppriv_mode7_keynotfound;
961 static int hf_ntppriv_mode7_encryptions;
962 static int hf_ntppriv_mode7_decryptions;
963 static int hf_ntppriv_mode7_expired;
964 static int hf_ntppriv_mode7_keyuncached;
965 static int hf_ntppriv_mode7_local_addr;
966 static int hf_ntppriv_mode7_trap_addr;
967 static int hf_ntppriv_mode7_trap_port;
968 static int hf_ntppriv_mode7_sequence;
969 static int hf_ntppriv_mode7_settime;
970 static int hf_ntppriv_mode7_origtime;
971 static int hf_ntppriv_mode7_resets;
972 static int hf_ntppriv_traps_flags;
973 static int hf_ntppriv_mode7_local_addr6;
974 static int hf_ntppriv_mode7_trap_addr6;
975 static int hf_ntppriv_mode7_last_offset;
976 static int hf_ntppriv_mode7_drift_comp;
977 static int hf_ntppriv_mode7_compliance;
978 static int hf_ntppriv_mode7_watchdog_timer;
979 static int hf_ntppriv_mode7_poll32;
980 static int hf_ntppriv_mode7_denied;
981 static int hf_ntppriv_mode7_oldversion;
982 static int hf_ntppriv_mode7_newversion;
983 static int hf_ntppriv_mode7_badlength;
984 static int hf_ntppriv_mode7_limitrejected;
985 static int hf_ntppriv_mode7_lamport;
986 static int hf_ntppriv_mode7_tsrounding;
987 static int hf_ntppriv_mode7_totalmem;
988 static int hf_ntppriv_mode7_freemem;
989 static int hf_ntppriv_mode7_findpeer_calls;
990 static int hf_ntppriv_mode7_allocations;
991 static int hf_ntppriv_mode7_demobilizations;
992 static int hf_ntppriv_mode7_hashcount;
993 static int hf_ntppriv_mode7_totalrecvbufs;
994 static int hf_ntppriv_mode7_freerecvbufs;
995 static int hf_ntppriv_mode7_fullrecvbufs;
996 static int hf_ntppriv_mode7_lowwater;
997 static int hf_ntppriv_mode7_dropped;
998 static int hf_ntppriv_mode7_ignored;
999 static int hf_ntppriv_mode7_received;
1000 static int hf_ntppriv_mode7_notsent;
1001 static int hf_ntppriv_mode7_interrupts;
1002 static int hf_ntppriv_mode7_int_received;
1003 static int hf_ntppriv_mode7_alarms;
1004 static int hf_ntppriv_mode7_overflows;
1005 static int hf_ntppriv_mode7_xmtcalls;
1006 static int hf_ntppriv_mode7_rflags;
1007 static int hf_ntppriv_mode7_mflags;
1008 static int hf_ntppriv_mode7_int_name;
1009 static int hf_ntppriv_mode7_int_flags;
1010 static int hf_ntppriv_mode7_last_ttl;
1011 static int hf_ntppriv_mode7_num_mcast;
1012 static int hf_ntppriv_mode7_uptime;
1013 static int hf_ntppriv_mode7_scopeid;
1014 static int hf_ntppriv_mode7_ifindex;
1015 static int hf_ntppriv_mode7_ifnum;
1016 static int hf_ntppriv_mode7_peercnt;
1017 static int hf_ntppriv_mode7_family;
1018 static int hf_ntppriv_mode7_ignore_pkt;
1019 static int hf_ntppriv_mode7_action;
1020 static int hf_ntppriv_mode7_nvalues;
1021 static int hf_ntppriv_mode7_ntimes;
1022 static int hf_ntppriv_mode7_svalues;
1023 static int hf_ntppriv_mode7_stimes;
1024 static int hf_ntppriv_mode7_values;
1025 static int hf_ntppriv_mode7_times;
1026 static int hf_ntppriv_mode7_which;
1027 static int hf_ntppriv_mode7_fudgetime;
1028 static int hf_ntppriv_mode7_fudgeval_flags;
1029 static int hf_ntppriv_mode7_ippeerlimit;
1030 static int hf_ntppriv_mode7_restrict_flags;
1032 static int ett_ntp;
1033 static int ett_ntp_flags;
1034 static int ett_ntp_ext;
1035 static int ett_ntp_ext_flags;
1036 static int ett_ntp_ext_nts;
1037 static int ett_ntpctrl_flags2;
1038 static int ett_ntpctrl_status;
1039 static int ett_ntpctrl_data;
1040 static int ett_ntpctrl_item;
1041 static int ett_ntppriv_auth_seq;
1042 static int ett_mode7_item;
1043 static int ett_ntp_authenticator;
1044 static int ett_ntppriv_peer_list_flags;
1045 static int ett_ntppriv_config_flags;
1046 static int ett_ntppriv_sys_flag_flags;
1047 static int ett_ntppriv_reset_stats_flags;
1049 static expert_field ei_ntp_ext_invalid_length;
1050 static expert_field ei_ntp_ext_historic;
1052 static const char *mon_names[12] = {
1053 "Jan",
1054 "Feb",
1055 "Mar",
1056 "Apr",
1057 "May",
1058 "Jun",
1059 "Jul",
1060 "Aug",
1061 "Sep",
1062 "Oct",
1063 "Nov",
1064 "Dec"
1067 static int * const ntp_header_fields[] = {
1068 &hf_ntp_flags_li,
1069 &hf_ntp_flags_vn,
1070 &hf_ntp_flags_mode,
1071 NULL
1075 * dissect peer status word:
1077 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
1078 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1079 * | Status | Sel | Count | Code |
1080 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1082 static int * const peer_status_flags[] = {
1083 &hf_ntpctrl_peer_status_b0,
1084 &hf_ntpctrl_peer_status_b1,
1085 &hf_ntpctrl_peer_status_b2,
1086 &hf_ntpctrl_peer_status_b3,
1087 &hf_ntpctrl_peer_status_b4,
1088 &hf_ntpctrl_peer_status_selection,
1089 &hf_ntpctrl_peer_status_count,
1090 &hf_ntpctrl_peer_status_code,
1091 NULL
1094 static int * const ntppriv_peer_list_flags[] = {
1095 &hf_ntppriv_mode7_peer_flags_config,
1096 &hf_ntppriv_mode7_peer_flags_syspeer,
1097 &hf_ntppriv_mode7_peer_flags_burst,
1098 &hf_ntppriv_mode7_peer_flags_refclock,
1099 &hf_ntppriv_mode7_peer_flags_prefer,
1100 &hf_ntppriv_mode7_peer_flags_authenable,
1101 &hf_ntppriv_mode7_peer_flags_sel_candidate,
1102 &hf_ntppriv_mode7_peer_flags_shortlist,
1103 NULL
1106 static int * const ntppriv_config_flags[] = {
1107 &hf_ntppriv_mode7_config_flags_auth,
1108 &hf_ntppriv_mode7_config_flags_prefer,
1109 &hf_ntppriv_mode7_config_flags_burst,
1110 &hf_ntppriv_mode7_config_flags_iburst,
1111 &hf_ntppriv_mode7_config_flags_noselect,
1112 &hf_ntppriv_mode7_config_flags_skey,
1113 NULL
1116 static int * const ntppriv_sys_flag_flags[] = {
1117 &hf_ntppriv_mode7_sys_flags_bclient,
1118 &hf_ntppriv_mode7_sys_flags_pps,
1119 &hf_ntppriv_mode7_sys_flags_ntp,
1120 &hf_ntppriv_mode7_sys_flags_kernel,
1121 &hf_ntppriv_mode7_sys_flags_monitor,
1122 &hf_ntppriv_mode7_sys_flags_filegen,
1123 &hf_ntppriv_mode7_sys_flags_auth,
1124 &hf_ntppriv_mode7_sys_flags_cal,
1125 NULL
1128 static int * const ntppriv_reset_stats_flags[] = {
1129 &hf_ntppriv_mode7_reset_stats_flags_allpeers,
1130 &hf_ntppriv_mode7_reset_stats_flags_io,
1131 &hf_ntppriv_mode7_reset_stats_flags_sys,
1132 &hf_ntppriv_mode7_reset_stats_flags_mem,
1133 &hf_ntppriv_mode7_reset_stats_flags_timer,
1134 &hf_ntppriv_mode7_reset_stats_flags_auth,
1135 &hf_ntppriv_mode7_reset_stats_flags_ctl,
1136 NULL
1139 /* parser definitions */
1140 static tvbparse_wanted_t *want;
1141 static tvbparse_wanted_t *want_ignore;
1143 /* NTS cookie and reminders */
1144 static nts_cookie_t *nts_cookie;
1145 static int nts_tvb_uid_offset;
1146 static int nts_tvb_uid_length;
1147 static int nts_aad_start;
1150 * NTP_BASETIME is in fact epoch - ntp_start_time; ntp_start_time
1151 * is January 1, 2036, 00:00:00 UTC.
1153 #define NTP_BASETIME EPOCH_DELTA_1900_01_01_00_00_00_UTC
1154 #define NTP_FLOAT_DENOM 4294967296.0
1155 #define NTP_TS_SIZE 110
1157 /* tvb_ntp_fmt_ts_sec - converts an NTP timestamps second part (32bits) to an human readable string.
1158 * TVB and an offset (IN).
1159 * returns pointer to filled buffer. This buffer will be freed automatically once
1160 * dissection of the next packet occurs.
1162 const char *
1163 tvb_ntp_fmt_ts_sec(tvbuff_t *tvb, int offset)
1165 uint32_t tempstmp;
1166 time_t temptime;
1167 struct tm *bd;
1168 char *buff;
1170 tempstmp = tvb_get_ntohl(tvb, offset);
1171 if (tempstmp == 0){
1172 return "NULL";
1175 /* We need a temporary variable here so the unsigned math
1176 * works correctly (for years > 2036 according to RFC 2030
1177 * chapter 3).
1179 temptime = (time_t)(tempstmp - NTP_BASETIME);
1180 bd = gmtime(&temptime);
1181 if (!bd){
1182 return "Not representable";
1185 buff = (char *)wmem_alloc(wmem_packet_scope(), NTP_TS_SIZE);
1186 snprintf(buff, NTP_TS_SIZE,
1187 "%s %2d, %d %02d:%02d:%02d UTC",
1188 mon_names[bd->tm_mon],
1189 bd->tm_mday,
1190 bd->tm_year + 1900,
1191 bd->tm_hour,
1192 bd->tm_min,
1193 bd->tm_sec);
1194 return buff;
1197 static tvbuff_t*
1198 ntp_decrypt_nts(tvbuff_t *parent_tvb, packet_info *pinfo, uint8_t *nonce, uint32_t nonce_len,
1199 uint8_t *ciphertext, uint32_t ciphertext_len, uint8_t *aad, uint32_t aad_len,
1200 const nts_aead *aead, uint8_t *key)
1202 gcry_cipher_hd_t gc_hd = NULL;
1203 gcry_error_t err;
1204 uint8_t *tag, *ct;
1205 uint32_t ct_len;
1207 /* Field ciphertext length is the total length, including authentication tag.
1208 * Now, as we know the AEAD details, we need to adjust the lengths and copy the bytes
1210 ct_len = ciphertext_len - aead->tag_len;
1212 /* SIV has authentication tag prepended */
1213 tag = wmem_alloc0(pinfo->pool, aead->tag_len);
1214 ct = wmem_alloc0(pinfo->pool, ct_len);
1216 /* GCRYPT 1.10.0 is mandatory for decryption due to SIV algos */
1217 #if GCRYPT_VERSION_NUMBER >= 0x010a00
1218 if(aead->mode == GCRY_CIPHER_MODE_SIV) {
1219 memcpy(tag, ciphertext, aead->tag_len);
1220 memcpy(ct, ciphertext + aead->tag_len, ct_len);
1221 } else {
1222 memcpy(ct, ciphertext, ct_len);
1223 memcpy(tag, ciphertext + ct_len, aead->tag_len);
1225 #else
1226 memcpy(ct, ciphertext, ct_len);
1227 memcpy(tag, ciphertext + ct_len, aead->tag_len);
1228 #endif
1231 * Be sure to align the following with supported ciphers in NTS-KE
1234 err = gcry_cipher_open(&gc_hd, aead->cipher, aead->mode, 0);
1235 if (err) { ws_debug("Decryption (open) failed: %s", gcry_strerror(err)); gcry_cipher_close(gc_hd); return NULL; }
1237 err = gcry_cipher_setkey(gc_hd, key, aead->key_len);
1238 if (err) { ws_debug("Decryption (setkey) failed: %s", gcry_strerror(err)); gcry_cipher_close(gc_hd); return NULL; }
1240 #if GCRYPT_VERSION_NUMBER >= 0x010a00
1242 /* gcry_cipher_setiv() blocks further gcry_cipher_authenticate() calls with GCRY_CIPHER_MODE_SIV */
1243 if(aead->mode != GCRY_CIPHER_MODE_SIV) {
1244 err = gcry_cipher_setiv(gc_hd, nonce, nonce_len);
1245 if (err) { ws_debug("Decryption (setiv) failed: %s", gcry_strerror(err)); gcry_cipher_close(gc_hd); return NULL; }
1248 err = gcry_cipher_authenticate(gc_hd, aad, aad_len);
1249 if (err) { ws_debug("Decryption (authenticate) failed: %s", gcry_strerror(err)); gcry_cipher_close(gc_hd); return NULL; }
1251 if(aead->mode == GCRY_CIPHER_MODE_SIV) {
1252 err = gcry_cipher_setiv(gc_hd, nonce, nonce_len);
1253 if (err) { ws_debug("Decryption (setiv) failed: %s", gcry_strerror(err)); gcry_cipher_close(gc_hd); return NULL; }
1256 err = gcry_cipher_set_decryption_tag(gc_hd, tag, aead->tag_len);
1257 if (err) { ws_debug("Decryption (decryption tag) failed: %s", gcry_strerror(err)); gcry_cipher_close(gc_hd); return NULL; }
1259 #else
1261 err = gcry_cipher_authenticate(gc_hd, aad, aad_len);
1262 if (err) { ws_debug("Decryption (authenticate) failed: %s", gcry_strerror(err)); gcry_cipher_close(gc_hd); return NULL; }
1264 err = gcry_cipher_setiv(gc_hd, nonce, nonce_len);
1265 if (err) { ws_debug("Decryption (setiv) failed: %s", gcry_strerror(err)); gcry_cipher_close(gc_hd); return NULL; }
1267 #endif
1269 err = gcry_cipher_decrypt(gc_hd, ct, ct_len, NULL, 0);
1270 if (err) { ws_debug("Decryption (decrypt) failed: %s", gcry_strerror(err)); gcry_cipher_close(gc_hd); return NULL; }
1272 err = gcry_cipher_checktag(gc_hd, tag, aead->tag_len);
1273 if (err) { ws_debug("Decryption (checktag) failed: %s", gcry_strerror(err)); gcry_cipher_close(gc_hd); return NULL; }
1275 if(gc_hd)
1276 gcry_cipher_close(gc_hd);
1278 return tvb_new_child_real_data(parent_tvb, ct, ct_len, ct_len);
1281 void
1282 ntp_to_nstime(tvbuff_t *tvb, int offset, nstime_t *nstime)
1284 uint32_t tempstmp;
1286 /* We need a temporary variable here so the unsigned math
1287 * works correctly (for years > 2036 according to RFC 2030
1288 * chapter 3).
1290 tempstmp = tvb_get_ntohl(tvb, offset);
1291 if (tempstmp)
1292 nstime->secs = (time_t)(tempstmp - NTP_BASETIME);
1293 else
1294 nstime->secs = (time_t)tempstmp; /* 0 */
1296 nstime->nsecs = (int)(tvb_get_ntohl(tvb, offset+4)/(NTP_FLOAT_DENOM/1000000000.0));
1299 static void
1300 dissect_nts_cookie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ext_tree, int offset, int length, uint64_t flags)
1302 proto_item *ct;
1303 nts_cookie_t *new_cookie;
1304 nts_used_frames_lookup_t lookup_data = {.tvb = tvb, .hfindex = hf_ntp_nts_cookie_used_frame};
1306 if ((flags & NTP_MODE_MASK) == NTP_MODE_CLIENT) {
1307 nts_cookie = nts_use_cookie(
1308 tvb_new_subset_length(tvb, offset, length),
1309 tvb_new_subset_length(tvb, nts_tvb_uid_offset, nts_tvb_uid_length),
1310 pinfo);
1311 if(nts_cookie) {
1312 ct = proto_tree_add_uint(ext_tree, hf_ntp_nts_cookie_receive_frame, tvb, 0, 0, nts_cookie->frame_received);
1313 proto_item_set_generated(ct);
1315 } else if ((flags & NTP_MODE_MASK) == NTP_MODE_SERVER && nts_cookie) {
1316 /* If a cookie extension was received in a server packet, we need to add it as a new one */
1317 new_cookie = nts_new_cookie_copy(tvb_new_subset_length(tvb, offset, length), nts_cookie, pinfo);
1319 if(new_cookie) {
1320 /* List all packets which made use of that cookie */
1321 lookup_data.tree = ext_tree;
1322 wmem_list_foreach(new_cookie->frames_used, nts_append_used_frames_to_tree, &lookup_data);
1327 static int
1328 dissect_ntp_ext_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ext_tree, int offset, uint16_t extlen)
1330 proto_item *tf;
1331 int value_length;
1333 tf = proto_tree_add_item(ext_tree, hf_ntp_ext_length, tvb, offset, 2, ENC_BIG_ENDIAN);
1334 offset += 2;
1336 if (extlen < 8) {
1337 /* Extension length isn't enough for the extension header.
1338 * Report the error, and return an offset that goes to
1339 * the end of the tvbuff, so we stop dissecting.
1341 expert_add_info_format(pinfo, tf, &ei_ntp_ext_invalid_length, "Extension length %u < 8", extlen);
1342 return tvb_reported_length(tvb);
1344 if (extlen % 4) {
1345 /* Extension length isn't a multiple of 4.
1346 * Report the error, and return an offset that goes
1347 * to the end of the tvbuff, so we stop dissecting.
1349 expert_add_info_format(pinfo, tf, &ei_ntp_ext_invalid_length, "Extension length %u isn't a multiple of 4",
1350 extlen);
1351 return tvb_reported_length(tvb);
1354 value_length = extlen - 4;
1355 proto_tree_add_item(ext_tree, hf_ntp_ext_value, tvb, offset, value_length, ENC_NA);
1357 return offset;
1360 static void
1361 // NOLINTNEXTLINE(misc-no-recursion)
1362 dissect_nts_ext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ext_tree, proto_tree *ntp_tree, int offset, int length, uint64_t flags, int ext_start)
1364 proto_tree *nts_tree;
1365 proto_item *tf, *af;
1366 uint32_t nonce_len, ciphertext_len, aad_len;
1367 uint8_t *nonce, *aad, *ciphertext;
1368 uint8_t *ptr_key = NULL;
1369 const nts_aead *aead;
1370 int crypto_offset = 0, offset_n = offset;
1371 tvbuff_t *decrypted;
1373 tf = proto_tree_add_item(ext_tree, hf_ntp_ext_nts, tvb, offset_n, length, ENC_NA);
1374 nts_tree = proto_item_add_subtree(tf, ett_ntp_ext_nts);
1376 proto_tree_add_item_ret_uint(nts_tree, hf_ntp_nts_nonce_length, tvb, offset_n, 2, ENC_BIG_ENDIAN, &nonce_len);
1377 offset_n += 2;
1379 proto_tree_add_item_ret_uint(nts_tree, hf_ntp_nts_ciphertext_length, tvb, offset_n, 2, ENC_BIG_ENDIAN, &ciphertext_len);
1380 offset_n += 2;
1382 proto_tree_add_item(nts_tree, hf_ntp_nts_nonce, tvb, offset_n, nonce_len, ENC_NA);
1383 nonce = (uint8_t *)tvb_memdup(pinfo->pool, tvb, offset_n, nonce_len);
1384 offset_n += nonce_len;
1386 proto_tree_add_item(nts_tree, hf_ntp_nts_ciphertext, tvb, offset_n, ciphertext_len, ENC_NA);
1387 ciphertext = (uint8_t *)tvb_memdup(pinfo->pool, tvb, offset_n, ciphertext_len);
1389 /* CLIENT REQUEST: C2S key is required, used cookie data should already be available */
1390 if ((flags & NTP_MODE_MASK) == NTP_MODE_CLIENT) {
1391 if(!nts_cookie)
1392 return;
1393 ptr_key = nts_cookie->key_c2s;
1395 /* SERVER RESPONSE: S2C key is required, used cookie data has to be looked up by client request */
1396 } else if ((flags & NTP_MODE_MASK) == NTP_MODE_SERVER) {
1397 if(nts_tvb_uid_length > 0 && nts_tvb_uid_offset >0 ) {
1398 nts_cookie = nts_find_cookie_by_uid(tvb_new_subset_length(tvb, nts_tvb_uid_offset, nts_tvb_uid_length));
1400 if(!nts_cookie)
1401 return;
1402 ptr_key = nts_cookie->key_s2c;
1403 } else {
1404 return;
1407 /* Stop without valid crypto material */
1408 aead = nts_find_aead(nts_cookie->aead);
1409 if(!aead || !nts_cookie->keys_present)
1410 return;
1412 /* Create a buffer for the bytes to authenticate (associated data)
1413 * from packet start until end of previous extension (ext_start).
1415 aad_len = ext_start;
1416 aad = (uint8_t *)tvb_memdup(pinfo->pool, tvb, nts_aad_start, aad_len);
1418 decrypted = ntp_decrypt_nts(tvb, pinfo, nonce, nonce_len, ciphertext, ciphertext_len, aad, aad_len, aead, ptr_key);
1419 af = proto_tree_add_boolean(nts_tree, hf_ntp_nts_crypto_success, tvb, 0, 0, (bool)decrypted);
1420 proto_item_set_generated(af);
1422 if(decrypted) {
1423 add_new_data_source(pinfo, decrypted, "Decrypted NTP");
1424 while ((unsigned)crypto_offset < tvb_reported_length(decrypted)) {
1425 crypto_offset = dissect_ntp_ext(decrypted, pinfo, ntp_tree, crypto_offset, flags);
1430 static int
1431 // NOLINTNEXTLINE(misc-no-recursion)
1432 dissect_ntp_ext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ntp_tree, int offset, uint64_t flags)
1434 proto_tree *ext_tree;
1435 proto_item *tf, *ti, *ei;
1436 uint16_t extlen;
1437 uint32_t type;
1438 int value_length, offset_m = offset;
1439 const char *ext_historic;
1441 increment_dissection_depth(pinfo);
1443 extlen = tvb_get_ntohs(tvb, offset+2);
1444 tf = proto_tree_add_item(ntp_tree, hf_ntp_ext, tvb, offset, extlen, ENC_NA);
1445 ext_tree = proto_item_add_subtree(tf, ett_ntp_ext);
1447 ti = proto_tree_add_item_ret_uint(ext_tree, hf_ntp_ext_type, tvb, offset, 2, ENC_BIG_ENDIAN, &type);
1448 offset += 2;
1450 /* Inform about historic extensions */
1451 ext_historic = try_val_to_str(type, ntp_ext_field_types_historic);
1452 if(ext_historic) {
1453 ei = expert_add_info(pinfo, ti, &ei_ntp_ext_historic);
1454 proto_item_append_text(ei, " for %s", ext_historic);
1457 offset = dissect_ntp_ext_data(tvb, pinfo, ext_tree, offset, extlen);
1459 value_length = extlen - 4;
1461 if(type == 0x0104) { /* NTS UID extension -> remember offset and length */
1462 nts_tvb_uid_offset = offset;
1463 nts_tvb_uid_length = value_length;
1465 /* Every NTP NTS packet must have this extension, so use it to add INFO */
1466 col_append_sep_fstr(pinfo->cinfo, COL_INFO, ",", " NTS");
1468 if(type == 0x0204) /* NTS cookie extension */
1469 dissect_nts_cookie(tvb, pinfo, ext_tree, offset, value_length, flags);
1470 if(type == 0x0404) /* NTS authentication and encryption extension */
1471 dissect_nts_ext(tvb, pinfo, ext_tree, ntp_tree, offset, value_length, flags, offset_m);
1473 offset += value_length;
1475 decrement_dissection_depth(pinfo);
1477 return offset;
1480 static void
1481 dissect_ntp_std(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ntp_tree, ntp_conv_info_t *ntp_conv)
1483 uint8_t stratum;
1484 int8_t ppoll;
1485 int8_t precision;
1486 uint32_t rootdelay;
1487 double rootdelay_double;
1488 uint32_t rootdispersion;
1489 double rootdispersion_double;
1490 uint32_t refid_addr;
1491 char *buff;
1492 int i;
1493 int efs_end;
1494 uint16_t last_extlen = 0;
1495 int macofs;
1496 unsigned maclen;
1497 ntp_trans_info_t *ntp_trans;
1498 wmem_tree_key_t key[3];
1499 uint64_t flags;
1500 uint32_t seq;
1502 proto_tree_add_bitmask_ret_uint64(ntp_tree, tvb, 0, hf_ntp_flags, ett_ntp_flags,
1503 ntp_header_fields, ENC_NA, &flags);
1505 seq = 0xffffffff;
1506 key[0].length = 1;
1507 key[0].key = &seq;
1508 key[1].length = 1;
1509 key[1].key = &pinfo->num;
1510 key[2].length = 0;
1511 key[2].key = NULL;
1512 if ((flags & NTP_MODE_MASK) == NTP_MODE_CLIENT) {
1513 if (!PINFO_FD_VISITED(pinfo)) {
1514 ntp_trans = wmem_new(wmem_file_scope(), ntp_trans_info_t);
1515 ntp_trans->req_frame = pinfo->num;
1516 ntp_trans->resp_frame = 0;
1517 ntp_trans->req_time = pinfo->abs_ts;
1518 ntp_trans->seq = seq;
1519 wmem_tree_insert32_array(ntp_conv->trans, key, (void *)ntp_trans);
1520 } else {
1521 ntp_trans = (ntp_trans_info_t *)wmem_tree_lookup32_array_le(ntp_conv->trans, key);
1522 if (ntp_trans && ntp_trans->resp_frame != 0 && ntp_trans->seq == seq) {
1523 proto_item *resp_it;
1525 resp_it = proto_tree_add_uint(ntp_tree, hf_ntp_response_in, tvb, 0, 0, ntp_trans->resp_frame);
1526 proto_item_set_generated(resp_it);
1529 } else if ((flags & NTP_MODE_MASK) == NTP_MODE_SERVER) {
1530 ntp_trans = (ntp_trans_info_t *)wmem_tree_lookup32_array_le(ntp_conv->trans, key);
1531 if (ntp_trans && ntp_trans->seq == seq) {
1532 if (!PINFO_FD_VISITED(pinfo)) {
1533 if (ntp_trans->resp_frame == 0) {
1534 ntp_trans->resp_frame = pinfo->num;
1536 } else if (ntp_trans->resp_frame == pinfo->num) {
1537 proto_item *req_it;
1538 nstime_t delta;
1540 req_it = proto_tree_add_uint(ntp_tree, hf_ntp_request_in, tvb, 0, 0, ntp_trans->req_frame);
1541 proto_item_set_generated(req_it);
1542 nstime_delta(&delta, &pinfo->abs_ts, &ntp_trans->req_time);
1543 req_it = proto_tree_add_time(ntp_tree, hf_ntp_delta_time, tvb, 0, 0, &delta);
1544 proto_item_set_generated(req_it);
1549 /* Stratum, 1byte field represents distance from primary source
1551 proto_tree_add_item(ntp_tree, hf_ntp_stratum, tvb, 1, 1, ENC_NA);
1552 stratum = tvb_get_uint8(tvb, 1);
1554 /* Poll interval, 1byte field indicating the maximum interval
1555 * between successive messages, in seconds to the nearest
1556 * power of two.
1558 ppoll = tvb_get_int8(tvb, 2);
1559 proto_tree_add_int_format_value(ntp_tree, hf_ntp_ppoll, tvb, 2, 1,
1560 ppoll, ppoll >= 0 ? "%d (%.0f seconds)" : "%d (%5.3f seconds)",
1561 ppoll, pow(2, ppoll));
1563 /* Precision, 1 byte field indicating the precision of the
1564 * local clock, in seconds to the nearest power of two.
1566 precision = tvb_get_int8(tvb, 3);
1567 proto_tree_add_int_format_value(ntp_tree, hf_ntp_precision, tvb, 3, 1,
1568 precision, "%d (%11.9f seconds)", precision, pow(2, precision));
1570 /* Root Delay is a 32-bit signed fixed-point number indicating
1571 * the total roundtrip delay to the primary reference source,
1572 * in seconds with fraction point between bits 15 and 16.
1574 rootdelay = tvb_get_ntohl(tvb, 4);
1575 rootdelay_double = (rootdelay >> 16) + (rootdelay & 0xffff) / 65536.0;
1576 proto_tree_add_uint_format_value(ntp_tree, hf_ntp_rootdelay, tvb, 4, 4,
1577 rootdelay, "%8.6f seconds", rootdelay_double);
1579 /* Root Dispersion, 32-bit unsigned fixed-point number indicating
1580 * the nominal error relative to the primary reference source, in
1581 * seconds with fraction point between bits 15 and 16.
1583 rootdispersion = tvb_get_ntohl(tvb, 8);
1584 rootdispersion_double = (rootdispersion >> 16) + (rootdispersion & 0xffff) / 65536.0;
1585 proto_tree_add_uint_format_value(ntp_tree, hf_ntp_rootdispersion, tvb, 8, 4,
1586 rootdispersion, "%8.6f seconds", rootdispersion_double);
1588 /* Now, there is a problem with secondary servers. Standards
1589 * asks from stratum-2 - stratum-15 servers to set this to the
1590 * low order 32 bits of the latest transmit timestamp of the
1591 * reference source.
1592 * But, all V3 and V4 servers set this to IP address of their
1593 * higher level server. My decision was to resolve this address.
1595 buff = (char *)wmem_alloc(pinfo->pool, NTP_TS_SIZE);
1596 if (stratum == 0) {
1597 snprintf (buff, NTP_TS_SIZE, "Unidentified Kiss-o\'-Death message '%s'",
1598 tvb_get_string_enc(pinfo->pool, tvb, 12, 4, ENC_ASCII));
1599 for (i = 0; kod_messages[i].id; i++) {
1600 if (tvb_memeql(tvb, 12, kod_messages[i].id, 4) == 0) {
1601 snprintf(buff, NTP_TS_SIZE, "%s",
1602 kod_messages[i].data);
1603 break;
1606 } else if (stratum == 1) {
1607 snprintf (buff, NTP_TS_SIZE, "Unidentified reference source '%s'",
1608 tvb_get_string_enc(pinfo->pool, tvb, 12, 4, ENC_ASCII));
1609 for (i = 0; primary_sources[i].id; i++) {
1610 if (tvb_memeql(tvb, 12, (const uint8_t*)primary_sources[i].id, 4) == 0) {
1611 snprintf(buff, NTP_TS_SIZE, "%s",
1612 primary_sources[i].data);
1613 break;
1616 } else {
1617 int buffpos;
1618 refid_addr = tvb_get_ipv4(tvb, 12);
1619 buffpos = snprintf(buff, NTP_TS_SIZE, "%s", get_hostname (refid_addr));
1620 if (buffpos >= NTP_TS_SIZE) {
1621 buff[NTP_TS_SIZE-4]='.';
1622 buff[NTP_TS_SIZE-3]='.';
1623 buff[NTP_TS_SIZE-2]='.';
1624 buff[NTP_TS_SIZE-1]=0;
1627 proto_tree_add_bytes_format_value(ntp_tree, hf_ntp_refid, tvb, 12, 4,
1628 NULL, "%s", buff);
1630 /* Reference Timestamp: This is the time at which the local clock was
1631 * last set or corrected.
1633 proto_tree_add_item(ntp_tree, hf_ntp_reftime, tvb, 16, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
1635 /* Originate Timestamp: This is the time at which the request departed
1636 * the client for the server.
1638 proto_tree_add_item(ntp_tree, hf_ntp_org, tvb, 24, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
1640 /* Receive Timestamp: This is the time at which the request arrived at
1641 * the server.
1643 proto_tree_add_item(ntp_tree, hf_ntp_rec, tvb, 32, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
1645 /* Transmit Timestamp: This is the time at which the reply departed the
1646 * server for the client.
1648 proto_tree_add_item(ntp_tree, hf_ntp_xmt, tvb, 40, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
1651 * Optional fields:
1653 * - Optional Extension fields (EFs), at minimum 16 bytes each.
1654 * Used for Autokey (RFC 5906, requires a MAC) and others.
1656 * - Optional Message Authentication Codes (MACs), consisting of a
1657 * 32-bit key ID concatenated with the digest. Per RFC 7822, this MAC
1658 * can be 24 bytes (SHA-1, AES-CMAC from RFC 8573), 20 octets (MD5),
1659 * or 4 bytes (crypto-NAK, MAC contains four zeroes). However,
1660 * implementations such as chrony and NTPsec support additional hash
1661 * algorithms such as SHA-512 which result in a MAC of 68 bytes.
1663 * Since MACs cannot unambiguously be recognized from EFs based on size
1664 * alone due to the larger, non-standard MAC algorithms, follow this:
1666 * 1. Find the end of EFs, stopping as soon as it looks invalid (too
1667 * small or large Length field).
1668 * 2. If there is any trailing data, assume a MAC is present. If it is
1669 * too small, remove a field that was assumed to be an EF.
1671 efs_end = 48;
1672 while (tvb_reported_length_remaining(tvb, efs_end) >= 16) {
1673 uint16_t extlen = tvb_get_ntohs(tvb, efs_end + 2);
1674 if (extlen < 16) {
1675 break;
1677 if (tvb_reported_length_remaining(tvb, efs_end) < extlen) {
1678 break;
1680 efs_end += extlen;
1681 last_extlen = extlen;
1684 maclen = tvb_reported_length_remaining(tvb, efs_end);
1685 if (maclen == 0) {
1686 /* MAC is missing. */
1687 } else if (maclen == 4 && tvb_get_ntohl(tvb, efs_end) == 0) {
1688 /* crypto-NAK - continue as normal. */
1689 } else if (maclen < 20) {
1690 /* last field was most likely not an EF, remove it. */
1691 efs_end -= last_extlen;
1694 macofs = 48;
1695 while (macofs < efs_end) {
1696 macofs = dissect_ntp_ext(tvb, pinfo, ntp_tree, macofs, flags);
1699 /* When the NTP authentication scheme is implemented, the
1700 * Key Identifier and Message Digest fields contain the
1701 * message authentication code (MAC) information defined in
1702 * Appendix C of RFC-1305. Will print this as hex code for now.
1704 if (tvb_reported_length_remaining(tvb, macofs) >= 4)
1705 proto_tree_add_item(ntp_tree, hf_ntp_keyid, tvb, macofs, 4, ENC_NA);
1706 macofs += 4;
1707 maclen = tvb_reported_length_remaining(tvb, macofs);
1708 if (maclen > 0)
1709 proto_tree_add_item(ntp_tree, hf_ntp_mac, tvb, macofs, maclen, ENC_NA);
1712 static void
1713 dissect_ntp_ctrl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ntp_tree, ntp_conv_info_t *ntp_conv)
1715 uint8_t flags2;
1716 proto_tree *data_tree, *item_tree, *auth_tree;
1717 proto_item *td, *ti;
1718 uint16_t associd;
1719 uint16_t datalen;
1720 uint16_t data_offset;
1721 int length_remaining;
1722 bool auth_diss = false;
1723 ntp_trans_info_t *ntp_trans;
1724 uint32_t seq;
1725 wmem_tree_key_t key[3];
1727 tvbparse_t *tt;
1728 tvbparse_elem_t *element;
1730 static int * const ntpctrl_flags[] = {
1731 &hf_ntpctrl_flags2_r,
1732 &hf_ntpctrl_flags2_error,
1733 &hf_ntpctrl_flags2_more,
1734 &hf_ntpctrl_flags2_opcode,
1735 NULL
1737 proto_tree_add_bitmask(ntp_tree, tvb, 0, hf_ntp_flags, ett_ntp_flags, ntp_header_fields, ENC_NA);
1738 proto_tree_add_bitmask(ntp_tree, tvb, 1, hf_ntpctrl_flags2, ett_ntpctrl_flags2, ntpctrl_flags, ENC_NA);
1739 flags2 = tvb_get_uint8(tvb, 1);
1741 proto_tree_add_item_ret_uint(ntp_tree, hf_ntpctrl_sequence, tvb, 2, 2, ENC_BIG_ENDIAN, &seq);
1742 key[0].length = 1;
1743 key[0].key = &seq;
1744 key[1].length = 1;
1745 key[1].key = &pinfo->num;
1746 key[2].length = 0;
1747 key[2].key = NULL;
1748 associd = tvb_get_ntohs(tvb, 6);
1750 * further processing of status is only necessary in server responses
1752 if (flags2 & NTPCTRL_R_MASK) {
1753 ntp_trans = (ntp_trans_info_t *)wmem_tree_lookup32_array_le(ntp_conv->trans, key);
1754 if (ntp_trans && ntp_trans->seq == seq) {
1755 if (!PINFO_FD_VISITED(pinfo)) {
1756 if (ntp_trans->resp_frame == 0) {
1757 ntp_trans->resp_frame = pinfo->num;
1759 } else {
1760 proto_item *req_it;
1761 nstime_t delta;
1763 req_it = proto_tree_add_uint(ntp_tree, hf_ntp_request_in, tvb, 0, 0, ntp_trans->req_frame);
1764 proto_item_set_generated(req_it);
1765 nstime_delta(&delta, &pinfo->abs_ts, &ntp_trans->req_time);
1766 req_it = proto_tree_add_time(ntp_tree, hf_ntp_delta_time, tvb, 0, 0, &delta);
1767 proto_item_set_generated(req_it);
1770 if (flags2 & NTPCTRL_ERROR_MASK) {
1772 * if error bit is set: dissect error status word
1774 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
1775 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1776 * | Error Code | reserved |
1777 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1779 static int * const errorstatus[] = {
1780 &hf_ntpctrl_error_status_word,
1781 NULL
1784 /* Check if this is an error response... */
1785 proto_tree_add_bitmask(ntp_tree, tvb, 4, hf_ntpctrl_status, ett_ntpctrl_status, errorstatus, ENC_BIG_ENDIAN);
1786 } else {
1787 /* ...otherwise status word depends on OpCode */
1788 switch (flags2 & NTPCTRL_OP_MASK) {
1789 case NTPCTRL_OP_READSTAT:
1790 case NTPCTRL_OP_READVAR:
1791 case NTPCTRL_OP_WRITEVAR:
1792 case NTPCTRL_OP_ASYNCMSG:
1793 if (associd)
1794 proto_tree_add_bitmask(ntp_tree, tvb, 4, hf_ntpctrl_status, ett_ntpctrl_status, peer_status_flags, ENC_BIG_ENDIAN);
1795 else
1798 * dissect system status word:
1800 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
1801 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1802 * |LI | ClkSource | Count | Code |
1803 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1805 static int * const systemstatus[] = {
1806 &hf_ntpctrl_sys_status_li,
1807 &hf_ntpctrl_sys_status_clksrc,
1808 &hf_ntpctrl_sys_status_count,
1809 &hf_ntpctrl_sys_status_code,
1810 NULL
1813 proto_tree_add_bitmask(ntp_tree, tvb, 4, hf_ntpctrl_status, ett_ntpctrl_status, systemstatus, ENC_BIG_ENDIAN);
1815 break;
1816 case NTPCTRL_OP_READCLOCK:
1817 case NTPCTRL_OP_WRITECLOCK:
1820 * dissect clock status word:
1822 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
1823 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1824 * | Clock Status | Event Code |
1825 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1827 static int * const clockstatus[] = {
1828 &hf_ntpctrl_clk_status,
1829 &hf_ntpctrl_clk_status_code,
1830 NULL
1833 proto_tree_add_bitmask(ntp_tree, tvb, 4, hf_ntpctrl_status, ett_ntpctrl_status, clockstatus, ENC_BIG_ENDIAN);
1835 break;
1836 case NTPCTRL_OP_SETTRAP:
1837 case NTPCTRL_OP_UNSETTRAP:
1838 default:
1839 proto_tree_add_item(ntp_tree, hf_ntpctrl_status, tvb, 4, 2, ENC_BIG_ENDIAN);
1840 break;
1844 else
1846 if (!PINFO_FD_VISITED(pinfo)) {
1847 ntp_trans = wmem_new(wmem_file_scope(), ntp_trans_info_t);
1848 ntp_trans->req_frame = pinfo->num;
1849 ntp_trans->resp_frame = 0;
1850 ntp_trans->req_time = pinfo->abs_ts;
1851 ntp_trans->seq = seq;
1852 wmem_tree_insert32_array(ntp_conv->trans, key, (void *)ntp_trans);
1853 } else {
1854 ntp_trans = (ntp_trans_info_t *)wmem_tree_lookup32_array_le(ntp_conv->trans, key);
1855 if (ntp_trans && ntp_trans->resp_frame != 0 && ntp_trans->seq == seq) {
1856 proto_item *resp_it;
1858 resp_it = proto_tree_add_uint(ntp_tree, hf_ntp_response_in, tvb, 0, 0, ntp_trans->resp_frame);
1859 proto_item_set_generated(resp_it);
1862 proto_tree_add_item(ntp_tree, hf_ntpctrl_status, tvb, 4, 2, ENC_BIG_ENDIAN);
1864 proto_tree_add_item(ntp_tree, hf_ntpctrl_associd, tvb, 6, 2, ENC_BIG_ENDIAN);
1865 proto_tree_add_item(ntp_tree, hf_ntpctrl_offset, tvb, 8, 2, ENC_BIG_ENDIAN);
1866 datalen = tvb_get_ntohs(tvb, 10);
1867 proto_tree_add_uint(ntp_tree, hf_ntpctrl_count, tvb, 10, 2, datalen);
1870 * dissect Data part of the NTP control message
1872 if (datalen) {
1873 data_offset = 12;
1874 td = proto_tree_add_item(ntp_tree, hf_ntpctrl_data, tvb, data_offset, datalen, ENC_NA);
1875 data_tree = proto_item_add_subtree(td, ett_ntpctrl_data);
1876 switch(flags2 & NTPCTRL_OP_MASK) {
1877 case NTPCTRL_OP_READSTAT:
1878 if (!associd) {
1880 * if associd == 0 then data part contains a list of the form
1881 * <association identifier><status word>,
1883 while(datalen) {
1884 ti = proto_tree_add_item(data_tree, hf_ntpctrl_item, tvb, data_offset, 4, ENC_NA);
1885 item_tree = proto_item_add_subtree(ti, ett_ntpctrl_item);
1886 proto_tree_add_item(item_tree, hf_ntpctrl_associd, tvb, data_offset, 2, ENC_BIG_ENDIAN);
1887 data_offset += 2;
1888 proto_tree_add_bitmask(ntp_tree, tvb, data_offset, hf_ntpctrl_status, ett_ntpctrl_status, peer_status_flags, ENC_BIG_ENDIAN);
1889 data_offset += 2;
1890 datalen -= 4;
1892 break;
1895 * but if associd != 0,
1896 * then data part could be the same as if opcode is NTPCTRL_OP_READVAR
1897 * --> so, no "break" here!
1899 /* FALL THROUGH */
1900 case NTPCTRL_OP_READVAR:
1901 case NTPCTRL_OP_WRITEVAR:
1902 case NTPCTRL_OP_READCLOCK:
1903 case NTPCTRL_OP_WRITECLOCK:
1904 tt = tvbparse_init(pinfo->pool, tvb, data_offset, datalen, NULL, want_ignore);
1905 while( (element = tvbparse_get(tt, want)) != NULL ) {
1906 tvbparse_tree_add_elem(data_tree, element);
1908 break;
1909 case NTPCTRL_OP_ASYNCMSG:
1910 proto_tree_add_item(data_tree, hf_ntpctrl_trapmsg, tvb, data_offset, datalen, ENC_ASCII);
1911 break;
1912 case NTPCTRL_OP_CONFIGURE:
1913 case NTPCTRL_OP_SAVECONFIG:
1914 proto_tree_add_item(data_tree, hf_ntpctrl_configuration, tvb, data_offset, datalen, ENC_ASCII);
1915 auth_diss = true;
1916 break;
1917 case NTPCTRL_OP_READ_MRU:
1918 proto_tree_add_item(data_tree, hf_ntpctrl_mru, tvb, data_offset, datalen, ENC_ASCII);
1919 auth_diss = true;
1920 break;
1921 case NTPCTRL_OP_READ_ORDLIST_A:
1922 proto_tree_add_item(data_tree, hf_ntpctrl_ordlist, tvb, data_offset, datalen, ENC_ASCII);
1923 auth_diss = true;
1924 break;
1925 case NTPCTRL_OP_REQ_NONCE:
1926 proto_tree_add_item(data_tree, hf_ntpctrl_nonce, tvb, data_offset, datalen, ENC_ASCII);
1927 auth_diss = true;
1928 break;
1929 /* these opcodes doesn't carry any data: NTPCTRL_OP_SETTRAP, NTPCTRL_OP_UNSETTRAP, NTPCTRL_OP_UNSPEC */
1933 data_offset = 12+datalen;
1935 /* Check if there is authentication */
1936 if (((flags2 & NTPCTRL_R_MASK) == 0) || auth_diss == true)
1938 int padding_length;
1940 length_remaining = tvb_reported_length_remaining(tvb, data_offset);
1941 /* Check padding presence */
1942 padding_length = (data_offset & 7) ? 8 - (data_offset & 7) : 0;
1943 if (length_remaining > padding_length)
1945 if (padding_length)
1947 proto_tree_add_item(ntp_tree, hf_ntp_padding, tvb, data_offset, padding_length, ENC_NA);
1948 data_offset += padding_length;
1949 length_remaining -= padding_length;
1951 auth_tree = proto_tree_add_subtree(ntp_tree, tvb, data_offset, -1, ett_ntp_authenticator, NULL, "Authenticator");
1952 switch (length_remaining)
1954 case 20:
1955 ti = proto_tree_add_uint(auth_tree, hf_ntp_key_type, tvb, data_offset, 0, NTP_MD5_ALGO);
1956 proto_item_set_generated(ti);
1957 proto_tree_add_item(auth_tree, hf_ntp_key_index, tvb, data_offset, 4, ENC_BIG_ENDIAN);
1958 proto_tree_add_item(auth_tree, hf_ntp_key_signature, tvb, data_offset+4, 16, ENC_NA);
1959 break;
1960 case 24:
1961 ti = proto_tree_add_uint(auth_tree, hf_ntp_key_type, tvb, data_offset, 0, NTP_SHA_ALGO);
1962 proto_item_set_generated(ti);
1963 proto_tree_add_item(auth_tree, hf_ntp_key_index, tvb, data_offset, 4, ENC_BIG_ENDIAN);
1964 proto_tree_add_item(auth_tree, hf_ntp_key_signature, tvb, data_offset+4, 20, ENC_NA);
1965 break;
1972 * Initialize tvb-parser, which is used to dissect data part of NTP control
1973 * messages
1975 * Here some constants are defined, which describes character groups used for
1976 * various purposes. These groups are then used to configure the two global
1977 * variables "want_ignore" and "want" that we use for dissection
1979 static void
1980 init_parser(void)
1982 /* specify what counts as character */
1983 tvbparse_wanted_t *want_identifier_str = tvbparse_chars(-1, 1, 0,
1984 "abcdefghijklmnopqrstuvwxyz-_ABCDEFGHIJKLMNOPQRSTUVWXYZ.0123456789", NULL, NULL, NULL);
1985 /* this is the equal sign used in assignments */
1986 tvbparse_wanted_t *want_equalsign = tvbparse_char(-1, "=", NULL, NULL, NULL);
1987 /* possible characters allowed for values */
1988 tvbparse_wanted_t *want_value = tvbparse_set_oneof(0, NULL, NULL, NULL,
1989 tvbparse_quoted(-1, NULL, NULL, tvbparse_shrink_token_cb, '\"', '\\'),
1990 tvbparse_quoted(-1, NULL, NULL, tvbparse_shrink_token_cb, '\'', '\\'),
1991 tvbparse_chars(-1, 1, 0, "abcdefghijklmnopqrstuvwxyz-_ABCDEFGHIJKLMNOPQRSTUVWXYZ.0123456789 ", NULL, NULL, NULL),
1992 NULL);
1993 tvbparse_wanted_t *want_comma = tvbparse_until(-1, NULL, NULL, NULL,
1994 tvbparse_char(-1, ",", NULL, NULL, NULL), TP_UNTIL_SPEND);
1995 /* the following specifies an identifier */
1996 tvbparse_wanted_t *want_identifier = tvbparse_set_seq(-1, NULL, NULL, NULL,
1997 want_identifier_str,
1998 tvbparse_some(-1, 0, 1, NULL, NULL, NULL, want_comma),
1999 NULL);
2000 /* the following specifies an assignment of the form identifier=value */
2001 tvbparse_wanted_t *want_assignment = tvbparse_set_seq(-1, NULL, NULL, NULL,
2002 want_identifier_str,
2003 want_equalsign,
2004 tvbparse_some(-1, 0, 1, NULL, NULL, NULL, want_value),
2005 tvbparse_some(-1, 0, 1, NULL, NULL, NULL, want_comma),
2006 NULL);
2008 /* we ignore white space characters */
2009 want_ignore = tvbparse_chars(-1, 1, 0, " \t\r\n", NULL, NULL, NULL);
2010 /* data part of control messages consists of either identifiers or assignments */
2011 want = tvbparse_set_oneof(-1, NULL, NULL, NULL,
2012 want_assignment,
2013 want_identifier,
2014 NULL);
2017 static void
2018 dissect_ntp_priv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ntp_tree, ntp_conv_info_t *ntp_conv)
2020 uint32_t impl, reqcode;
2021 uint64_t flags, auth_seq;
2022 ntp_trans_info_t *ntp_trans;
2023 wmem_tree_key_t key[3];
2024 uint32_t seq;
2026 static int * const priv_flags[] = {
2027 &hf_ntppriv_flags_r,
2028 &hf_ntppriv_flags_more,
2029 &hf_ntp_flags_vn,
2030 &hf_ntp_flags_mode,
2031 NULL
2034 static int * const auth_flags[] = {
2035 &hf_ntppriv_auth,
2036 &hf_ntppriv_seq,
2037 NULL
2040 proto_tree_add_bitmask_ret_uint64(ntp_tree, tvb, 0, hf_ntp_flags, ett_ntp_flags, priv_flags, ENC_NA, &flags);
2041 proto_tree_add_bitmask_ret_uint64(ntp_tree, tvb, 1, hf_ntppriv_auth_seq, ett_ntppriv_auth_seq, auth_flags, ENC_NA, &auth_seq);
2042 proto_tree_add_item_ret_uint(ntp_tree, hf_ntppriv_impl, tvb, 2, 1, ENC_NA, &impl);
2043 proto_tree_add_item_ret_uint(ntp_tree, hf_ntppriv_reqcode, tvb, 3, 1, ENC_NA, &reqcode);
2045 col_append_fstr(pinfo->cinfo, COL_INFO, ", %s, %s",
2046 (flags & NTPPRIV_R_MASK) ? "Response" : "Request",
2047 val_to_str_ext_const(reqcode, &priv_rc_types_ext, "Unknown"));
2050 seq = 0xff000000 | impl;
2051 key[0].length = 1;
2052 key[0].key = &seq;
2053 key[1].length = 1;
2054 key[1].key = &pinfo->num;
2055 key[2].length = 0;
2056 key[2].key = NULL;
2058 if (flags & NTPPRIV_R_MASK) {
2059 /* response */
2060 ntp_trans = (ntp_trans_info_t *)wmem_tree_lookup32_array_le(ntp_conv->trans, key);
2061 if (ntp_trans && ntp_trans->seq == seq) {
2062 if (!PINFO_FD_VISITED(pinfo)) {
2063 if (ntp_trans->resp_frame == 0) {
2064 ntp_trans->resp_frame = pinfo->num;
2066 } else {
2067 proto_item *req_it;
2068 nstime_t delta;
2070 req_it = proto_tree_add_uint(ntp_tree, hf_ntp_request_in, tvb, 0, 0, ntp_trans->req_frame);
2071 proto_item_set_generated(req_it);
2072 nstime_delta(&delta, &pinfo->abs_ts, &ntp_trans->req_time);
2073 req_it = proto_tree_add_time(ntp_tree, hf_ntp_delta_time, tvb, 0, 0, &delta);
2074 proto_item_set_generated(req_it);
2077 } else {
2078 /* request */
2079 if (!PINFO_FD_VISITED(pinfo)) {
2080 ntp_trans = wmem_new(wmem_file_scope(), ntp_trans_info_t);
2081 ntp_trans->req_frame = pinfo->num;
2082 ntp_trans->resp_frame = 0;
2083 ntp_trans->req_time = pinfo->abs_ts;
2084 ntp_trans->seq = seq;
2085 wmem_tree_insert32_array(ntp_conv->trans, key, (void *)ntp_trans);
2086 } else {
2087 ntp_trans = (ntp_trans_info_t *)wmem_tree_lookup32_array_le(ntp_conv->trans, key);
2088 if (ntp_trans && ntp_trans->resp_frame != 0 && ntp_trans->seq == seq) {
2089 proto_item *resp_it;
2091 resp_it = proto_tree_add_uint(ntp_tree, hf_ntp_response_in, tvb, 0, 0, ntp_trans->resp_frame);
2092 proto_item_set_generated(resp_it);
2097 if (impl == XNTPD) {
2099 uint64_t numitems;
2100 uint64_t itemsize;
2101 uint16_t offset;
2102 unsigned i;
2104 uint32_t v6_flag = 0;
2106 proto_item *mode7_item;
2107 proto_tree *mode7_item_tree = NULL;
2109 proto_tree_add_bits_item(ntp_tree, hf_ntppriv_errcode, tvb, 32, 4, ENC_BIG_ENDIAN);
2110 proto_tree_add_bits_ret_val(ntp_tree, hf_ntppriv_numitems, tvb, 36, 12, &numitems, ENC_BIG_ENDIAN);
2111 proto_tree_add_bits_item(ntp_tree, hf_ntppriv_mbz, tvb, 48, 4, ENC_BIG_ENDIAN);
2112 proto_tree_add_bits_ret_val(ntp_tree, hf_ntppriv_itemsize, tvb, 52, 12, &itemsize, ENC_BIG_ENDIAN);
2114 for (i = 0; i < (uint16_t)numitems; i++) {
2116 offset = 8 + (uint16_t)itemsize * i;
2118 if ((reqcode != PRIV_RC_MON_GETLIST) && (reqcode != PRIV_RC_MON_GETLIST_1)) {
2119 mode7_item = proto_tree_add_string_format(ntp_tree, hf_ntppriv_mode7_item, tvb, offset,(int)itemsize,
2120 "", "%s Item", val_to_str_ext_const(reqcode, &priv_rc_types_ext, "Unknown") );
2121 mode7_item_tree = proto_item_add_subtree(mode7_item, ett_mode7_item);
2124 switch (reqcode) {
2125 case PRIV_RC_MON_GETLIST:
2126 case PRIV_RC_MON_GETLIST_1:
2128 mode7_item = proto_tree_add_string_format(ntp_tree, hf_ntppriv_mode7_item, tvb, offset,
2129 (int)itemsize, "Monlist Item", "Monlist item: address: %s:%u",
2130 tvb_ip_to_str(pinfo->pool, tvb, offset + 16), tvb_get_ntohs(tvb, offset + ((reqcode == PRIV_RC_MON_GETLIST_1) ? 28 : 20)));
2131 mode7_item_tree = proto_item_add_subtree(mode7_item, ett_mode7_item);
2133 proto_tree_add_item(mode7_item_tree, hf_ntppriv_avgint, tvb, offset, 4, ENC_BIG_ENDIAN);
2134 offset += 4;
2135 proto_tree_add_item(mode7_item_tree, hf_ntppriv_lsint, tvb, offset, 4, ENC_BIG_ENDIAN);
2136 offset += 4;
2137 proto_tree_add_item(mode7_item_tree, hf_ntppriv_restr, tvb, offset, 4, ENC_BIG_ENDIAN);
2138 offset += 4;
2139 proto_tree_add_item(mode7_item_tree, hf_ntppriv_count, tvb, offset, 4, ENC_BIG_ENDIAN);
2140 offset += 4;
2141 proto_tree_add_item(mode7_item_tree, hf_ntppriv_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2142 offset += 4;
2143 if (reqcode == PRIV_RC_MON_GETLIST_1) {
2144 proto_tree_add_item(mode7_item_tree, hf_ntppriv_daddr, tvb, offset, 4, ENC_BIG_ENDIAN);
2145 offset += 4;
2146 proto_tree_add_item(mode7_item_tree, hf_ntppriv_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
2147 offset += 4;
2149 proto_tree_add_item(mode7_item_tree, hf_ntppriv_port, tvb, offset, 2, ENC_BIG_ENDIAN);
2150 offset += 2;
2151 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
2152 offset += 1;
2153 proto_tree_add_item(mode7_item_tree, hf_ntppriv_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2154 offset += 1;
2155 proto_tree_add_item_ret_uint(mode7_item_tree, hf_ntppriv_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN, &v6_flag);
2156 offset += 4;
2157 proto_tree_add_item(mode7_item_tree, hf_ntppriv_unused, tvb, offset, 4, ENC_BIG_ENDIAN);
2158 offset += 4;
2159 if (v6_flag != 0) {
2160 proto_tree_add_item(mode7_item_tree, hf_ntppriv_addr6, tvb, offset, 16, ENC_NA);
2161 offset += 16;
2162 if (reqcode == PRIV_RC_MON_GETLIST_1)
2163 proto_tree_add_item(mode7_item_tree, hf_ntppriv_daddr6, tvb, offset, 16, ENC_NA);
2165 break;
2167 case PRIV_RC_PEER_LIST:
2169 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2170 offset += 4;
2171 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_port, tvb, offset, 2, ENC_BIG_ENDIAN);
2172 offset += 2;
2173 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hmode, tvb, offset, 1, ENC_BIG_ENDIAN);
2174 offset += 1;
2175 proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_peer_flags, ett_ntppriv_peer_list_flags, ntppriv_peer_list_flags, ENC_BIG_ENDIAN);
2176 offset += 1;
2177 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2178 offset += 4;
2179 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2180 offset += 4;
2181 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
2182 break;
2184 case PRIV_RC_PEER_LIST_SUM:
2186 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dstaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
2187 offset += 4;
2188 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
2189 offset += 4;
2190 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcport, tvb, offset, 2, ENC_BIG_ENDIAN);
2191 offset += 2;
2192 proto_tree_add_item(mode7_item_tree, hf_ntp_stratum, tvb, offset, 1, ENC_BIG_ENDIAN);
2193 offset += 1;
2194 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hpoll, tvb, offset, 1, ENC_BIG_ENDIAN);
2195 offset += 1;
2196 proto_tree_add_item(mode7_item_tree, hf_ntp_ppoll, tvb, offset, 1, ENC_BIG_ENDIAN);
2197 offset += 1;
2198 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_reach, tvb, offset, 1, ENC_BIG_ENDIAN);
2199 offset += 1;
2200 proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_peer_flags, ett_ntppriv_peer_list_flags, ntppriv_peer_list_flags, ENC_BIG_ENDIAN);
2201 offset += 1;
2202 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hmode, tvb, offset, 1, ENC_BIG_ENDIAN);
2203 offset += 1;
2204 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_delay, tvb, offset, 4, ENC_BIG_ENDIAN);
2205 offset += 4;
2206 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_offset, tvb, offset, 8, ENC_BIG_ENDIAN);
2207 offset += 8;
2208 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dispersion, tvb, offset, 4, ENC_BIG_ENDIAN);
2209 offset += 4;
2210 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2211 offset += 4;
2212 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2213 offset += 4;
2214 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dstaddr6, tvb, offset, 16, ENC_NA);
2215 offset += 16;
2216 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcaddr6, tvb, offset, 16, ENC_NA);
2217 break;
2219 case PRIV_RC_PEER_INFO:
2221 if (flags & NTPPRIV_R_MASK) {
2222 /* response */
2223 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dstaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
2224 offset += 4;
2225 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
2226 offset += 4;
2227 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcport, tvb, offset, 2, ENC_BIG_ENDIAN);
2228 offset += 2;
2229 proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_peer_flags, ett_ntppriv_peer_list_flags, ntppriv_peer_list_flags, ENC_BIG_ENDIAN);
2230 offset += 1;
2231 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_leap, tvb, offset, 1, ENC_BIG_ENDIAN);
2232 offset += 1;
2233 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hmode, tvb, offset, 1, ENC_BIG_ENDIAN);
2234 offset += 1;
2235 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_pmode, tvb, offset, 1, ENC_BIG_ENDIAN);
2236 offset += 1;
2237 proto_tree_add_item(mode7_item_tree, hf_ntp_stratum, tvb, offset, 1, ENC_BIG_ENDIAN);
2238 offset += 1;
2239 proto_tree_add_item(mode7_item_tree, hf_ntp_ppoll, tvb, offset, 1, ENC_BIG_ENDIAN);
2240 offset += 1;
2241 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hpoll, tvb, offset, 1, ENC_BIG_ENDIAN);
2242 offset += 1;
2243 proto_tree_add_item(mode7_item_tree, hf_ntp_precision, tvb, offset, 1, ENC_BIG_ENDIAN);
2244 offset += 1;
2245 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2246 offset += 1;
2247 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 1, ENC_NA);
2248 offset += 1;
2249 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_reach, tvb, offset, 1, ENC_BIG_ENDIAN);
2250 offset += 1;
2251 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unreach, tvb, offset, 1, ENC_BIG_ENDIAN);
2252 offset += 1;
2253 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_flash, tvb, offset, 1, ENC_BIG_ENDIAN);
2254 offset += 1;
2255 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2256 offset += 1;
2257 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_flash2, tvb, offset, 2, ENC_BIG_ENDIAN);
2258 offset += 2;
2259 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_associd, tvb, offset, 2, ENC_BIG_ENDIAN);
2260 offset += 2;
2261 proto_tree_add_item(mode7_item_tree, hf_ntp_keyid, tvb, offset, 4, ENC_NA);
2262 offset += 4;
2263 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_pkeyid, tvb, offset, 4, ENC_BIG_ENDIAN);
2264 offset += 4;
2265 proto_tree_add_item(mode7_item_tree, hf_ntp_refid, tvb, offset, 4, ENC_NA);
2266 offset += 4;
2267 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timer, tvb, offset, 4, ENC_BIG_ENDIAN);
2268 offset += 4;
2269 proto_tree_add_item(mode7_item_tree, hf_ntp_rootdelay, tvb, offset, 4, ENC_BIG_ENDIAN);
2270 offset += 4;
2271 proto_tree_add_item(mode7_item_tree, hf_ntp_rootdispersion, tvb, offset, 4, ENC_BIG_ENDIAN);
2272 offset += 4;
2273 proto_tree_add_item(mode7_item_tree, hf_ntp_reftime, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
2274 offset += 8;
2275 proto_tree_add_item(mode7_item_tree, hf_ntp_org, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
2276 offset += 8;
2277 proto_tree_add_item(mode7_item_tree, hf_ntp_rec, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
2278 offset += 8;
2279 proto_tree_add_item(mode7_item_tree, hf_ntp_xmt, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
2280 offset += 8;
2281 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_filtdelay, tvb, offset, 4, ENC_BIG_ENDIAN);
2282 offset += 4;
2283 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_filtoffset, tvb, offset, 8, ENC_BIG_ENDIAN);
2284 offset += 8;
2285 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_order, tvb, offset, 1, ENC_BIG_ENDIAN);
2286 offset += 1;
2287 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_delay, tvb, offset, 4, ENC_BIG_ENDIAN);
2288 offset += 4;
2289 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dispersion, tvb, offset, 4, ENC_BIG_ENDIAN);
2290 offset += 4;
2291 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_offset, tvb, offset, 8, ENC_BIG_ENDIAN);
2292 offset += 8;
2293 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_selectdis, tvb, offset, 4, ENC_BIG_ENDIAN);
2294 offset += 4;
2295 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2296 offset += 4;
2297 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2298 offset += 4;
2299 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2300 offset += 4;
2301 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2302 offset += 4;
2303 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2304 offset += 4;
2305 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2306 offset += 4;
2307 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2308 offset += 4;
2309 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_estbdelay, tvb, offset, 4, ENC_BIG_ENDIAN);
2310 offset += 4;
2311 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2312 offset += 4;
2313 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2314 offset += 4;
2315 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dstaddr6, tvb, offset, 16, ENC_NA);
2316 offset += 16;
2317 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcaddr6, tvb, offset, 16, ENC_NA);
2318 } else {
2319 /* request */
2320 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2321 offset += 4;
2322 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_port, tvb, offset, 2, ENC_BIG_ENDIAN);
2323 offset += 2;
2324 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hmode, tvb, offset, 1, ENC_BIG_ENDIAN);
2325 offset += 1;
2326 proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_peer_flags, ett_ntppriv_peer_list_flags, ntppriv_peer_list_flags, ENC_BIG_ENDIAN);
2327 offset += 1;
2328 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2329 offset += 4;
2330 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2331 offset += 4;
2332 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
2334 break;
2336 case PRIV_RC_PEER_STATS:
2338 if (flags & NTPPRIV_R_MASK) {
2339 /* response */
2340 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dstaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
2341 offset += 4;
2342 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
2343 offset += 4;
2344 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcport, tvb, offset, 2, ENC_BIG_ENDIAN);
2345 offset += 2;
2346 proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_peer_flags, ett_ntppriv_peer_list_flags, ntppriv_peer_list_flags, ENC_BIG_ENDIAN);
2347 offset += 1;
2348 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
2349 offset += 4;
2350 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereceived, tvb, offset, 4, ENC_BIG_ENDIAN);
2351 offset += 4;
2352 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timetosend, tvb, offset, 4, ENC_BIG_ENDIAN);
2353 offset += 4;
2354 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereachable, tvb, offset, 4, ENC_BIG_ENDIAN);
2355 offset += 4;
2356 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_sent, tvb, offset, 4, ENC_BIG_ENDIAN);
2357 offset += 4;
2358 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2359 offset += 4;
2360 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_processed, tvb, offset, 4, ENC_BIG_ENDIAN);
2361 offset += 4;
2362 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2363 offset += 4;
2364 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badauth, tvb, offset, 4, ENC_BIG_ENDIAN);
2365 offset += 4;
2366 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_bogusorg, tvb, offset, 4, ENC_BIG_ENDIAN);
2367 offset += 4;
2368 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_oldpkt, tvb, offset, 4, ENC_BIG_ENDIAN);
2369 offset += 4;
2370 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2371 offset += 4;
2372 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2373 offset += 4;
2374 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_seldisp, tvb, offset, 4, ENC_BIG_ENDIAN);
2375 offset += 4;
2376 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_selbroken, tvb, offset, 4, ENC_BIG_ENDIAN);
2377 offset += 4;
2378 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2379 offset += 4;
2380 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_candidate, tvb, offset, 1, ENC_BIG_ENDIAN);
2381 offset += 1;
2382 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 1, ENC_NA);
2383 offset += 1;
2384 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 1, ENC_NA);
2385 offset += 1;
2386 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 1, ENC_NA);
2387 offset += 1;
2388 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2389 offset += 4;
2390 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2391 offset += 4;
2392 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dstaddr6, tvb, offset, 16, ENC_NA);
2393 offset += 16;
2394 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_srcaddr6, tvb, offset, 16, ENC_NA);
2395 } else {
2396 /* request */
2397 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2398 offset += 4;
2399 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_port, tvb, offset, 2, ENC_BIG_ENDIAN);
2400 offset += 2;
2401 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hmode, tvb, offset, 1, ENC_BIG_ENDIAN);
2402 offset += 1;
2403 proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_peer_flags, ett_ntppriv_peer_list_flags, ntppriv_peer_list_flags, ENC_BIG_ENDIAN);
2404 offset += 1;
2405 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2406 offset += 4;
2407 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2408 offset += 4;
2409 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
2411 break;
2413 case PRIV_RC_SYS_INFO:
2414 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2415 offset += 4;
2416 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_pmode, tvb, offset, 1, ENC_BIG_ENDIAN);
2417 offset += 1;
2418 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_leap, tvb, offset, 1, ENC_BIG_ENDIAN);
2419 offset += 1;
2420 proto_tree_add_item(mode7_item_tree, hf_ntp_stratum, tvb, offset, 1, ENC_BIG_ENDIAN);
2421 offset += 1;
2422 proto_tree_add_item(mode7_item_tree, hf_ntp_precision, tvb, offset, 1, ENC_BIG_ENDIAN);
2423 offset += 1;
2424 proto_tree_add_item(mode7_item_tree, hf_ntp_rootdelay, tvb, offset, 4, ENC_BIG_ENDIAN);
2425 offset += 4;
2426 proto_tree_add_item(mode7_item_tree, hf_ntp_rootdispersion, tvb, offset, 4, ENC_BIG_ENDIAN);
2427 offset += 4;
2428 proto_tree_add_item(mode7_item_tree, hf_ntp_refid, tvb, offset, 4, ENC_NA);
2429 offset += 4;
2430 proto_tree_add_item(mode7_item_tree, hf_ntp_reftime, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
2431 offset += 8;
2432 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_poll32, tvb, offset, 4, ENC_BIG_ENDIAN);
2433 offset += 4;
2434 proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_sys_flags8, ett_ntppriv_sys_flag_flags, ntppriv_sys_flag_flags, ENC_BIG_ENDIAN);
2435 offset += 1;
2436 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 3, ENC_NA);
2437 offset += 3;
2438 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_bdelay, tvb, offset, 4, ENC_BIG_ENDIAN);
2439 offset += 4;
2440 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_freq, tvb, offset, 4, ENC_BIG_ENDIAN);
2441 offset += 4;
2442 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_authdelay, tvb, offset, 8, ENC_BIG_ENDIAN);
2443 offset += 8;
2444 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_stability, tvb, offset, 4, ENC_BIG_ENDIAN);
2445 offset += 4;
2446 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2447 offset += 4;
2448 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2449 offset += 4;
2450 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
2451 break;
2453 case PRIV_RC_SYS_STATS:
2454 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timeup, tvb, offset, 4, ENC_BIG_ENDIAN);
2455 offset += 4;
2456 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
2457 offset += 4;
2458 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_denied, tvb, offset, 4, ENC_BIG_ENDIAN);
2459 offset += 4;
2460 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_oldversion, tvb, offset, 4, ENC_BIG_ENDIAN);
2461 offset += 4;
2462 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_newversion, tvb, offset, 4, ENC_BIG_ENDIAN);
2463 offset += 4;
2464 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badversion, tvb, offset, 4, ENC_BIG_ENDIAN);
2465 offset += 4;
2466 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badlength, tvb, offset, 4, ENC_BIG_ENDIAN);
2467 offset += 4;
2468 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_processed, tvb, offset, 4, ENC_BIG_ENDIAN);
2469 offset += 4;
2470 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badauth, tvb, offset, 4, ENC_BIG_ENDIAN);
2471 offset += 4;
2472 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereceived, tvb, offset, 4, ENC_BIG_ENDIAN);
2473 offset += 4;
2474 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_limitrejected, tvb, offset, 4, ENC_BIG_ENDIAN);
2475 offset += 4;
2476 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_lamport, tvb, offset, 4, ENC_BIG_ENDIAN);
2477 offset += 4;
2478 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_tsrounding, tvb, offset, 4, ENC_BIG_ENDIAN);
2479 break;
2481 case PRIV_RC_IO_STATS:
2482 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
2483 offset += 4;
2484 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_totalrecvbufs, tvb, offset, 2, ENC_BIG_ENDIAN);
2485 offset += 2;
2486 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_freerecvbufs, tvb, offset, 2, ENC_BIG_ENDIAN);
2487 offset += 2;
2488 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fullrecvbufs, tvb, offset, 2, ENC_BIG_ENDIAN);
2489 offset += 2;
2490 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_lowwater, tvb, offset, 2, ENC_BIG_ENDIAN);
2491 offset += 2;
2492 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_dropped, tvb, offset, 4, ENC_BIG_ENDIAN);
2493 offset += 4;
2494 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ignored, tvb, offset, 4, ENC_BIG_ENDIAN);
2495 offset += 4;
2496 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_received, tvb, offset, 4, ENC_BIG_ENDIAN);
2497 offset += 4;
2498 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_sent, tvb, offset, 4, ENC_BIG_ENDIAN);
2499 offset += 4;
2500 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_notsent, tvb, offset, 4, ENC_BIG_ENDIAN);
2501 offset += 4;
2502 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_interrupts, tvb, offset, 4, ENC_BIG_ENDIAN);
2503 offset += 4;
2504 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_int_received, tvb, offset, 4, ENC_BIG_ENDIAN);
2505 break;
2507 case PRIV_RC_MEM_STATS:
2508 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
2509 offset += 4;
2510 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_totalmem, tvb, offset, 2, ENC_BIG_ENDIAN);
2511 offset += 2;
2512 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_freemem, tvb, offset, 2, ENC_BIG_ENDIAN);
2513 offset += 2;
2514 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_findpeer_calls, tvb, offset, 4, ENC_BIG_ENDIAN);
2515 offset += 4;
2516 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_allocations, tvb, offset, 4, ENC_BIG_ENDIAN);
2517 offset += 4;
2518 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_demobilizations, tvb, offset, 4, ENC_BIG_ENDIAN);
2519 offset += 4;
2520 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hashcount, tvb, offset, (int)itemsize - 20, ENC_NA);
2521 break;
2523 case PRIV_RC_LOOP_INFO:
2524 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_last_offset, tvb, offset, 8, ENC_BIG_ENDIAN);
2525 offset += 8;
2526 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_drift_comp, tvb, offset, 8, ENC_BIG_ENDIAN);
2527 offset += 8;
2528 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_compliance, tvb, offset, 4, ENC_BIG_ENDIAN);
2529 offset += 4;
2530 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_watchdog_timer, tvb, offset, 4, ENC_BIG_ENDIAN);
2531 break;
2533 case PRIV_RC_TIMER_STATS:
2534 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
2535 offset += 4;
2536 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_alarms, tvb, offset, 4, ENC_BIG_ENDIAN);
2537 offset += 4;
2538 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_overflows, tvb, offset, 4, ENC_BIG_ENDIAN);
2539 offset += 4;
2540 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_xmtcalls, tvb, offset, 4, ENC_BIG_ENDIAN);
2541 break;
2543 case PRIV_RC_CONFIG:
2545 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2546 offset += 4;
2547 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_hmode, tvb, offset, 1, ENC_BIG_ENDIAN);
2548 offset += 1;
2549 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_version, tvb, offset, 1, ENC_BIG_ENDIAN);
2550 offset += 1;
2551 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_minpoll, tvb, offset, 1, ENC_BIG_ENDIAN);
2552 offset += 1;
2553 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_maxpoll, tvb, offset, 1, ENC_BIG_ENDIAN);
2554 offset += 1;
2555 proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_config_flags, ett_ntppriv_config_flags, ntppriv_config_flags, ENC_BIG_ENDIAN);
2556 offset += 1;
2557 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
2558 offset += 1;
2559 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 2, ENC_NA);
2560 offset += 2;
2561 proto_tree_add_item(mode7_item_tree, hf_ntp_keyid, tvb, offset, 4, ENC_NA);
2562 offset += 4;
2563 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_key_file, tvb, offset, 128, ENC_ASCII);
2564 offset += 128;
2565 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2566 offset += 4;
2567 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2568 offset += 4;
2569 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
2570 break;
2572 case PRIV_RC_UNCONFIG:
2574 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2575 offset += 4;
2576 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2577 offset += 4;
2578 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
2579 break;
2581 case PRIV_RC_SET_SYS_FLAG:
2582 case PRIV_RC_CLR_SYS_FLAG:
2584 proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_sys_flags, ett_ntppriv_sys_flag_flags, ntppriv_sys_flag_flags, ENC_BIG_ENDIAN);
2585 break;
2587 case PRIV_RC_GET_RESTRICT:
2588 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2589 offset += 4;
2590 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mask, tvb, offset, 4, ENC_BIG_ENDIAN);
2591 offset += 4;
2592 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_count, tvb, offset, 4, ENC_BIG_ENDIAN);
2593 offset += 4;
2594 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_rflags, tvb, offset, 2, ENC_BIG_ENDIAN);
2595 offset += 2;
2596 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mflags, tvb, offset, 2, ENC_BIG_ENDIAN);
2597 offset += 2;
2598 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2599 offset += 4;
2600 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2601 offset += 4;
2602 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
2603 offset += 16;
2604 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mask6, tvb, offset, 16, ENC_NA);
2605 break;
2607 case PRIV_RC_RESADDFLAGS:
2608 case PRIV_RC_RESSUBFLAGS:
2609 case PRIV_RC_UNRESTRICT:
2610 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2611 offset += 4;
2612 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mask, tvb, offset, 4, ENC_BIG_ENDIAN);
2613 offset += 4;
2614 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ippeerlimit, tvb, offset, 2, ENC_BIG_ENDIAN);
2615 offset += 2;
2616 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_restrict_flags, tvb, offset, 2, ENC_BIG_ENDIAN);
2617 offset += 2;
2618 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mflags, tvb, offset, 2, ENC_BIG_ENDIAN);
2619 offset += 2;
2620 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2621 offset += 4;
2622 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
2623 offset += 16;
2624 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mask6, tvb, offset, 16, ENC_NA);
2625 break;
2627 case PRIV_RC_RESET_STATS:
2629 proto_tree_add_bitmask(mode7_item_tree, tvb, offset, hf_ntppriv_mode7_reset_stats_flags, ett_ntppriv_reset_stats_flags, ntppriv_reset_stats_flags, ENC_BIG_ENDIAN);
2630 break;
2632 case PRIV_RC_RESET_PEER:
2634 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2635 offset += 4;
2636 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2637 offset += 4;
2638 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
2639 break;
2641 case PRIV_RC_TRUSTKEY:
2642 case PRIV_RC_UNTRUSTKEY:
2644 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_key, tvb, offset, 8, ENC_LITTLE_ENDIAN);
2645 break;
2647 case PRIV_RC_AUTHINFO:
2649 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
2650 offset += 4;
2651 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_numkeys, tvb, offset, 4, ENC_BIG_ENDIAN);
2652 offset += 4;
2653 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_numfreekeys, tvb, offset, 4, ENC_BIG_ENDIAN);
2654 offset += 4;
2655 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_keylookups, tvb, offset, 4, ENC_BIG_ENDIAN);
2656 offset += 4;
2657 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_keynotfound, tvb, offset, 4, ENC_BIG_ENDIAN);
2658 offset += 4;
2659 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_encryptions, tvb, offset, 4, ENC_BIG_ENDIAN);
2660 offset += 4;
2661 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_decryptions, tvb, offset, 4, ENC_BIG_ENDIAN);
2662 offset += 4;
2663 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_expired, tvb, offset, 4, ENC_BIG_ENDIAN);
2664 offset += 4;
2665 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_keyuncached, tvb, offset, 4, ENC_BIG_ENDIAN);
2666 break;
2668 case PRIV_RC_TRAPS:
2670 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_local_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2671 offset += 4;
2672 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_trap_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2673 offset += 4;
2674 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_trap_port, tvb, offset, 2, ENC_BIG_ENDIAN);
2675 offset += 2;
2676 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_sequence, tvb, offset, 2, ENC_BIG_ENDIAN);
2677 offset += 2;
2678 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_settime, tvb, offset, 4, ENC_BIG_ENDIAN);
2679 offset += 4;
2680 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_origtime, tvb, offset, 4, ENC_BIG_ENDIAN);
2681 offset += 4;
2682 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_resets, tvb, offset, 4, ENC_BIG_ENDIAN);
2683 offset += 4;
2684 proto_tree_add_item(mode7_item_tree, hf_ntppriv_traps_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
2685 offset += 4;
2686 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2687 offset += 4;
2688 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_local_addr6, tvb, offset, 16, ENC_NA);
2689 offset += 16;
2690 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_trap_addr6, tvb, offset, 16, ENC_NA);
2691 break;
2693 case PRIV_RC_ADD_TRAP:
2694 case PRIV_RC_CLR_TRAP:
2696 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_local_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2697 offset += 4;
2698 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_trap_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2699 offset += 4;
2700 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_trap_port, tvb, offset, 2, ENC_BIG_ENDIAN);
2701 offset += 2;
2702 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 2, ENC_NA);
2703 offset += 2;
2704 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2705 offset += 4;
2706 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_local_addr6, tvb, offset, 16, ENC_NA);
2707 offset += 16;
2708 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_trap_addr6, tvb, offset, 16, ENC_NA);
2709 break;
2711 case PRIV_RC_REQUEST_KEY:
2712 case PRIV_RC_CONTROL_KEY:
2714 proto_tree_add_item(mode7_item_tree, hf_ntp_keyid, tvb, offset, 4, ENC_NA);
2715 break;
2717 case PRIV_RC_CTL_STATS:
2719 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timereset, tvb, offset, 4, ENC_BIG_ENDIAN);
2720 offset += 4;
2721 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_req, tvb, offset, 4, ENC_BIG_ENDIAN);
2722 offset += 4;
2723 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badpkts, tvb, offset, 4, ENC_BIG_ENDIAN);
2724 offset += 4;
2725 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_responses, tvb, offset, 4, ENC_BIG_ENDIAN);
2726 offset += 4;
2727 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_frags, tvb, offset, 4, ENC_BIG_ENDIAN);
2728 offset += 4;
2729 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_errors, tvb, offset, 4, ENC_BIG_ENDIAN);
2730 offset += 4;
2731 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_tooshort, tvb, offset, 4, ENC_BIG_ENDIAN);
2732 offset += 4;
2733 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_inputresp, tvb, offset, 4, ENC_BIG_ENDIAN);
2734 offset += 4;
2735 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_inputfrag, tvb, offset, 4, ENC_BIG_ENDIAN);
2736 offset += 4;
2737 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_inputerr, tvb, offset, 4, ENC_BIG_ENDIAN);
2738 offset += 4;
2739 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badoffset, tvb, offset, 4, ENC_BIG_ENDIAN);
2740 offset += 4;
2741 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badversion, tvb, offset, 4, ENC_BIG_ENDIAN);
2742 offset += 4;
2743 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_datatooshort, tvb, offset, 4, ENC_BIG_ENDIAN);
2744 offset += 4;
2745 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badop, tvb, offset, 4, ENC_BIG_ENDIAN);
2746 offset += 4;
2747 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_asyncmsgs, tvb, offset, 4, ENC_BIG_ENDIAN);
2748 break;
2750 case PRIV_RC_GET_CLOCKINFO:
2752 if (flags & NTPPRIV_R_MASK) {
2753 /* response */
2754 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2755 offset += 4;
2756 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2757 offset += 1;
2758 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_clock_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
2759 offset += 1;
2760 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_lastevent, tvb, offset, 1, ENC_BIG_ENDIAN);
2761 offset += 1;
2762 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_currentstatus, tvb, offset, 1, ENC_BIG_ENDIAN);
2763 offset += 1;
2764 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_polls, tvb, offset, 4, ENC_BIG_ENDIAN);
2765 offset += 4;
2766 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_noresponse, tvb, offset, 4, ENC_BIG_ENDIAN);
2767 offset += 4;
2768 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_badformat, tvb, offset, 4, ENC_BIG_ENDIAN);
2769 offset += 4;
2770 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_baddata, tvb, offset, 4, ENC_BIG_ENDIAN);
2771 offset += 4;
2772 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_timestarted, tvb, offset, 4, ENC_BIG_ENDIAN);
2773 offset += 4;
2774 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fudgetime1, tvb, offset, 8, ENC_BIG_ENDIAN);
2775 offset += 8;
2776 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fudgetime2, tvb, offset, 8, ENC_BIG_ENDIAN);
2777 offset += 8;
2778 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fudgeval1, tvb, offset, 4, ENC_BIG_ENDIAN);
2779 offset += 4;
2780 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fudgeval2, tvb, offset, 4, ENC_BIG_ENDIAN);
2781 } else {
2782 /* request */
2783 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2785 break;
2787 case PRIV_RC_SET_CLKFUDGE:
2788 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2789 offset += 4;
2790 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_which, tvb, offset, 4, ENC_BIG_ENDIAN);
2791 offset += 4;
2792 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fudgetime, tvb, offset, 8, ENC_BIG_ENDIAN);
2793 offset += 8;
2794 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_fudgeval_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
2795 break;
2797 case PRIV_RC_GET_KERNEL:
2799 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_kernel_offset, tvb, offset, 4, ENC_BIG_ENDIAN);
2800 offset += 4;
2801 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_freq, tvb, offset, 4, ENC_BIG_ENDIAN);
2802 offset += 4;
2803 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_maxerror, tvb, offset, 4, ENC_BIG_ENDIAN);
2804 offset += 4;
2805 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_esterror, tvb, offset, 4, ENC_BIG_ENDIAN);
2806 offset += 4;
2807 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_status, tvb, offset, 2, ENC_BIG_ENDIAN);
2808 offset += 2;
2809 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_shift, tvb, offset, 2, ENC_BIG_ENDIAN);
2810 offset += 2;
2811 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_constant, tvb, offset, 4, ENC_BIG_ENDIAN);
2812 offset += 4;
2813 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_precision, tvb, offset, 4, ENC_BIG_ENDIAN);
2814 offset += 4;
2815 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_tolerance, tvb, offset, 4, ENC_BIG_ENDIAN);
2816 offset += 4;
2817 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ppsfreq, tvb, offset, 4, ENC_BIG_ENDIAN);
2818 offset += 4;
2819 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_jitter, tvb, offset, 4, ENC_BIG_ENDIAN);
2820 offset += 4;
2821 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_stabil, tvb, offset, 4, ENC_BIG_ENDIAN);
2822 offset += 4;
2823 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_jitcnt, tvb, offset, 4, ENC_BIG_ENDIAN);
2824 offset += 4;
2825 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_calcnt, tvb, offset, 4, ENC_BIG_ENDIAN);
2826 offset += 4;
2827 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_errcnt, tvb, offset, 4, ENC_BIG_ENDIAN);
2828 offset += 4;
2829 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_stbcnt, tvb, offset, 4, ENC_BIG_ENDIAN);
2830 break;
2832 case PRIV_RC_GET_CLKBUGINFO:
2833 if (flags & NTPPRIV_R_MASK) {
2834 /* response */
2835 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2836 offset += 4;
2837 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_nvalues, tvb, offset, 1, ENC_BIG_ENDIAN);
2838 offset += 1;
2839 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ntimes, tvb, offset, 1, ENC_BIG_ENDIAN);
2840 offset += 1;
2841 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_svalues, tvb, offset, 2, ENC_BIG_ENDIAN);
2842 offset += 2;
2843 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_stimes, tvb, offset, 4, ENC_BIG_ENDIAN);
2844 offset += 4;
2845 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_values, tvb, offset, 64, ENC_NA);
2846 offset += 64;
2847 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_times, tvb, offset, 256, ENC_NA);
2848 } else {
2849 /* request */
2850 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2852 break;
2854 case PRIV_RC_IF_STATS:
2855 case PRIV_RC_IF_RELOAD:
2856 v6_flag = tvb_get_ntohl(tvb, offset + 48);
2857 if (v6_flag == 0) {
2858 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
2859 offset += 16;
2860 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_bcast, tvb, offset, 4, ENC_BIG_ENDIAN);
2861 offset += 16;
2862 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mask, tvb, offset, 4, ENC_BIG_ENDIAN);
2863 offset += 16;
2864 } else {
2865 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_addr6, tvb, offset, 16, ENC_NA);
2866 offset += 16;
2867 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_bcast6, tvb, offset, 16, ENC_NA);
2868 offset += 16;
2869 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_mask6, tvb, offset, 16, ENC_NA);
2870 offset += 16;
2872 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_v6_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
2873 offset += 4;
2874 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_int_name, tvb, offset, 32, ENC_ASCII);
2875 offset += 32;
2876 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_int_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
2877 offset += 4;
2878 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_last_ttl, tvb, offset, 4, ENC_BIG_ENDIAN);
2879 offset += 4;
2880 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_num_mcast, tvb, offset, 4, ENC_BIG_ENDIAN);
2881 offset += 4;
2882 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_received, tvb, offset, 4, ENC_BIG_ENDIAN);
2883 offset += 4;
2884 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_sent, tvb, offset, 4, ENC_BIG_ENDIAN);
2885 offset += 4;
2886 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_notsent, tvb, offset, 4, ENC_BIG_ENDIAN);
2887 offset += 4;
2888 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_uptime, tvb, offset, 4, ENC_BIG_ENDIAN);
2889 offset += 4;
2890 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_scopeid, tvb, offset, 4, ENC_BIG_ENDIAN);
2891 offset += 4;
2892 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ifindex, tvb, offset, 4, ENC_BIG_ENDIAN);
2893 offset += 4;
2894 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ifnum, tvb, offset, 4, ENC_BIG_ENDIAN);
2895 offset += 4;
2896 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_peercnt, tvb, offset, 4, ENC_BIG_ENDIAN);
2897 offset += 4;
2898 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_family, tvb, offset, 2, ENC_BIG_ENDIAN);
2899 offset += 2;
2900 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_ignore_pkt, tvb, offset, 1, ENC_BIG_ENDIAN);
2901 offset += 1;
2902 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_action, tvb, offset, 1, ENC_BIG_ENDIAN);
2903 offset += 1;
2904 proto_tree_add_item(mode7_item_tree, hf_ntppriv_mode7_unused, tvb, offset, 4, ENC_NA);
2905 break;
2910 if ((flags & NTPPRIV_R_MASK) == 0 && (auth_seq & NTPPRIV_AUTH_MASK)) {
2911 /* request message with authentication bit */
2912 int len;
2913 proto_tree_add_item(ntp_tree, hf_ntppriv_tstamp, tvb, 184, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
2914 proto_tree_add_item(ntp_tree, hf_ntp_keyid, tvb, 192, 4, ENC_NA);
2915 len = tvb_reported_length_remaining(tvb, 196);
2916 if (len)
2917 proto_tree_add_item(ntp_tree, hf_ntp_mac, tvb, 196, len, ENC_NA);
2921 /* dissect_ntp - dissects NTP packet data
2922 * tvb - tvbuff for packet data (IN)
2923 * pinfo - packet info
2924 * proto_tree - resolved protocol tree
2926 static int
2927 dissect_ntp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
2929 proto_tree *ntp_tree;
2930 proto_item *ti = NULL;
2931 uint8_t flags;
2932 conversation_t *conversation;
2933 ntp_conv_info_t *ntp_conv;
2934 void (*dissector)(tvbuff_t *, packet_info *, proto_tree *, ntp_conv_info_t *);
2936 col_set_str(pinfo->cinfo, COL_PROTOCOL, "NTP");
2938 col_clear(pinfo->cinfo, COL_INFO);
2940 /* Reset NTS cookie, UID TVB and AAD reminders */
2941 nts_cookie = NULL;
2942 nts_tvb_uid_offset = 0;
2943 nts_tvb_uid_length = 0;
2944 nts_aad_start = 0;
2946 flags = tvb_get_uint8(tvb, 0);
2947 switch (flags & NTP_MODE_MASK) {
2948 default:
2949 dissector = dissect_ntp_std;
2950 break;
2951 case NTP_MODE_CTRL:
2952 dissector = dissect_ntp_ctrl;
2953 break;
2954 case NTP_MODE_PRIV:
2955 dissector = dissect_ntp_priv;
2956 break;
2959 /* Adding NTP item and subtree */
2960 ti = proto_tree_add_item(tree, proto_ntp, tvb, 0, -1, ENC_NA);
2961 ntp_tree = proto_item_add_subtree(ti, ett_ntp);
2963 /* Show version and mode in info column and NTP root */
2964 col_add_fstr(pinfo->cinfo, COL_INFO, "%s, %s",
2965 val_to_str_const((flags & NTP_VN_MASK) >> 3, ver_nums, "Unknown version"),
2966 val_to_str_const(flags & NTP_MODE_MASK, info_mode_types, "Unknown"));
2968 proto_item_append_text(ti, " (%s, %s)",
2969 val_to_str_const((flags & NTP_VN_MASK) >> 3, ver_nums, "Unknown version"),
2970 val_to_str_const(flags & NTP_MODE_MASK, info_mode_types, "Unknown"));
2972 conversation = find_or_create_conversation(pinfo);
2973 ntp_conv = (ntp_conv_info_t *)conversation_get_proto_data(conversation, proto_ntp);
2974 if (!ntp_conv) {
2975 ntp_conv = wmem_new(wmem_file_scope(), ntp_conv_info_t);
2976 ntp_conv->trans = wmem_tree_new(wmem_file_scope());
2977 conversation_add_proto_data(conversation, proto_ntp, ntp_conv);
2980 /* Dissect according to mode */
2981 (*dissector)(tvb, pinfo, ntp_tree, ntp_conv);
2982 return tvb_captured_length(tvb);
2985 void
2986 proto_register_ntp(void)
2988 static hf_register_info hf[] = {
2989 { &hf_ntp_flags, {
2990 "Flags", "ntp.flags", FT_UINT8, BASE_HEX,
2991 NULL, 0, "Flags (Leap/Version/Mode)", HFILL }},
2992 { &hf_ntp_flags_li, {
2993 "Leap Indicator", "ntp.flags.li", FT_UINT8, BASE_DEC,
2994 VALS(li_types), NTP_LI_MASK, "Warning of an impending leap second to be inserted or deleted in the last minute of the current month", HFILL }},
2995 { &hf_ntp_flags_vn, {
2996 "Version number", "ntp.flags.vn", FT_UINT8, BASE_DEC,
2997 VALS(ver_nums), NTP_VN_MASK, NULL, HFILL }},
2998 { &hf_ntp_flags_mode, {
2999 "Mode", "ntp.flags.mode", FT_UINT8, BASE_DEC,
3000 VALS(mode_types), NTP_MODE_MASK, NULL, HFILL }},
3001 { &hf_ntp_stratum, {
3002 "Peer Clock Stratum", "ntp.stratum", FT_UINT8, BASE_DEC|BASE_RANGE_STRING,
3003 RVALS(stratum_rvals), 0, NULL, HFILL }},
3004 { &hf_ntp_ppoll, {
3005 "Peer Polling Interval", "ntp.ppoll", FT_INT8, BASE_DEC,
3006 NULL, 0, "Maximum interval between successive messages", HFILL }},
3007 { &hf_ntp_precision, {
3008 "Peer Clock Precision", "ntp.precision", FT_INT8, BASE_DEC,
3009 NULL, 0, "The precision of the system clock", HFILL }},
3010 { &hf_ntp_rootdelay, {
3011 "Root Delay", "ntp.rootdelay", FT_UINT32, BASE_DEC,
3012 NULL, 0, "Total round-trip delay to the reference clock", HFILL }},
3013 { &hf_ntp_rootdispersion, {
3014 "Root Dispersion", "ntp.rootdispersion", FT_UINT32, BASE_DEC,
3015 NULL, 0, "Total dispersion to the reference clock", HFILL }},
3016 { &hf_ntp_refid, {
3017 "Reference ID", "ntp.refid", FT_BYTES, BASE_NONE,
3018 NULL, 0, "Particular server or reference clock being used", HFILL }},
3019 { &hf_ntp_reftime, {
3020 "Reference Timestamp", "ntp.reftime", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC,
3021 NULL, 0, "Time when the system clock was last set or corrected", HFILL }},
3022 { &hf_ntp_org, {
3023 "Origin Timestamp", "ntp.org", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC,
3024 NULL, 0, "Time at the client when the request departed for the server", HFILL }},
3025 { &hf_ntp_rec, {
3026 "Receive Timestamp", "ntp.rec", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC,
3027 NULL, 0, "Time at the server when the request arrived from the client", HFILL }},
3028 { &hf_ntp_xmt, {
3029 "Transmit Timestamp", "ntp.xmt", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC,
3030 NULL, 0, "Time at the server when the response left for the client", HFILL }},
3031 { &hf_ntp_keyid, {
3032 "Key ID", "ntp.keyid", FT_BYTES, BASE_NONE,
3033 NULL, 0, NULL, HFILL }},
3034 { &hf_ntp_mac, {
3035 "Message Authentication Code", "ntp.mac", FT_BYTES, BASE_NONE,
3036 NULL, 0, NULL, HFILL }},
3037 { &hf_ntp_padding, {
3038 "Padding", "ntp.padding", FT_BYTES, BASE_NONE,
3039 NULL, 0, NULL, HFILL }},
3040 { &hf_ntp_key_type, {
3041 "Key type", "ntp.key_type", FT_UINT8, BASE_DEC,
3042 VALS(authentication_types), 0, "Authentication algorithm used", HFILL }},
3043 { &hf_ntp_key_index, {
3044 "KeyIndex", "ntp.key_index", FT_UINT32, BASE_HEX,
3045 NULL, 0, NULL, HFILL }},
3046 { &hf_ntp_key_signature, {
3047 "Signature", "ntp.key_signature", FT_BYTES, BASE_NONE,
3048 NULL, 0, NULL, HFILL }},
3049 { &hf_ntp_response_in, {
3050 "Response In", "ntp.response_in", FT_FRAMENUM, BASE_NONE,
3051 FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0, NULL, HFILL }},
3052 { &hf_ntp_request_in, {
3053 "Request In", "ntp.request_in", FT_FRAMENUM, BASE_NONE,
3054 FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0, NULL, HFILL }},
3055 { &hf_ntp_delta_time, {
3056 "Delta Time", "ntp.delta_time", FT_RELATIVE_TIME, BASE_NONE,
3057 NULL, 0, "Time between request and response", HFILL }},
3059 { &hf_ntp_ext, {
3060 "Extension", "ntp.ext", FT_NONE, BASE_NONE,
3061 NULL, 0, NULL, HFILL }},
3062 { &hf_ntp_ext_type, {
3063 "Field Type", "ntp.ext.type", FT_UINT16, BASE_HEX|BASE_RANGE_STRING,
3064 RVALS(ntp_ext_field_types), 0, NULL, HFILL }},
3065 { &hf_ntp_ext_length, {
3066 "Length", "ntp.ext.length", FT_UINT16, BASE_DEC,
3067 NULL, 0, "Entire extension length including padding", HFILL }},
3068 { &hf_ntp_ext_value, {
3069 "Value", "ntp.ext.value", FT_BYTES, BASE_NONE,
3070 NULL, 0, "Type-specific value", HFILL }},
3072 { &hf_ntp_ext_nts, {
3073 "Network Time Security", "ntp.ext.nts", FT_NONE, BASE_NONE,
3074 NULL, 0, NULL, HFILL }},
3075 { &hf_ntp_nts_nonce_length, {
3076 "Nonce Length", "ntp.nts.nonce.length", FT_UINT16, BASE_DEC,
3077 NULL, 0, "Length of NTS nonce", HFILL }},
3078 { &hf_ntp_nts_ciphertext_length, {
3079 "Ciphertext Length", "ntp.nts.ciphertext.length", FT_UINT16, BASE_DEC,
3080 NULL, 0, "Length of NTS ciphertext", HFILL }},
3081 { &hf_ntp_nts_nonce, {
3082 "Nonce", "ntp.nts.nonce", FT_BYTES, BASE_NONE,
3083 NULL, 0, "Length of NTS ciphertext", HFILL }},
3084 { &hf_ntp_nts_ciphertext, {
3085 "Ciphertext", "ntp.nts.ciphertext", FT_BYTES, BASE_NONE,
3086 NULL, 0, "Length of NTS ciphertext", HFILL }},
3087 { &hf_ntp_nts_cookie_receive_frame, {
3088 "Received cookie in", "ntp.nts.cookie.receive_frame", FT_FRAMENUM, BASE_NONE,
3089 NULL, 0, "Frame where cookie was received", HFILL }},
3090 { &hf_ntp_nts_cookie_used_frame, {
3091 "Used cookie in", "ntp.nts.cookie.use_frame", FT_FRAMENUM, BASE_NONE,
3092 NULL, 0, NULL, HFILL }},
3093 { &hf_ntp_nts_crypto_success, {
3094 "Cryptography Success", "ntp.nts.crypto_success", FT_BOOLEAN, BASE_NONE,
3095 TFS(&tfs_yes_no), 0, "Decryption and authentication was successful", HFILL }},
3097 { &hf_ntpctrl_flags2, {
3098 "Flags 2", "ntp.ctrl.flags2", FT_UINT8, BASE_HEX,
3099 NULL, 0, "Flags (Response/Error/More/Opcode)", HFILL }},
3100 { &hf_ntpctrl_flags2_r, {
3101 "Response bit", "ntp.ctrl.flags2.r", FT_BOOLEAN, 8,
3102 TFS(&tfs_response_request), NTPCTRL_R_MASK, NULL, HFILL }},
3103 { &hf_ntpctrl_flags2_error, {
3104 "Error bit", "ntp.ctrl.flags2.error", FT_UINT8, BASE_DEC,
3105 NULL, NTPCTRL_ERROR_MASK, NULL, HFILL }},
3106 { &hf_ntpctrl_flags2_more, {
3107 "More bit", "ntp.ctrl.flags2.more", FT_UINT8, BASE_DEC,
3108 NULL, NTPCTRL_MORE_MASK, NULL, HFILL }},
3109 { &hf_ntpctrl_flags2_opcode, {
3110 "Opcode", "ntp.ctrl.flags2.opcode", FT_UINT8, BASE_DEC,
3111 VALS(ctrl_op_types), NTPCTRL_OP_MASK, NULL, HFILL }},
3112 { &hf_ntpctrl_sequence, {
3113 "Sequence", "ntp.ctrl.sequence", FT_UINT16, BASE_DEC,
3114 NULL, 0, NULL, HFILL }},
3115 { &hf_ntpctrl_status, {
3116 "Status", "ntp.ctrl.status", FT_UINT16, BASE_HEX,
3117 NULL, 0, NULL, HFILL }},
3118 { &hf_ntpctrl_error_status_word, {
3119 "Error Status Word", "ntp.ctrl.err_status", FT_UINT16, BASE_DEC,
3120 VALS(ctrl_err_status_types), NTP_CTRL_ERRSTATUS_CODE_MASK, NULL, HFILL }},
3121 { &hf_ntpctrl_sys_status_li, {
3122 "Leap Indicator", "ntp.ctrl.sys_status.li", FT_UINT16, BASE_DEC,
3123 VALS(li_types), NTPCTRL_SYSSTATUS_LI_MASK, "Warning of an impending leap second to be inserted or deleted in the last minute of the current month", HFILL }},
3124 { &hf_ntpctrl_sys_status_clksrc, {
3125 "Clock Source", "ntp.ctrl.sys_status.clksrc", FT_UINT16, BASE_DEC,
3126 VALS(ctrl_sys_status_clksource_types), NTPCTRL_SYSSTATUS_CLK_MASK, NULL, HFILL }},
3127 { &hf_ntpctrl_sys_status_count, {
3128 "System Event Counter", "ntp.ctrl.sys_status.count", FT_UINT16, BASE_DEC,
3129 NULL, NTPCTRL_SYSSTATUS_COUNT_MASK, NULL, HFILL }},
3130 { &hf_ntpctrl_sys_status_code, {
3131 "System Event Code", "ntp.ctrl.sys_status.code", FT_UINT16, BASE_DEC,
3132 VALS(ctrl_sys_status_event_types), NTPCTRL_SYSSTATUS_CODE_MASK, NULL, HFILL }},
3133 { &hf_ntpctrl_peer_status_b0, {
3134 "Peer Status", "ntp.ctrl.peer_status.config", FT_BOOLEAN, 16,
3135 TFS(&tfs_ctrl_peer_status_config), NTPCTRL_PEERSTATUS_CONFIG_MASK, NULL, HFILL }},
3136 { &hf_ntpctrl_peer_status_b1, {
3137 "Peer Status", "ntp.ctrl.peer_status.authenable", FT_BOOLEAN, 16,
3138 TFS(&tfs_ctrl_peer_status_authenable), NTPCTRL_PEERSTATUS_AUTHENABLE_MASK, NULL, HFILL }},
3139 { &hf_ntpctrl_peer_status_b2, {
3140 "Peer Status", "ntp.ctrl.peer_status.authentic", FT_BOOLEAN, 16,
3141 TFS(&tfs_ctrl_peer_status_authentic), NTPCTRL_PEERSTATUS_AUTHENTIC_MASK, NULL, HFILL }},
3142 { &hf_ntpctrl_peer_status_b3, {
3143 "Peer Status", "ntp.ctrl.peer_status.reach", FT_BOOLEAN, 16,
3144 TFS(&tfs_ctrl_peer_status_reach), NTPCTRL_PEERSTATUS_REACH_MASK, NULL, HFILL }},
3145 { &hf_ntpctrl_peer_status_b4, {
3146 "Peer Status broadcast association", "ntp.ctrl.peer_status.bcast", FT_BOOLEAN, 16,
3147 TFS(&tfs_set_notset), NTPCTRL_PEERSTATUS_BCAST_MASK, NULL, HFILL }},
3148 { &hf_ntpctrl_peer_status_selection, {
3149 "Peer Selection", "ntp.ctrl.peer_status.selection", FT_UINT16, BASE_DEC,
3150 VALS(ctrl_peer_status_selection_types), NTPCTRL_PEERSTATUS_SEL_MASK, NULL, HFILL }},
3151 { &hf_ntpctrl_peer_status_count, {
3152 "Peer Event Counter", "ntp.ctrl.peer_status.count", FT_UINT16, BASE_DEC,
3153 NULL, NTPCTRL_PEERSTATUS_COUNT_MASK, NULL, HFILL }},
3154 { &hf_ntpctrl_peer_status_code, {
3155 "Peer Event Code", "ntp.ctrl.peer_status.code", FT_UINT16, BASE_DEC,
3156 VALS(ctrl_peer_status_event_types), NTPCTRL_PEERSTATUS_CODE_MASK, NULL, HFILL }},
3157 { &hf_ntpctrl_clk_status, {
3158 "Clock Status", "ntp.ctrl.clock_status.status", FT_UINT16, BASE_DEC,
3159 VALS(ctrl_clk_status_types), NTPCTRL_CLKSTATUS_STATUS_MASK, NULL, HFILL }},
3160 { &hf_ntpctrl_clk_status_code, {
3161 "Clock Event Code", "ntp.ctrl.clock_status.code", FT_UINT16, BASE_DEC,
3162 NULL, NTPCTRL_CLKSTATUS_CODE_MASK, NULL, HFILL }},
3163 { &hf_ntpctrl_data, {
3164 "Data", "ntp.ctrl.data", FT_NONE, BASE_NONE,
3165 NULL, 0, NULL, HFILL }},
3166 { &hf_ntpctrl_item, {
3167 "Item", "ntp.ctrl.item", FT_NONE, BASE_NONE,
3168 NULL, 0, NULL, HFILL }},
3169 { &hf_ntpctrl_associd, {
3170 "AssociationID", "ntp.ctrl.associd", FT_UINT16, BASE_DEC,
3171 NULL, 0, NULL, HFILL }},
3172 { &hf_ntpctrl_offset, {
3173 "Offset", "ntp.ctrl.offset", FT_UINT16, BASE_DEC,
3174 NULL, 0, NULL, HFILL }},
3175 { &hf_ntpctrl_count, {
3176 "Count", "ntp.ctrl.count", FT_UINT16, BASE_DEC,
3177 NULL, 0, NULL, HFILL }},
3178 { &hf_ntpctrl_trapmsg, {
3179 "Trap message", "ntp.ctrl.trapmsg", FT_STRING, BASE_NONE,
3180 NULL, 0, NULL, HFILL }},
3181 { &hf_ntpctrl_configuration, {
3182 "Configuration", "ntp.ctrl.configuration", FT_STRING, BASE_NONE,
3183 NULL, 0, NULL, HFILL }},
3184 { &hf_ntpctrl_mru, {
3185 "MRU", "ntp.ctrl.mru", FT_STRING, BASE_NONE,
3186 NULL, 0, NULL, HFILL }},
3187 { &hf_ntpctrl_ordlist, {
3188 "Ordered List", "ntp.ctrl.ordlist", FT_STRING, BASE_NONE,
3189 NULL, 0, NULL, HFILL }},
3190 { &hf_ntpctrl_nonce, {
3191 "Nonce", "ntp.ctrl.nonce", FT_STRING, BASE_NONE,
3192 NULL, 0, NULL, HFILL }},
3194 { &hf_ntppriv_flags_r, {
3195 "Response bit", "ntp.priv.flags.r", FT_BOOLEAN, 8,
3196 TFS(&tfs_response_request), NTPPRIV_R_MASK, NULL, HFILL }},
3197 { &hf_ntppriv_flags_more, {
3198 "More bit", "ntp.priv.flags.more", FT_UINT8, BASE_DEC,
3199 NULL, NTPPRIV_MORE_MASK, NULL, HFILL }},
3200 { &hf_ntppriv_auth_seq, {
3201 "Auth, sequence", "ntp.priv.auth_seq", FT_UINT8, BASE_DEC,
3202 NULL, 0, "Auth bit, sequence number", HFILL }},
3203 { &hf_ntppriv_auth, {
3204 "Auth bit", "ntp.priv.auth", FT_UINT8, BASE_DEC,
3205 NULL, NTPPRIV_AUTH_MASK, NULL, HFILL }},
3206 { &hf_ntppriv_seq, {
3207 "Sequence number", "ntp.priv.seq", FT_UINT8, BASE_DEC,
3208 NULL, NTPPRIV_SEQ_MASK, NULL, HFILL }},
3209 { &hf_ntppriv_impl, {
3210 "Implementation", "ntp.priv.impl", FT_UINT8, BASE_DEC,
3211 VALS(priv_impl_types), 0, NULL, HFILL }},
3212 { &hf_ntppriv_reqcode, {
3213 "Request code", "ntp.priv.reqcode", FT_UINT8, BASE_DEC | BASE_EXT_STRING,
3214 &priv_rc_types_ext, 0, NULL, HFILL }},
3215 { &hf_ntppriv_errcode, {
3216 "Err", "ntp.priv.err", FT_UINT8, BASE_HEX,
3217 VALS(err_values_types), 0, NULL, HFILL }},
3218 { &hf_ntppriv_numitems, {
3219 "Number of data items", "ntp.priv.numitems", FT_UINT16, BASE_DEC,
3220 NULL, 0, NULL, HFILL }},
3221 { &hf_ntppriv_mbz, {
3222 "Reserved", "ntp.priv.reserved", FT_UINT8, BASE_HEX,
3223 NULL, 0, NULL, HFILL }},
3224 { &hf_ntppriv_mode7_item, {
3225 "Mode7 item", "ntp.priv.mode7.item",
3226 FT_STRINGZ, BASE_NONE, NULL, 0x00, NULL, HFILL }},
3227 { &hf_ntppriv_itemsize, {
3228 "Size of data item", "ntp.priv.itemsize", FT_UINT16, BASE_DEC,
3229 NULL, 0, NULL, HFILL }},
3230 { &hf_ntppriv_avgint, {
3231 "avgint", "ntp.priv.monlist.avgint", FT_UINT32, BASE_DEC,
3232 NULL, 0, NULL, HFILL }},
3233 { &hf_ntppriv_lsint, {
3234 "lsint", "ntp.priv.monlist.lsint", FT_UINT32, BASE_DEC,
3235 NULL, 0, NULL, HFILL }},
3236 { &hf_ntppriv_restr, {
3237 "restr", "ntp.priv.monlist.restr", FT_UINT32, BASE_HEX,
3238 NULL, 0, NULL, HFILL }},
3239 { &hf_ntppriv_count, {
3240 "count", "ntp.priv.monlist.count", FT_UINT32, BASE_DEC,
3241 NULL, 0, NULL, HFILL }},
3242 { &hf_ntppriv_addr, {
3243 "remote address", "ntp.priv.monlist.remote_address", FT_IPv4, BASE_NONE,
3244 NULL, 0, NULL, HFILL }},
3245 { &hf_ntppriv_daddr, {
3246 "local address", "ntp.priv.monlist.local_address", FT_IPv4, BASE_NONE,
3247 NULL, 0, NULL, HFILL }},
3248 { &hf_ntppriv_flags, {
3249 "flags", "ntp.priv.monlist.flags", FT_UINT32, BASE_HEX,
3250 NULL, 0, NULL, HFILL }},
3251 { &hf_ntppriv_port, {
3252 "port", "ntp.priv.monlist.port", FT_UINT16, BASE_DEC,
3253 NULL, 0, NULL, HFILL }},
3254 { &hf_ntppriv_mode, {
3255 "mode", "ntp.priv.monlist.mode", FT_UINT8, BASE_DEC,
3256 NULL, 0, NULL, HFILL }},
3257 { &hf_ntppriv_version, {
3258 "version", "ntp.priv.monlist.version", FT_UINT8, BASE_DEC,
3259 NULL, 0, NULL, HFILL }},
3260 { &hf_ntppriv_v6_flag, {
3261 "ipv6", "ntp.priv.monlist.ipv6", FT_UINT32, BASE_HEX,
3262 NULL, 0, NULL, HFILL }},
3263 { &hf_ntppriv_unused, {
3264 "unused", "ntp.priv.monlist.unused", FT_UINT32, BASE_HEX,
3265 NULL, 0, NULL, HFILL }},
3266 { &hf_ntppriv_addr6, {
3267 "ipv6 remote addr", "ntp.priv.monlist.addr6", FT_IPv6, BASE_NONE,
3268 NULL, 0, NULL, HFILL }},
3269 { &hf_ntppriv_daddr6, {
3270 "ipv6 local addr", "ntp.priv.monlist.daddr6", FT_IPv6, BASE_NONE,
3271 NULL, 0, NULL, HFILL }},
3272 { &hf_ntppriv_tstamp, {
3273 "Authentication timestamp", "ntp.priv.tstamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_NTP_UTC,
3274 NULL, 0, NULL, HFILL }},
3275 { &hf_ntppriv_mode7_addr, {
3276 "Address", "ntp.priv.mode7.address", FT_IPv4, BASE_NONE,
3277 NULL, 0, NULL, HFILL }},
3278 { &hf_ntppriv_mode7_mask, {
3279 "Mask", "ntp.priv.mode7.mask", FT_IPv4, BASE_NONE,
3280 NULL, 0, NULL, HFILL }},
3281 { &hf_ntppriv_mode7_bcast, {
3282 "Bcast", "ntp.priv.mode7.bcast", FT_IPv4, BASE_NONE,
3283 NULL, 0, NULL, HFILL }},
3284 { &hf_ntppriv_mode7_port, {
3285 "Port", "ntp.priv.mode7.port", FT_UINT16, BASE_DEC,
3286 NULL, 0, NULL, HFILL }},
3287 { &hf_ntppriv_mode7_hmode, {
3288 "HMode", "ntp.priv.mode7.hmode", FT_UINT8, BASE_DEC,
3289 VALS(mode_types), 0, NULL, HFILL }},
3290 { &hf_ntppriv_mode7_peer_flags, {
3291 "Flags", "ntp.priv.mode7.peer.flags", FT_UINT8, BASE_HEX,
3292 NULL, 0xFF, NULL, HFILL }},
3293 { &hf_ntppriv_mode7_v6_flag, {
3294 "IPv6 Flag", "ntp.priv.mode7.ipv6_flag", FT_UINT32, BASE_DEC,
3295 NULL, 0, NULL, HFILL }},
3296 { &hf_ntppriv_mode7_unused, {
3297 "Unused", "ntp.priv.mode7.unused", FT_BYTES, BASE_NONE,
3298 NULL, 0, NULL, HFILL }},
3299 { &hf_ntppriv_mode7_addr6, {
3300 "IPv6 addr", "ntp.priv.mode7.address6", FT_IPv6, BASE_NONE,
3301 NULL, 0, NULL, HFILL }},
3302 { &hf_ntppriv_mode7_mask6, {
3303 "IPv6 mask", "ntp.priv.mode7.mask6", FT_IPv6, BASE_NONE,
3304 NULL, 0, NULL, HFILL }},
3305 { &hf_ntppriv_mode7_bcast6, {
3306 "IPv6 bcast", "ntp.priv.mode7.bcast6", FT_IPv6, BASE_NONE,
3307 NULL, 0, NULL, HFILL }},
3308 { &hf_ntppriv_mode7_peer_flags_config, {
3309 "Config", "ntp.priv.mode7.peer.flags.config", FT_BOOLEAN, 8,
3310 TFS(&tfs_set_notset), PRIV_INFO_FLAG_CONFIG, NULL, HFILL }},
3311 { &hf_ntppriv_mode7_peer_flags_syspeer, {
3312 "Syspeer", "ntp.priv.mode7.peer.flags.syspeer", FT_BOOLEAN, 8,
3313 TFS(&tfs_set_notset), PRIV_INFO_FLAG_SYSPEER, NULL, HFILL }},
3314 { &hf_ntppriv_mode7_peer_flags_burst, {
3315 "Burst", "ntp.priv.mode7.peer.flags.burst", FT_BOOLEAN, 8,
3316 TFS(&tfs_set_notset), PRIV_INFO_FLAG_BURST, NULL, HFILL }},
3317 { &hf_ntppriv_mode7_peer_flags_refclock, {
3318 "Refclock", "ntp.priv.mode7.peer.flags.refclock", FT_BOOLEAN, 8,
3319 TFS(&tfs_set_notset), PRIV_INFO_FLAG_REFCLOCK, NULL, HFILL }},
3320 { &hf_ntppriv_mode7_peer_flags_prefer, {
3321 "Prefer", "ntp.priv.mode7.peer.flags.prefer", FT_BOOLEAN, 8,
3322 TFS(&tfs_set_notset), PRIV_INFO_FLAG_PREFER, NULL, HFILL }},
3323 { &hf_ntppriv_mode7_peer_flags_authenable, {
3324 "Auth enable", "ntp.priv.mode7.peer.flags.authenable", FT_BOOLEAN, 8,
3325 TFS(&tfs_set_notset), PRIV_INFO_FLAG_AUTHENABLE, NULL, HFILL }},
3326 { &hf_ntppriv_mode7_peer_flags_sel_candidate, {
3327 "Sel Candidate", "ntp.priv.mode7.peer.flags.sel_candidate", FT_BOOLEAN, 8,
3328 TFS(&tfs_set_notset), PRIV_INFO_FLAG_SEL_CANDIDATE, NULL, HFILL }},
3329 { &hf_ntppriv_mode7_peer_flags_shortlist, {
3330 "Shortlist", "ntp.priv.mode7.peer.flags.shortlist", FT_BOOLEAN, 8,
3331 TFS(&tfs_set_notset), PRIV_INFO_FLAG_SHORTLIST, NULL, HFILL }},
3332 { &hf_ntppriv_mode7_dstaddr, {
3333 "Destination address", "ntp.priv.mode7.dstaddress", FT_IPv4, BASE_NONE,
3334 NULL, 0, NULL, HFILL }},
3335 { &hf_ntppriv_mode7_srcaddr, {
3336 "Source address", "ntp.priv.mode7.srcaddress", FT_IPv4, BASE_NONE,
3337 NULL, 0, NULL, HFILL }},
3338 { &hf_ntppriv_mode7_srcport, {
3339 "Source port", "ntp.priv.mode7.srcport", FT_UINT16, BASE_DEC,
3340 NULL, 0, NULL, HFILL }},
3341 { &hf_ntppriv_mode7_count, {
3342 "Count", "ntp.priv.mode7.count", FT_UINT32, BASE_DEC,
3343 NULL, 0, NULL, HFILL }},
3344 { &hf_ntppriv_mode7_hpoll, {
3345 "Host polling interval", "ntp.priv.mode7.hpoll", FT_INT8, BASE_DEC,
3346 NULL, 0, NULL, HFILL }},
3347 { &hf_ntppriv_mode7_reach, {
3348 "Reach", "ntp.priv.mode7.reach", FT_UINT8, BASE_DEC,
3349 NULL, 0, NULL, HFILL }},
3350 { &hf_ntppriv_mode7_delay, {
3351 "Delay", "ntp.priv.mode7.delay", FT_INT32, BASE_DEC,
3352 NULL, 0, NULL, HFILL }},
3353 { &hf_ntppriv_mode7_offset, {
3354 "Offset", "ntp.priv.mode7.offset", FT_UINT64, BASE_DEC,
3355 NULL, 0, NULL, HFILL }},
3356 { &hf_ntppriv_mode7_dispersion, {
3357 "Dispersion", "ntp.priv.mode7.dispersion", FT_UINT32, BASE_DEC,
3358 NULL, 0, NULL, HFILL }},
3359 { &hf_ntppriv_mode7_dstaddr6, {
3360 "IPv6 destination addr", "ntp.priv.mode7.dstaddress6", FT_IPv6, BASE_NONE,
3361 NULL, 0, NULL, HFILL }},
3362 { &hf_ntppriv_mode7_srcaddr6, {
3363 "IPv6 source addr", "ntp.priv.mode7.srcaddress6", FT_IPv6, BASE_NONE,
3364 NULL, 0, NULL, HFILL }},
3365 { &hf_ntppriv_mode7_leap, {
3366 "Leap", "ntp.priv.mode7.leap", FT_UINT8, BASE_DEC,
3367 NULL, 0, NULL, HFILL }},
3368 { &hf_ntppriv_mode7_pmode, {
3369 "Peer mode", "ntp.priv.mode7.pmode", FT_UINT8, BASE_DEC,
3370 VALS(mode_types), 0, NULL, HFILL }},
3371 { &hf_ntppriv_mode7_version, {
3372 "Version", "ntp.priv.mode7.version", FT_UINT8, BASE_DEC,
3373 NULL, 0, NULL, HFILL }},
3374 { &hf_ntppriv_mode7_unreach, {
3375 "Unreach", "ntp.priv.mode7.unreach", FT_UINT8, BASE_DEC,
3376 NULL, 0, NULL, HFILL }},
3377 { &hf_ntppriv_mode7_flash, {
3378 "Flash", "ntp.priv.mode7.flash", FT_UINT8, BASE_DEC,
3379 NULL, 0, NULL, HFILL }},
3380 { &hf_ntppriv_mode7_ttl, {
3381 "TTL", "ntp.priv.mode7.ttl", FT_UINT8, BASE_DEC,
3382 NULL, 0, NULL, HFILL }},
3383 { &hf_ntppriv_mode7_flash2, {
3384 "Flash new", "ntp.priv.mode7.flash2", FT_UINT16, BASE_DEC,
3385 NULL, 0, NULL, HFILL }},
3386 { &hf_ntppriv_mode7_associd, {
3387 "Association ID", "ntp.priv.mode7.associd", FT_UINT16, BASE_DEC,
3388 NULL, 0, NULL, HFILL }},
3389 { &hf_ntppriv_mode7_pkeyid, {
3390 "Peer Key ID", "ntp.priv.mode7.pkeyid", FT_UINT32, BASE_DEC,
3391 NULL, 0, NULL, HFILL }},
3392 { &hf_ntppriv_mode7_timer, {
3393 "Timer", "ntp.priv.mode7.timer", FT_UINT32, BASE_DEC,
3394 NULL, 0, NULL, HFILL }},
3395 { &hf_ntppriv_mode7_filtdelay, {
3396 "Filt delay", "ntp.priv.mode7.filtdelay", FT_INT32, BASE_DEC,
3397 NULL, 0, NULL, HFILL }},
3398 { &hf_ntppriv_mode7_filtoffset, {
3399 "Filt offset", "ntp.priv.mode7.filtoffset", FT_INT64, BASE_DEC,
3400 NULL, 0, NULL, HFILL }},
3401 { &hf_ntppriv_mode7_order, {
3402 "Order", "ntp.priv.mode7.order", FT_UINT8, BASE_DEC,
3403 NULL, 0, NULL, HFILL }},
3404 { &hf_ntppriv_mode7_selectdis, {
3405 "Selectdis", "ntp.priv.mode7.selectdis", FT_UINT32, BASE_DEC,
3406 NULL, 0, NULL, HFILL }},
3407 { &hf_ntppriv_mode7_estbdelay, {
3408 "Estbdelay", "ntp.priv.mode7.estbdelay", FT_INT32, BASE_DEC,
3409 NULL, 0, NULL, HFILL }},
3410 { &hf_ntppriv_mode7_bdelay, {
3411 "Bdelay", "ntp.priv.mode7.bdelay", FT_INT32, BASE_DEC,
3412 NULL, 0, NULL, HFILL }},
3413 { &hf_ntppriv_mode7_authdelay, {
3414 "Auth delay", "ntp.priv.mode7.authdelay", FT_INT64, BASE_DEC,
3415 NULL, 0, NULL, HFILL }},
3416 { &hf_ntppriv_mode7_minpoll, {
3417 "Minpoll", "ntp.priv.mode7.minpoll", FT_UINT8, BASE_DEC,
3418 NULL, 0, NULL, HFILL }},
3419 { &hf_ntppriv_mode7_maxpoll, {
3420 "Maxpoll", "ntp.priv.mode7.maxpoll", FT_UINT8, BASE_DEC,
3421 NULL, 0, NULL, HFILL }},
3422 { &hf_ntppriv_mode7_config_flags, {
3423 "Flags", "ntp.priv.config.flags", FT_UINT8, BASE_HEX,
3424 NULL, 0xFF, NULL, HFILL }},
3425 { &hf_ntppriv_mode7_config_flags_auth, {
3426 "Authenable", "ntp.priv.mode7.config.flags.authenable", FT_BOOLEAN, 8,
3427 TFS(&tfs_set_notset), PRIV_CONF_FLAG_AUTHENABLE, NULL, HFILL }},
3428 { &hf_ntppriv_mode7_config_flags_prefer, {
3429 "Prefer", "ntp.priv.mode7.config.flags.prefer", FT_BOOLEAN, 8,
3430 TFS(&tfs_set_notset), PRIV_CONF_FLAG_PREFER, NULL, HFILL }},
3431 { &hf_ntppriv_mode7_config_flags_burst, {
3432 "Burst", "ntp.priv.mode7.config.flags.burst", FT_BOOLEAN, 8,
3433 TFS(&tfs_set_notset), PRIV_CONF_FLAG_BURST, NULL, HFILL }},
3434 { &hf_ntppriv_mode7_config_flags_iburst, {
3435 "IBurst", "ntp.priv.mode7.config.flags.iburst", FT_BOOLEAN, 8,
3436 TFS(&tfs_set_notset), PRIV_CONF_FLAG_IBURST, NULL, HFILL }},
3437 { &hf_ntppriv_mode7_config_flags_noselect, {
3438 "No Select", "ntp.priv.mode7.config.flags.no_select", FT_BOOLEAN, 8,
3439 TFS(&tfs_set_notset), PRIV_CONF_FLAG_NOSELECT, NULL, HFILL }},
3440 { &hf_ntppriv_mode7_config_flags_skey, {
3441 "Skey", "ntp.priv.mode7.config.flags.skey", FT_BOOLEAN, 8,
3442 TFS(&tfs_set_notset), PRIV_CONF_FLAG_SKEY, NULL, HFILL }},
3443 { &hf_ntppriv_mode7_key_file, {
3444 "Key file name", "ntp.priv.mode7.key_file", FT_STRING, BASE_NONE,
3445 NULL, 0, NULL, HFILL }},
3446 { &hf_ntppriv_mode7_sys_flags, {
3447 "Flags", "ntp.priv.mode7.sys.flags", FT_UINT32, BASE_HEX,
3448 NULL, 0xFF, NULL, HFILL }},
3449 { &hf_ntppriv_mode7_sys_flags_bclient, {
3450 "Bclient", "ntp.priv.mode7.sys.flags.bclient", FT_BOOLEAN, 8,
3451 TFS(&tfs_set_notset), PRIV_SYS_FLAG_BCLIENT, NULL, HFILL }},
3452 { &hf_ntppriv_mode7_sys_flags_pps, {
3453 "PPS", "ntp.priv.mode7.sys.flags.pps", FT_BOOLEAN, 8,
3454 TFS(&tfs_set_notset), PRIV_SYS_FLAG_PPS, NULL, HFILL }},
3455 { &hf_ntppriv_mode7_sys_flags_ntp, {
3456 "NTP", "ntp.priv.mode7.sys.flags.ntp", FT_BOOLEAN, 8,
3457 TFS(&tfs_set_notset), PRIV_SYS_FLAG_NTP, NULL, HFILL }},
3458 { &hf_ntppriv_mode7_sys_flags_kernel, {
3459 "Kernel", "ntp.priv.mode7.sys.flags.kernel", FT_BOOLEAN, 8,
3460 TFS(&tfs_set_notset), PRIV_SYS_FLAG_KERNEL, NULL, HFILL }},
3461 { &hf_ntppriv_mode7_sys_flags_monitor, {
3462 "Monitor", "ntp.priv.mode7.sys.flags.monitor", FT_BOOLEAN, 8,
3463 TFS(&tfs_set_notset), PRIV_SYS_FLAG_MONITOR, NULL, HFILL }},
3464 { &hf_ntppriv_mode7_sys_flags_filegen, {
3465 "Filegen", "ntp.priv.mode7.sys.flags.filegen", FT_BOOLEAN, 8,
3466 TFS(&tfs_set_notset), PRIV_SYS_FLAG_FILEGEN, NULL, HFILL }},
3467 { &hf_ntppriv_mode7_sys_flags_auth, {
3468 "Auth", "ntp.priv.mode7.sys.flags.auth", FT_BOOLEAN, 8,
3469 TFS(&tfs_set_notset), PRIV_SYS_FLAG_AUTH, NULL, HFILL }},
3470 { &hf_ntppriv_mode7_sys_flags_cal, {
3471 "Cal", "ntp.priv.mode7.sys.flags.cal", FT_BOOLEAN, 8,
3472 TFS(&tfs_set_notset), PRIV_SYS_FLAG_CAL, NULL, HFILL }},
3473 { &hf_ntppriv_mode7_reset_stats_flags, {
3474 "Flags", "ntp.priv.mode7.reset_stats.flags", FT_UINT32, BASE_HEX,
3475 NULL, 0xFF, NULL, HFILL }},
3476 { &hf_ntppriv_mode7_reset_stats_flags_allpeers, {
3477 "All Peers", "ntp.priv.mode7.reset_stats.flags.allpeers", FT_BOOLEAN, 32,
3478 TFS(&tfs_set_notset), PRIV_RESET_FLAG_ALLPEERS, NULL, HFILL }},
3479 { &hf_ntppriv_mode7_reset_stats_flags_io, {
3480 "IO", "ntp.priv.mode7.reset_stats.flags.io", FT_BOOLEAN, 32,
3481 TFS(&tfs_set_notset), PRIV_RESET_FLAG_IO, NULL, HFILL }},
3482 { &hf_ntppriv_mode7_reset_stats_flags_sys, {
3483 "Sys", "ntp.priv.mode7.reset_stats.flags.sys", FT_BOOLEAN, 32,
3484 TFS(&tfs_set_notset), PRIV_RESET_FLAG_SYS, NULL, HFILL }},
3485 { &hf_ntppriv_mode7_reset_stats_flags_mem, {
3486 "Mem", "ntp.priv.mode7.reset_stats.flags.mem", FT_BOOLEAN, 32,
3487 TFS(&tfs_set_notset), PRIV_RESET_FLAG_MEM, NULL, HFILL }},
3488 { &hf_ntppriv_mode7_reset_stats_flags_timer, {
3489 "Timer", "ntp.priv.mode7.reset_stats.flags.timer", FT_BOOLEAN, 32,
3490 TFS(&tfs_set_notset), PRIV_RESET_FLAG_TIMER, NULL, HFILL }},
3491 { &hf_ntppriv_mode7_reset_stats_flags_auth, {
3492 "Auth", "ntp.priv.mode7.reset_stats.flags.auth", FT_BOOLEAN, 32,
3493 TFS(&tfs_set_notset), PRIV_RESET_FLAG_AUTH, NULL, HFILL }},
3494 { &hf_ntppriv_mode7_reset_stats_flags_ctl, {
3495 "Ctl", "ntp.priv.mode7.reset_stats.flags.ctl", FT_BOOLEAN, 32,
3496 TFS(&tfs_set_notset), PRIV_RESET_FLAG_CTL, NULL, HFILL }},
3497 { &hf_ntppriv_mode7_key, {
3498 "Key", "ntp.priv.mode7.key", FT_UINT64, BASE_HEX,
3499 NULL, 0, NULL, HFILL }},
3500 { &hf_ntppriv_mode7_timeup, {
3501 "Time up", "ntp.priv.mode7.timeup", FT_UINT32, BASE_DEC,
3502 NULL, 0, "time counters were reset", HFILL }},
3503 { &hf_ntppriv_mode7_timereset, {
3504 "Time reset", "ntp.priv.mode7.timereset", FT_UINT32, BASE_DEC,
3505 NULL, 0, "time counters were reset", HFILL }},
3506 { &hf_ntppriv_mode7_timereceived, {
3507 "Time received", "ntp.priv.mode7.timereceived", FT_UINT32, BASE_DEC,
3508 NULL, 0, "time since a packet received", HFILL }},
3509 { &hf_ntppriv_mode7_timetosend, {
3510 "Time to send", "ntp.priv.mode7.timetosend", FT_UINT32, BASE_DEC,
3511 NULL, 0, "time until a packet sent", HFILL }},
3512 { &hf_ntppriv_mode7_timereachable, {
3513 "Time reachable", "ntp.priv.mode7.timereachable", FT_UINT32, BASE_DEC,
3514 NULL, 0, "time peer has been reachable", HFILL }},
3515 { &hf_ntppriv_mode7_sent, {
3516 "Sent", "ntp.priv.mode7.sent", FT_UINT32, BASE_DEC,
3517 NULL, 0, NULL, HFILL }},
3518 { &hf_ntppriv_mode7_processed, {
3519 "Processed", "ntp.priv.mode7.processed", FT_UINT32, BASE_DEC,
3520 NULL, 0, NULL, HFILL }},
3521 { &hf_ntppriv_mode7_badauth, {
3522 "Bad authentication", "ntp.priv.mode7.badauth", FT_UINT32, BASE_DEC,
3523 NULL, 0, NULL, HFILL }},
3524 { &hf_ntppriv_mode7_bogusorg, {
3525 "Bogus origin", "ntp.priv.mode7.bogusorg", FT_UINT32, BASE_DEC,
3526 NULL, 0, NULL, HFILL }},
3527 { &hf_ntppriv_mode7_oldpkt, {
3528 "Old packet", "ntp.priv.mode7.oldpkt", FT_UINT32, BASE_DEC,
3529 NULL, 0, NULL, HFILL }},
3530 { &hf_ntppriv_mode7_seldisp, {
3531 "Bad dispersion", "ntp.priv.mode7.seldisp", FT_UINT32, BASE_DEC,
3532 NULL, 0, NULL, HFILL }},
3533 { &hf_ntppriv_mode7_selbroken, {
3534 "Bad reference time", "ntp.priv.mode7.selbroken", FT_UINT32, BASE_DEC,
3535 NULL, 0, NULL, HFILL }},
3536 { &hf_ntppriv_mode7_candidate, {
3537 "Candidate", "ntp.priv.mode7.candidate", FT_UINT32, BASE_DEC,
3538 NULL, 0, NULL, HFILL }},
3539 { &hf_ntppriv_mode7_numkeys, {
3540 "Num keys", "ntp.priv.mode7.numkeys", FT_UINT32, BASE_DEC,
3541 NULL, 0, NULL, HFILL }},
3542 { &hf_ntppriv_mode7_numfreekeys, {
3543 "Num free keys", "ntp.priv.mode7.numfreekeys", FT_UINT32, BASE_DEC,
3544 NULL, 0, NULL, HFILL }},
3545 { &hf_ntppriv_mode7_keylookups, {
3546 "Keylookups", "ntp.priv.mode7.keylookups", FT_UINT32, BASE_DEC,
3547 NULL, 0, NULL, HFILL }},
3548 { &hf_ntppriv_mode7_keynotfound, {
3549 "Key not found", "ntp.priv.mode7.keynotfound", FT_UINT32, BASE_DEC,
3550 NULL, 0, NULL, HFILL }},
3551 { &hf_ntppriv_mode7_encryptions, {
3552 "Encryptions", "ntp.priv.mode7.encryptions", FT_UINT32, BASE_DEC,
3553 NULL, 0, NULL, HFILL }},
3554 { &hf_ntppriv_mode7_decryptions, {
3555 "Decryptions", "ntp.priv.mode7.decryptions", FT_UINT32, BASE_DEC,
3556 NULL, 0, NULL, HFILL }},
3557 { &hf_ntppriv_mode7_expired, {
3558 "Expired", "ntp.priv.mode7.expired", FT_UINT32, BASE_DEC,
3559 NULL, 0, NULL, HFILL }},
3560 { &hf_ntppriv_mode7_keyuncached, {
3561 "Key uncached", "ntp.priv.mode7.keyuncached", FT_UINT32, BASE_DEC,
3562 NULL, 0, NULL, HFILL }},
3563 { &hf_ntppriv_mode7_local_addr, {
3564 "Local address", "ntp.priv.mode7.local_address", FT_IPv4, BASE_NONE,
3565 NULL, 0, NULL, HFILL }},
3566 { &hf_ntppriv_mode7_trap_addr, {
3567 "Trap address", "ntp.priv.mode7.trap_address", FT_IPv4, BASE_NONE,
3568 NULL, 0, NULL, HFILL }},
3569 { &hf_ntppriv_mode7_trap_port, {
3570 "Trap port", "ntp.priv.mode7.trap_port", FT_UINT16, BASE_DEC,
3571 NULL, 0, NULL, HFILL }},
3572 { &hf_ntppriv_mode7_sequence, {
3573 "Sequence number", "ntp.priv.mode7.sequence", FT_UINT16, BASE_DEC,
3574 NULL, 0, NULL, HFILL }},
3575 { &hf_ntppriv_mode7_settime, {
3576 "Trap set time", "ntp.priv.mode7.settime", FT_UINT32, BASE_DEC,
3577 NULL, 0, NULL, HFILL }},
3578 { &hf_ntppriv_mode7_origtime, {
3579 "Trap originally time", "ntp.priv.mode7.origtime", FT_UINT32, BASE_DEC,
3580 NULL, 0, NULL, HFILL }},
3581 { &hf_ntppriv_mode7_resets, {
3582 "Resets", "ntp.priv.mode7.resets", FT_UINT32, BASE_DEC,
3583 NULL, 0, NULL, HFILL }},
3584 { &hf_ntppriv_traps_flags, {
3585 "Flags", "ntp.priv.traps.flags", FT_UINT32, BASE_HEX,
3586 NULL, 0, NULL, HFILL }},
3587 { &hf_ntppriv_mode7_local_addr6, {
3588 "IPv6 local addr", "ntp.priv.mode7.local_address6", FT_IPv6, BASE_NONE,
3589 NULL, 0, NULL, HFILL }},
3590 { &hf_ntppriv_mode7_trap_addr6, {
3591 "IPv6 trap addr", "ntp.priv.mode7.trap_address6", FT_IPv6, BASE_NONE,
3592 NULL, 0, NULL, HFILL }},
3593 { &hf_ntppriv_mode7_req, {
3594 "Requests", "ntp.priv.mode7.requests", FT_UINT32, BASE_DEC,
3595 NULL, 0, NULL, HFILL }},
3596 { &hf_ntppriv_mode7_badpkts, {
3597 "Bad packets", "ntp.priv.mode7.bad_packets", FT_UINT32, BASE_DEC,
3598 NULL, 0, NULL, HFILL }},
3599 { &hf_ntppriv_mode7_responses, {
3600 "Responses", "ntp.priv.mode7.responses", FT_UINT32, BASE_DEC,
3601 NULL, 0, NULL, HFILL }},
3602 { &hf_ntppriv_mode7_frags, {
3603 "Fragments", "ntp.priv.mode7.fragments", FT_UINT32, BASE_DEC,
3604 NULL, 0, NULL, HFILL }},
3605 { &hf_ntppriv_mode7_errors, {
3606 "Errors", "ntp.priv.mode7.errors", FT_UINT32, BASE_DEC,
3607 NULL, 0, NULL, HFILL }},
3608 { &hf_ntppriv_mode7_tooshort, {
3609 "Too short packets", "ntp.priv.mode7.too_short", FT_UINT32, BASE_DEC,
3610 NULL, 0, NULL, HFILL }},
3611 { &hf_ntppriv_mode7_inputresp, {
3612 "Responses on input", "ntp.priv.mode7.input_responses", FT_UINT32, BASE_DEC,
3613 NULL, 0, NULL, HFILL }},
3614 { &hf_ntppriv_mode7_inputfrag, {
3615 "Fragments on input", "ntp.priv.mode7.input_fragments", FT_UINT32, BASE_DEC,
3616 NULL, 0, NULL, HFILL }},
3617 { &hf_ntppriv_mode7_inputerr, {
3618 "Errors on input", "ntp.priv.mode7.input_errors", FT_UINT32, BASE_DEC,
3619 NULL, 0, NULL, HFILL }},
3620 { &hf_ntppriv_mode7_badoffset, {
3621 "Non zero offset packets", "ntp.priv.mode7.bad_offset", FT_UINT32, BASE_DEC,
3622 NULL, 0, NULL, HFILL }},
3623 { &hf_ntppriv_mode7_badversion, {
3624 "Unknown version packets", "ntp.priv.mode7.bad_version", FT_UINT32, BASE_DEC,
3625 NULL, 0, NULL, HFILL }},
3626 { &hf_ntppriv_mode7_datatooshort, {
3627 "Data too short", "ntp.priv.mode7.data_too_short", FT_UINT32, BASE_DEC,
3628 NULL, 0, NULL, HFILL }},
3629 { &hf_ntppriv_mode7_badop, {
3630 "Bad op code found", "ntp.priv.mode7.badop", FT_UINT32, BASE_DEC,
3631 NULL, 0, NULL, HFILL }},
3632 { &hf_ntppriv_mode7_asyncmsgs, {
3633 "Async messages", "ntp.priv.mode7.async_messages", FT_UINT32, BASE_DEC,
3634 NULL, 0, NULL, HFILL }},
3635 { &hf_ntppriv_mode7_type, {
3636 "Type", "ntp.priv.mode7.type", FT_UINT8, BASE_DEC,
3637 NULL, 0, NULL, HFILL }},
3638 { &hf_ntppriv_mode7_clock_flags, {
3639 "Clock Flags", "ntp.priv.mode7.clock_flags", FT_UINT8, BASE_DEC,
3640 NULL, 0, NULL, HFILL }},
3641 { &hf_ntppriv_mode7_lastevent, {
3642 "Last event", "ntp.priv.mode7.lastevent", FT_UINT8, BASE_DEC,
3643 NULL, 0, NULL, HFILL }},
3644 { &hf_ntppriv_mode7_currentstatus, {
3645 "Current status", "ntp.priv.mode7.currentstatus", FT_UINT8, BASE_DEC,
3646 NULL, 0, NULL, HFILL }},
3647 { &hf_ntppriv_mode7_polls, {
3648 "Polls", "ntp.priv.mode7.polls", FT_UINT32, BASE_DEC,
3649 NULL, 0, NULL, HFILL }},
3650 { &hf_ntppriv_mode7_noresponse, {
3651 "Noresponse", "ntp.priv.mode7.noresponse", FT_UINT32, BASE_DEC,
3652 NULL, 0, NULL, HFILL }},
3653 { &hf_ntppriv_mode7_badformat, {
3654 "Bad format", "ntp.priv.mode7.badformat", FT_UINT32, BASE_DEC,
3655 NULL, 0, NULL, HFILL }},
3656 { &hf_ntppriv_mode7_baddata, {
3657 "Bad data", "ntp.priv.mode7.baddata", FT_UINT32, BASE_DEC,
3658 NULL, 0, NULL, HFILL }},
3659 { &hf_ntppriv_mode7_timestarted, {
3660 "Time started", "ntp.priv.mode7.timestarted", FT_UINT32, BASE_DEC,
3661 NULL, 0, NULL, HFILL }},
3662 { &hf_ntppriv_mode7_fudgetime1, {
3663 "Fudge time 1", "ntp.priv.mode7.fudgetime1", FT_UINT64, BASE_HEX,
3664 NULL, 0, NULL, HFILL }},
3665 { &hf_ntppriv_mode7_fudgetime2, {
3666 "Fudge time 2", "ntp.priv.mode7.fudgetime2", FT_UINT64, BASE_HEX,
3667 NULL, 0, NULL, HFILL }},
3668 { &hf_ntppriv_mode7_fudgeval1, {
3669 "Fudge val 1", "ntp.priv.mode7.fudgeval1", FT_INT32, BASE_DEC,
3670 NULL, 0, NULL, HFILL }},
3671 { &hf_ntppriv_mode7_fudgeval2, {
3672 "Fudge val 2", "ntp.priv.mode7.fudgeval2", FT_UINT32, BASE_DEC,
3673 NULL, 0, NULL, HFILL }},
3674 { &hf_ntppriv_mode7_kernel_offset, {
3675 "Offset", "ntp.priv.mode7.kernel_offset", FT_INT32, BASE_DEC,
3676 NULL, 0, NULL, HFILL }},
3677 { &hf_ntppriv_mode7_freq, {
3678 "Freq", "ntp.priv.mode7.freq", FT_INT32, BASE_DEC,
3679 NULL, 0, NULL, HFILL }},
3680 { &hf_ntppriv_mode7_stability, {
3681 "Stability (ppm)", "ntp.priv.mode7.stability", FT_UINT32, BASE_DEC,
3682 NULL, 0, NULL, HFILL }},
3683 { &hf_ntppriv_mode7_maxerror, {
3684 "Max error", "ntp.priv.mode7.maxerror", FT_INT32, BASE_DEC,
3685 NULL, 0, NULL, HFILL }},
3686 { &hf_ntppriv_mode7_esterror, {
3687 "Est error", "ntp.priv.mode7.esterror", FT_INT32, BASE_DEC,
3688 NULL, 0, NULL, HFILL }},
3689 { &hf_ntppriv_mode7_status, {
3690 "Status", "ntp.priv.mode7.status", FT_UINT16, BASE_DEC,
3691 NULL, 0, NULL, HFILL }},
3692 { &hf_ntppriv_mode7_shift, {
3693 "Shift", "ntp.priv.mode7.shift", FT_UINT16, BASE_DEC,
3694 NULL, 0, NULL, HFILL }},
3695 { &hf_ntppriv_mode7_constant, {
3696 "Constant", "ntp.priv.mode7.constant", FT_INT32, BASE_DEC,
3697 NULL, 0, NULL, HFILL }},
3698 { &hf_ntppriv_mode7_precision, {
3699 "Precision", "ntp.priv.mode7.precision", FT_INT32, BASE_DEC,
3700 NULL, 0, NULL, HFILL }},
3701 { &hf_ntppriv_mode7_tolerance, {
3702 "tolerance", "ntp.priv.mode7.tolerance", FT_INT32, BASE_DEC,
3703 NULL, 0, NULL, HFILL }},
3704 { &hf_ntppriv_mode7_ppsfreq, {
3705 "ppsfreq", "ntp.priv.mode7.ppsfreq", FT_INT32, BASE_DEC,
3706 NULL, 0, NULL, HFILL }},
3707 { &hf_ntppriv_mode7_jitter, {
3708 "jitter", "ntp.priv.mode7.jitter", FT_INT32, BASE_DEC,
3709 NULL, 0, NULL, HFILL }},
3710 { &hf_ntppriv_mode7_stabil, {
3711 "stabil", "ntp.priv.mode7.stabil", FT_INT32, BASE_DEC,
3712 NULL, 0, NULL, HFILL }},
3713 { &hf_ntppriv_mode7_jitcnt, {
3714 "jitcnt", "ntp.priv.mode7.jitcnt", FT_INT32, BASE_DEC,
3715 NULL, 0, NULL, HFILL }},
3716 { &hf_ntppriv_mode7_calcnt, {
3717 "calcnt", "ntp.priv.mode7.calcnt", FT_INT32, BASE_DEC,
3718 NULL, 0, NULL, HFILL }},
3719 { &hf_ntppriv_mode7_errcnt, {
3720 "errcnt", "ntp.priv.mode7.errcnt", FT_INT32, BASE_DEC,
3721 NULL, 0, NULL, HFILL }},
3722 { &hf_ntppriv_mode7_stbcnt, {
3723 "stbcnt", "ntp.priv.mode7.stbcnt", FT_INT32, BASE_DEC,
3724 NULL, 0, NULL, HFILL }},
3725 { &hf_ntppriv_mode7_last_offset, {
3726 "Last offset", "ntp.priv.mode7.last_offset", FT_INT64, BASE_DEC,
3727 NULL, 0, NULL, HFILL }},
3728 { &hf_ntppriv_mode7_drift_comp, {
3729 "Drift comp", "ntp.priv.mode7.drift_comp", FT_INT64, BASE_DEC,
3730 NULL, 0, NULL, HFILL }},
3731 { &hf_ntppriv_mode7_compliance, {
3732 "Compliance", "ntp.priv.mode7.compliance", FT_UINT32, BASE_DEC,
3733 NULL, 0, NULL, HFILL }},
3734 { &hf_ntppriv_mode7_watchdog_timer, {
3735 "Watchdog timer", "ntp.priv.mode7.watchdog_timer", FT_UINT32, BASE_DEC,
3736 NULL, 0, NULL, HFILL }},
3737 { &hf_ntppriv_mode7_poll32, {
3738 "Poll", "ntp.priv.mode7.poll", FT_UINT32, BASE_DEC,
3739 NULL, 0, NULL, HFILL }},
3740 { &hf_ntppriv_mode7_sys_flags8, {
3741 "Flags", "ntp.priv.mode7.sys.flags8", FT_UINT8, BASE_HEX,
3742 NULL, 0xFF, NULL, HFILL }},
3743 { &hf_ntppriv_mode7_denied, {
3744 "Denied", "ntp.priv.mode7.denied", FT_UINT32, BASE_DEC,
3745 NULL, 0, NULL, HFILL }},
3746 { &hf_ntppriv_mode7_oldversion, {
3747 "Old version", "ntp.priv.mode7.oldversion", FT_UINT32, BASE_DEC,
3748 NULL, 0, NULL, HFILL }},
3749 { &hf_ntppriv_mode7_newversion, {
3750 "New version", "ntp.priv.mode7.newversion", FT_UINT32, BASE_DEC,
3751 NULL, 0, NULL, HFILL }},
3752 { &hf_ntppriv_mode7_badlength, {
3753 "Bad length", "ntp.priv.mode7.badlength", FT_UINT32, BASE_DEC,
3754 NULL, 0, NULL, HFILL }},
3755 { &hf_ntppriv_mode7_limitrejected, {
3756 "Limit rejected", "ntp.priv.mode7.limitrejected", FT_UINT32, BASE_DEC,
3757 NULL, 0, NULL, HFILL }},
3758 { &hf_ntppriv_mode7_lamport, {
3759 "Lamport violation", "ntp.priv.mode7.lamport", FT_UINT32, BASE_DEC,
3760 NULL, 0, NULL, HFILL }},
3761 { &hf_ntppriv_mode7_tsrounding, {
3762 "Timestamp rounding error", "ntp.priv.mode7.tsrounding", FT_UINT32, BASE_DEC,
3763 NULL, 0, NULL, HFILL }},
3764 { &hf_ntppriv_mode7_totalmem, {
3765 "Total memory", "ntp.priv.mode7.totalmem", FT_UINT16, BASE_DEC,
3766 NULL, 0, NULL, HFILL }},
3767 { &hf_ntppriv_mode7_freemem, {
3768 "Free memory", "ntp.priv.mode7.freemem", FT_UINT16, BASE_DEC,
3769 NULL, 0, NULL, HFILL }},
3770 { &hf_ntppriv_mode7_findpeer_calls, {
3771 "Find peer calls", "ntp.priv.mode7.findpeer_calls", FT_UINT32, BASE_DEC,
3772 NULL, 0, NULL, HFILL }},
3773 { &hf_ntppriv_mode7_allocations, {
3774 "Allocations", "ntp.priv.mode7.allocations", FT_UINT32, BASE_DEC,
3775 NULL, 0, NULL, HFILL }},
3776 { &hf_ntppriv_mode7_demobilizations, {
3777 "Demobilizations", "ntp.priv.mode7.demobilizations", FT_UINT32, BASE_DEC,
3778 NULL, 0, NULL, HFILL }},
3779 { &hf_ntppriv_mode7_hashcount, {
3780 "Hashcount", "ntp.priv.mode7.hashcount", FT_BYTES, BASE_NONE,
3781 NULL, 0, NULL, HFILL }},
3782 { &hf_ntppriv_mode7_totalrecvbufs, {
3783 "Toal receive buffer", "ntp.priv.mode7.totalrecvbufs", FT_UINT16, BASE_DEC,
3784 NULL, 0, NULL, HFILL }},
3785 { &hf_ntppriv_mode7_freerecvbufs, {
3786 "Free receive buffer", "ntp.priv.mode7.freerecvbufs", FT_UINT16, BASE_DEC,
3787 NULL, 0, NULL, HFILL }},
3788 { &hf_ntppriv_mode7_fullrecvbufs, {
3789 "Full receive buffer", "ntp.priv.mode7.fullrecvbufs", FT_UINT16, BASE_DEC,
3790 NULL, 0, NULL, HFILL }},
3791 { &hf_ntppriv_mode7_lowwater, {
3792 "Low water", "ntp.priv.mode7.lowwater", FT_UINT16, BASE_DEC,
3793 NULL, 0, NULL, HFILL }},
3794 { &hf_ntppriv_mode7_dropped, {
3795 "Dropped packets", "ntp.priv.mode7.dropped", FT_UINT32, BASE_DEC,
3796 NULL, 0, NULL, HFILL }},
3797 { &hf_ntppriv_mode7_ignored, {
3798 "Ignored packets", "ntp.priv.mode7.ignored", FT_UINT32, BASE_DEC,
3799 NULL, 0, NULL, HFILL }},
3800 { &hf_ntppriv_mode7_received, {
3801 "Received packets", "ntp.priv.mode7.received", FT_UINT32, BASE_DEC,
3802 NULL, 0, NULL, HFILL }},
3803 { &hf_ntppriv_mode7_notsent, {
3804 "Not sent packets", "ntp.priv.mode7.notsent", FT_UINT32, BASE_DEC,
3805 NULL, 0, NULL, HFILL }},
3806 { &hf_ntppriv_mode7_interrupts, {
3807 "Interrupts", "ntp.priv.mode7.interrupts", FT_UINT32, BASE_DEC,
3808 NULL, 0, NULL, HFILL }},
3809 { &hf_ntppriv_mode7_int_received, {
3810 "Received by interrupt handler", "ntp.priv.mode7.int_received", FT_UINT32, BASE_DEC,
3811 NULL, 0, NULL, HFILL }},
3812 { &hf_ntppriv_mode7_alarms, {
3813 "Alarms", "ntp.priv.mode7.alarms", FT_UINT32, BASE_DEC,
3814 NULL, 0, NULL, HFILL }},
3815 { &hf_ntppriv_mode7_overflows, {
3816 "Overflows", "ntp.priv.mode7.overflows", FT_UINT32, BASE_DEC,
3817 NULL, 0, NULL, HFILL }},
3818 { &hf_ntppriv_mode7_xmtcalls, {
3819 "Transmitted calls", "ntp.priv.mode7.xmtcalls", FT_UINT32, BASE_DEC,
3820 NULL, 0, NULL, HFILL }},
3821 { &hf_ntppriv_mode7_rflags, {
3822 "Rflags", "ntp.priv.mode7.rflags", FT_UINT16, BASE_DEC,
3823 NULL, 0, NULL, HFILL }},
3824 { &hf_ntppriv_mode7_mflags, {
3825 "Mflags", "ntp.priv.mode7.mflags", FT_UINT16, BASE_DEC,
3826 NULL, 0, NULL, HFILL }},
3827 { &hf_ntppriv_mode7_int_name, {
3828 "Interface name", "ntp.priv.mode7.int_name", FT_STRING, BASE_NONE,
3829 NULL, 0, NULL, HFILL }},
3830 { &hf_ntppriv_mode7_int_flags, {
3831 "Interface flags", "ntp.priv.mode7.int_flags", FT_INT32, BASE_DEC,
3832 NULL, 0, NULL, HFILL }},
3833 { &hf_ntppriv_mode7_last_ttl, {
3834 "Last TTL specified", "ntp.priv.mode7.last_ttl", FT_INT32, BASE_DEC,
3835 NULL, 0, NULL, HFILL }},
3836 { &hf_ntppriv_mode7_num_mcast, {
3837 "Numer multicast sockets", "ntp.priv.mode7.num_mcast", FT_INT32, BASE_DEC,
3838 NULL, 0, NULL, HFILL }},
3839 { &hf_ntppriv_mode7_uptime, {
3840 "Uptime", "ntp.priv.mode7.uptime", FT_INT32, BASE_DEC,
3841 NULL, 0, NULL, HFILL }},
3842 { &hf_ntppriv_mode7_scopeid, {
3843 "Scopeid", "ntp.priv.mode7.scopeid", FT_UINT32, BASE_DEC,
3844 NULL, 0, NULL, HFILL }},
3845 { &hf_ntppriv_mode7_ifindex, {
3846 "Ifindex", "ntp.priv.mode7.ifindex", FT_UINT32, BASE_DEC,
3847 NULL, 0, NULL, HFILL }},
3848 { &hf_ntppriv_mode7_ifnum, {
3849 "Ifnum", "ntp.priv.mode7.ifnum", FT_UINT32, BASE_DEC,
3850 NULL, 0, NULL, HFILL }},
3851 { &hf_ntppriv_mode7_peercnt, {
3852 "Peer count", "ntp.priv.mode7.peercnt", FT_UINT32, BASE_DEC,
3853 NULL, 0, NULL, HFILL }},
3854 { &hf_ntppriv_mode7_family, {
3855 "Address family", "ntp.priv.mode7.family", FT_UINT16, BASE_DEC,
3856 NULL, 0, NULL, HFILL }},
3857 { &hf_ntppriv_mode7_ignore_pkt, {
3858 "Ignore packets", "ntp.priv.mode7.ignore_pkts", FT_UINT8, BASE_DEC,
3859 NULL, 0, NULL, HFILL }},
3860 { &hf_ntppriv_mode7_action, {
3861 "Action", "ntp.priv.mode7.action", FT_UINT8, BASE_DEC,
3862 VALS(priv_mode7_int_action), 0, NULL, HFILL }},
3863 { &hf_ntppriv_mode7_nvalues, {
3864 "Nvalues", "ntp.priv.mode7.nvalues", FT_UINT8, BASE_DEC,
3865 NULL, 0, NULL, HFILL }},
3866 { &hf_ntppriv_mode7_ntimes, {
3867 "Ntimes", "ntp.priv.mode7.ntimes", FT_UINT8, BASE_DEC,
3868 NULL, 0, NULL, HFILL }},
3869 { &hf_ntppriv_mode7_svalues, {
3870 "Svalues", "ntp.priv.mode7.svalues", FT_UINT16, BASE_DEC,
3871 NULL, 0, NULL, HFILL }},
3872 { &hf_ntppriv_mode7_stimes, {
3873 "Stimes", "ntp.priv.mode7.stimes", FT_UINT32, BASE_DEC,
3874 NULL, 0, NULL, HFILL }},
3875 { &hf_ntppriv_mode7_values, {
3876 "Values", "ntp.priv.mode7.values", FT_BYTES, BASE_NONE,
3877 NULL, 0, NULL, HFILL }},
3878 { &hf_ntppriv_mode7_times, {
3879 "Times", "ntp.priv.mode7.times", FT_BYTES, BASE_NONE,
3880 NULL, 0, NULL, HFILL }},
3881 { &hf_ntppriv_mode7_which, {
3882 "Which", "ntp.priv.mode7.which", FT_UINT32, BASE_DEC,
3883 NULL, 0, NULL, HFILL }},
3884 { &hf_ntppriv_mode7_fudgetime, {
3885 "Fudgetime", "ntp.priv.mode7.fudgetime", FT_UINT64, BASE_DEC,
3886 NULL, 0, NULL, HFILL }},
3887 { &hf_ntppriv_mode7_fudgeval_flags, {
3888 "Fudgeval flags", "ntp.priv.mode7.fudgeval_flags", FT_UINT32, BASE_DEC,
3889 NULL, 0, NULL, HFILL }},
3890 { &hf_ntppriv_mode7_ippeerlimit, {
3891 "IP peer limit", "ntp.priv.mode7.ippeerlimit", FT_INT16, BASE_DEC,
3892 NULL, 0, NULL, HFILL }},
3893 { &hf_ntppriv_mode7_restrict_flags, {
3894 "Restrict flags", "ntp.priv.mode7.restrict_flags", FT_UINT16, BASE_DEC,
3895 NULL, 0, NULL, HFILL }},
3896 /* Todo */
3899 static int *ett[] = {
3900 &ett_ntp,
3901 &ett_ntp_flags,
3902 &ett_ntp_ext,
3903 &ett_ntp_ext_flags,
3904 &ett_ntp_ext_nts,
3905 &ett_ntpctrl_flags2,
3906 &ett_ntpctrl_status,
3907 &ett_ntpctrl_data,
3908 &ett_ntpctrl_item,
3909 &ett_ntppriv_auth_seq,
3910 &ett_mode7_item,
3911 &ett_ntppriv_peer_list_flags,
3912 &ett_ntppriv_config_flags,
3913 &ett_ntppriv_sys_flag_flags,
3914 &ett_ntppriv_reset_stats_flags,
3915 &ett_ntp_authenticator
3918 static ei_register_info ei[] = {
3919 { &ei_ntp_ext_invalid_length, { "ntp.ext.invalid_length", PI_PROTOCOL, PI_WARN, "Extension invalid length", EXPFILL }},
3920 { &ei_ntp_ext_historic, { "ntp.ext.historic", PI_DEPRECATED, PI_NOTE, "Historic extension type", EXPFILL }},
3923 expert_module_t* expert_ntp;
3925 proto_ntp = proto_register_protocol("Network Time Protocol", "NTP", "ntp");
3926 proto_register_field_array(proto_ntp, hf, array_length(hf));
3927 proto_register_subtree_array(ett, array_length(ett));
3928 expert_ntp = expert_register_protocol(proto_ntp);
3929 expert_register_field_array(expert_ntp, ei, array_length(ei));
3931 ntp_handle = register_dissector("ntp", dissect_ntp, proto_ntp);
3933 init_parser();
3936 void
3937 proto_reg_handoff_ntp(void)
3939 dissector_add_uint_with_preference("udp.port", UDP_PORT_NTP, ntp_handle);
3940 dissector_add_uint_with_preference("tcp.port", TCP_PORT_NTP, ntp_handle);
3944 * Editor modelines - https://www.wireshark.org/tools/modelines.html
3946 * Local variables:
3947 * c-basic-offset: 8
3948 * tab-width: 8
3949 * indent-tabs-mode: t
3950 * End:
3952 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
3953 * :indentSize=8:tabSize=8:noTabs=false: