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)
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * This module defines routines only for the common part of LDP
28 * and RSVP to support for Diffserv MPLS as described in RFC 3270
29 * and RFC 3140. Protocol specific routines of each signaling
30 * protocol are defined in each dissector.
36 #include <epan/packet.h>
37 #include "packet-diffserv-mpls-common.h"
39 #define hf_map *hfindexes[0]
40 #define hf_exp *hfindexes[1]
41 #define hf_phbid *hfindexes[2]
42 #define hf_phbid_dscp *hfindexes[3]
43 #define hf_phbid_code *hfindexes[4]
44 #define hf_phbid_bit14 *hfindexes[5]
45 #define hf_phbid_bit15 *hfindexes[6]
46 #define ett_map *etts[0]
47 #define ett_map_phbid *etts[1]
49 const value_string phbid_bit14_vals
[] = {
55 const value_string phbid_bit15_vals
[] = {
56 {0, "PHBs defined by standards action"},
57 {1, "PHBs not defined by standards action"},
62 dissect_diffserv_mpls_common(tvbuff_t
*tvb
, proto_tree
*tree
, int type
,
63 int offset
, int **hfindexes
, gint
**etts
)
65 proto_item
*ti
= NULL
, *sub_ti
;
66 proto_tree
*tree2
= NULL
, *phbid_subtree
;
72 ti
= proto_tree_add_item(tree
, hf_map
, tvb
, offset
, 4, ENC_NA
);
73 tree2
= proto_item_add_subtree(ti
, ett_map
);
74 proto_item_set_text(ti
, "MAP: ");
76 exp
= tvb_get_guint8(tvb
, offset
) & 7;
77 proto_tree_add_uint(tree2
, hf_exp
, tvb
, offset
, 1, exp
);
78 proto_item_append_text(ti
, "EXP %u, ", exp
);
89 sub_ti
= proto_tree_add_item(tree2
, hf_phbid
, tvb
, offset
, 2, ENC_NA
);
90 phbid_subtree
= proto_item_add_subtree(sub_ti
, ett_map_phbid
);
91 proto_item_set_text(sub_ti
, "%s: ", (type
== 1) ? PHBID_DESCRIPTION
: "PSC");
92 phbid
= tvb_get_ntohs(tvb
, offset
);
94 if ((phbid
& 1) == 0) {
95 /* Case 1 of RFC 3140 */
96 proto_tree_add_uint(phbid_subtree
, hf_phbid_dscp
,
97 tvb
, offset
, 2, phbid
);
99 proto_item_append_text(ti
, "DSCP %u", phbid
>> 10);
100 proto_item_append_text(sub_ti
, "DSCP %u", phbid
>> 10);
103 /* Case 2 of RFC 3140 */
104 proto_tree_add_uint(phbid_subtree
, hf_phbid_code
,
105 tvb
, offset
, 2, phbid
);
107 proto_item_append_text(ti
, "PHB id code %u", phbid
>> 4);
108 proto_item_append_text(sub_ti
, "PHB id code %u", phbid
>> 4);
110 proto_tree_add_uint(phbid_subtree
, hf_phbid_bit14
, tvb
, offset
, 2, phbid
);
111 proto_tree_add_uint(phbid_subtree
, hf_phbid_bit15
, tvb
, offset
, 2, phbid
);