aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/acn/packet-acn.c
blob: ebaa3570cb54979e31ce6303d6573e73b3425ec4 (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
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
/* packet-acn.c
 * Routines for ACN packet disassembly
 *
 * $Id: packet-acn.c,v 1.1 2003/10/14 01:18:11 guy Exp $
 *
 * Copyright (c) 2003 by Erwin Rol <erwin@erwinrol.com>
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@ethereal.com>
 * Copyright 1999 Gerald Combs
 *
 * 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.
 */

/* Include files */

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

#include "plugins/plugin_api.h"

#include "moduleinfo.h"
#include "acn.h"

#include <stdio.h>
#include <stdlib.h>
#include <gmodule.h>
#include <ctype.h>
#include <time.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/resolv.h>
#include "prefs.h"
#include <epan/strutil.h>

#include "plugins/plugin_api_defs.h"

/* Define version if we are not building ethereal statically */

#ifndef ENABLE_STATIC
G_MODULE_EXPORT const gchar version[] = VERSION;
#endif

/*
 * See
 *
 *	http://www.esta.org/tsp/E1-17inst.htm
 */

static const value_string acn_proto_vals[] = {
	{ ACN_PDU_PROTO_UNKNOWN,	"ACN Unknown Protocol"},
	{ ACN_PDU_PROTO_SDT,		"ACN SDT Protocol" },
	{ ACN_PDU_PROTO_DMP,		"ACN DMP Protocol" },
	{ 0,				NULL }
};

static const value_string acn_sdt_type_vals[] = {
	{ ACN_SDT_TYPE_UNKNOWN,		"ACN SDT Unknown Type"},
	{ ACN_SDT_TYPE_RELSEQDATA,	"ACN SDT RELSEQDATA"},
	{ ACN_SDT_TYPE_UNRELSEQDATA,	"ACN SDT UNRELSEQDATA"},
	{ ACN_SDT_TYPE_UNSEQDATA,	"ACN SDT UNSEQDATA"},
	{ ACN_SDT_TYPE_JOIN,		"ACN SDT JOIN"},
	{ ACN_SDT_TYPE_TRANSFER,	"ACN SDT TRANSFER"},
	{ ACN_SDT_TYPE_JOINREF,		"ACN SDT JOINREF"},
	{ ACN_SDT_TYPE_JOINACC,		"ACN SDT JOINACC"},
	{ ACN_SDT_TYPE_LEAVEREQ,	"ACN SDT LEAVEREQ"},
	{ ACN_SDT_TYPE_LEAVE,		"ACN SDT LEAVE"},
	{ ACN_SDT_TYPE_LEAVING,		"ACN SDT LEAVING"},
	{ ACN_SDT_TYPE_NAKUPON,		"ACN SDT NAKUPON"},
	{ ACN_SDT_TYPE_NAKUPOFF,	"ACN SDT NAKUPOFF"},
	{ ACN_SDT_TYPE_NAKDOWNON,	"ACN SDT NAKDOWNON"},
	{ ACN_SDT_TYPE_NAKDOWNOFF,	"ACN SDT NAKDOWNOFF"},
	{ ACN_SDT_TYPE_REPLOSTSEQON,	"ACN SDT REPLOSTSEQON"},
	{ ACN_SDT_TYPE_REPLOSTSEQOFF,	"ACN SDT REPLOSTSEQOFF"},
	{ ACN_SDT_TYPE_SESSEXPIRY,	"ACN SDT SESEXPIRY"},
	{ ACN_SDT_TYPE_MAK,		"ACN SDT MAC"},
	{ ACN_SDT_TYPE_ACK,		"ACN SDT ACK"},
	{ ACN_SDT_TYPE_NAK,		"ACN SDT NAK"},
	{ ACN_SDT_TYPE_SEQLOST,		"ACN SDT SEQLOST"},
	{ ACN_SDT_TYPE_NAKPARAMS,	"ACN SDT NAKPARAMS"},
	{ 0,				NULL }
};

static const value_string acn_dmp_type_vals[] = {
	{ ACN_DMP_TYPE_UNKNOWN,		"ACN DMP Unknown Type"},
	{ 0,				NULL }
};

void proto_reg_handoff_acn(void);

/* Define the acn proto */
static int proto_acn = -1;

/* Define the tree for acn */
static int ett_acn = -1;

/* PDU */
static int hf_acn_pdu = -1;

static int hf_acn_pdu_flags = -1;

static int hf_acn_pdu_des = -1;
static int hf_acn_pdu_src = -1;
static int hf_acn_pdu_flag_p = -1;
static int hf_acn_pdu_flag_t = -1;
static int hf_acn_pdu_flag_res = -1;
static int hf_acn_pdu_flag_z = -1;
static int hf_acn_pdu_length = -1;

/* PDU optional */
static int hf_acn_pdu_ext_length_16 = -1;
static int hf_acn_pdu_ext_length_32 = -1;
static int hf_acn_pdu_source_ps = -1;
static int hf_acn_pdu_source_cid = -1;
static int hf_acn_pdu_destination_ps = -1;
static int hf_acn_pdu_destination_cid = -1;
static int hf_acn_pdu_protocol = -1;
static int hf_acn_pdu_type = -1;
static int hf_acn_pdu_type_sdt = -1;
static int hf_acn_pdu_type_dmp = -1;
static int hf_acn_pdu_data = -1;

static int hf_acn_pdu_padding = -1;

/* SDT */
static int hf_acn_sdt_session_nr = -1;
static int hf_acn_sdt_tot_seq_nr = -1;
static int hf_acn_sdt_rel_seq_nr = -1;
static int hf_acn_sdt_unavailable_wrappers = -1;
static int hf_acn_sdt_refuse_code = -1;
static int hf_acn_sdt_last_rel_seq = -1;
static int hf_acn_sdt_last_rel_wrapper = -1;
static int hf_acn_sdt_session_exp_time = -1;


/*
 * Here are the global variables associated with the preferences
 * for acn
 */

static guint global_udp_port_acn = 0;
static guint udp_port_acn = 0;

/* A static handle for the ip dissector */
static dissector_handle_t ip_handle;

static guint dissect_pdu(tvbuff_t *tvb, guint offset, proto_tree *tree, acn_pdu_history_t* parent_hist, guint max_size);
static guint dissect_sdt(tvbuff_t *tvb, guint offset, proto_tree *tree, acn_pdu_history_t* parent_hist, guint max_size);
static guint dissect_dmp(tvbuff_t *tvb, guint offset, proto_tree *tree, acn_pdu_history_t* parent_hist, guint max_size);

static guint 
dissect_sdt(tvbuff_t *tvb, guint offset, proto_tree *tree, acn_pdu_history_t* parent_hist, guint max_size)
{
	proto_tree *flags_tree, *flags_item;
	guint start_offset = offset;
	acn_pdu_history_t hist;
	guint size = 0;

	hist = *parent_hist;

	switch( parent_hist->type )
	{
		case ACN_SDT_TYPE_UNKNOWN:
			break;

		case ACN_SDT_TYPE_RELSEQDATA:
		case ACN_SDT_TYPE_UNRELSEQDATA:
			proto_tree_add_item(tree, hf_acn_sdt_session_nr, tvb,
						offset, 2, FALSE);
			offset += 2;
			
			proto_tree_add_item(tree, hf_acn_sdt_tot_seq_nr, tvb,
						offset, 4, FALSE);
			offset += 4;

			proto_tree_add_item(tree, hf_acn_sdt_rel_seq_nr, tvb,
						offset, 4, FALSE);
			offset += 4;

			proto_tree_add_item(tree, hf_acn_sdt_unavailable_wrappers, tvb,
						offset, 4, FALSE);
			offset += 4;

			max_size = max_size - (offset - start_offset);
			while( max_size >= ACN_PDU_MIN_SIZE) {
				size = dissect_pdu( tvb, offset, tree, &hist, max_size);
				offset += size;
				max_size -= size;
			}
			
			size = offset - start_offset;

			break;

		case ACN_SDT_TYPE_UNSEQDATA:
			proto_tree_add_item(tree, hf_acn_sdt_session_nr, tvb,
						offset, 2, FALSE);
			offset += 2;

			max_size = max_size - (offset - start_offset);
			while( max_size >= ACN_PDU_MIN_SIZE) {
				size = dissect_pdu( tvb, offset, tree, &hist, max_size);
				offset += size;
				max_size -= size;
			}
			
			size = offset - start_offset;

			break;
			
		case ACN_SDT_TYPE_JOIN:
			break;

		case ACN_SDT_TYPE_TRANSFER:
			break;

		case ACN_SDT_TYPE_JOINREF:
			proto_tree_add_item(tree, hf_acn_sdt_session_nr, tvb,
						offset, 2, FALSE);
			offset += 2;

			proto_tree_add_item(tree, hf_acn_sdt_refuse_code, tvb,
						offset, 2, FALSE);
			offset += 2;

			size = offset - start_offset;
			break;

		case ACN_SDT_TYPE_JOINACC:
		case ACN_SDT_TYPE_ACK:
			proto_tree_add_item(tree, hf_acn_sdt_last_rel_seq, tvb,
						offset, 4, FALSE);
			offset += 4;

			size = offset - start_offset;

			break;

		case ACN_SDT_TYPE_LEAVING:
			proto_tree_add_item(tree, hf_acn_sdt_last_rel_wrapper, tvb,
						offset, 4, FALSE);
			offset += 4;

			size = offset - start_offset;
			break;


		case ACN_SDT_TYPE_SESSEXPIRY:
			proto_tree_add_item(tree, hf_acn_sdt_session_exp_time, tvb,
						offset, 2, FALSE);
			offset += 2;

			size = offset - start_offset;
			break;

		case ACN_SDT_TYPE_MAK:
			break;
			
		case ACN_SDT_TYPE_NAK:
			break;
			
		case ACN_SDT_TYPE_SEQLOST:
			break;

		case ACN_SDT_TYPE_NAKPARAMS:
			break;

		case ACN_SDT_TYPE_LEAVEREQ:
		case ACN_SDT_TYPE_LEAVE:
		case ACN_SDT_TYPE_NAKUPON:
		case ACN_SDT_TYPE_NAKUPOFF:
		case ACN_SDT_TYPE_NAKDOWNON:
		case ACN_SDT_TYPE_NAKDOWNOFF:
		case ACN_SDT_TYPE_REPLOSTSEQON:
		case ACN_SDT_TYPE_REPLOSTSEQOFF:
			/* no data */
			break;

		default:
			break;
	}
	
	return size;
}

static guint 
dissect_dmp(tvbuff_t *tvb, guint offset, proto_tree *tree, acn_pdu_history_t* parent_hist, guint max_size)
{
	return 0;
}

static guint 
dissect_pdu(tvbuff_t *tvb, guint offset, proto_tree *tree, acn_pdu_history_t* parent_hist, guint max_size)
{
	guint size,data_size;
	guint8 flags;
	guint src,des;
	proto_tree *ti, *si, *flags_tree, *flags_item;
	guint start_offset = offset;
	acn_pdu_history_t hist;
	

	ti = proto_tree_add_item(tree,
				hf_acn_pdu,
				tvb,
				offset,
				0,
				FALSE);
 
	si = proto_item_add_subtree(ti, ett_acn);
 
	flags = tvb_get_guint8(tvb, offset);
	flags_item = proto_tree_add_uint(si, hf_acn_pdu_flags, tvb,
					offset, 1, flags);

	flags_tree=proto_item_add_subtree(flags_item, ett_acn);
	
	proto_tree_add_item(flags_tree, hf_acn_pdu_des, tvb, offset, 1, FALSE);
	proto_tree_add_item(flags_tree, hf_acn_pdu_src, tvb, offset, 1, FALSE);
	proto_tree_add_item(flags_tree, hf_acn_pdu_flag_p, tvb, offset, 1, FALSE);
	proto_tree_add_item(flags_tree, hf_acn_pdu_flag_t, tvb, offset, 1, FALSE);
	proto_tree_add_item(flags_tree, hf_acn_pdu_flag_res, tvb, offset, 1, FALSE);
	proto_tree_add_item(flags_tree, hf_acn_pdu_flag_z, tvb, offset, 1, FALSE);

	offset += 1;

	size = tvb_get_guint8(tvb, offset);	
	proto_tree_add_uint(si, hf_acn_pdu_length, tvb,
	                          offset, 1, size);
	offset += 1;
	

	if( size == 0 ){
		size = tvb_get_ntohs(tvb, offset);
		proto_tree_add_uint(si, hf_acn_pdu_ext_length_16, tvb,
					offset, 2, size);	
		offset += 2;	
	} else if( size == 1 ){
		size = tvb_get_ntohl( tvb, offset);
		proto_tree_add_uint(si, hf_acn_pdu_ext_length_32, tvb,
					offset, 4, size);	
		offset += 4;
	}

	switch( hist.source_type )
	{
		case ACN_PDU_SRC_SAME:
			break;
			
		case ACN_PDU_SRC_PS:
			hist.source_type = ACN_PDU_SRC_PS;
			src = tvb_get_ntohs(tvb, offset);
			hist.source.ps = src;
			proto_tree_add_uint(si, hf_acn_pdu_source_ps, tvb,
						offset, 2, src);
			offset += 2;
			break;
			
		case ACN_PDU_SRC_CID:
			hist.source_type = ACN_PDU_SRC_CID;
			tvb_memcpy(tvb, hist.source.cid, offset, 16 );
			proto_tree_add_item(si, hf_acn_pdu_source_cid, tvb,
						offset, 16, FALSE);
			offset += 16;
			break;
			
		case ACN_PDU_SRC_UM:
			hist.source_type = ACN_PDU_SRC_UM;
			break;	
	} 


	switch( flags & ACN_PDU_DES )
	{	
		case ACN_PDU_DES_SAME:
			break;
			
		case ACN_PDU_DES_PS:
			hist.destination_type = ACN_PDU_DES_PS;
			des = tvb_get_ntohs(tvb, offset);
			hist.destination.ps = des;
			proto_tree_add_uint(si, hf_acn_pdu_destination_ps, tvb,
						offset, 2, des);	
			offset += 2;
			break;
			
		case ACN_PDU_DES_CID:
			hist.destination_type = ACN_PDU_DES_CID;
			tvb_memcpy(tvb, hist.destination.cid, offset, 16 );
			proto_tree_add_item(si, hf_acn_pdu_destination_cid, tvb,
						offset, 16, FALSE);
			offset += 16;
			break;
			
		case ACN_PDU_DES_ALL:
			hist.destination_type = ACN_PDU_DES_ALL;
			break;	
	} 

	if( flags & ACN_PDU_FLAG_P )
	{
		hist.protocol = tvb_get_ntohs( tvb, offset );
		proto_tree_add_item(si, hf_acn_pdu_protocol, tvb,
					offset, 2, TRUE );
		offset += 2;
	}

	if( flags & ACN_PDU_FLAG_T )
	{
		hist.type = tvb_get_ntohs( tvb, offset );
	
		switch( hist.protocol ) { 
			case ACN_PDU_PROTO_SDT:
				proto_tree_add_item(si, hf_acn_pdu_type_sdt, tvb,
						offset, 2, TRUE );
				break;

			case ACN_PDU_PROTO_DMP:
				proto_tree_add_item(si, hf_acn_pdu_type_dmp, tvb,
						offset, 2, TRUE );
				break;
				
			default:
				proto_tree_add_item(si, hf_acn_pdu_type, tvb,
						offset, 2, TRUE );
				break;	
	
	
	
		}
		
		offset += 2;
	}

	hist = *parent_hist;

	if( flags & ACN_PDU_FLAG_Z )
	{
		data_size = size - (offset - start_offset);
		
		switch( hist.protocol ) {
			case ACN_PDU_PROTO_SDT:
				dissect_sdt( tvb, offset, si, &hist, data_size);
				break;
			
			case ACN_PDU_PROTO_DMP:
				dissect_dmp( tvb, offset, si, &hist, data_size);	
				break;
	
			default:
				proto_tree_add_item(si, hf_acn_pdu_data, tvb,
							offset, data_size, TRUE );
				break;	
		}

		offset += data_size;
	}

	if( size & 0x00000001 )
	{
	
		proto_tree_add_item(si, hf_acn_pdu_padding, tvb,
					offset, 1, TRUE );
		
		size += 1;
		offset += 1;
	}

	proto_item_set_len(si, size);

	return size;
}

static void
dissect_acn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
	gint offset = 0;
	guint size,max_size;
	acn_pdu_history_t hist;

	/* Set the protocol column */
	if(check_col(pinfo->cinfo,COL_PROTOCOL)){
		col_set_str(pinfo->cinfo,COL_PROTOCOL,"ACN");
	}

	/* Clear out stuff in the info column */
	if(check_col(pinfo->cinfo,COL_INFO)){
		col_clear(pinfo->cinfo,COL_INFO);
	}

	if (tree) 
	{
		/* history default values */
		hist.destination_type = ACN_PDU_DES_ALL; 
		hist.source_type = ACN_PDU_SRC_UM;
		hist.protocol = ACN_PDU_PROTO_UNKNOWN;
		hist.type = ACN_PDU_TYPE_UNKNOWN;
		
		max_size = tvb_reported_length_remaining(tvb, offset);
		
		while( max_size >= ACN_PDU_MIN_SIZE) {
			size = dissect_pdu( tvb, offset, tree, &hist, max_size);
			offset += size;
			max_size -= size;
		}
	}
}

void
proto_register_acn(void) {
  static hf_register_info hf[] = {
	/* PDU */
	{ &hf_acn_pdu,
	    { "ACN PDU", "acn.pdu",
		FT_NONE, BASE_NONE, NULL, 0,
		"ACN PDU", HFILL }},

	{ &hf_acn_pdu_flags,
	    { "PDU Flags","acn.pdu.flags",
		FT_UINT8, BASE_HEX, NULL, 0x0,
		"PDU flags", HFILL }},

	{ &hf_acn_pdu_des,
	    { "PDU des","acn.pdu.des",
		FT_UINT8, BASE_HEX, NULL, 0xC0,
		"PDU des", HFILL }},

	{ &hf_acn_pdu_src,
	    { "PDU src","acn.pdu.src",
		FT_UINT8, BASE_HEX, NULL, 0x30,
		"PDU src", HFILL }},

	{ &hf_acn_pdu_flag_p,
	    { "PDU Flag p","acn.pdu.flag_p",
		FT_UINT8, BASE_HEX, NULL, 0x08,
		"PDU flag p", HFILL }},

	{ &hf_acn_pdu_flag_t,
	    { "PDU Flag t","acn.pdu.flag_t",
		FT_UINT8, BASE_HEX, NULL, 0x04,
		"PDU flag t", HFILL }},

	{ &hf_acn_pdu_flag_z,
	    { "PDU Flag z","acn.pdu.flag_z",
		FT_UINT8, BASE_HEX, NULL, 0x01,
		"PDU flag z", HFILL }},

	{ &hf_acn_pdu_flag_res,
	    { "PDU Flag res","acn.pdu.flag_res",
		FT_UINT8, BASE_HEX, NULL, 0x02,
		"PDU flag res", HFILL }},

	{ &hf_acn_pdu_length,
	    { "PDU Lenght","acn.pdu.length",
		FT_UINT8, BASE_DEC, NULL, 0x0,
		"PDU Length", HFILL }},

	{ &hf_acn_pdu_ext_length_16,
	    { "PDU Ext Length 16bit","acn.pdu.ext_length_16",
		FT_UINT16, BASE_DEC, NULL, 0x0,
		"PDU Ext Length 16bit", HFILL }},

	{ &hf_acn_pdu_ext_length_32,
	    { "PDU Ext Length 32bit","acn.pdu.ext_length_32",
		FT_UINT32, BASE_DEC, NULL, 0x0,
		"PDU Ext Length 32bit", HFILL }},

	{ &hf_acn_pdu_source_ps,
	    { "PDU Source PS","acn.pdu.source_ps",
		FT_UINT16, BASE_HEX, NULL, 0x0,
		"PDU Source", HFILL }},

	{ &hf_acn_pdu_source_cid,
	    { "PDU Source CID","acn.pdu.source_cid",
		FT_BYTES, BASE_HEX, NULL, 0x0,
		"PDU Source CID", HFILL }},

	{ &hf_acn_pdu_destination_ps,
	    { "PDU Destination PS","acn.pdu.destination_ps",
		FT_UINT16, BASE_HEX, NULL, 0x0,
		"PDU Destination PS", HFILL }},

	{ &hf_acn_pdu_destination_cid,
	    { "PDU Destination CID","acn.pdu.destination_cid",
		FT_BYTES, BASE_HEX, NULL, 0x0,
		"PDU Destination CID", HFILL }},

	{ &hf_acn_pdu_protocol,
	    { "PDU Protocol","acn.pdu.protocol",
		FT_UINT16, BASE_HEX, VALS(acn_proto_vals), 0x0,
		"PDU Protocol", HFILL }},

	{ &hf_acn_pdu_type,
	    { "PDU Type","acn.pdu.type",
		FT_UINT16, BASE_HEX, NULL, 0x0,
		"PDU Type", HFILL }},

	{ &hf_acn_pdu_type_sdt,
	    { "PDU Type SDT","acn.pdu.type_sdt",
		FT_UINT16, BASE_HEX, VALS(acn_sdt_type_vals), 0x0,
		"PDU Type SDT", HFILL }},

	{ &hf_acn_pdu_type_dmp,
	    { "PDU Type DMP","acn.pdu.type_dmp",
		FT_UINT16, BASE_HEX, VALS(acn_dmp_type_vals), 0x0,
		"PDU Type DMP", HFILL }},
		
	{ &hf_acn_pdu_data,
	    { "PDU Data","acn.pdu.data",
		FT_BYTES, BASE_HEX, NULL, 0x0,
		"PDU Data", HFILL }},

	{ &hf_acn_pdu_padding,
	    { "PDU Padding","acn.pdu.padding",
		FT_UINT8, BASE_DEC, NULL, 0x0,
		"PDU Padding", HFILL }},

	{ &hf_acn_sdt_session_nr,
	    { "PDU SDT Session Nr","acn.sdt.session_nr",
		FT_UINT16, BASE_DEC, NULL, 0x0,
		"PDU SDT Session Nr", HFILL }},

	{ &hf_acn_sdt_tot_seq_nr,
	    { "PDU SDT Total Sequence Nr","acn.sdt.tot_seq_nr",
		FT_UINT32, BASE_DEC, NULL, 0x0,
		"PDU SDT Total Sequence Nr", HFILL }},

	{ &hf_acn_sdt_rel_seq_nr,
	    { "PDU SDT Rel Seq Nr","acn.sdt.rel_seq_nr",
		FT_UINT32, BASE_DEC, NULL, 0x0,
		"PDU SDT Rel Sequence Nr", HFILL }},

	{ &hf_acn_sdt_unavailable_wrappers,
	    { "PDU SDT Unavailable Wrappers","acn.sdt.unavailable_wrappers",
		FT_UINT32, BASE_DEC, NULL, 0x0,
		"PDU SDT Unavailable Wrappers", HFILL }},
		
	{ &hf_acn_sdt_refuse_code,
	    { "PDU SDT Refuse code","acn.sdt.refuse_code",
		FT_UINT16, BASE_DEC, NULL, 0x0,
		"PDU SDT Refuse Code", HFILL }},

	{ &hf_acn_sdt_last_rel_seq,
	    { "PDU SDT Last reliable seq nr","acn.sdt.last_rel_seq",
		FT_UINT32, BASE_DEC, NULL, 0x0,
		"PDU SDT Last reliable seq nr", HFILL }},

	{ &hf_acn_sdt_last_rel_wrapper,
	    { "PDU SDT Last reliable Wrapper","acn.sdt.last_rel_wrapper",
		FT_UINT32, BASE_DEC, NULL, 0x0,
		"PDU SDT Last reliable Wrapper", HFILL }},

	{ &hf_acn_sdt_session_exp_time,
	    { "PDU SDT Session expire time","acn.sdt.session_exp_time",
		FT_UINT16, BASE_DEC, NULL, 0x0,
		"PDU SDT Session expire time", HFILL }}

  };

  static gint *ett[] = {
    &ett_acn,
  };

  module_t *acn_module;

  proto_acn = proto_register_protocol("ACN",
				      "ACN","acn");
  proto_register_field_array(proto_acn,hf,array_length(hf));
  proto_register_subtree_array(ett,array_length(ett));

  acn_module = prefs_register_protocol(proto_acn,
				       proto_reg_handoff_acn);
#if 0
  prefs_register_uint_preference(artnet_module, "udp_port",
				 "ARTNET UDP Port",
				 "The UDP port on which "
				 "Art-Net "
				 "packets will be sent",
				 10,&global_udp_port_artnet);
#endif
}

/* The registration hand-off routing */

void
proto_reg_handoff_acn(void) {
  static int acn_initialized = FALSE;
  static dissector_handle_t acn_handle;

  ip_handle = find_dissector("ip");

  if(!acn_initialized) {
    acn_handle = create_dissector_handle(dissect_acn,proto_acn);
    acn_initialized = TRUE;
  } else {
    dissector_delete("udp.port",udp_port_acn,acn_handle);
  }

  udp_port_acn = global_udp_port_acn;
  
  dissector_add("udp.port",global_udp_port_acn,acn_handle);
}

/* Start the functions we need for the plugin stuff */

#ifndef ENABLE_STATIC

G_MODULE_EXPORT void
plugin_reg_handoff(void){
  proto_reg_handoff_acn();
}

G_MODULE_EXPORT void
plugin_init(plugin_address_table_t *pat
#ifndef PLUGINS_NEED_ADDRESS_TABLE
_U_
#endif
){
  /* initialise the table of pointers needed in Win32 DLLs */
  plugin_address_table_init(pat);
  /* register the new protocol, protocol fields, and subtrees */
  if (proto_acn == -1) { /* execute protocol initialization only once */
    proto_register_acn();
  }
}

#endif

/* End the functions we need for plugin stuff */