aboutsummaryrefslogtreecommitdiffstats
path: root/packet-ntp.c
blob: 69b33f4ae55761b2c4c0087361fafe9113a67bdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
/* packet-ntp.c
 * Routines for NTP packet dissection
 * Copyright 1999, Nathan Neulinger <nneul@umr.edu>
 *
 * $Id: packet-ntp.c,v 1.32 2001/12/10 00:25:31 guy Exp $
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@ethereal.com>
 * Copyright 1998 Gerald Combs
 *
 * Copied from packet-tftp.c
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdio.h>

#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif

#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif

#include <string.h>
#include <time.h>
#include <math.h>
#include <glib.h>

#ifdef NEED_SNPRINTF_H
# include "snprintf.h"
#endif

#include "packet.h"
#include "resolv.h"
#include "packet-ntp.h"

/*
 * Dissecting NTP packets version 3 and 4 (RFC2030, RFC1769, RFC1361,
 * RFC1305).
 *
 * Those packets have simple structure:
 *                      1                   2                   3
 *  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
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |LI | VN  |Mode |    Stratum    |     Poll      |   Precision   |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                          Root Delay                           |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                       Root Dispersion                         |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                    Reference Identifier                       |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                   Reference Timestamp (64)                    |
 * |                                                               |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                   Originate Timestamp (64)                    |
 * |                                                               |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                    Receive Timestamp (64)                     |
 * |                                                               |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                    Transmit Timestamp (64)                    |
 * |                                                               |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                 Key Identifier (optional) (32)                |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                 Message Digest (optional) (128)               |
 * |                                                               |
 * |                                                               |
 * |                                                               |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * NTP timestamps are represented as a 64-bit unsigned fixed-point number,
 * in seconds relative to 0h on 1 January 1900. The integer part is in the
 * first 32 bits and the fraction part in the last 32 bits.
 */

#define UDP_PORT_NTP	123
#define TCP_PORT_NTP	123

/* Leap indicator, 2bit field is used to warn of a inserted/deleted
 * second, or to alarm loosed synchronization.
 */
#define NTP_LI_MASK	0xC0

#define NTP_LI_NONE	0
#define NTP_LI_61	1
#define NTP_LI_59	2
#define NTP_LI_ALARM	3

static const value_string li_types[] = {
	{ NTP_LI_NONE,	"no warning" },
	{ NTP_LI_61,	"last minute has 61 seconds" },
	{ NTP_LI_59,	"last minute has 59 seconds" },
	{ NTP_LI_ALARM,	"alarm condition (clock not synchronized)" },
	{ 0,		NULL}
};

/* Version info, 3bit field informs about NTP version used in particular
 * packet. According to rfc2030, version info could be only 3 or 4, but I
 * have noticed packets with 1 or even 6 as version numbers. They are
 * produced as a result of ntptrace command. Are those packets mailformed
 * on purpose? I don't know yet, probably some browsing through ntp sources
 * would help. My solution is to put them as reserved for now.
 */
#define NTP_VN_MASK	0x38

static const value_string ver_nums[] = {
	{ 0,	"reserved" },
	{ 1,	"reserved" },
	{ 2,	"reserved" },
	{ 3,	"NTP Version 3" },
	{ 4,	"NTP Version 4" },
	{ 5,	"reserved" },
	{ 6,	"reserved" },
	{ 7,	"reserved" },
	{ 0,	NULL}
};

/* Mode, 3bit field representing mode of comunication.
 */
#define NTP_MODE_MASK   7

#define NTP_MODE_RSV	0
#define NTP_MODE_SYMACT	1
#define NTP_MODE_SYMPAS	2
#define NTP_MODE_CLIENT	3
#define NTP_MODE_SERVER	4
#define NTP_MODE_BCAST	5
#define NTP_MODE_CTRL	6
#define NTP_MODE_PRIV	7

static const value_string mode_types[] = {
	{ NTP_MODE_RSV,		"reserved" },
	{ NTP_MODE_SYMACT,	"symmetric active" },
	{ NTP_MODE_SYMPAS,	"symmetric passive" },
	{ NTP_MODE_CLIENT,	"client" },
	{ NTP_MODE_SERVER,	"server" },
	{ NTP_MODE_BCAST,	"broadcast" },
	{ NTP_MODE_CTRL,	"reserved for NTP control message"},
	{ NTP_MODE_PRIV,	"reserved for private use" },
	{ 0,		NULL}
};

/* According to rfc, primary (stratum-0 and stratum-1) servers should set
 * their Reference Clock ID (4bytes field) according to following table:
 */
static const struct {
	char *id;
	char *data;
} primary_sources[] = {
	{ "LOCL",	"uncalibrated local clock" },
	{ "PPS\0",	"atomic clock or other pulse-per-second source" },
	{ "ACTS",	"NIST dialup modem service" },
	{ "USNO",	"USNO modem service" },
	{ "PTB\0",	"PTB (Germany) modem service" },
	{ "TDF\0",	"Allouis (France) Radio 164 kHz" },
	{ "DCF\0",	"Mainflingen (Germany) Radio 77.5 kHz" },
	{ "MSF\0",	"Rugby (UK) Radio 60 kHz" },
	{ "WWV\0",	"Ft. Collins (US) Radio 2.5, 5, 10, 15, 20 MHz" },
	{ "WWVB",	"Boulder (US) Radio 60 kHz" },
	{ "WWVH",	"Kaui Hawaii (US) Radio 2.5, 5, 10, 15 MHz" },
	{ "CHU\0",	"Ottawa (Canada) Radio 3330, 7335, 14670 kHz" },
	{ "LORC",	"LORAN-C radionavigation system" },
	{ "OMEG",	"OMEGA radionavigation system" },
	{ "GPS\0",	"Global Positioning Service" },
	{ "GOES",	"Geostationary Orbit Environment Satellite" },
	{ "DCN\0",	"DCN routing protocol" },
	{ "NIST",	"NIST public modem" },
	{ "TSP\0",	"TSP time protocol" },
	{ "DTS\0",	"Digital Time Service" },
	{ "ATOM",	"Atomic clock (calibrated)" },
	{ "VLF\0",	"VLF radio (OMEGA,, etc.)" },
	{ "IRIG",	"IRIG-B timecode" },
	{ "1PPS",	"External 1 PPS input" },
	{ "FREE",	"(Internal clock)" },
	{ NULL,		NULL}
};

static int proto_ntp = -1;
static int hf_ntp_flags = -1;
static int hf_ntp_flags_li = -1;
static int hf_ntp_flags_vn = -1;
static int hf_ntp_flags_mode = -1;
static int hf_ntp_stratum = -1;
static int hf_ntp_ppoll = -1;
static int hf_ntp_precision = -1;
static int hf_ntp_rootdelay = -1;
static int hf_ntp_rootdispersion = -1;
static int hf_ntp_refid = -1;
static int hf_ntp_reftime = -1;
static int hf_ntp_org = -1;
static int hf_ntp_rec = -1;
static int hf_ntp_xmt = -1;
static int hf_ntp_keyid = -1;
static int hf_ntp_mac = -1;

static gint ett_ntp = -1;
static gint ett_ntp_flags = -1;

/* ntp_fmt_ts - converts NTP timestamp to human readable string.
 * reftime - 64bit timestamp (IN)
 * buff - string buffer for result (OUT)
 * returns pointer to filled buffer.
 */
static char *
ntp_fmt_ts(const guint8 *reftime, char* buff)
{
	guint32 tempstmp, tempfrac;
	time_t temptime;
	struct tm *bd;
	double fractime;

	tempstmp = pntohl(&reftime[0]);
	tempfrac = pntohl(&reftime[4]);
	if ((tempstmp == 0) && (tempfrac == 0)) {
		strcpy (buff, "NULL");
		return buff;
	} else {
		temptime = tempstmp - (guint32) NTP_BASETIME;
		bd = gmtime(&temptime);
		if (bd != NULL) {
			fractime = bd->tm_sec + tempfrac / 4294967296.0;
			snprintf(buff, NTP_TS_SIZE,
				 "%04d-%02d-%02d %02d:%02d:%07.4f UTC",
				 bd->tm_year + 1900, bd->tm_mon + 1, bd->tm_mday,
				 bd->tm_hour, bd->tm_min, fractime);
		} else
			strncpy(buff, "Not representable", NTP_TS_SIZE);
	}
	return buff;
}
		
/* dissect_ntp - dissects NTP packet data
 * tvb - tvbuff for packet data (IN)
 * pinfo - packet info
 * proto_tree - resolved protocol tree
 */
static void
dissect_ntp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	proto_tree      *ntp_tree, *flags_tree;
	proto_item	*ti, *tf;
	guint8		flags;
	guint8		stratum;
	guint8		ppoll;
	gint8		precision;
	double		rootdelay;
	double		rootdispersion;
	const guint8	*refid;
	const guint8	*reftime;
	const guint8	*org;
	const guint8	*rec;
	const guint8	*xmt;
	gchar		buff[NTP_TS_SIZE];
	int		i;

	if (check_col(pinfo->cinfo, COL_PROTOCOL))
		col_set_str(pinfo->cinfo, COL_PROTOCOL, "NTP");

	if (check_col(pinfo->cinfo, COL_INFO))
		col_set_str(pinfo->cinfo, COL_INFO, "NTP");

	if (tree) {
		/* Adding NTP item and subtree */
		ti = proto_tree_add_item(tree, proto_ntp, tvb, 0,
		    tvb_length(tvb), FALSE);
		ntp_tree = proto_item_add_subtree(ti, ett_ntp);

		flags = tvb_get_guint8(tvb, 0);
		tf = proto_tree_add_uint(ntp_tree, hf_ntp_flags, tvb, 0, 1,
		    flags);

		/* Adding flag subtree and items */
		flags_tree = proto_item_add_subtree(tf, ett_ntp_flags);
		proto_tree_add_uint(flags_tree, hf_ntp_flags_li, tvb, 0, 1,
					   flags);
		proto_tree_add_uint(flags_tree, hf_ntp_flags_vn, tvb, 0, 1,
					   flags);
		proto_tree_add_uint(flags_tree, hf_ntp_flags_mode, tvb, 0, 1,
					   flags);

		/* Stratum, 1byte field represents distance from primary source
		 */
		stratum = tvb_get_guint8(tvb, 1);
		if (stratum == 0) {
			strcpy (buff, "Peer Clock Stratum: unspecified or unavailable (%u)");
		} else if (stratum == 1) {
			strcpy (buff, "Peer Clock Stratum: primary reference (%u)");
		} else if ((stratum >= 2) && (stratum <= 15)) {
			strcpy (buff, "Peer Clock Stratum: secondary reference (%u)");
		} else {
			strcpy (buff, "Peer Clock Stratum: reserved: %u");
		}
		proto_tree_add_uint_format(ntp_tree, hf_ntp_stratum, tvb, 1, 1,
					   stratum, buff, stratum);
		/* Poll interval, 1byte field indicating the maximum interval
		 * between successive messages, in seconds to the nearest
		 * power of two.
		 */
		ppoll = tvb_get_guint8(tvb, 2);
		proto_tree_add_uint_format(ntp_tree, hf_ntp_ppoll, tvb, 2, 1,
					   ppoll,
					   (((ppoll >= 4) && (ppoll <= 16)) ? 
					   "Peer Polling Interval: %u (%u sec)" :
					   "Peer Polling Interval: invalid (%u)"),
					   ppoll,
					   1 << ppoll);

		/* Precision, 1byte field indicating the precision of the
		 * local clock, in seconds to the nearest power of two.
		 */
		precision = tvb_get_guint8(tvb, 3);
		proto_tree_add_uint_format(ntp_tree, hf_ntp_precision, tvb, 3, 1,
					   precision,
					   "Peer Clock Precision: %8.6f sec",
					   pow(2, precision));

		/* Root Delay is a 32-bit signed fixed-point number indicating
		 * the total roundtrip delay to the primary reference source,
		 * in seconds with fraction point between bits 15 and 16.
		 */
		rootdelay = ((gint16)tvb_get_ntohs(tvb, 4)) +
				(tvb_get_ntohs(tvb, 6) / 65536.0);
		proto_tree_add_double_format(ntp_tree, hf_ntp_rootdelay, tvb, 4, 4,
					   rootdelay,
					   "Root Delay: %9.4f sec",
					   rootdelay);

		/* Root Dispersion, 32-bit unsigned fixed-point number indicating
		 * the nominal error relative to the primary reference source, in
		 * seconds with fraction point between bits 15 and 16.
		 */
		rootdispersion = ((gint16)tvb_get_ntohs(tvb, 8)) +
					(tvb_get_ntohs(tvb, 10) / 65536.0);
		proto_tree_add_double_format(ntp_tree, hf_ntp_rootdispersion, tvb, 8, 4,
					   rootdispersion,
					   "Clock Dispersion: %9.4f sec",
					   rootdispersion);

		/* Now, there is a problem with secondary servers.  Standards
		 * asks from stratum-2 - stratum-15 servers to set this to the
		 * low order 32 bits of the latest transmit timestamp of the
		 * reference source.
		 * But, all V3 and V4 servers set this to IP adress of their
		 * higher level server. My decision was to resolve this address.
		 */
		refid = tvb_get_ptr(tvb, 12, 4);
		if (stratum <= 1) {
			snprintf (buff, sizeof buff,
			    "Unindentified reference source '%.4s'",
			    refid);
			for (i = 0; primary_sources[i].id; i++) {
				if (memcmp (refid, primary_sources[i].id,
				    4) == 0) {
					strcpy (buff, primary_sources[i].data);
					break;
				}
			}
		} else {
			buff[sizeof(buff) - 1] = '\0';
			strncpy (buff, get_hostname (htonl(tvb_get_ntohl(tvb, 12))),
			    sizeof(buff));
			if (buff[sizeof(buff) - 1] != '\0')
				strcpy(&buff[sizeof(buff) - 4], "...");
		}
		proto_tree_add_bytes_format(ntp_tree, hf_ntp_refid, tvb, 12, 4,
					   refid,
					   "Reference Clock ID: %s", buff);

		/* Reference Timestamp: This is the time at which the local clock was
		 * last set or corrected.
		 */
		reftime = tvb_get_ptr(tvb, 16, 8);
		proto_tree_add_bytes_format(ntp_tree, hf_ntp_reftime, tvb, 16, 8,
					   reftime,
				           "Reference Clock Update Time: %s", 
					   ntp_fmt_ts(reftime, buff));

		/* Originate Timestamp: This is the time at which the request departed
		 * the client for the server.
		 */
		org = tvb_get_ptr(tvb, 24, 8);
		proto_tree_add_bytes_format(ntp_tree, hf_ntp_org, tvb, 24, 8,
					   org,
				           "Originate Time Stamp: %s", 
					   ntp_fmt_ts(org, buff));
		/* Receive Timestamp: This is the time at which the request arrived at
		 * the server.
		 */
		rec = tvb_get_ptr(tvb, 32, 8);
		proto_tree_add_bytes_format(ntp_tree, hf_ntp_rec, tvb, 32, 8,
					   rec,
				           "Receive Time Stamp: %s", 
					   ntp_fmt_ts(rec, buff));
		/* Transmit Timestamp: This is the time at which the reply departed the
		 * server for the client.
		 */
		xmt = tvb_get_ptr(tvb, 40, 8);
		proto_tree_add_bytes_format(ntp_tree, hf_ntp_xmt, tvb, 40, 8,
					   xmt,
				           "Transmit Time Stamp: %s", 
					   ntp_fmt_ts(xmt, buff));

		/* When the NTP authentication scheme is implemented, the
		 * Key Identifier and Message Digest fields contain the
		 * message authentication code (MAC) information defined in
		 * Appendix C of RFC-1305. Will print this as hex code for now.
		 */
		if ( tvb_reported_length_remaining(tvb, 48) >= 4 )
			proto_tree_add_item(ntp_tree, hf_ntp_keyid, tvb, 48, 4,
					   FALSE);
		if ( tvb_reported_length_remaining(tvb, 52) > 0 )
			proto_tree_add_item(ntp_tree, hf_ntp_mac, tvb, 52,
					   tvb_reported_length_remaining(tvb, 52),
					   FALSE);

	}
}

void
proto_register_ntp(void)
{
	static hf_register_info hf[] = {
		{ &hf_ntp_flags, {	
			"Flags", "ntp.flags", FT_UINT8, BASE_HEX, 
			NULL, 0, "Flags (Leap/Version/Mode)", HFILL }},
		{ &hf_ntp_flags_li, {
			"Leap Indicator", "ntp.flags.li", FT_UINT8, BASE_DEC,
			VALS(li_types), NTP_LI_MASK, "Leap Indicator", HFILL }},
		{ &hf_ntp_flags_vn, {
			"Version number", "ntp.flags.vn", FT_UINT8, BASE_DEC,
			VALS(ver_nums), NTP_VN_MASK, "Version number", HFILL }},
		{ &hf_ntp_flags_mode, {
			"Mode", "ntp.flags.mode", FT_UINT8, BASE_DEC,
			VALS(mode_types), NTP_MODE_MASK, "Mode", HFILL }},
		{ &hf_ntp_stratum, {	
			"Peer Clock Stratum", "ntp.stratum", FT_UINT8, BASE_DEC,
			NULL, 0, "Peer Clock Stratum", HFILL }},
		{ &hf_ntp_ppoll, {	
			"Peer Polling Interval", "ntp.ppoll", FT_UINT8, BASE_DEC, 
			NULL, 0, "Peer Polling Interval", HFILL }},
		{ &hf_ntp_precision, {	
			"Peer Clock Precision", "ntp.precision", FT_UINT8, BASE_DEC, 
			NULL, 0, "Peer Clock Precision", HFILL }},
		{ &hf_ntp_rootdelay, {	
			"Root Delay", "ntp.rootdelay", FT_DOUBLE, BASE_DEC,
			NULL, 0, "Root Delay", HFILL }},
		{ &hf_ntp_rootdispersion, {	
			"Clock Dispersion", "ntp.rootdispersion", FT_DOUBLE, BASE_DEC, 
			NULL, 0, "Clock Dispersion", HFILL }},
		{ &hf_ntp_refid, {	
			"Reference Clock ID", "ntp.refid", FT_BYTES, BASE_NONE, 
			NULL, 0, "Reference Clock ID", HFILL }},
		{ &hf_ntp_reftime, {	
			"Reference Clock Update Time", "ntp.reftime", FT_BYTES, BASE_NONE, 
			NULL, 0, "Reference Clock Update Time", HFILL }},
		{ &hf_ntp_org, {	
			"Originate Time Stamp", "ntp.org", FT_BYTES, BASE_NONE, 
			NULL, 0, "Originate Time Stamp", HFILL }},
		{ &hf_ntp_rec, {	
			"Receive Time Stamp", "ntp.rec", FT_BYTES, BASE_NONE, 
			NULL, 0, "Receive Time Stamp", HFILL }},
		{ &hf_ntp_xmt, {	
			"Transmit Time Stamp", "ntp.xmt", FT_BYTES, BASE_NONE, 
			NULL, 0, "Transmit Time Stamp", HFILL }},
		{ &hf_ntp_keyid, {	
			"Key ID", "ntp.keyid", FT_BYTES, BASE_HEX, 
			NULL, 0, "Key ID", HFILL }},
		{ &hf_ntp_mac, {	
			"Message Authentication Code", "ntp.mac", FT_BYTES, BASE_HEX, 
			NULL, 0, "Message Authentication Code", HFILL }},
        };
	static gint *ett[] = {
		&ett_ntp,
		&ett_ntp_flags,
	};

	proto_ntp = proto_register_protocol("Network Time Protocol", "NTP",
	    "ntp");
	proto_register_field_array(proto_ntp, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));
}

void
proto_reg_handoff_ntp(void)
{
	dissector_handle_t ntp_handle;

	ntp_handle = create_dissector_handle(dissect_ntp, proto_ntp);
	dissector_add("udp.port", UDP_PORT_NTP, ntp_handle);
	dissector_add("tcp.port", TCP_PORT_NTP, ntp_handle);
}