2 * Common functions and objects for PWE3 dissectors.
3 * Copyright 2009, Artem Tamazov <artem.tamazov@tellabs.com>
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
14 #include <epan/packet.h>
15 #include <wsutil/str_util.h>
16 #include "packet-pw-common.h"
18 void proto_register_pw_padding(void);
20 static const char string_ok
[] = "Ok";
23 pwc_vals_cw_l_bit
[] = {
25 { 0x1, "Attachment Circuit Fault" },
31 pwc_vals_cw_r_bit
[] = {
33 { 0x1, "Packet Loss State" },
38 pwc_vals_cw_frag
[] = {
39 { 0x0, "Unfragmented" },
40 { 0x1, "First fragment" },
41 { 0x2, "Last fragment" },
42 { 0x3, "Intermediate fragment" },
47 void pwc_item_append_cw(proto_item
* item
, const uint32_t cw
, const bool append_text
)
53 proto_item_append_text(item
, ", CW");
55 proto_item_append_text(item
, ": 0x%.8" PRIx32
, cw
);
61 void pwc_item_append_text_n_items(proto_item
* item
, const int n
, const char * const item_text
)
67 proto_item_append_text(item
, ", %d %s%s", n
, item_text
, plurality(n
,"","s"));
74 static int proto_pw_padding
;
75 static int ett_pw_common
;
76 static int hf_padding_len
;
79 int dissect_pw_padding(tvbuff_t
* tvb
, packet_info
* pinfo
, proto_tree
* tree
, void* data _U_
)
84 size
= tvb_reported_length_remaining(tvb
, 0);
85 item
= proto_tree_add_item(tree
, proto_pw_padding
, tvb
, 0, -1, ENC_NA
);
86 pwc_item_append_text_n_items(item
,size
,"byte");
87 tree_p
= proto_item_add_subtree(item
, ett_pw_common
);
89 call_data_dissector(tvb
, pinfo
, tree_p
);
90 item
= proto_tree_add_int(tree_p
, hf_padding_len
, tvb
, 0, 0, size
);
91 proto_item_set_hidden(item
); /*allow filtering*/
93 return tvb_captured_length(tvb
);
96 void proto_register_pw_padding(void)
98 static hf_register_info hfpadding
[] = {
99 {&hf_padding_len
,{"Length" ,"pw.padding.len"
100 ,FT_INT32
,BASE_DEC
,NULL
,0
103 static int *ett_array
[] = {
106 proto_pw_padding
= proto_register_protocol("Pseudowire Padding","PW Padding","pw.padding");
107 proto_register_field_array(proto_pw_padding
, hfpadding
, array_length(hfpadding
));
108 proto_register_subtree_array(ett_array
, array_length(ett_array
));
109 register_dissector("pw_padding", dissect_pw_padding
, proto_pw_padding
);
114 * Editor modelines - https://www.wireshark.org/tools/modelines.html
119 * indent-tabs-mode: t
122 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
123 * :indentSize=8:tabSize=8:noTabs=false: