Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-docsis-vendor.c
blob3e4008051949e3ddf7c4456fdf8dbc86c4301108
1 /* packet-vendor.c
2 * Routines for Vendor Specific Encodings dissection
3 * Copyright 2002, Anand V. Narwani <anand[AT]narwani.org>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
13 /* Notes to Adding dissectors for Vendor specific TLVs:
14 * 1. Create a dissect_<vendorname> function with the following prototype:
15 * dissect_foovendor(tvbuff_t *tvb, proto_tree *tree, int vsif_len)
16 * 2. vsif_len will be the *entire* length of the vsif TLV (including the
17 * Vendor ID TLV, which is 5 bytes long).
18 * 3. Create a new 'case' statement in dissect_vsif, for your specific Vendor
19 * ID.
20 * 4. In that 'case' statement you will make the following calls:
21 * (assume for this example that your vendor ID is 0x000054)
22 * #define VENDOR_FOOVENDOR 0x00054
23 * case VENDOR_FOOVENDOR:
24 * proto_item_append_text (it, " (foo vendor)");
25 * dissect_foovendor (tvb, vsif_tree, vsif_len);
26 * break;
27 * 5. Please see dissect_cisco for an example of how to do this.
30 #include "config.h"
32 #include <epan/packet.h>
33 #include <epan/expert.h>
35 /* Define Vendor ID's here */
36 #define VENDOR_CISCO 0x00000C
37 #define VENDOR_GENERAL 0xFFFFFF
39 void proto_register_docsis_vsif(void);
40 void proto_reg_handoff_docsis_vsif(void);
42 /* Initialize the protocol and registered fields */
43 static int proto_docsis_vsif;
44 static int hf_docsis_vsif_vendorid;
45 static int hf_docsis_vsif_vendor_unknown;
46 static int hf_docsis_vsif_cisco_numphones;
47 /* static int hf_docsis_vsif_cisco_ipprec; */
48 static int hf_docsis_vsif_cisco_ipprec_val;
49 static int hf_docsis_vsif_cisco_ipprec_bw;
50 static int hf_docsis_vsif_cisco_config_file;
52 static int hf_docsis_vsif_gex_loadbal_policy_id;
53 static int hf_docsis_vsif_gex_loadbal_priority;
54 static int hf_docsis_vsif_gex_loadbal_group_id;
55 static int hf_docsis_vsif_gex_ranging_class_id_extension;
56 static int hf_docsis_vsif_gex_l2vpn_encoding;
57 static int hf_docsis_vsif_gex_ecm;
58 static int hf_docsis_vsif_gex_sav;
59 static int hf_docsis_vsif_gex_cmam;
60 static int hf_docsis_vsif_gex_imja;
61 static int hf_docsis_vsif_gex_service_type_identifier;
63 static int hf_docsis_vsif_gex_ecm_extended_cmts_mic_hmac_type;
64 static int hf_docsis_vsif_gex_ecm_extended_cmts_mic_bitmap;
65 static int hf_docsis_vsif_gex_ecm_explicit_extended_cmts_mic_digest_subtype;
67 static int hf_docsis_vsif_gex_sav_group_name;
68 static int hf_docsis_vsif_gex_sav_static_prefix_rule;
70 static int hf_docsis_vsif_gex_sav_static_prefix_addressv4;
71 static int hf_docsis_vsif_gex_sav_static_prefix_addressv6;
72 static int hf_docsis_vsif_gex_sav_static_prefix_length;
74 static int hf_docsis_vsif_gex_cmam_cm_required_downstream_attribute_mask;
75 static int hf_docsis_vsif_gex_cmam_cm_forbidden_downstream_attribute_mask;
76 static int hf_docsis_vsif_gex_cmam_cm_required_upstream_attribute_mask;
77 static int hf_docsis_vsif_gex_cmam_cm_forbidden_upstream_attribute_mask;
79 static int hf_docsis_vsif_gex_imja_ip_multicast_profile_name;
80 static int hf_docsis_vsif_gex_imja_ssr;
81 static int hf_docsis_vsif_gex_imja_maximum_multicast_sessions;
83 static int hf_docsis_vsif_gex_imja_ssr_rule_priority;
84 static int hf_docsis_vsif_gex_imja_ssr_authorization_action;
85 static int hf_docsis_vsif_gex_imja_ssr_source_prefix_addressv4;
86 static int hf_docsis_vsif_gex_imja_ssr_source_prefix_addressv6;
87 static int hf_docsis_vsif_gex_imja_ssr_source_prefix_length;
88 static int hf_docsis_vsif_gex_imja_ssr_group_prefix_addressv4;
89 static int hf_docsis_vsif_gex_imja_ssr_group_prefix_addressv6;
90 static int hf_docsis_vsif_gex_imja_ssr_group_prefix_length;
92 static int hf_docsis_vsif_tlv_unknown;
95 /* Initialize the subtree pointers */
96 static int ett_docsis_vsif;
97 static int ett_docsis_vsif_ipprec;
98 static int ett_docsis_vsif_gex_ecm;
99 static int ett_docsis_vsif_gex_sav;
100 static int ett_docsis_vsif_gex_sav_spr;
101 static int ett_docsis_vsif_gex_cmam;
102 static int ett_docsis_vsif_gex_imja;
103 static int ett_docsis_vsif_gex_imja_ssr;
106 static expert_field ei_docsis_vsif_tlvlen_bad;
107 static expert_field ei_docsis_vsif_tlvtype_unknown;
109 static const value_string vendorid_vals[] = {
110 {VENDOR_CISCO, "Cisco Systems, Inc."},
111 {VENDOR_GENERAL, "General Extension Information"},
112 {0, NULL},
115 static const value_string hmac_vals[] = {
116 {1, "MD5 HMAC [RFC 2104]"},
117 {2, "MMH16-sigma-n HMAC [DOCSIS SECv3.0]"},
118 {43, "Vendor Specific"},
119 {0, NULL},
122 static const value_string authorization_action_vals[] = {
123 {0, "permit"},
124 {1, "deny"},
125 {0, NULL},
129 /* Dissector for Cisco Vendor Specific TLVs */
131 #define NUM_PHONES 0x0a
132 #define IOS_CONFIG_FILE 0x80
133 #define IP_PREC 0x0b
134 #define IP_PREC_VAL 0x01
135 #define IP_PREC_BW 0x02
137 static void dissect_general_extension_information (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
138 int vsif_len);
141 static void
142 dissect_cisco (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, int vsif_len)
144 /* Start at pos = 5, since tvb includes the Vendor ID field */
145 int pos = 5;
146 uint8_t type, length;
147 proto_tree *ipprec_tree;
148 proto_item *ipprec_item;
149 int templen;
151 while (pos < vsif_len)
153 /* Extract the type and length Fields from the TLV */
154 type = tvb_get_uint8 (tvb, pos++);
155 length = tvb_get_uint8 (tvb, pos++);
156 switch (type)
158 case NUM_PHONES:
159 proto_tree_add_item (tree, hf_docsis_vsif_cisco_numphones, tvb,
160 pos, length, ENC_BIG_ENDIAN);
161 break;
162 case IP_PREC:
163 ipprec_tree =
164 proto_tree_add_subtree(tree, tvb, pos, length, ett_docsis_vsif_ipprec, &ipprec_item, "IP Precedence");
165 /* Handle Sub-TLVs in IP Precedence */
166 templen = pos + length;
167 while (pos < templen)
169 type = tvb_get_uint8 (tvb, pos++);
170 length = tvb_get_uint8 (tvb, pos++);
171 switch (type)
173 case IP_PREC_VAL:
174 if (length == 1)
176 proto_tree_add_item (ipprec_tree,
177 hf_docsis_vsif_cisco_ipprec_val, tvb,
178 pos, length, ENC_BIG_ENDIAN);
180 else
182 expert_add_info_format(pinfo, ipprec_item, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
184 break;
185 case IP_PREC_BW:
186 if (length != 4)
188 proto_tree_add_item (ipprec_tree,
189 hf_docsis_vsif_cisco_ipprec_bw, tvb,
190 pos, length, ENC_BIG_ENDIAN);
192 else
194 expert_add_info_format(pinfo, ipprec_item, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
196 break;
197 default:
198 expert_add_info_format(pinfo, ipprec_item, &ei_docsis_vsif_tlvtype_unknown, "Unknown TLV: %u", type);
200 pos += length;
202 break;
203 case IOS_CONFIG_FILE:
204 proto_tree_add_item (tree, hf_docsis_vsif_cisco_config_file, tvb,
205 pos, length, ENC_ASCII);
207 pos += length;
211 /* Dissection */
212 static int
213 dissect_vsif (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_)
215 proto_item *it;
216 proto_tree *vsif_tree;
217 uint8_t type;
218 uint8_t length;
219 uint32_t value;
220 int vsif_len;
222 /* get the reported length of the VSIF TLV */
223 vsif_len = tvb_reported_length_remaining (tvb, 0);
225 it = proto_tree_add_protocol_format (tree, proto_docsis_vsif, tvb, 0, -1,
226 "VSIF Encodings");
227 vsif_tree = proto_item_add_subtree (it, ett_docsis_vsif);
228 proto_tree_add_item_ret_uint(vsif_tree, hf_docsis_vsif_vendorid, tvb, 2, 3, ENC_BIG_ENDIAN, &value);
230 /* The first TLV in the VSIF encodings must be type 0x08 (Vendor ID) and
231 * length 3.
233 type = tvb_get_uint8 (tvb, 0);
234 if (type != 0x08)
235 expert_add_info_format(pinfo, it, &ei_docsis_vsif_tlvtype_unknown, "Unknown TLV: %u", type);
237 length = tvb_get_uint8 (tvb, 1);
238 if (length != 3)
239 expert_add_info_format(pinfo, it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
241 /* switch on the Vendor ID */
242 switch (value)
244 case VENDOR_CISCO:
245 proto_item_append_text (it, " (Cisco)");
246 dissect_cisco (tvb, pinfo, vsif_tree, vsif_len);
247 break;
248 case VENDOR_GENERAL:
249 proto_item_append_text (it, " (General Extension Information)");
250 dissect_general_extension_information (tvb, pinfo, vsif_tree, vsif_len);
251 break;
252 default:
253 proto_item_append_text (it, " (Unknown)");
254 proto_tree_add_item (vsif_tree, hf_docsis_vsif_vendor_unknown, tvb,
255 0, -1, ENC_NA);
256 break;
259 return tvb_captured_length(tvb);
263 #define GEX_ECM_EXTENDED_CMTS_MIC_HMAC_TYPE 1
264 #define GEX_ECM_EXTENDED_CMTS_MIC_BITMAP 2
265 #define GEX_ECM_EXPLICIT_EXTENDED_CMTS_MIC_DIGEST_SUBTYPE 3
267 static void
268 dissect_extended_cmts_mic(tvbuff_t * tvb, proto_tree *tree, int start, uint16_t len)
270 proto_item *ecm_it;
271 proto_tree *ecm_tree;
272 uint8_t type, length;
273 int pos = start;
275 ecm_it = proto_tree_add_item (tree, hf_docsis_vsif_gex_ecm, tvb, start, len, ENC_NA);
276 ecm_tree = proto_item_add_subtree(ecm_it, ett_docsis_vsif_gex_ecm);
278 while (pos < (start + len))
280 type = tvb_get_uint8 (tvb, pos++);
281 length = tvb_get_uint8 (tvb, pos++);
282 switch (type)
284 case GEX_ECM_EXTENDED_CMTS_MIC_HMAC_TYPE:
285 proto_tree_add_item (ecm_tree, hf_docsis_vsif_gex_ecm_extended_cmts_mic_hmac_type, tvb, pos, length, ENC_BIG_ENDIAN);
286 break;
287 case GEX_ECM_EXTENDED_CMTS_MIC_BITMAP:
288 proto_tree_add_item (ecm_tree, hf_docsis_vsif_gex_ecm_extended_cmts_mic_bitmap, tvb, pos, length, ENC_NA);
289 break;
290 case GEX_ECM_EXPLICIT_EXTENDED_CMTS_MIC_DIGEST_SUBTYPE:
291 proto_tree_add_item (ecm_tree, hf_docsis_vsif_gex_ecm_explicit_extended_cmts_mic_digest_subtype, tvb, pos, length, ENC_NA);
292 break;
293 default:
294 proto_tree_add_item (ecm_tree, hf_docsis_vsif_tlv_unknown, tvb, pos, length, ENC_NA);
295 break;
296 } /* switch */
297 pos += length;
298 } /* while */
301 #define GEX_SAV_STATIC_PREFIX_ADDRESS 1
302 #define GEX_SAV_STATIC_PREFIX_LENGTH 2
304 static void
305 dissect_sav_static_prefix_rule(tvbuff_t * tvb, packet_info * pinfo, proto_tree *tree, int start, uint16_t len)
307 proto_item *sav_spr_it;
308 proto_tree *sav_spr_tree;
309 uint8_t type, length;
310 int pos = start;
312 sav_spr_it = proto_tree_add_item (tree, hf_docsis_vsif_gex_sav_static_prefix_rule, tvb, start, len, ENC_NA);
313 sav_spr_tree = proto_item_add_subtree(sav_spr_it, ett_docsis_vsif_gex_sav_spr);
315 while (pos < (start + len))
317 type = tvb_get_uint8 (tvb, pos++);
318 length = tvb_get_uint8 (tvb, pos++);
319 switch (type)
321 case GEX_SAV_STATIC_PREFIX_ADDRESS:
322 if (length == 4) {
323 proto_tree_add_item (sav_spr_tree, hf_docsis_vsif_gex_sav_static_prefix_addressv4, tvb, pos, length, ENC_BIG_ENDIAN);
324 } else if (length == 6) {
325 proto_tree_add_item (sav_spr_tree, hf_docsis_vsif_gex_sav_static_prefix_addressv6, tvb, pos, length, ENC_NA);
326 } else {
327 expert_add_info_format(pinfo, sav_spr_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
329 break;
330 case GEX_SAV_STATIC_PREFIX_LENGTH:
331 if (length == 1) {
332 proto_tree_add_item (sav_spr_tree, hf_docsis_vsif_gex_sav_static_prefix_length, tvb, pos, length, ENC_BIG_ENDIAN);
333 } else {
334 expert_add_info_format(pinfo, sav_spr_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
336 break;
337 default:
338 proto_tree_add_item (sav_spr_tree, hf_docsis_vsif_tlv_unknown, tvb, pos, length, ENC_NA);
339 break;
340 } /* switch */
341 pos += length;
342 } /* while */
347 #define GEX_SAV_GROUP_NAME 1
348 #define GEX_SAV_STATIC_PREFIX_RULE 2
351 static void
352 dissect_sav(tvbuff_t * tvb, packet_info * pinfo, proto_tree *tree, int start, uint16_t len)
354 proto_item *sav_it;
355 proto_tree *sav_tree;
356 uint8_t type, length;
357 int pos = start;
359 sav_it = proto_tree_add_item (tree, hf_docsis_vsif_gex_sav, tvb, start, len, ENC_NA);
360 sav_tree = proto_item_add_subtree(sav_it, ett_docsis_vsif_gex_sav);
362 while (pos < (start + len))
364 type = tvb_get_uint8 (tvb, pos++);
365 length = tvb_get_uint8 (tvb, pos++);
366 switch (type)
368 case GEX_SAV_GROUP_NAME:
369 proto_tree_add_item (sav_tree, hf_docsis_vsif_gex_sav_group_name, tvb, pos, length, ENC_ASCII);
370 break;
371 case GEX_SAV_STATIC_PREFIX_RULE:
372 dissect_sav_static_prefix_rule(tvb, pinfo, sav_tree, pos, length);
373 break;
374 default:
375 proto_tree_add_item (sav_tree, hf_docsis_vsif_tlv_unknown, tvb, pos, length, ENC_NA);
376 break;
377 } /* switch */
378 pos += length;
379 } /* while */
383 #define GEX_CM_REQUIRED_DOWNSTREAM_ATTRIBUTE_MASK 1
384 #define GEX_CM_FORBIDDEN_DOWNSTREAM_ATTRIBUTE_MASK 2
385 #define GEX_CM_REQUIRED_UPSTREAM_ATTRIBUTE_MASK 3
386 #define GEX_CM_FORBIDDEN_UPSTREAM_ATTRIBUTE_MASK 4
388 static void
389 dissect_cable_modem_attribute_masks(tvbuff_t * tvb, packet_info * pinfo, proto_tree *tree, int start, uint16_t len)
391 proto_item *cmam_it;
392 proto_tree *cmam_tree;
393 uint8_t type, length;
394 int pos = start;
396 cmam_it = proto_tree_add_item (tree, hf_docsis_vsif_gex_cmam, tvb, start, len, ENC_NA);
397 cmam_tree = proto_item_add_subtree(cmam_it, ett_docsis_vsif_gex_cmam);
399 while (pos < (start + len))
401 type = tvb_get_uint8 (tvb, pos++);
402 length = tvb_get_uint8 (tvb, pos++);
403 switch (type)
405 case GEX_CM_REQUIRED_DOWNSTREAM_ATTRIBUTE_MASK:
406 if (length != 4) {
407 expert_add_info_format(pinfo, cmam_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
409 proto_tree_add_item (cmam_tree, hf_docsis_vsif_gex_cmam_cm_required_downstream_attribute_mask, tvb, pos, length, ENC_NA);
410 break;
411 case GEX_CM_FORBIDDEN_DOWNSTREAM_ATTRIBUTE_MASK:
412 if (length != 4) {
413 expert_add_info_format(pinfo, cmam_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
415 proto_tree_add_item (cmam_tree, hf_docsis_vsif_gex_cmam_cm_forbidden_downstream_attribute_mask, tvb, pos, length, ENC_NA);
416 break;
417 case GEX_CM_REQUIRED_UPSTREAM_ATTRIBUTE_MASK:
418 if (length != 4) {
419 expert_add_info_format(pinfo, cmam_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
421 proto_tree_add_item (cmam_tree, hf_docsis_vsif_gex_cmam_cm_required_upstream_attribute_mask, tvb, pos, length, ENC_NA);
422 break;
423 case GEX_CM_FORBIDDEN_UPSTREAM_ATTRIBUTE_MASK:
424 if (length != 4) {
425 expert_add_info_format(pinfo, cmam_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
427 proto_tree_add_item (cmam_tree, hf_docsis_vsif_gex_cmam_cm_forbidden_upstream_attribute_mask, tvb, pos, length, ENC_NA);
428 break;
429 default: proto_tree_add_item (cmam_tree, hf_docsis_vsif_tlv_unknown, tvb, pos, length, ENC_NA);
430 } /* switch */
431 pos += length;
432 } /* while */
436 #define GEX_IMJA_SSR_RULE_PRIORITY 1
437 #define GEX_IMJA_SSR_AUTHORIZATION_ACTION 2
438 #define GEX_IMJA_SSR_AUTHORIZATION_SOURCE_PREFIX_ADDRESS 3
439 #define GEX_IMJA_SSR_AUTHORIZATION_SOURCE_PREFIX_LENGTH 4
440 #define GEX_IMJA_SSR_AUTHORIZATION_GROUP_PREFIX_ADDRESS 5
441 #define GEX_IMJA_SSR_AUTHORIZATION_GROUP_PREFIX_LENGTH 6
444 static void
445 dissect_ip_multicast_join_authorization_static_session_rule(tvbuff_t * tvb, packet_info * pinfo, proto_tree *tree, int start, uint16_t len)
447 proto_item *imja_ssr_it;
448 proto_tree *imja_ssr_tree;
449 uint8_t type, length;
450 int pos = start;
452 imja_ssr_it = proto_tree_add_item (tree, hf_docsis_vsif_gex_imja_ssr, tvb, start, len, ENC_NA);
453 imja_ssr_tree = proto_item_add_subtree(imja_ssr_it, ett_docsis_vsif_gex_imja_ssr);
455 while (pos < (start + len))
457 type = tvb_get_uint8 (tvb, pos++);
458 length = tvb_get_uint8 (tvb, pos++);
459 switch (type)
461 case GEX_IMJA_SSR_RULE_PRIORITY:
462 if (length != 1) {
463 expert_add_info_format(pinfo, imja_ssr_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
465 proto_tree_add_item (imja_ssr_tree, hf_docsis_vsif_gex_imja_ssr_rule_priority, tvb, pos, length, ENC_BIG_ENDIAN);
466 break;
467 case GEX_IMJA_SSR_AUTHORIZATION_ACTION:
468 if (length != 1) {
469 expert_add_info_format(pinfo, imja_ssr_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
471 proto_tree_add_item (imja_ssr_tree, hf_docsis_vsif_gex_imja_ssr_authorization_action, tvb, pos, length, ENC_BIG_ENDIAN);
472 break;
473 case GEX_IMJA_SSR_AUTHORIZATION_SOURCE_PREFIX_ADDRESS:
474 if (length == 4) {
475 proto_tree_add_item (imja_ssr_tree, hf_docsis_vsif_gex_imja_ssr_source_prefix_addressv4, tvb, pos, length, ENC_BIG_ENDIAN);
476 } else if (length == 6) {
477 proto_tree_add_item (imja_ssr_tree, hf_docsis_vsif_gex_imja_ssr_source_prefix_addressv6, tvb, pos, length, ENC_NA);
478 } else {
479 expert_add_info_format(pinfo, imja_ssr_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
481 break;
482 case GEX_IMJA_SSR_AUTHORIZATION_SOURCE_PREFIX_LENGTH:
483 if (length != 1) {
484 expert_add_info_format(pinfo, imja_ssr_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
486 proto_tree_add_item (imja_ssr_tree, hf_docsis_vsif_gex_imja_ssr_source_prefix_length, tvb, pos, length, ENC_BIG_ENDIAN);
487 break;
488 case GEX_IMJA_SSR_AUTHORIZATION_GROUP_PREFIX_ADDRESS:
489 if (length == 4) {
490 proto_tree_add_item (imja_ssr_tree, hf_docsis_vsif_gex_imja_ssr_group_prefix_addressv4, tvb, pos, length, ENC_BIG_ENDIAN);
491 } else if (length == 6) {
492 proto_tree_add_item (imja_ssr_tree, hf_docsis_vsif_gex_imja_ssr_group_prefix_addressv6, tvb, pos, length, ENC_NA);
493 } else {
494 expert_add_info_format(pinfo, imja_ssr_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
496 break;
497 case GEX_IMJA_SSR_AUTHORIZATION_GROUP_PREFIX_LENGTH:
498 if (length != 1) {
499 expert_add_info_format(pinfo, imja_ssr_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
501 proto_tree_add_item (imja_ssr_tree, hf_docsis_vsif_gex_imja_ssr_group_prefix_length, tvb, pos, length, ENC_BIG_ENDIAN);
502 break;
503 default: proto_tree_add_item (imja_ssr_tree, hf_docsis_vsif_tlv_unknown, tvb, pos, length, ENC_NA);
504 } /* switch */
505 pos += length;
506 } /* while */
509 #define GEX_IMJA_IP_MULTICAST_PROFILE_NAME 1
510 #define GEX_IMJA_IP_MULTICAST_PROFILE_JOIN_AUTHORIZATION_STATIC_SESSION_RULE 2
511 #define GEX_IMJA_MAXIMUM_MULTICAST_SESSIONS 3
514 static void
515 dissect_ip_multicast_join_authorization(tvbuff_t * tvb, packet_info * pinfo, proto_tree *tree, int start, uint16_t len)
517 proto_item *imja_it;
518 proto_tree *imja_tree;
519 uint8_t type, length;
520 int pos = start;
522 imja_it = proto_tree_add_item (tree, hf_docsis_vsif_gex_imja, tvb, start, len, ENC_NA);
523 imja_tree = proto_item_add_subtree(imja_it, ett_docsis_vsif_gex_imja);
525 while (pos < (start + len))
527 type = tvb_get_uint8 (tvb, pos++);
528 length = tvb_get_uint8 (tvb, pos++);
529 switch (type)
531 case GEX_IMJA_IP_MULTICAST_PROFILE_NAME:
532 if ((length < 1) || (length > 15)) {
533 expert_add_info_format(pinfo, imja_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
535 proto_tree_add_item (imja_tree, hf_docsis_vsif_gex_imja_ip_multicast_profile_name, tvb, pos, length, ENC_ASCII);
536 break;
537 case GEX_IMJA_IP_MULTICAST_PROFILE_JOIN_AUTHORIZATION_STATIC_SESSION_RULE:
538 dissect_ip_multicast_join_authorization_static_session_rule(tvb, pinfo, imja_tree, pos, length);
539 break;
540 case GEX_IMJA_MAXIMUM_MULTICAST_SESSIONS:
541 if (length != 2) {
542 expert_add_info_format(pinfo, imja_it, &ei_docsis_vsif_tlvlen_bad, "Wrong TLV length: %u", length);
544 proto_tree_add_item (imja_tree, hf_docsis_vsif_gex_imja_maximum_multicast_sessions, tvb, pos, length, ENC_BIG_ENDIAN);
545 break;
546 default: proto_tree_add_item (imja_tree, hf_docsis_vsif_tlv_unknown, tvb, pos, length, ENC_NA);
547 } /* switch */
548 pos += length;
549 } /* while */
554 /* Dissector for General Extension TLVs */
556 #define GEX_CM_LOAD_BALANCING_POLICY_ID 1
557 #define GEX_CM_LOAD_BALANCING_PRIORITY 2
558 #define GEX_CM_LOAD_BALANCING_GROUP_ID 3
559 #define GEX_CM_RANGING_CLASS_ID_EXTENSION 4
560 #define GEX_L2VPN_ENCODING 5
561 #define GEX_EXTENDED_CMTS_MIC_CONFIGURATION_SETTING 6
562 #define GEX_EXTENDED_SAV 7
563 #define GEX_CABLE_MODEM_ATTRIBUTE_MASKS 9
564 #define GEX_IP_MULTICAST_JOIN_AUTHORIZATION 10
565 #define GEX_SERVICE_TYPE_IDENTIFIER 11
569 static void
570 dissect_general_extension_information (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, int vsif_len)
572 /* Start at pos = 5, since tvb includes the Vendor ID field */
573 int pos = 5;
574 uint8_t type, length;
576 while (pos < vsif_len)
578 /* Extract the type and length Fields from the TLV */
579 type = tvb_get_uint8 (tvb, pos++);
580 length = tvb_get_uint8 (tvb, pos++);
581 switch (type)
583 case GEX_CM_LOAD_BALANCING_POLICY_ID:
584 proto_tree_add_item (tree, hf_docsis_vsif_gex_loadbal_policy_id, tvb, pos, length, ENC_BIG_ENDIAN);
585 break;
586 case GEX_CM_LOAD_BALANCING_PRIORITY:
587 proto_tree_add_item (tree, hf_docsis_vsif_gex_loadbal_priority, tvb, pos, length, ENC_BIG_ENDIAN);
588 break;
589 case GEX_CM_LOAD_BALANCING_GROUP_ID:
590 proto_tree_add_item (tree, hf_docsis_vsif_gex_loadbal_group_id, tvb, pos, length, ENC_BIG_ENDIAN);
591 break;
592 case GEX_CM_RANGING_CLASS_ID_EXTENSION:
593 proto_tree_add_item (tree, hf_docsis_vsif_gex_ranging_class_id_extension, tvb, pos, length, ENC_BIG_ENDIAN);
594 break;
595 case GEX_L2VPN_ENCODING:
596 proto_tree_add_item (tree, hf_docsis_vsif_gex_l2vpn_encoding, tvb, pos, length, ENC_NA);
597 break;
598 case GEX_EXTENDED_CMTS_MIC_CONFIGURATION_SETTING:
599 dissect_extended_cmts_mic(tvb, tree, pos, length);
600 break;
601 case GEX_EXTENDED_SAV:
602 dissect_sav(tvb, pinfo, tree, pos, length);
603 break;
604 case GEX_CABLE_MODEM_ATTRIBUTE_MASKS:
605 dissect_cable_modem_attribute_masks(tvb, pinfo, tree, pos, length);
606 break;
607 case GEX_IP_MULTICAST_JOIN_AUTHORIZATION:
608 dissect_ip_multicast_join_authorization(tvb, pinfo, tree, pos, length);
609 break;
610 case GEX_SERVICE_TYPE_IDENTIFIER:
611 proto_tree_add_item (tree, hf_docsis_vsif_gex_service_type_identifier, tvb, pos, length, ENC_ASCII);
612 break;
613 default:
614 proto_tree_add_item (tree, hf_docsis_vsif_tlv_unknown, tvb, pos, length, ENC_NA);
616 pos += length;
621 /* Register the protocol with Wireshark */
622 void
623 proto_register_docsis_vsif (void)
625 static hf_register_info hf[] = {
626 {&hf_docsis_vsif_vendorid,
627 {"Vendor ID", "docsis_vsif.vendorid",
628 FT_UINT24, BASE_HEX, VALS(vendorid_vals), 0x0,
629 "Vendor Identifier", HFILL}
631 {&hf_docsis_vsif_vendor_unknown,
632 {"VSIF Encodings", "docsis_vsif.unknown",
633 FT_BYTES, BASE_NONE, NULL, 0x0,
634 "Unknown Vendor", HFILL}
636 {&hf_docsis_vsif_cisco_numphones,
637 {"Number of phone lines", "docsis_vsif.cisco.numphones",
638 FT_UINT8, BASE_DEC, NULL, 0x0,
639 NULL, HFILL}
641 #if 0
642 {&hf_docsis_vsif_cisco_ipprec,
643 {"IP Precedence Encodings", "docsis_vsif.cisco.ipprec",
644 FT_BYTES, BASE_NONE, NULL, 0x0,
645 NULL, HFILL}
647 #endif
648 {&hf_docsis_vsif_cisco_ipprec_val,
649 {"IP Precedence Value", "docsis_vsif.cisco.ipprec.value",
650 FT_UINT8, BASE_DEC, NULL, 0x0,
651 NULL, HFILL}
653 {&hf_docsis_vsif_cisco_ipprec_bw,
654 {"IP Precedence Bandwidth", "docsis_vsif.cisco.ipprec.bw",
655 FT_UINT8, BASE_DEC, NULL, 0x0,
656 NULL, HFILL}
658 {&hf_docsis_vsif_cisco_config_file,
659 {"IOS Config File", "docsis_vsif.cisco.iosfile",
660 FT_STRING, BASE_NONE, NULL, 0x0,
661 NULL, HFILL}
663 {&hf_docsis_vsif_gex_loadbal_policy_id,
664 {".1 CM Load Balancing Policy ID", "docsis_vsif.gex.loadbal_policyid",
665 FT_UINT32, BASE_DEC, NULL, 0x0,
666 "General Extension Information - CM Load Balancing Policy ID", HFILL}
668 {&hf_docsis_vsif_gex_loadbal_priority,
669 {".2 CM Load Balancing Priority", "docsis_vsif.gex.loadbal_priority",
670 FT_UINT32, BASE_DEC, NULL, 0x0,
671 "General Extension Information - CM Load Balancing Priority", HFILL}
673 {&hf_docsis_vsif_gex_loadbal_group_id,
674 {".3 CM Load Balancing Group ID", "docsis_vsif.gex.loadbal_group_id",
675 FT_UINT32, BASE_DEC, NULL, 0x0,
676 "General Extension Information - CM Load Balancing Group ID", HFILL}
678 {&hf_docsis_vsif_gex_ranging_class_id_extension,
679 {".4 CM Ranging Class ID Extension", "docsis_vsif.gex.ranging_class_id_extension",
680 FT_UINT32, BASE_DEC, NULL, 0x0,
681 "General Extension Information - CM Ranging Class ID Extension", HFILL}
683 {&hf_docsis_vsif_gex_l2vpn_encoding,
684 {".5 L2VPN Encoding", "docsis_vsif.gex.l2vpn_encoding",
685 FT_BYTES, BASE_NONE, NULL, 0x0,
686 "General Extension Information - L2VPN Encoding", HFILL}
688 {&hf_docsis_vsif_gex_ecm,
689 {".6 Extended CMTS MIC Configuration Setting", "docsis_vsif.gex.extended_cmts_mic_configuration_setting",
690 FT_BYTES, BASE_NONE, NULL, 0x0,
691 "General Extension Information - Extended CMTS MIC Configuration Setting", HFILL}
693 {&hf_docsis_vsif_gex_ecm_extended_cmts_mic_hmac_type,
694 {"..1 Extended CMTS MIC Hmac type", "docsis_vsif.gex.extended_cmts_mic_hmac_type",
695 FT_UINT8, BASE_DEC, VALS(hmac_vals), 0x0,
696 "General Extension Information - Extended CMTS MIC Hmac type", HFILL}
698 {&hf_docsis_vsif_gex_ecm_extended_cmts_mic_bitmap,
699 {"..2 Extended CMTS MIC Bitmap", "docsis_vsif.gex.extended_cmts_mic_bitmap",
700 FT_BYTES, BASE_NONE, NULL, 0x0,
701 "General Extension Information - Extended CMTS MIC Bitmap", HFILL}
703 {&hf_docsis_vsif_gex_ecm_explicit_extended_cmts_mic_digest_subtype,
704 {"..3 Explicit Extended CMTS MIC Digest Subtype", "docsis_vsif.gex.extended_cmts_mic_digest_subtype",
705 FT_BYTES, BASE_NONE, NULL, 0x0,
706 "General Extension Information - Explicit Extended CMTS MIC Digest Subtype", HFILL}
708 {&hf_docsis_vsif_gex_sav,
709 {".7 Source Address Verification (SAV) Authorization Encoding", "docsis_vsif.gex.sav",
710 FT_BYTES, BASE_NONE, NULL, 0x0,
711 "General Extension Information - Source Address Verification (SAV) Authorization Encoding", HFILL}
713 {&hf_docsis_vsif_gex_sav_group_name,
714 {"..1 SAV Group Name", "docsis_vsif.gex.sav.sav_group_name",
715 FT_STRING, BASE_NONE, NULL, 0x0,
716 "General Extension Information - SAV - SAV Group Name", HFILL}
718 {&hf_docsis_vsif_gex_sav_static_prefix_rule,
719 {"..2 SAV Static Prefix Rule", "docsis_vsif.gex.sav.static_prefix_rule",
720 FT_BYTES, BASE_NONE, NULL, 0x0,
721 "General Extension Information - SAV -Static Prefix Rule", HFILL}
723 {&hf_docsis_vsif_gex_sav_static_prefix_addressv4,
724 {"...1 SAV Static Prefix Address", "docsis_vsif.gex.sav.spr.static_prefix_address4",
725 FT_IPv4, BASE_NONE, NULL, 0x0,
726 "General Extension Information - SAV -Static Prefix Rule - Static Prefix Address", HFILL}
728 {&hf_docsis_vsif_gex_sav_static_prefix_addressv6,
729 {"...1 SAV Static Prefix Address", "docsis_vsif.gex.sav.spr.static_prefix_address6",
730 FT_IPv6, BASE_NONE, NULL, 0x0,
731 "General Extension Information - SAV -Static Prefix Rule - Static Prefix Address", HFILL}
733 {&hf_docsis_vsif_gex_sav_static_prefix_length,
734 {"...2 SAV Static Prefix Length", "docsis_vsif.gex.sav.spr.static_prefix_length",
735 FT_UINT8, BASE_DEC, NULL, 0x0,
736 "General Extension Information - SAV -Static Prefix Rule - Static Prefix Length", HFILL}
738 {&hf_docsis_vsif_gex_cmam,
739 {".9 CM Attribute Mask", "docsis_vsif.gex.cmam",
740 FT_BYTES, BASE_NONE, NULL, 0x0,
741 "General Extension Information - CM Attribute Mask", HFILL}
743 {&hf_docsis_vsif_gex_cmam_cm_required_downstream_attribute_mask,
744 {"..1 CM Required Downstream Attribute", "docsis_vsif.gex.cmam.cm_required_downstream_attribute",
745 FT_BYTES, BASE_NONE, NULL, 0x0,
746 "General Extension Information - CM Attribute Mask - CM Required Downstream Attribute", HFILL}
748 {&hf_docsis_vsif_gex_cmam_cm_forbidden_downstream_attribute_mask,
749 {"..2 CM Forbidden Downstream Attribute", "docsis_vsif.gex.cmam.cm_forbidden_downstream_attribute",
750 FT_BYTES, BASE_NONE, NULL, 0x0,
751 "General Extension Information - CM Attribute Mask - CM Forbidden Downstream Attribute", HFILL}
753 {&hf_docsis_vsif_gex_cmam_cm_required_upstream_attribute_mask,
754 {"..3 CM Required Upstream Attribute", "docsis_vsif.gex.cmam.cm_required_upstream_attribute",
755 FT_BYTES, BASE_NONE, NULL, 0x0,
756 "General Extension Information - CM Attribute Mask - CM Required Upstream Attribute", HFILL}
758 {&hf_docsis_vsif_gex_cmam_cm_forbidden_upstream_attribute_mask,
759 {"..4 CM Forbidden Upstream Attribute", "docsis_vsif.gex.cmam.cm_forbidden_upstream_attribute",
760 FT_BYTES, BASE_NONE, NULL, 0x0,
761 "General Extension Information - CM Attribute Mask - CM Forbidden Upstream Attribute", HFILL}
763 {&hf_docsis_vsif_gex_imja,
764 {".10 IP Multicast Join Authorization", "docsis_vsif.gex.imja",
765 FT_BYTES, BASE_NONE, NULL, 0x0,
766 "General Extension Information - IP Multicast Join Authorization", HFILL}
768 {&hf_docsis_vsif_gex_imja_ip_multicast_profile_name,
769 {"..1 IP Multicast Profile Name", "docsis_vsif.gex.imja.ip_multicast_profile_name",
770 FT_STRING, BASE_NONE, NULL, 0x0,
771 "General Extension Information - IP Multicast Join Authorization - IP Multicast Profile Name", HFILL}
773 {&hf_docsis_vsif_gex_imja_ssr,
774 {"..2 IP Multicast Profile Join Authorization Static Session Rule", "docsis_vsif.gex.imja.ip_multicast_join_authorization_static_session_rule",
775 FT_BYTES, BASE_NONE, NULL, 0x0,
776 "General Extension Information - IP Multicast Join Authorization - IP Multicast Profile Join Authorization Static Session Rule", HFILL}
778 {&hf_docsis_vsif_gex_imja_ssr_rule_priority,
779 {"...1 Rule Priority", "docsis_vsif.gex.imja.imja_ssr_rule_priority",
780 FT_UINT8, BASE_DEC, NULL, 0x0,
781 "General Extension Information - IP Multicast Join Authorization - IP Multicast Profile Join Authorization Static Session Rule - Rule Priority", HFILL}
783 {&hf_docsis_vsif_gex_imja_ssr_authorization_action,
784 {"...2 Authorization Action", "docsis_vsif.gex.imja.imja_ssr_authorization_action",
785 FT_UINT8, BASE_DEC, VALS(authorization_action_vals), 0x0,
786 "General Extension Information - IP Multicast Join Authorization - IP Multicast Profile Join Authorization Static Session Rule - Rule Priority", HFILL}
788 {&hf_docsis_vsif_gex_imja_ssr_source_prefix_addressv4,
789 {"...3 Source Prefix Address", "docsis_vsif.gex.imja.imja_ssr_source_prefix_address4",
790 FT_IPv4, BASE_NONE, NULL, 0x0,
791 "General Extension Information - IP Multicast Join Authorization - IP Multicast Profile Join Authorization Static Session Rule - Source Prefix Address", HFILL}
793 {&hf_docsis_vsif_gex_imja_ssr_source_prefix_addressv6,
794 {"...3 Source Prefix Address", "docsis_vsif.gex.imja.imja_ssr_source_prefix_address6",
795 FT_IPv6, BASE_NONE, NULL, 0x0,
796 "General Extension Information - IP Multicast Join Authorization - IP Multicast Profile Join Authorization Static Session Rule - Source Prefix Address", HFILL}
798 {&hf_docsis_vsif_gex_imja_ssr_source_prefix_length,
799 {"...4 Source Prefix Length", "docsis_vsif.gex.imja.imja_ssr_source_prefix_length",
800 FT_UINT8, BASE_DEC, NULL, 0x0,
801 "General Extension Information - IP Multicast Join Authorization - IP Multicast Profile Join Authorization Static Session Rule - Source Prefix Length", HFILL}
803 {&hf_docsis_vsif_gex_imja_ssr_group_prefix_addressv4,
804 {"...5 Group Prefix Address", "docsis_vsif.gex.imja.imja_ssr_group_prefix_address4",
805 FT_IPv4, BASE_NONE, NULL, 0x0,
806 "General Extension Information - IP Multicast Join Authorization - IP Multicast Profile Join Authorization Static Session Rule - Group Prefix Address", HFILL}
808 {&hf_docsis_vsif_gex_imja_ssr_group_prefix_addressv6,
809 {"...5 Group Prefix Address", "docsis_vsif.gex.imja.imja_ssr_group_prefix_address6",
810 FT_IPv6, BASE_NONE, NULL, 0x0,
811 "General Extension Information - IP Multicast Join Authorization - IP Multicast Profile Join Authorization Static Session Rule - Group Prefix Address", HFILL}
813 {&hf_docsis_vsif_gex_imja_ssr_group_prefix_length,
814 {"...6 Group Prefix Length", "docsis_vsif.gex.imja.imja_ssr_group_prefix_length",
815 FT_UINT8, BASE_DEC, NULL, 0x0,
816 "General Extension Information - IP Multicast Join Authorization - IP Multicast Profile Join Authorization Static Session Rule - Group Prefix Length", HFILL}
818 {&hf_docsis_vsif_gex_imja_maximum_multicast_sessions,
819 {"..3 Maximum Multicast Sessions", "docsis_vsif.gex.imja.imja_maximum_multicast_sessions",
820 FT_UINT16, BASE_DEC, NULL, 0x0,
821 "General Extension Information - IP Multicast Join Authorization - Maximum Multicast Sessions", HFILL}
823 {&hf_docsis_vsif_gex_service_type_identifier,
824 {".11 Service Type Identifier", "docsis_vsif.gex.service_type_identifier",
825 FT_STRING, BASE_NONE, NULL, 0x0,
826 "General Extension Information - Service Type Identifier", HFILL}
828 {&hf_docsis_vsif_tlv_unknown,
829 {"Unknown VSIF TLV", "docsis_vsif.unknown",
830 FT_BYTES, BASE_NONE, NULL, 0x0,
831 NULL, HFILL}
835 static int *ett[] = {
836 &ett_docsis_vsif,
837 &ett_docsis_vsif_ipprec,
838 &ett_docsis_vsif_gex_ecm,
839 &ett_docsis_vsif_gex_sav,
840 &ett_docsis_vsif_gex_sav_spr,
841 &ett_docsis_vsif_gex_cmam,
842 &ett_docsis_vsif_gex_imja,
843 &ett_docsis_vsif_gex_imja_ssr
846 expert_module_t* expert_docsis_vsif;
848 static ei_register_info ei[] = {
849 {&ei_docsis_vsif_tlvlen_bad, { "docsis_vsif.tlvlenbad", PI_MALFORMED, PI_ERROR, "Bad TLV length", EXPFILL}},
850 {&ei_docsis_vsif_tlvtype_unknown, { "docsis_vsif.tlvtypeunknown", PI_PROTOCOL, PI_WARN, "Unknown TLV type", EXPFILL}},
853 proto_docsis_vsif =
854 proto_register_protocol ("DOCSIS Vendor Specific Encodings",
855 "DOCSIS VSIF", "docsis_vsif");
857 proto_register_field_array (proto_docsis_vsif, hf, array_length (hf));
858 proto_register_subtree_array (ett, array_length (ett));
859 expert_docsis_vsif = expert_register_protocol(proto_docsis_vsif);
860 expert_register_field_array(expert_docsis_vsif, ei, array_length(ei));
862 register_dissector ("docsis_vsif", dissect_vsif, proto_docsis_vsif);
865 void
866 proto_reg_handoff_docsis_vsif (void)
868 #if 0
869 dissector_handle_t docsis_vsif_handle;
871 docsis_vsif_handle = find_dissector ("docsis_vsif");
872 dissector_add_uint ("docsis", 0xFD, docsis_vsif_handle);
873 #endif
877 * Editor modelines - https://www.wireshark.org/tools/modelines.html
879 * Local Variables:
880 * c-basic-offset: 2
881 * tab-width: 8
882 * indent-tabs-mode: nil
883 * End:
885 * ex: set shiftwidth=2 tabstop=8 expandtab:
886 * :indentSize=2:tabSize=8:noTabs=true: