aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-extreme.c
blob: 33484172ba3904af6f55c0e6d412eae42ad8d23e (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
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
/* packet-extreme.c
 * Routines for the disassembly of Extreme Networks specific
 * protocols (EDP/ESRP/EAPS)
 *
 * $Id$
 *
 * Copyright 2005 Joerg Mayer (see AUTJORS file)
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@ethereal.com>
 * Copyright 1998 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.
 */

/* Specs:

   EAPS v1 is specified in RFC3619

  TODO:
   EAPS v2 is not supported (no spec)
   Some stuff in the EDP Info field (no spec)
   The Display string may be incomplete (no spec)
   Look for FIXME in the code :-)

ESRP Packet Format:
-------------------

 0                               1
 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0000
|                       SOURCE MAC ADDRESS                      |
+-------------------------------+-------------------------------+ 0004
|   SOURCE MAC ADDRESS (CONT)   |        DEST MAC ADDRESS       |
+-------------------------------+-------------------------------+ 0008
|                    DEST MAC ADDRESS (CONT)                    |
+-------------------------------+---------------+---------------+ 000C
|            LENGTH             |  DSAP = AA    |  SSAP = AA    |
+---------------+---------------+---------------+---------------+ 0010
| LLC TYPE = UI |                  UID = 00E02B                 |
+---------------+---------------+---------------+---------------+ 0014
|         SNAP TYPE = 00BB      |   EDP VERSION |   RESERVED    |
+-------------------------------+---------------+---------------+ 0018
|            LENGTH             |           CHECKSUM            |
+-------------------------------+-------------------------------+ 001C
|        SEQUENCE NUMBER        |          MACHINE ID           |
+-------------------------------+-------------------------------+ 0020
|                      MACHINE ID (CONT.)                       |
+-------------------------------+---------------+---------------+ 0024
|      MACHINE ID (CONT.)       | MARKER=99(EDP)| TYPE=08 (ESRP)|
+-------------------------------+---------------+---------------+ 0028
|         LENGTH = 001C         |0=IP 1=IPX 2=L2|   GROUP = 0   |
+-------------------------------+-------------------------------+ 002C
|           PRIORITY            |  STATE: 0=?? 1=MSTR 2=SLAVE   |
+-------------------------------+-------------------------------+ 0030
|    NUMBER OF ACTIVE PORTS     |      VIRTUAL IP ADDRESS       |
+-------------------------------+-------------------------------+ 0034
|  VIRTUAL IP ADDRESS (CONT)    |     SYSTEM MAC ADDRESS        |
+-------------------------------+-------------------------------+ 0038
|                   SYSTEM MAC ADDRESS (CONT.)                  |
+-------------------------------+-------------------------------+ 003C
|         HELLO TIMER           |           RESERVED            |
+-------------------------------+-------------------------------+ 0040


******************************************************************************


EDP is a SNAP encapsulated frame.  The top level looks like this:
The top level format is like this:
[ SNAP header ] [ EDP header] [ TLV 0 ] [ TLV 1 ] ... [ TLV N ]

 */

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

#include <glib.h>
#include <epan/packet.h>
#include "packet-llc.h"
#include "oui.h"

static int hf_llc_extreme_pid = -1;

static int proto_edp = -1;
/* EDP header */
static int hf_edp_version = -1;
static int hf_edp_reserved = -1;
static int hf_edp_length = -1;
static int hf_edp_chksum = -1;
static int hf_edp_seqno = -1;
static int hf_edp_midtype = -1;
static int hf_edp_midmac = -1;
/* TLV header */
static int hf_edp_tlv_marker = -1;
static int hf_edp_tlv_type = -1;
static int hf_edp_tlv_length = -1;
/* Display string */
static int hf_edp_display = -1;
/* Info element */
static int hf_edp_info_slot = -1;
static int hf_edp_info_port = -1;
static int hf_edp_info_vchassid = -1;
static int hf_edp_info_reserved = -1;
static int hf_edp_info_version = -1;
static int hf_edp_info_version_major1 = -1;
static int hf_edp_info_version_major2 = -1;
static int hf_edp_info_version_sustaining = -1;
static int hf_edp_info_version_internal = -1;
static int hf_edp_info_vchassconn = -1;
/* Vlan element */
static int hf_edp_vlan_flags = -1;
static int hf_edp_vlan_reserved1 = -1;
static int hf_edp_vlan_id = -1;
static int hf_edp_vlan_reserved2 = -1;
static int hf_edp_vlan_ip = -1;
static int hf_edp_vlan_name = -1;
/* ESRP element */
static int hf_edp_esrp_proto = -1;
static int hf_edp_esrp_group = -1;
static int hf_edp_esrp_prio = -1;
static int hf_edp_esrp_state = -1;
static int hf_edp_esrp_ports = -1;
static int hf_edp_esrp_virtip = -1;
static int hf_edp_esrp_sysmac = -1;
static int hf_edp_esrp_hello = -1;
static int hf_edp_esrp_reserved = -1;
/* EAPS element */
static int hf_edp_eaps_ver = -1;
static int hf_edp_eaps_type = -1;
static int hf_edp_eaps_ctrlvlanid = -1;
static int hf_edp_eaps_reserved0 = -1;
static int hf_edp_eaps_sysmac = -1;
static int hf_edp_eaps_hello = -1;
static int hf_edp_eaps_fail = -1;
static int hf_edp_eaps_state = -1;
static int hf_edp_eaps_reserved1 = -1;
static int hf_edp_eaps_helloseq = -1;
static int hf_edp_eaps_reserved2 = -1;

static gint ett_edp = -1;
static gint ett_edp_tlv = -1;

#define PROTO_SHORT_NAME "EDP"
#define PROTO_LONG_NAME "Extreme Discovery Protocol"

static const value_string extreme_pid_vals[] = {
	{ 0x00bb,	"EDP" },

	{ 0,		NULL }
};

static const value_string esrp_proto_vals[] = {
	{ 0,	"IP" },
	{ 1,	"IPX" },
	{ 2,	"L2" },

	{ 0, NULL }
};

static const value_string esrp_state_vals[] = {
	{ 0,	"??" },
	{ 1,	"Master" },
	{ 2,	"Slave" },

	{ 0, NULL }
};

typedef enum {
	EDP_TYPE_NULL = 0,
	EDP_TYPE_DISPLAY,
	EDP_TYPE_INFO,
	EDP_TYPE_VLAN = 5,
	EDP_TYPE_ESRP = 8,
	EDP_TYPE_EAPS = 0xb
} edp_type_t;

static const value_string edp_type_vals[] = {
	{ EDP_TYPE_NULL,	"Null"},
	{ EDP_TYPE_DISPLAY,	"Display"},
	{ EDP_TYPE_INFO,	"System"},
	{ EDP_TYPE_VLAN,	"Vlan"},
	{ EDP_TYPE_ESRP,	"ESRP"},
	{ EDP_TYPE_EAPS,	"EAPS"},

	{ 0,	NULL }
};

static const value_string edp_midtype_vals[] = {
	{ 0,	"MAC" },

	{ 0,	NULL }
};

static const value_string eaps_type_vals[] = {
	{ 5,	"Health" },
	{ 6,	"Ring up flush fdb" },
	{ 7,	"Ring down flush fdb" },
	{ 8,	"Link down" },

	{ 0,	NULL }
};

static const value_string eaps_state_vals[] = {
	{ 0,	"Idle" },
	{ 1,	"Complete" },
	{ 2,	"Failed" },
	{ 3,	"Links up" },
	{ 4,	"Links down" },
	{ 5,	"Pre Forwarding" },

	{ 0,	NULL }
};

static void
dissect_display_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, int offset, int length, proto_tree *tree)
{
	/* FIXME: I don't think that this is the right solution but don't
	 	know what is */
        proto_tree_add_string(tree, hf_edp_display, tvb, offset, length,
                tvb_format_stringzpad(tvb, offset, length));
}

static void
dissect_info_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, int offset, int length _U_, proto_tree *tree)
{
	proto_item *tlvi;
	proto_tree *ver_tree;
	guint8 major1, major2, sustaining, internal;

	proto_tree_add_uint(tree, hf_edp_info_slot, tvb, offset, 2,
		tvb_get_ntohs(tvb, offset));
	offset += 2;

	proto_tree_add_uint(tree, hf_edp_info_port, tvb, offset, 2,
		tvb_get_ntohs(tvb, offset));
	offset += 2;

	proto_tree_add_uint(tree, hf_edp_info_vchassid, tvb, offset, 2,
		tvb_get_ntohs(tvb, offset));
	offset += 2;

	proto_tree_add_bytes(tree, hf_edp_info_reserved, tvb, offset, 6,
		tvb_get_ptr(tvb, offset, 6));
	offset += 6;

	/* Begin version subtree */
	major1 = tvb_get_guint8(tvb, offset);
	major2 = tvb_get_guint8(tvb, offset + 1);
	sustaining = tvb_get_guint8(tvb, offset + 2);
	internal = tvb_get_guint8(tvb, offset + 3);

	tlvi = proto_tree_add_text(tree, tvb, offset, 4,
		"Version: %u.%u.%u Internal: %u", major1, major2,
		sustaining, internal);

	ver_tree = proto_item_add_subtree(tlvi, ett_edp_tlv);

	proto_tree_add_uint(ver_tree, hf_edp_info_version, tvb, offset, 4,
		tvb_get_ntohl(tvb, offset));

	proto_tree_add_uint(ver_tree, hf_edp_info_version_major1, tvb, offset, 1,
		major1);
	offset += 1;

	proto_tree_add_uint(ver_tree, hf_edp_info_version_major2, tvb, offset, 1,
		major2);
	offset += 1;

	proto_tree_add_uint(ver_tree, hf_edp_info_version_sustaining, tvb, offset, 1,
		sustaining);
	offset += 1;

	proto_tree_add_uint(ver_tree, hf_edp_info_version_internal, tvb, offset, 1,
		internal);
	offset += 1;
	/* End of version subtree */

	proto_tree_add_bytes(tree, hf_edp_info_vchassconn, tvb, offset, 16,
		tvb_get_ptr(tvb, offset, 16));
	offset += 16;
}

static void
dissect_vlan_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, int offset, int length, proto_tree *tree)
{
	/* FIXME: properly decode the bit(s):
		bit 2^7 = 1 -> has ip interface
		bit 2^0 = ? */
	proto_tree_add_uint(tree, hf_edp_vlan_flags, tvb, offset, 1,
		tvb_get_guint8(tvb, offset));
	offset += 1;

	proto_tree_add_bytes(tree, hf_edp_vlan_reserved1, tvb, offset, 1,
		tvb_get_ptr(tvb, offset, 1));
	offset += 1;

	proto_tree_add_uint(tree, hf_edp_vlan_id, tvb, offset, 2,
		tvb_get_ntohs(tvb, offset));
	offset += 2;

	proto_tree_add_bytes(tree, hf_edp_vlan_reserved2, tvb, offset, 4,
		tvb_get_ptr(tvb, offset, 4));
	offset += 4;

	proto_tree_add_ipv4(tree, hf_edp_vlan_ip, tvb, offset, 4,
		*((guint32*)ep_tvb_memdup(tvb, offset, 4))); 
	offset += 4;

	proto_tree_add_string(tree, hf_edp_vlan_name, tvb, offset, length - 12,
		tvb_format_stringzpad(tvb, offset, length - 12));
	offset += (length - 12);
}

static void
dissect_esrp_tlv(tvbuff_t *tvb, packet_info *pinfo, int offset, int length _U_, proto_tree *tree)
{
	if (check_col(pinfo->cinfo, COL_PROTOCOL))
		col_set_str(pinfo->cinfo, COL_PROTOCOL, "ESRP");

	proto_tree_add_uint(tree, hf_edp_esrp_proto, tvb, offset, 1,
		tvb_get_guint8(tvb, offset));
	offset += 1;

	proto_tree_add_uint(tree, hf_edp_esrp_group, tvb, offset, 1,
		tvb_get_guint8(tvb, offset));
	offset += 1;

	proto_tree_add_uint(tree, hf_edp_esrp_prio, tvb, offset, 2,
		tvb_get_ntohs(tvb, offset));
	offset += 2;
	
	proto_tree_add_uint(tree, hf_edp_esrp_state, tvb, offset, 2,
		tvb_get_ntohs(tvb, offset));
	offset += 2;

	proto_tree_add_uint(tree, hf_edp_esrp_ports, tvb, offset, 2,
		tvb_get_ntohs(tvb, offset));
	offset += 2;

	proto_tree_add_ipv4(tree, hf_edp_esrp_virtip, tvb, offset, 4,
                *((guint32*)ep_tvb_memdup(tvb, offset, 4)));
	offset += 4;

	proto_tree_add_ether(tree, hf_edp_esrp_sysmac, tvb, offset, 6,
		tvb_get_ptr(tvb, offset, 6));
	offset += 6;

	proto_tree_add_uint(tree, hf_edp_esrp_hello, tvb, offset, 2,
		tvb_get_ntohs(tvb, offset));
	offset += 2;

	proto_tree_add_bytes(tree, hf_edp_esrp_reserved, tvb, offset, 2,
		tvb_get_ptr(tvb, offset, 2));
	offset += 2;
}

static void
dissect_eaps_tlv(tvbuff_t *tvb, packet_info *pinfo, int offset, int length _U_, proto_tree *tree)
{
	if (check_col(pinfo->cinfo, COL_PROTOCOL))
		col_set_str(pinfo->cinfo, COL_PROTOCOL, "EAPS");

	proto_tree_add_uint(tree, hf_edp_eaps_ver, tvb, offset, 1,
		tvb_get_guint8(tvb, offset));
	offset += 1;

	proto_tree_add_uint(tree, hf_edp_eaps_type, tvb, offset, 1,
		tvb_get_guint8(tvb, offset));
	offset += 1;

	proto_tree_add_uint(tree, hf_edp_eaps_ctrlvlanid, tvb, offset, 2,
		tvb_get_ntohs(tvb, offset));
	offset += 2;

	proto_tree_add_bytes(tree, hf_edp_eaps_reserved0, tvb, offset, 4,
		tvb_get_ptr(tvb, offset, 4));
	offset += 4;

	proto_tree_add_ether(tree, hf_edp_eaps_sysmac, tvb, offset, 6,
		tvb_get_ptr(tvb, offset, 6));
	offset += 6;

	proto_tree_add_uint(tree, hf_edp_eaps_hello, tvb, offset, 2,
		tvb_get_ntohs(tvb, offset));
	offset += 2;

	proto_tree_add_uint(tree, hf_edp_eaps_fail, tvb, offset, 2,
		tvb_get_ntohs(tvb, offset));
	offset += 2;

	proto_tree_add_uint(tree, hf_edp_eaps_state, tvb, offset, 1,
		tvb_get_guint8(tvb, offset));
	offset += 1;

	proto_tree_add_bytes(tree, hf_edp_eaps_reserved1, tvb, offset, 1,
		tvb_get_ptr(tvb, offset, 1));
	offset += 1;

	proto_tree_add_uint(tree, hf_edp_eaps_helloseq, tvb, offset, 2,
		tvb_get_ntohs(tvb, offset));
	offset += 2;

	proto_tree_add_bytes(tree, hf_edp_eaps_reserved2, tvb, offset, 38,
		tvb_get_ptr(tvb, offset, 38));
	offset += 38;
}

static void
dissect_edp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	proto_item *ti;
	proto_item *tlvi;
	proto_tree *tlv_tree;
	proto_tree *edp_tree = NULL;
	guint32 offset = 0;
	guint last = 0;
	guint8 tlv_marker;
	guint8 tlv_type;
	guint16 tlv_length;
	guint16 data_length;
	guint16 length_remaining;

	if (check_col(pinfo->cinfo, COL_PROTOCOL))
		col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_SHORT_NAME);
	if (check_col(pinfo->cinfo, COL_INFO))
		col_set_str(pinfo->cinfo, COL_INFO, PROTO_SHORT_NAME ":");

	if (tree) {
		length_remaining = tvb_reported_length_remaining(tvb, offset);

		ti = proto_tree_add_item(tree, proto_edp, tvb, offset, -1,
		    FALSE);
		edp_tree = proto_item_add_subtree(ti, ett_edp);

		proto_tree_add_item(edp_tree, hf_edp_version, tvb, offset, 1,
		    TRUE);
		offset += 1;

		proto_tree_add_item(edp_tree, hf_edp_reserved, tvb, offset, 1,
			TRUE);
		offset += 1;

		data_length = tvb_get_ntohs(tvb, offset);
		proto_tree_add_uint(edp_tree, hf_edp_length, tvb, offset, 2,
			data_length);
		offset += 2;

		proto_tree_add_uint(edp_tree, hf_edp_chksum, tvb, offset, 2,
			tvb_get_ntohs(tvb, offset));
		offset += 2;

		proto_tree_add_uint(edp_tree, hf_edp_seqno, tvb, offset, 2,
			tvb_get_ntohs(tvb, offset));
		offset += 2;

		/* Machine ID is 8 bytes, if it starts with 0000, the remaining
		   6 bytes are a MAC */
		proto_tree_add_uint(edp_tree, hf_edp_midtype, tvb, offset, 2,
			tvb_get_ntohs(tvb, offset));
		offset += 2;

		proto_tree_add_ether(edp_tree, hf_edp_midmac, tvb, offset, 6,
			tvb_get_ptr(tvb, offset, 6));
		offset += 6;

		/* Decode the individual TLVs */
		while (offset < data_length && last == 0) {
			if (data_length - offset < 4) {
	                	tlvi = proto_tree_add_text(edp_tree, tvb, offset, 4,
                    			"Too few bytes left for TLV: %u (< 4)",
					data_length - offset);
				offset += 4;
				break;
			}
			tlv_marker = tvb_get_guint8(tvb, offset);
			tlv_type = tvb_get_guint8(tvb, offset + 1);
			tlv_length = tvb_get_ntohs(tvb, offset + 2);

			if ((tlv_length < 4) || (tlv_length > (data_length - offset))) {
	                	tlvi = proto_tree_add_text(edp_tree, tvb, offset, 0,
                    			"TLV with invalid length: %u", tlv_length);
				last = 1;
				break;
			}
			/* FIXME: Show type specific information */
			tlvi = proto_tree_add_text(edp_tree, tvb, offset,
				tlv_length, "Type: %s, length: %d bytes",
				val_to_str(tlv_type, edp_type_vals, "Unknown (0x%02x)"),
				tlv_length);

			tlv_tree = proto_item_add_subtree(tlvi, ett_edp_tlv);
			proto_tree_add_uint(tlv_tree, hf_edp_tlv_marker, tvb, offset, 1,
				tlv_marker);
			offset += 1;

			proto_tree_add_uint(tlv_tree, hf_edp_tlv_type, tvb, offset, 1,
				tlv_type);
			offset += 1;

			proto_tree_add_uint(tlv_tree, hf_edp_tlv_length, tvb, offset, 2,
				tlv_length);
			offset += 2;

			if (check_col(pinfo->cinfo, COL_INFO))
				col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
					val_to_str(tlv_type, edp_type_vals, "[0x%02x]"));

			switch (tlv_type) {
			case EDP_TYPE_NULL: /* Last TLV */
				last = 1;
				break;
			case EDP_TYPE_DISPLAY: /* MIB II display string */
				dissect_display_tlv(tvb, pinfo, offset, tlv_length - 4, tlv_tree);
				break;
			case EDP_TYPE_INFO: /* Basic system information */
				dissect_info_tlv(tvb, pinfo, offset, tlv_length - 4, tlv_tree);
				break;
			case EDP_TYPE_VLAN: /* VLAN info */
				dissect_vlan_tlv(tvb, pinfo, offset, tlv_length - 4, tlv_tree);
				break;
			case EDP_TYPE_ESRP: /* Extreme Standby Router Protocol */
				dissect_esrp_tlv(tvb, pinfo, offset, tlv_length - 4, tlv_tree);
				break;
			case EDP_TYPE_EAPS: /* Ethernet Automatic Protection Swtiching */
				dissect_eaps_tlv(tvb, pinfo, offset, tlv_length - 4, tlv_tree);
				break;
			default:
				proto_tree_add_text(tlv_tree, tvb, offset,
					tlv_length - 4, "Unknown data");
				break;
			}
			offset += (tlv_length - 4);
		}

	}
}

void
proto_register_edp(void)
{
	static hf_register_info hf[] = {

	/* EDP header */
		{ &hf_edp_version,
		{ "Version",	"edp.version", FT_UINT8, BASE_DEC, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_reserved,
		{ "Reserved",	"edp.reserved", FT_UINT8, BASE_DEC, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_length,
		{ "Data length",	"edp.length", FT_UINT16, BASE_DEC, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_chksum,
		{ "Checksum",	"edp.checksum", FT_UINT16, BASE_HEX, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_seqno,
		{ "Sequence number",	"edp.seqno", FT_UINT16, BASE_DEC, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_midtype,
		{ "Machine ID type",	"edp.midtype", FT_UINT16, BASE_DEC, VALS(edp_midtype_vals),
			0x0, "", HFILL }},

		{ &hf_edp_midmac,
		{ "Machine MAC",	"edp.midmac", FT_ETHER, BASE_NONE, NULL,
			0x0, "", HFILL }},

	/* TLV header */
		{ &hf_edp_tlv_marker,
		{ "TLV Marker",	"edp.tlv.marker", FT_UINT8, BASE_HEX, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_tlv_type,
		{ "TLV type",	"edp.tlv.type", FT_UINT8, BASE_DEC, VALS(edp_type_vals),
			0x0, "", HFILL }},

		{ &hf_edp_tlv_length,
		{ "TLV length",	"edp.tlv.length", FT_UINT16, BASE_DEC, NULL,
			0x0, "", HFILL }},

	/* Display string */
		{ &hf_edp_display,
		{ "Display",	"edp.display", FT_STRING, BASE_NONE, NULL,
			0x0, "MIB II display string", HFILL }},

	/* Info element */
		{ &hf_edp_info_slot,
		{ "Slot",	"edp.info.slot", FT_UINT16, BASE_DEC, NULL,
			0x0, "Originating slot #", HFILL }},

		{ &hf_edp_info_port,
		{ "Port",	"edp.info.port", FT_UINT16, BASE_DEC, NULL,
			0x0, "Originating port #", HFILL }},

		{ &hf_edp_info_vchassid,
		{ "Virt chassis",	"edp.info.vchassid", FT_UINT16, BASE_DEC, NULL,
			0x0, "Virtual chassis ID", HFILL }},

		{ &hf_edp_info_reserved,
		{ "Reserved",	"edp.info.reserved", FT_BYTES, BASE_NONE, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_info_version,
		{ "Version",	"edp.info.version", FT_UINT32, BASE_HEX, NULL,
			0x0, "Software version", HFILL }},

		{ &hf_edp_info_version_major1,
		{ "Version (major1)",	"edp.info.version.major1", FT_UINT8, BASE_DEC, NULL,
			0x0, "Software version (major1)", HFILL }},

		{ &hf_edp_info_version_major2,
		{ "Version (major2)",	"edp.info.version.major2", FT_UINT8, BASE_DEC, NULL,
			0x0, "Software version (major2)", HFILL }},

		{ &hf_edp_info_version_sustaining,
		{ "Version (sustaining)",	"edp.info.version.sustaining", FT_UINT8, BASE_DEC, NULL,
			0x0, "Software version (sustaining)", HFILL }},

		{ &hf_edp_info_version_internal,
		{ "Version (internal)",	"edp.info.version.internal", FT_UINT8, BASE_DEC, NULL,
			0x0, "Software version (internal)", HFILL }},

		{ &hf_edp_info_vchassconn,
		{ "Connections",	"edp.info.vchassconn", FT_BYTES, BASE_NONE, NULL,
			0x0, "Virtual chassis connections", HFILL }},

	/* Vlan element */
		/* FIXME: properly decode the bit(s) */
		{ &hf_edp_vlan_flags,
		{ "Flags",	"edp.vlan.flags", FT_UINT8, BASE_DEC, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_vlan_reserved1,
		{ "Reserved1",	"edp.vlan.reserved1", FT_BYTES, BASE_NONE, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_vlan_id,
		{ "Vlan ID",	"edp.vlan.id", FT_UINT16, BASE_DEC, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_vlan_reserved2,
		{ "Reserved2",	"edp.vlan.reserved2", FT_BYTES, BASE_NONE, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_vlan_ip,
		{ "IP addr",	"edp.vlan.ip", FT_IPv4, BASE_NONE, NULL,
			0x0, "VLAN IP address", HFILL }},

		{ &hf_edp_vlan_name,
		{ "Name",	"edp.vlan.name", FT_STRING, BASE_NONE, NULL,
			0x0, "VLAN name", HFILL }},

	/* ESRP element */
		{ &hf_edp_esrp_proto,
		{ "Protocol",	"edp.esrp.proto", FT_UINT8, BASE_DEC, VALS(esrp_proto_vals),
			0x0, "", HFILL }},

		{ &hf_edp_esrp_group,
		{ "Group",	"edp.esrp.group", FT_UINT8, BASE_DEC, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_esrp_prio,
		{ "Prio",	"edp.esrp.prio", FT_UINT16, BASE_DEC, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_esrp_state,
		{ "State",	"edp.esrp.state", FT_UINT16, BASE_DEC, VALS(esrp_state_vals),
			0x0, "", HFILL }},

		{ &hf_edp_esrp_ports,
		{ "Ports",	"edp.esrp.ports", FT_UINT16, BASE_DEC, NULL,
			0x0, "Number of active ports", HFILL }},

		{ &hf_edp_esrp_virtip,
		{ "VirtIP",	"edp.esrp.virtip", FT_IPv4, BASE_NONE, NULL,
			0x0, "Virtual IP address", HFILL }},

		{ &hf_edp_esrp_sysmac,
		{ "Sys MAC",	"edp.esrp.sysmac", FT_ETHER, BASE_NONE, NULL,
			0x0, "System MAC address", HFILL }},

		{ &hf_edp_esrp_hello,
		{ "Hello",	"edp.esrp.hello", FT_UINT16, BASE_DEC, NULL,
			0x0, "Hello timer", HFILL }},

		{ &hf_edp_esrp_reserved,
		{ "Reserved",	"edp.esrp.reserved", FT_BYTES, BASE_NONE, NULL,
			0x0, "", HFILL }},

	/* EAPS element */
		{ &hf_edp_eaps_ver,
		{ "Version",	"edp.eaps.ver", FT_UINT8, BASE_DEC, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_eaps_type,
		{ "Type",	"edp.eaps.type", FT_UINT8, BASE_DEC, VALS(eaps_type_vals),
			0x0, "", HFILL }},

		{ &hf_edp_eaps_ctrlvlanid,
		{ "Vlan ID",	"edp.eaps.vlanid", FT_UINT16, BASE_DEC, NULL,
			0x0, "Control Vlan ID", HFILL }},

		{ &hf_edp_eaps_reserved0,
		{ "Reserved0",	"edp.eaps.reserved0", FT_BYTES, BASE_NONE, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_eaps_sysmac,
		{ "Sys MAC",	"edp.eaps.sysmac", FT_ETHER, BASE_NONE, NULL,
			0x0, "System MAC address", HFILL }},

		{ &hf_edp_eaps_hello,
		{ "Hello",	"edp.eaps.hello", FT_UINT16, BASE_DEC, NULL,
			0x0, "Hello timer", HFILL }},

		{ &hf_edp_eaps_fail,
		{ "Fail",	"edp.eaps.fail", FT_UINT16, BASE_DEC, NULL,
			0x0, "Fail timer", HFILL }},

		{ &hf_edp_eaps_state,
		{ "State",	"edp.eaps.state", FT_UINT8, BASE_DEC, VALS(eaps_state_vals),
			0x0, "", HFILL }},

		{ &hf_edp_eaps_reserved1,
		{ "Reserved1",	"edp.eaps.reserved1", FT_BYTES, BASE_NONE, NULL,
			0x0, "", HFILL }},

		{ &hf_edp_eaps_helloseq,
		{ "Helloseq",	"edp.eaps.helloseq", FT_UINT16, BASE_DEC, NULL,
			0x0, "Hello sequence", HFILL }},

		{ &hf_edp_eaps_reserved2,
		{ "Reserved2",	"edp.eaps.reserved2", FT_BYTES, BASE_NONE, NULL,
			0x0, "", HFILL }},

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

        proto_edp = proto_register_protocol(PROTO_LONG_NAME,
	    PROTO_SHORT_NAME, "edp");
        proto_register_field_array(proto_edp, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));
}

void
proto_reg_handoff_edp(void)
{
	dissector_handle_t edp_handle;

	edp_handle = create_dissector_handle(dissect_edp, proto_edp);
	dissector_add("llc.extreme_pid", 0x00bb, edp_handle);
}

void
proto_register_extreme_oui(void)
{
	static hf_register_info hf = {
	    &hf_llc_extreme_pid,
		{ "PID",	"llc.extreme_pid",  FT_UINT16, BASE_HEX,
		  VALS(extreme_pid_vals), 0x0, "", HFILL },
	};

	llc_add_oui(OUI_EXTREME, "llc.extreme_pid", "Extreme OUI PID", &hf);
}