HACK: 2nd try to match RowsetProperties
[wireshark-wip.git] / epan / dissectors / packet-pw-oam.c
blob20fff938a4827aa358ed378f04c53141213a3eb8
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 * $Id$
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "config.h"
30 #include <glib.h>
31 #include <epan/packet.h>
33 /* MPLS-TP FM protocol specific variables */
34 static gint proto_pw_oam = -1;
35 static gint ett_pw_oam = -1;
36 static gint ett_pw_oam_flags = -1;
37 static gint ett_pw_oam_tlv_tree = -1;
39 static int hf_pw_oam_tlv_reserved = -1;
40 static int hf_pw_oam_tlv_type = -1;
41 static int hf_pw_oam_total_tlv_len = -1;
42 static int hf_pw_oam_code = -1;
43 static int hf_pw_oam_flags = -1;
44 static int hf_pw_oam_flags_a = -1;
45 static int hf_pw_oam_refresh_timer = -1;
46 static int hf_pw_oam_tlv_len = -1;
48 static const value_string pw_oam_code[] = {
49 {0x00000002, "Local Attachment Circuit(ingress) Receive Fault"},
50 {0x00000004, "Local Attachment Circuit(egress) Transmit Fault"},
51 {0x00000020, "PW Forwarding Standby"},
52 {0x00000040, "Request Switchover to this PW"},
53 {0, NULL}
56 /* PW-Status TLV dissector */
57 void
58 dissect_pw_status_tlv (tvbuff_t *tvb, proto_tree *tree, gint offset)
60 proto_item *ti;
61 proto_tree *pw_oam_tlv_tree;
64 ti = proto_tree_add_protocol_format (tree, proto_pw_oam, tvb, offset, 8,
65 "Pseudo-Wire Status TLV");
68 if (!tree)
69 return;
71 pw_oam_tlv_tree = proto_item_add_subtree (ti, ett_pw_oam_tlv_tree);
73 proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_tlv_reserved, tvb, offset,
74 2, ENC_BIG_ENDIAN);
75 proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_tlv_type, tvb, offset,
76 2, ENC_BIG_ENDIAN);
77 offset = offset + 2;
79 proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_tlv_len, tvb, offset,
80 2, ENC_BIG_ENDIAN);
81 offset = offset + 2;
82 proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_code, tvb, offset,
83 4, ENC_BIG_ENDIAN);
84 /*offset = offset + 4;*/
86 return ;
89 /* Dissector for PW OAM protocol: RFC 6478 */
90 static void
91 dissect_pw_oam(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
93 proto_item *ti = NULL, *ti_flags = NULL;
94 proto_tree *pw_oam_tree = NULL, *pw_oam_flags = NULL;
96 guint8 offset = 0;
97 guint16 pw_tlv_type = 0;
99 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PW OAM");
100 col_clear(pinfo->cinfo, COL_INFO);
102 if (!tree)
103 return;
105 ti = proto_tree_add_item(tree, proto_pw_oam, tvb, 0, -1, ENC_NA);
107 pw_oam_tree = proto_item_add_subtree (ti, ett_pw_oam);
109 /* Refresh-Timer field */
110 proto_tree_add_item (pw_oam_tree, hf_pw_oam_refresh_timer, tvb, offset,
111 2, ENC_BIG_ENDIAN);
112 offset = offset + 2;
114 /* Total-TLV length */
115 proto_tree_add_item (pw_oam_tree, hf_pw_oam_total_tlv_len, tvb, offset,
116 1, ENC_BIG_ENDIAN);
117 offset = offset + 1;
119 /* Flags field */
120 ti_flags = proto_tree_add_item (pw_oam_tree, hf_pw_oam_flags, tvb,
121 offset, 1, ENC_BIG_ENDIAN);
122 pw_oam_flags = proto_item_add_subtree(ti_flags, ett_pw_oam_flags);
123 proto_tree_add_item (pw_oam_flags, hf_pw_oam_flags_a, tvb, offset, 1, ENC_BIG_ENDIAN);
125 offset = offset + 1;
126 pw_tlv_type = tvb_get_ntohs (tvb, offset);
128 /* TLVs */
129 switch (pw_tlv_type)
131 /* The switch cases below have to be based on the LDP-name space.
132 http://www.iana.org/assignments/ldp-namespaces/ldp-namespaces.xml */
134 case 0x096A: /* PW-Status TLV */
135 dissect_pw_status_tlv (tvb, tree, offset);
136 break;
138 default:
139 break;
142 return;
145 void
146 proto_register_pw_oam(void)
148 static hf_register_info hf[] = {
150 {&hf_pw_oam_refresh_timer,
151 {"Refresh-Timer", "pw_oam.refresh-timer", FT_UINT16,
152 BASE_HEX, NULL, 0x0, NULL, HFILL }},
154 {&hf_pw_oam_total_tlv_len,
155 {"TLV Length", "pw_oam.total-tlv-len", FT_UINT8,
156 BASE_HEX, NULL, 0x0, NULL, HFILL }},
158 {&hf_pw_oam_flags,
159 {"Flags", "pw_oam.flags", FT_UINT8,
160 BASE_HEX, NULL, 0x0000, "OAM Flags", HFILL }},
162 {&hf_pw_oam_flags_a,
163 {"Acknowledgement", "pw_oam.flags_a",
164 FT_BOOLEAN, 8, NULL, 0x0080, "ACK bit", HFILL}
167 {&hf_pw_oam_tlv_reserved,
168 {"Reserved", "pw_oam.tlv-reserved",
169 FT_UINT16, BASE_HEX, NULL, 0xC000, NULL, HFILL}
172 {&hf_pw_oam_tlv_type,
173 {"TLV Type", "pw_oam.tlv-type",
174 FT_UINT16, BASE_HEX, NULL, 0x3FFF, NULL, HFILL}
177 {&hf_pw_oam_tlv_len,
178 {"TLV Length", "pw_oam.tlv-len",
179 FT_UINT16, BASE_HEX, NULL, 0x00, NULL, HFILL}
182 {&hf_pw_oam_code,
183 {"Status code", "pw_oam.code", FT_UINT16,
184 BASE_HEX, VALS(pw_oam_code), 0x0, "PW Status Code", HFILL }
189 static gint *ett[] = {
190 &ett_pw_oam,
191 &ett_pw_oam_tlv_tree,
192 &ett_pw_oam_flags,
195 proto_pw_oam =
196 proto_register_protocol("Pseudo-Wire OAM", "PW-OAM "
197 "Pseudo-Wire OAM Protocol",
198 "pw_oam");
200 proto_register_field_array (proto_pw_oam, hf, array_length(hf));
201 proto_register_subtree_array (ett, array_length(ett));
203 register_dissector("pw_oam", dissect_pw_oam, proto_pw_oam);
207 * Editor modelines - http://www.wireshark.org/tools/modelines.html
209 * Local variables:
210 * c-basic-offset: 2
211 * tab-width: 8
212 * indent-tabs-mode: nil
213 * End:
215 * vi: set shiftwidth=2 tabstop=8 expandtab:
216 * :indentSize=2:tabSize=8:noTabs=true: