Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-pw-common.c
blob2ce5880b8f9039a34429b6996c75dc0c79ade20f
1 /* packet-pw-common.c
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
12 #include "config.h"
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";
22 const value_string
23 pwc_vals_cw_l_bit[] = {
24 { 0x0, string_ok },
25 { 0x1, "Attachment Circuit Fault" },
26 { 0, NULL }
30 const value_string
31 pwc_vals_cw_r_bit[] = {
32 { 0x0, string_ok },
33 { 0x1, "Packet Loss State" },
34 { 0, NULL }
37 const value_string
38 pwc_vals_cw_frag[] = {
39 { 0x0, "Unfragmented" },
40 { 0x1, "First fragment" },
41 { 0x2, "Last fragment" },
42 { 0x3, "Intermediate fragment" },
43 { 0, NULL }
47 void pwc_item_append_cw(proto_item* item, const uint32_t cw, const bool append_text)
49 if (item != NULL)
51 if (append_text)
53 proto_item_append_text(item, ", CW");
55 proto_item_append_text(item, ": 0x%.8" PRIx32, cw);
57 return;
61 void pwc_item_append_text_n_items(proto_item* item, const int n, const char * const item_text)
63 if (item != NULL)
65 if (n >=0)
67 proto_item_append_text(item, ", %d %s%s", n, item_text, plurality(n,"","s"));
70 return;
74 static int proto_pw_padding;
75 static int ett_pw_common;
76 static int hf_padding_len;
78 static
79 int dissect_pw_padding(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_)
81 int size;
82 proto_item* item;
83 proto_tree* tree_p;
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
101 ,NULL ,HFILL }}
103 static int *ett_array[] = {
104 &ett_pw_common
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
116 * Local variables:
117 * c-basic-offset: 8
118 * tab-width: 8
119 * indent-tabs-mode: t
120 * End:
122 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
123 * :indentSize=8:tabSize=8:noTabs=false: