2 * Routines for Solaris ECP/VDP dissection based on IEEE 802.1Qbg Draft 2.1
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include <epan/packet.h>
14 #include <epan/etypes.h>
15 #include <epan/to_str.h>
16 #include <epan/expert.h>
19 void proto_register_ecp(void);
20 void proto_register_vdp(void);
21 void proto_reg_handoff_ecp_21(void);
22 void proto_reg_handoff_vdp(void);
24 static dissector_handle_t ecp_handle
;
25 static dissector_handle_t vdp_handle
;
28 static int hf_ecp_version
;
30 static int hf_ecp_subtype
;
31 static int hf_ecp_seqno
;
34 static int hf_vdp_tlv_type
;
35 static int hf_vdp_tlv_len
;
36 static int hf_vdp_tlv_assoc_reason
;
37 static int hf_vdp_vidstr_ps
;
38 static int hf_vdp_vidstr_pcp
;
39 static int hf_vdp_vidstr_vid
;
40 static int hf_vdp_vsitypeid
;
41 static int hf_vdp_vsiversion
;
42 static int hf_vdp_vsiid_format
;
43 static int hf_vdp_vsiid
;
44 static int hf_vdp_filter_format
;
45 static int hf_vdp_assoc_mac_id
;
46 static int hf_vdp_manager_id
;
47 static int hf_vdp_data
;
48 static int hf_vdp_tlv_org_oui
;
49 static int hf_vdp_tlv_oracle_subtype
;
50 static int hf_vdp_tlv_assoc_flag_mbit
;
51 static int hf_vdp_tlv_assoc_flag_sbit
;
52 static int hf_vdp_tlv_assoc_flag_req_rsp
;
53 static int hf_vdp_tlv_assoc_request_flags
;
54 static int hf_vdp_tlv_assoc_flag_hard_error
;
55 static int hf_vdp_tlv_assoc_flag_keep
;
56 static int hf_vdp_tlv_assoc_error
;
57 static int hf_vdp_tlv_assoc_response_flags
;
59 static int hf_oui_oracle_encoding
;
62 static int ett_vdp_tlv
;
63 static int ett_vdp_tlv_assoc
;
64 static int ett_vdp_tlv_org
;
65 static int ett_vdp_assoc_flags
;
67 static expert_field ei_vdp_tlvlen_bad
;
69 static dissector_table_t ecp_subdissector_table
;
71 #define ECP_OP_REQ 0x0
72 #define ECP_OP_ACK 0x1
74 #define ECP_SUBTYPE_VDP 0x0001
75 #define ECP_SUBTYPE_PECSP 0x0002
77 #define VDP_TLV_PREASSOC 0x01
78 #define VDP_TLV_PREASSOCRR 0x02
79 #define VDP_TLV_ASSOC 0x03
80 #define VDP_TLV_DEASSOC 0x04
81 #define VDP_TLV_MGRID 0x05
82 #define VDP_TLV_ORG 0x7F
84 #define VSI_FMT_IPv4 0x01
85 #define VSI_FMT_IPv6 0x02
86 #define VSI_FMT_MAC 0x03
87 #define VSI_FMT_LOCAL 0x04
88 #define VSI_FMT_UUID 0x05
90 #define VDP_FILTER_VID 0x01
91 #define VDP_FILTER_MACVID 0x02
92 #define VDP_FILTER_GRPVID 0x03
93 #define VDP_FILTER_GRPMACVID 0x04
95 /* Masks - from packet-lldp.c */
96 #define TLV_TYPE_MASK 0xFE00
97 #define TLV_TYPE(value) (((value) & TLV_TYPE_MASK) >> 9)
98 #define TLV_INFO_LEN_MASK 0x01FF
99 #define TLV_INFO_LEN(value) ((value) & TLV_INFO_LEN_MASK)
101 #define ECP_VERSION_MASK 0xF000
102 #define ECP_OP_MASK 0x0C00
103 #define ECP_SUBTYPE_MASK 0x03FF
105 #define ECP_VERSION(value) (((value) & ECP_VERSION_MASK) >> 12)
106 #define ECP_OP(value) (((value) & ECP_OP_MASK) >> 10)
107 #define ECP_SUBTYPE(value) (((value) & ECP_SUBTYPE_MASK))
109 #define OUI_ORACLE_VSIMGR_SUBTYPE 0x01
111 static const value_string ecp_op_vals
[] = {
112 { ECP_OP_REQ
, "ECP request" },
113 { ECP_OP_ACK
, "ECP acknowledgement" },
117 static const value_string ecp_subtype_vals
[] = {
118 { ECP_SUBTYPE_VDP
, "VDP" },
122 static const value_string vdp_tlv_type_vals
[] = {
123 { VDP_TLV_PREASSOC
, "PreAssociate" },
124 { VDP_TLV_PREASSOCRR
, "PreAssociate with RR" },
125 { VDP_TLV_ASSOC
, "Associate" },
126 { VDP_TLV_DEASSOC
, "DeAssociate" },
127 { VDP_TLV_MGRID
, "VSI Manager ID" },
128 { VDP_TLV_ORG
, "Organizationally defined TLV" },
132 static const value_string oui_oracle_subtype_vals
[] = {
133 { OUI_ORACLE_VSIMGR_SUBTYPE
, "VSI Manager Subtype" },
137 static const value_string oui_oracle_encoding_vals
[] = {
138 { 0x1, "oracle_vsi_v1" },
142 static const value_string vdp_response_error_type_vals
[] = {
144 { 0x1, "Invalid Format" },
145 { 0x2, "Insufficient Resource" },
146 { 0x3, "Unable to Contact VSI Manager" },
147 { 0x4, "Other Failure" },
148 { 0x5, "Invalid VID, GroupID, or Mac address" },
152 static const value_string vdp_vsiid_format_vals
[] = {
153 { VSI_FMT_IPv4
, "IPv4" },
154 { VSI_FMT_IPv6
, "IPv6" },
155 { VSI_FMT_MAC
, "MAC" },
156 { VSI_FMT_LOCAL
, "Local" },
157 { VSI_FMT_UUID
, "UUID" },
161 static const value_string vdp_filter_format_vals
[] = {
162 { VDP_FILTER_VID
, "VID" },
163 { VDP_FILTER_MACVID
, "MAC/VID" },
164 { VDP_FILTER_GRPVID
, "GroupID/VID" },
165 { VDP_FILTER_GRPMACVID
, "GroupID/MAC/VID" },
170 vdp_add_vidstr(tvbuff_t
*tvb
, proto_tree
*tree
, uint32_t offset
)
173 proto_tree_add_item(tree
, hf_vdp_vidstr_ps
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
174 proto_tree_add_item(tree
, hf_vdp_vidstr_pcp
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
175 proto_tree_add_item(tree
, hf_vdp_vidstr_vid
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
180 dissect_vdp_tlv_assoc(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, proto_item
* length_item _U_
, int offset
, uint8_t tlvtype
, int tlvlen _U_
)
182 proto_tree
*vdp_tlv_assoc_tree
;
183 proto_item
*associate_item
;
184 uint8_t reason
, filter_format
;
185 int start_offset
= offset
;
187 if (tlvtype
== VDP_TLV_ASSOC
)
188 vdp_tlv_assoc_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, 0,
189 ett_vdp_tlv_assoc
, &associate_item
, "VDP Associate");
191 vdp_tlv_assoc_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, 0,
192 ett_vdp_tlv_assoc
, &associate_item
, "VDP DeAssociate");
195 reason
= tvb_get_uint8(tvb
, offset
);
197 static int * const response_flags
[] = {
198 &hf_vdp_tlv_assoc_flag_hard_error
,
199 &hf_vdp_tlv_assoc_flag_keep
,
200 &hf_vdp_tlv_assoc_flag_req_rsp
,
204 proto_tree_add_item(vdp_tlv_assoc_tree
, hf_vdp_tlv_assoc_error
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
205 proto_tree_add_bitmask(vdp_tlv_assoc_tree
, tvb
, offset
, hf_vdp_tlv_assoc_response_flags
, ett_vdp_assoc_flags
, response_flags
, ENC_BIG_ENDIAN
);
207 static int * const request_flags
[] = {
208 &hf_vdp_tlv_assoc_flag_mbit
,
209 &hf_vdp_tlv_assoc_flag_sbit
,
210 &hf_vdp_tlv_assoc_flag_req_rsp
,
214 proto_tree_add_item(vdp_tlv_assoc_tree
, hf_vdp_tlv_assoc_reason
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
215 proto_tree_add_bitmask(vdp_tlv_assoc_tree
, tvb
, offset
, hf_vdp_tlv_assoc_request_flags
, ett_vdp_assoc_flags
, request_flags
, ENC_BIG_ENDIAN
);
219 /* VSITYPEID/VERSION */
220 proto_tree_add_item(vdp_tlv_assoc_tree
, hf_vdp_vsitypeid
, tvb
, offset
, 3, ENC_BIG_ENDIAN
);
222 proto_tree_add_item(vdp_tlv_assoc_tree
, hf_vdp_vsiversion
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
226 proto_tree_add_item(vdp_tlv_assoc_tree
, hf_vdp_vsiid_format
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
230 proto_tree_add_item(vdp_tlv_assoc_tree
, hf_vdp_vsiid
, tvb
, offset
, 16, ENC_NA
);
234 proto_tree_add_item(vdp_tlv_assoc_tree
, hf_vdp_filter_format
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
235 filter_format
= tvb_get_uint8(tvb
, offset
);
238 switch (filter_format
) {
240 vdp_add_vidstr(tvb
, vdp_tlv_assoc_tree
, offset
);
243 case VDP_FILTER_MACVID
:
244 proto_tree_add_item(vdp_tlv_assoc_tree
, hf_vdp_assoc_mac_id
, tvb
, offset
, 6, ENC_NA
);
246 vdp_add_vidstr(tvb
, vdp_tlv_assoc_tree
, offset
);
251 proto_item_set_len(associate_item
, offset
-start_offset
);
255 dissect_vdp_tlv_mgrid(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, proto_item
* length_item
, int offset
, int tlvlen
)
258 expert_add_info(pinfo
, length_item
, &ei_vdp_tlvlen_bad
);
260 proto_tree_add_item(tree
, hf_vdp_manager_id
, tvb
, offset
, 16, ENC_NA
);
265 dissect_oracle_tlv(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, uint32_t offset
)
267 proto_tree_add_item(tree
, hf_oui_oracle_encoding
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
271 dissect_vdp_tlv_org(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, proto_item
* length_item
, int offset
, int tlvlen
)
277 expert_add_info(pinfo
, length_item
, &ei_vdp_tlvlen_bad
);
281 proto_tree_add_item_ret_uint(tree
, hf_vdp_tlv_org_oui
, tvb
, offset
, 3, ENC_BIG_ENDIAN
, &oui
);
284 /* XXX only support Oracle OUI for now */
285 if (oui
!= OUI_ORACLE
)
288 proto_tree_add_item(tree
, hf_vdp_tlv_oracle_subtype
, tvb
, offset
, 1, ENC_NA
);
289 subtype
= tvb_get_uint8(tvb
, offset
);
293 case OUI_ORACLE_VSIMGR_SUBTYPE
:
294 dissect_oracle_tlv(tvb
, pinfo
, tree
, offset
);
300 dissect_vdp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
302 proto_tree
*vdp_tlv_tree
;
303 proto_item
*ti
, *length_item
;
309 while (tvb_reported_length_remaining(tvb
, offset
) > 0) {
310 tlvhdr
= tvb_get_ntohs(tvb
, offset
);
311 tlvtype
= TLV_TYPE(tlvhdr
);
312 tlvlen
= TLV_INFO_LEN(tlvhdr
);
314 if (tlvtype
== 0) /* XXX most likely it's padding */
317 vdp_tlv_tree
= proto_tree_add_subtree(tree
, tvb
, offset
,
318 tlvlen
+ 2, ett_vdp_tlv
, &ti
, "VDP TLV");
319 proto_tree_add_item(vdp_tlv_tree
, hf_vdp_tlv_type
, tvb
,
320 offset
, 2, ENC_BIG_ENDIAN
);
321 length_item
= proto_tree_add_item(vdp_tlv_tree
, hf_vdp_tlv_len
, tvb
,
322 offset
, 2, ENC_BIG_ENDIAN
);
326 case VDP_TLV_PREASSOC
:
328 case VDP_TLV_PREASSOCRR
:
331 case VDP_TLV_DEASSOC
:
332 dissect_vdp_tlv_assoc(tvb
, pinfo
, vdp_tlv_tree
, length_item
, offset
, tlvtype
, tlvlen
);
335 dissect_vdp_tlv_mgrid(tvb
, pinfo
, vdp_tlv_tree
, length_item
, offset
, tlvlen
);
338 dissect_vdp_tlv_org(tvb
, pinfo
, vdp_tlv_tree
, length_item
, offset
, tlvlen
);
341 proto_tree_add_item(vdp_tlv_tree
, hf_vdp_data
, tvb
, offset
, tlvlen
, ENC_NA
);
352 dissect_ecp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
355 proto_tree
*ecp_tree
= NULL
;
358 uint16_t hdr
, ver
, op
, subtype
, seqno
;
360 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "ECP");
361 col_clear(pinfo
->cinfo
, COL_INFO
);
364 ti
= proto_tree_add_item(tree
, proto_ecp
, tvb
, 0, -1, ENC_NA
);
365 ecp_tree
= proto_item_add_subtree(ti
, ett_ecp
);
367 proto_tree_add_item(ecp_tree
, hf_ecp_version
, tvb
, offset
, 2,
369 proto_tree_add_item(ecp_tree
, hf_ecp_op
, tvb
, offset
, 2,
371 proto_tree_add_item(ecp_tree
, hf_ecp_subtype
, tvb
, offset
, 2,
374 /* Version/OP/Subtype */
375 hdr
= tvb_get_ntohs(tvb
, offset
);
376 ver
= ECP_VERSION(hdr
);
378 subtype
= ECP_SUBTYPE(hdr
);
379 col_add_fstr(pinfo
->cinfo
, COL_INFO
,
380 "PDU Version = %x OP = %x Subtype = %x", ver
, op
, subtype
);
386 proto_tree_add_item(ecp_tree
, hf_ecp_seqno
, tvb
, offset
, 2,
389 seqno
= tvb_get_ntohs(tvb
, offset
);
392 col_append_fstr(pinfo
->cinfo
, COL_INFO
,
393 " SEQ = 0x%x", seqno
);
396 col_append_fstr(pinfo
->cinfo
, COL_INFO
,
397 " ACK = 0x%x", seqno
);
402 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
403 if (!dissector_try_uint(ecp_subdissector_table
, subtype
, next_tvb
, pinfo
, ecp_tree
))
405 call_data_dissector(next_tvb
, pinfo
, tree
);
408 return tvb_captured_length(tvb
);
412 proto_register_ecp(void)
414 static hf_register_info hf
[] = {
416 { "Version", "ecp.ver", FT_UINT16
, BASE_DEC
,
417 NULL
, ECP_VERSION_MASK
, NULL
, HFILL
}},
419 { "Operation", "ecp.op", FT_UINT16
, BASE_HEX
,
420 VALS(ecp_op_vals
), ECP_OP_MASK
, NULL
, HFILL
}},
422 { "Subtype", "ecp.subtype", FT_UINT16
, BASE_HEX
,
423 VALS(ecp_subtype_vals
), ECP_SUBTYPE_MASK
, NULL
, HFILL
}},
425 { "Sequence number", "ecp.seqno", FT_UINT16
, BASE_DEC
,
426 NULL
, 0x0, NULL
, HFILL
}},
429 static int *ett
[] = {
433 proto_ecp
= proto_register_protocol("Edge Control Protocol", "ECP21", "ecp21");
434 proto_register_field_array(proto_ecp
, hf
, array_length(hf
));
435 proto_register_subtree_array(ett
, array_length(ett
));
437 ecp_handle
= register_dissector("ecp21", dissect_ecp
, proto_ecp
);
438 ecp_subdissector_table
= register_dissector_table("ecp.subtype", "ECP Subtypes", proto_ecp
, FT_UINT32
, BASE_DEC
);
442 proto_register_vdp(void)
444 static hf_register_info hf
[] = {
446 { "VDP TLV Type", "vdp21.tlvtype", FT_UINT16
, BASE_DEC
,
447 VALS(vdp_tlv_type_vals
), TLV_TYPE_MASK
, NULL
, HFILL
}},
449 { "VDP TLV Length", "vdp21.tlvlen", FT_UINT16
, BASE_DEC
,
450 NULL
, TLV_INFO_LEN_MASK
, NULL
, HFILL
}},
451 { &hf_vdp_tlv_assoc_reason
,
452 { "Reason", "vdp21.assoc.reason", FT_UINT8
, BASE_HEX
,
453 NULL
, 0x0F, NULL
, HFILL
}},
454 { &hf_vdp_tlv_assoc_error
,
455 { "Error", "vdp21.assoc.error", FT_UINT8
, BASE_HEX
,
456 VALS(vdp_response_error_type_vals
), 0x0F, NULL
, HFILL
}},
457 { &hf_vdp_tlv_assoc_request_flags
,
458 { "Flags", "vdp21.assoc.request_flags", FT_UINT8
, BASE_HEX
,
459 NULL
, 0xF0, NULL
, HFILL
}},
460 { &hf_vdp_tlv_assoc_response_flags
,
461 { "Flags", "vdp21.assoc.response_flags", FT_UINT8
, BASE_HEX
,
462 NULL
, 0xF0, NULL
, HFILL
}},
463 { &hf_vdp_tlv_assoc_flag_mbit
,
464 { "M-Bit", "vdp21.assoc.flags.mbit", FT_BOOLEAN
, 8,
465 NULL
, 0x10, NULL
, HFILL
}},
466 { &hf_vdp_tlv_assoc_flag_sbit
,
467 { "S-Bit", "vdp21.assoc.flags.sbit", FT_BOOLEAN
, 8,
468 NULL
, 0x20, NULL
, HFILL
}},
469 { &hf_vdp_tlv_assoc_flag_req_rsp
,
470 { "Response", "vdp21.assoc.flags.req_rsp", FT_BOOLEAN
, 8,
471 NULL
, 0x40, NULL
, HFILL
}},
472 { &hf_vdp_tlv_assoc_flag_hard_error
,
473 { "Hard Error", "vdp21.assoc.flags.hard_error", FT_BOOLEAN
, 8,
474 NULL
, 0x10, NULL
, HFILL
}},
475 { &hf_vdp_tlv_assoc_flag_keep
,
476 { "Keep", "vdp21.assoc.flags.keep", FT_BOOLEAN
, 8,
477 NULL
, 0x20, NULL
, HFILL
}},
478 { &hf_oui_oracle_encoding
,
479 { "VSI Manager ID Encoding", "vdp21.oracle.encoding", FT_UINT8
,
480 BASE_HEX
, VALS(oui_oracle_encoding_vals
),
483 { "VSI Type ID", "vdp21.vsitypeid", FT_UINT24
,
484 BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
485 { &hf_vdp_vsiversion
,
486 { "VSI Version", "vdp21.vsiversion", FT_UINT8
,
487 BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
488 { &hf_vdp_vsiid_format
,
489 { "VSIID Format", "vdp21.vsiidformat", FT_UINT8
,
490 BASE_HEX
, VALS(vdp_vsiid_format_vals
), 0x0,
492 { &hf_vdp_filter_format
,
493 { "VDP Filter Format", "vdp21.filterformat", FT_UINT8
,
494 BASE_HEX
, VALS(vdp_filter_format_vals
), 0x0,
496 { &hf_vdp_assoc_mac_id
,
497 { "MAC ID", "vdp21.assoc.mac_id", FT_ETHER
, BASE_NONE
,
498 NULL
, 0x0, NULL
, HFILL
}},
500 { "VSIID", "vdp21.VSIID", FT_BYTES
, SEP_COLON
,
501 NULL
, 0x0, NULL
, HFILL
}},
503 { "VIDSTR PS", "vdp21.vidstr.ps", FT_UINT16
, BASE_HEX
,
504 NULL
, 0x0800, NULL
, HFILL
}},
505 { &hf_vdp_vidstr_pcp
,
506 { "VIDSTR PCP", "vdp21.vidstr.pcp", FT_UINT16
, BASE_HEX
,
507 NULL
, 0x0700, NULL
, HFILL
}},
508 { &hf_vdp_vidstr_vid
,
509 { "VIDSTR VID", "vdp21.vidstr.vid", FT_UINT16
, BASE_HEX
,
510 NULL
, 0x0FFF, NULL
, HFILL
}},
511 { &hf_vdp_manager_id
,
512 { "VDP Manager ID", "vdp21.manager_id", FT_IPv6
, BASE_NONE
,
513 NULL
, 0x0, NULL
, HFILL
}},
515 { "Data", "vdp21.data", FT_BYTES
, BASE_NONE
,
516 NULL
, 0x0, NULL
, HFILL
}},
517 { &hf_vdp_tlv_org_oui
,
518 { "VIDSTR VID", "vdp21.org_oui", FT_UINT24
, BASE_OUI
,
519 NULL
, 0x0, NULL
, HFILL
}},
520 { &hf_vdp_tlv_oracle_subtype
,
521 { "Oracle Subtype", "vdp21.org.oracle.subtype", FT_UINT8
, BASE_HEX
,
522 VALS(oui_oracle_subtype_vals
), 0x0, NULL
, HFILL
}},
525 static int *ett
[] = {
529 &ett_vdp_assoc_flags
,
532 static ei_register_info ei
[] = {
533 { &ei_vdp_tlvlen_bad
, { "vdp21.tlvlen.bad", PI_MALFORMED
, PI_ERROR
, "VDP TLV Invalid Length", EXPFILL
}},
536 expert_module_t
* expert_vdp
;
538 proto_vdp
= proto_register_protocol("VSI protocol", "VDP21", "vdp21");
539 proto_register_field_array(proto_vdp
, hf
, array_length(hf
));
540 proto_register_subtree_array(ett
, array_length(ett
));
541 expert_vdp
= expert_register_protocol(proto_vdp
);
542 expert_register_field_array(expert_vdp
, ei
, array_length(ei
));
544 vdp_handle
= register_dissector("vdp21", dissect_vdp
, proto_vdp
);
548 proto_reg_handoff_ecp_21(void)
550 dissector_add_uint("ethertype", ETHERTYPE_ECP
, ecp_handle
);
554 proto_reg_handoff_vdp(void)
556 dissector_add_uint("ecp.subtype", ECP_SUBTYPE_VDP
, vdp_handle
);
560 * Editor modelines - https://www.wireshark.org/tools/modelines.html
565 * indent-tabs-mode: nil
568 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
569 * :indentSize=8:tabSize=8:noTabs=true: