HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-pw-common.c
blob7189d0bf459d0f2fcfc4aec958a1ad732c6dc54b
1 /* packet-pw-common.c
2 * Common functions and objects for PWE3 dissectors.
3 * Copyright 2009, Artem Tamazov <artem.tamazov@tellabs.com>
5 * $Id$
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.
26 #include "config.h"
28 #include <epan/packet.h>
29 #include "packet-pw-common.h"
31 static const char string_ok[] = "Ok";
33 const value_string
34 pwc_vals_cw_l_bit[] = {
35 { 0x0, string_ok },
36 { 0x1, "Attachment Circuit Fault" },
37 { 0, NULL }
41 const value_string
42 pwc_vals_cw_r_bit[] = {
43 { 0x0, string_ok },
44 { 0x1, "Packet Loss State" },
45 { 0, NULL }
48 const value_string
49 pwc_vals_cw_frag[] = {
50 { 0x0, "Unfragmented" },
51 { 0x1, "First fragment" },
52 { 0x2, "Last fragment" },
53 { 0x3, "Intermediate fragment" },
54 { 0, NULL }
58 void pwc_item_append_cw(proto_item* item, const guint32 cw, const gboolean append_text)
60 if (item != NULL)
62 if (append_text)
64 proto_item_append_text(item, ", CW");
66 proto_item_append_text(item, ": 0x%.8" G_GINT32_MODIFIER "x", cw);
68 return;
72 void pwc_item_append_text_n_items(proto_item* item, const int n, const char * const item_text)
74 if (item != NULL)
76 if (n >=0)
78 proto_item_append_text(item, ", %d %s%s", n, item_text, plurality(n,"","s"));
81 return;
85 static gint proto_pw_padding = -1;
86 static gint ett = -1;
87 static int hf_padding_len = -1;
88 static dissector_handle_t dh_data;
90 static
91 void dissect_pw_padding(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
93 /* do not touch columns */
94 if (tree)
96 gint size;
97 proto_item* item;
98 size = tvb_reported_length_remaining(tvb, 0);
99 item = proto_tree_add_item(tree, proto_pw_padding, tvb, 0, -1, ENC_NA);
100 pwc_item_append_text_n_items(item,size,"byte");
102 proto_tree* tree_p;
103 tree_p = proto_item_add_subtree(item, ett);
104 call_dissector(dh_data, tvb, pinfo, tree_p);
105 item = proto_tree_add_int(tree_p, hf_padding_len, tvb, 0, 0, size);
106 PROTO_ITEM_SET_HIDDEN(item); /*allow filtering*/
109 return;
112 void proto_register_pw_padding(void)
114 static hf_register_info hfpadding[] = {
115 {&hf_padding_len ,{"Length" ,"pw.padding.len"
116 ,FT_INT32 ,BASE_DEC ,NULL ,0
117 ,NULL ,HFILL }}
119 static gint *ett_array[] = {
120 &ett
122 proto_pw_padding = proto_register_protocol("Pseudowire Padding","PW Padding","pwpadding");
123 proto_register_field_array(proto_pw_padding, hfpadding, array_length(hfpadding));
124 proto_register_subtree_array(ett_array, array_length(ett_array));
125 register_dissector("pw_padding", dissect_pw_padding, proto_pw_padding);
126 return;
130 void proto_reg_handoff_pw_padding(void)
132 dh_data = find_dissector("data");
133 return;