Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-pw-oam.c
blob927acc8eae5ae47f0c8beaf2d06e388bf9d578ba
1 /* packet-pw-oam.c
3 * Routines for Pseudowire Status for static pseudowires : RFC 6478
5 * (c) Copyright 2012, Krishnamurthy Mayya <krishnamurthymayya@gmail.com>
6 * Nikitha Malgi <nikitha01@gmail.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include "config.h"
16 #include <epan/packet.h>
17 #include "packet-mpls.h"
19 void proto_register_pw_oam(void);
20 void proto_reg_handoff_pw_oam(void);
22 static dissector_handle_t pw_oam_handle;
24 /* MPLS-TP FM protocol specific variables */
25 static int proto_pw_oam;
26 static int ett_pw_oam;
27 static int ett_pw_oam_flags;
28 static int ett_pw_oam_tlv_tree;
30 static int hf_pw_oam_tlv_reserved;
31 static int hf_pw_oam_tlv_type;
32 static int hf_pw_oam_total_tlv_len;
33 static int hf_pw_oam_code;
34 static int hf_pw_oam_flags;
35 static int hf_pw_oam_flags_a;
36 static int hf_pw_oam_refresh_timer;
37 static int hf_pw_oam_tlv_len;
39 static const value_string pw_oam_code[] = {
40 {0x00000002, "Local Attachment Circuit(ingress) Receive Fault"},
41 {0x00000004, "Local Attachment Circuit(egress) Transmit Fault"},
42 {0x00000020, "PW Forwarding Standby"},
43 {0x00000040, "Request Switchover to this PW"},
44 {0, NULL}
47 /* PW-Status TLV dissector */
48 static void
49 dissect_pw_status_tlv (tvbuff_t *tvb, proto_tree *tree, int offset)
51 proto_item *ti;
52 proto_tree *pw_oam_tlv_tree;
55 ti = proto_tree_add_protocol_format (tree, proto_pw_oam, tvb, offset, 8,
56 "Pseudo-Wire Status TLV");
59 if (!tree)
60 return;
62 pw_oam_tlv_tree = proto_item_add_subtree (ti, ett_pw_oam_tlv_tree);
64 proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_tlv_reserved, tvb, offset,
65 2, ENC_BIG_ENDIAN);
66 proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_tlv_type, tvb, offset,
67 2, ENC_BIG_ENDIAN);
68 offset = offset + 2;
70 proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_tlv_len, tvb, offset,
71 2, ENC_BIG_ENDIAN);
72 offset = offset + 2;
73 proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_code, tvb, offset,
74 4, ENC_BIG_ENDIAN);
75 /*offset = offset + 4;*/
77 return ;
80 /* Dissector for PW OAM protocol: RFC 6478 */
81 static int
82 dissect_pw_oam(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
84 proto_item *ti = NULL, *ti_flags = NULL;
85 proto_tree *pw_oam_tree = NULL, *pw_oam_flags = NULL;
87 uint8_t offset = 0;
88 uint16_t pw_tlv_type = 0;
90 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PW OAM");
91 col_clear(pinfo->cinfo, COL_INFO);
93 if (!tree)
94 return tvb_captured_length(tvb);
96 ti = proto_tree_add_item(tree, proto_pw_oam, tvb, 0, -1, ENC_NA);
98 pw_oam_tree = proto_item_add_subtree (ti, ett_pw_oam);
100 /* Refresh-Timer field */
101 proto_tree_add_item (pw_oam_tree, hf_pw_oam_refresh_timer, tvb, offset,
102 2, ENC_BIG_ENDIAN);
103 offset = offset + 2;
105 /* Total-TLV length */
106 proto_tree_add_item (pw_oam_tree, hf_pw_oam_total_tlv_len, tvb, offset,
107 1, ENC_BIG_ENDIAN);
108 offset = offset + 1;
110 /* Flags field */
111 ti_flags = proto_tree_add_item (pw_oam_tree, hf_pw_oam_flags, tvb,
112 offset, 1, ENC_BIG_ENDIAN);
113 pw_oam_flags = proto_item_add_subtree(ti_flags, ett_pw_oam_flags);
114 proto_tree_add_item (pw_oam_flags, hf_pw_oam_flags_a, tvb, offset, 1, ENC_BIG_ENDIAN);
116 offset = offset + 1;
117 pw_tlv_type = tvb_get_ntohs (tvb, offset);
119 /* TLVs */
120 switch (pw_tlv_type)
122 /* The switch cases below have to be based on the LDP-name space.
123 http://www.iana.org/assignments/ldp-namespaces/ldp-namespaces.xml */
125 case 0x096A: /* PW-Status TLV */
126 dissect_pw_status_tlv (tvb, tree, offset);
127 break;
129 default:
130 break;
133 return tvb_captured_length(tvb);
136 void
137 proto_register_pw_oam(void)
139 static hf_register_info hf[] = {
141 {&hf_pw_oam_refresh_timer,
142 {"Refresh-Timer", "pw_oam.refresh-timer", FT_UINT16,
143 BASE_HEX, NULL, 0x0, NULL, HFILL }},
145 {&hf_pw_oam_total_tlv_len,
146 {"TLV Length", "pw_oam.total-tlv-len", FT_UINT8,
147 BASE_HEX, NULL, 0x0, NULL, HFILL }},
149 {&hf_pw_oam_flags,
150 {"Flags", "pw_oam.flags", FT_UINT8,
151 BASE_HEX, NULL, 0x0, "OAM Flags", HFILL }},
153 {&hf_pw_oam_flags_a,
154 {"Acknowledgement", "pw_oam.flags_a",
155 FT_BOOLEAN, 8, NULL, 0x80, "ACK bit", HFILL}
158 {&hf_pw_oam_tlv_reserved,
159 {"Reserved", "pw_oam.tlv-reserved",
160 FT_UINT16, BASE_HEX, NULL, 0xC000, NULL, HFILL}
163 {&hf_pw_oam_tlv_type,
164 {"TLV Type", "pw_oam.tlv-type",
165 FT_UINT16, BASE_HEX, NULL, 0x3FFF, NULL, HFILL}
168 {&hf_pw_oam_tlv_len,
169 {"TLV Length", "pw_oam.tlv-len",
170 FT_UINT16, BASE_HEX, NULL, 0x00, NULL, HFILL}
173 {&hf_pw_oam_code,
174 {"Status code", "pw_oam.code", FT_UINT32,
175 BASE_HEX, VALS(pw_oam_code), 0x0, "PW Status Code", HFILL }
180 static int *ett[] = {
181 &ett_pw_oam,
182 &ett_pw_oam_tlv_tree,
183 &ett_pw_oam_flags,
186 proto_pw_oam =
187 proto_register_protocol("Pseudo-Wire OAM", "PW-OAM "
188 "Pseudo-Wire OAM Protocol",
189 "pw_oam");
191 proto_register_field_array (proto_pw_oam, hf, array_length(hf));
192 proto_register_subtree_array (ett, array_length(ett));
194 pw_oam_handle = register_dissector ("pw_oam", dissect_pw_oam, proto_pw_oam);
197 void
198 proto_reg_handoff_pw_oam(void)
200 dissector_add_uint("pwach.channel_type", PW_ACH_TYPE_PW_OAM, pw_oam_handle);
204 * Editor modelines - https://www.wireshark.org/tools/modelines.html
206 * Local variables:
207 * c-basic-offset: 2
208 * tab-width: 8
209 * indent-tabs-mode: nil
210 * End:
212 * vi: set shiftwidth=2 tabstop=8 expandtab:
213 * :indentSize=2:tabSize=8:noTabs=true: