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 * $Id: packet-diffserv-mpls-common.c,v 1.2 2003/10/13 20:53:30 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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.
38 #include <epan/packet.h>
39 #include "packet-diffserv-mpls-common.h"
41 #define hf_map *hfindexes[0]
42 #define hf_exp *hfindexes[1]
43 #define hf_phbid *hfindexes[2]
44 #define hf_phbid_dscp *hfindexes[3]
45 #define hf_phbid_code *hfindexes[4]
46 #define hf_phbid_bit14 *hfindexes[5]
47 #define hf_phbid_bit15 *hfindexes[6]
48 #define ett_map *etts[0]
49 #define ett_map_phbid *etts[1]
51 const value_string phbid_bit14_vals[] = {
57 const value_string phbid_bit15_vals[] = {
58 {0, "PHBs defined by standards action"},
59 {1, "PHBs not defined by standards action"},
64 dissect_diffserv_mpls_common(tvbuff_t *tvb, proto_tree *tree, int type,
65 int offset, int **hfindexes, gint **etts)
67 proto_item *ti = NULL, *sub_ti;
68 proto_tree *tree2 = NULL, *phbid_subtree;
74 ti = proto_tree_add_item(tree, hf_map, tvb, offset, 4, FALSE);
75 tree2 = proto_item_add_subtree(ti, ett_map);
76 proto_item_set_text(ti, "MAP: ");
78 exp = tvb_get_guint8(tvb, offset) & 7;
79 proto_tree_add_uint(tree2, hf_exp, tvb, offset, 1, exp);
80 proto_item_append_text(ti, "EXP %u, ", exp);
91 sub_ti = proto_tree_add_item(tree2, hf_phbid, tvb, offset, 2, FALSE);
92 phbid_subtree = proto_item_add_subtree(sub_ti, ett_map_phbid);
93 proto_item_set_text(sub_ti, "%s: ", (type == 1) ? "PHBID" : "PSC");
94 phbid = tvb_get_ntohs(tvb, offset);
96 if ((phbid & 1) == 0) {
97 /* Case 1 of RFC 3140 */
98 proto_tree_add_uint(phbid_subtree, hf_phbid_dscp,
99 tvb, offset, 2, phbid);
101 proto_item_append_text(ti, "DSCP %u", phbid >> 10);
102 proto_item_append_text(sub_ti, "DSCP %u", phbid >> 10);
105 /* Case 2 of RFC 3140 */
106 proto_tree_add_uint(phbid_subtree, hf_phbid_code,
107 tvb, offset, 2, phbid);
109 proto_item_append_text(ti, "PHB id code %u", phbid >> 4);
110 proto_item_append_text(sub_ti, "PHB id code %u", phbid >> 4);
112 proto_tree_add_uint(phbid_subtree, hf_phbid_bit14, tvb, offset, 2, phbid);
113 proto_tree_add_uint(phbid_subtree, hf_phbid_bit15, tvb, offset, 2, phbid);