Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-diffserv-mpls-common.c
blobf4add8a4a4a298211f727bbd9f78510f3650a7b6
1 /* packet-diffserv-mpls-common.c
2 * Routines for the common part of Diffserv MPLS signaling protocols
3 * Author: Endoh Akira (endoh@netmarks.co.jp)
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 * This module defines routines only for the common part of LDP
14 * and RSVP to support for Diffserv MPLS as described in RFC 3270
15 * and RFC 3140. Protocol specific routines of each signaling
16 * protocol are defined in each dissector.
19 #include "config.h"
21 #include <epan/packet.h>
22 #include "packet-diffserv-mpls-common.h"
24 #define hf_map *hfindexes[0]
25 #define hf_exp *hfindexes[1]
26 #define hf_phbid *hfindexes[2]
27 #define hf_phbid_dscp *hfindexes[3]
28 #define hf_phbid_code *hfindexes[4]
29 #define hf_phbid_bit14 *hfindexes[5]
30 #define hf_phbid_bit15 *hfindexes[6]
31 #define ett_map *etts[0]
32 #define ett_map_phbid *etts[1]
34 const value_string phbid_bit14_vals[] = {
35 {0, "Single PHB"},
36 {1, "Set of PHBs"},
37 {0, NULL}
40 const value_string phbid_bit15_vals[] = {
41 {0, "PHBs defined by standards action"},
42 {1, "PHBs not defined by standards action"},
43 {0, NULL}
46 void
47 dissect_diffserv_mpls_common(tvbuff_t *tvb, proto_tree *tree, int type,
48 int offset, int **hfindexes, int **etts)
50 proto_item *ti = NULL, *sub_ti;
51 proto_tree *tree2 = NULL, *phbid_subtree;
52 int exp;
53 uint16_t phbid;
55 switch (type) {
56 case 1: /* E-LSP */
57 ti = proto_tree_add_item(tree, hf_map, tvb, offset, 4, ENC_NA);
58 tree2 = proto_item_add_subtree(ti, ett_map);
59 proto_item_set_text(ti, "MAP: ");
60 offset ++;
61 exp = tvb_get_uint8(tvb, offset) & 7;
62 proto_tree_add_uint(tree2, hf_exp, tvb, offset, 1, exp);
63 proto_item_append_text(ti, "EXP %u, ", exp);
64 offset ++;
65 break;
66 case 2: /* L-LSP */
67 tree2 = tree;
68 break;
69 default:
70 return;
73 /* PHBID subtree */
74 sub_ti = proto_tree_add_item(tree2, hf_phbid, tvb, offset, 2, ENC_NA);
75 phbid_subtree = proto_item_add_subtree(sub_ti, ett_map_phbid);
76 proto_item_set_text(sub_ti, "%s: ", (type == 1) ? PHBID_DESCRIPTION : "PSC");
77 phbid = tvb_get_ntohs(tvb, offset);
79 if ((phbid & 1) == 0) {
80 /* Case 1 of RFC 3140 */
81 proto_tree_add_uint(phbid_subtree, hf_phbid_dscp,
82 tvb, offset, 2, phbid);
83 if (type == 1)
84 proto_item_append_text(ti, "DSCP %u", phbid >> 10);
85 proto_item_append_text(sub_ti, "DSCP %u", phbid >> 10);
87 else {
88 /* Case 2 of RFC 3140 */
89 proto_tree_add_uint(phbid_subtree, hf_phbid_code,
90 tvb, offset, 2, phbid);
91 if (type == 1)
92 proto_item_append_text(ti, "PHB id code %u", phbid >> 4);
93 proto_item_append_text(sub_ti, "PHB id code %u", phbid >> 4);
95 proto_tree_add_uint(phbid_subtree, hf_phbid_bit14, tvb, offset, 2, phbid);
96 proto_tree_add_uint(phbid_subtree, hf_phbid_bit15, tvb, offset, 2, phbid);
100 * Editor modelines - https://www.wireshark.org/tools/modelines.html
102 * Local variables:
103 * c-basic-offset: 4
104 * tab-width: 8
105 * indent-tabs-mode: nil
106 * End:
108 * vi: set shiftwidth=4 tabstop=8 expandtab:
109 * :indentSize=4:tabSize=8:noTabs=true: