/src/wireshark/epan/dissectors/packet-mpls-psc.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* packet-mpls-psc.c |
2 | | * |
3 | | * Routines for MPLS[-TP] Protection State Coordination (PSC) Protocol: it |
4 | | * should conform to RFC 6378. |
5 | | * |
6 | | * Copyright 2012 _FF_ |
7 | | * |
8 | | * Francesco Fondelli <francesco dot fondelli, gmail dot com> |
9 | | * |
10 | | * Wireshark - Network traffic analyzer |
11 | | * By Gerald Combs <gerald@wireshark.org> |
12 | | * Copyright 1998 Gerald Combs |
13 | | * |
14 | | * SPDX-License-Identifier: GPL-2.0-or-later |
15 | | */ |
16 | | |
17 | | #include "config.h" |
18 | | |
19 | | #include <epan/packet.h> |
20 | | #include "packet-mpls.h" |
21 | | |
22 | | void proto_register_mpls_psc(void); |
23 | | void proto_reg_handoff_mpls_psc(void); |
24 | | |
25 | | static dissector_handle_t mpls_psc_handle; |
26 | | |
27 | | static int proto_mpls_psc; |
28 | | |
29 | | static int ett_mpls_psc; |
30 | | |
31 | | static int hf_mpls_psc_ver; |
32 | | static int hf_mpls_psc_req; |
33 | | static int hf_mpls_psc_pt; |
34 | | static int hf_mpls_psc_rev; |
35 | | static int hf_mpls_psc_fpath; |
36 | | static int hf_mpls_psc_dpath; |
37 | | static int hf_mpls_psc_tlvlen; |
38 | | |
39 | | /* |
40 | | * FF: please keep this list in sync with |
41 | | * http://www.iana.org/assignments/mpls-oam-parameters/mpls-oam-parameters.xml |
42 | | * Registry Name: 'MPLS PSC Request' |
43 | | */ |
44 | | static const range_string mpls_psc_req_rvals[] = { |
45 | | { 0, 0, "No Request" }, |
46 | | { 1, 1, "Do Not Revert" }, |
47 | | { 2, 3, "Unassigned" }, |
48 | | { 4, 4, "Wait to Restore" }, |
49 | | { 5, 5, "Manual Switch" }, |
50 | | { 6, 6, "Unassigned" }, |
51 | | { 7, 7, "Signal Degrade" }, |
52 | | { 8, 9, "Unassigned" }, |
53 | | { 10, 10, "Signal Fail" }, |
54 | | { 11, 11, "Unassigned" }, |
55 | | { 12, 12, "Forced Switch" }, |
56 | | { 13, 13, "Unassigned" }, |
57 | | { 14, 14, "Lockout of protection" }, |
58 | | { 15, 15, "Unassigned" }, |
59 | | { 0, 0, NULL } |
60 | | }; |
61 | | |
62 | | static const value_string mpls_psc_req_short_vals[] = { |
63 | | { 0, "NR" }, |
64 | | { 1, "DNR" }, |
65 | | { 4, "WTR" }, |
66 | | { 5, "MS" }, |
67 | | { 7, "SD" }, |
68 | | { 10, "SF" }, |
69 | | { 12, "FS" }, |
70 | | { 14, "LO" }, |
71 | | { 0, NULL } |
72 | | }; |
73 | | |
74 | | static const range_string mpls_psc_pt_rvals[] = { |
75 | | { 0, 0, "for future extensions" }, |
76 | | { 1, 1, "unidirectional switching using a permanent bridge" }, |
77 | | { 2, 2, "bidirectional switching using a selector bridge" }, |
78 | | { 3, 3, "bidirectional switching using a permanent bridge" }, |
79 | | { 0, 0, NULL } |
80 | | }; |
81 | | |
82 | | static const range_string mpls_psc_rev_rvals[] = { |
83 | | { 0, 0, "non-revertive mode" }, |
84 | | { 1, 1, "revertive mode" }, |
85 | | { 0, 0, NULL } |
86 | | }; |
87 | | |
88 | | static const range_string mpls_psc_fpath_rvals[] = { |
89 | | { 0, 0, "protection" }, |
90 | | { 1, 1, "working" }, |
91 | | { 2, 255, "for future extensions" }, |
92 | | { 0, 0, NULL } |
93 | | }; |
94 | | |
95 | | static const range_string mpls_psc_dpath_rvals[] = { |
96 | | { 0, 0, "protection is not in use" }, |
97 | | { 1, 1, "protection is in use" }, |
98 | | { 2, 255, "for future extensions" }, |
99 | | { 0, 0, NULL } |
100 | | }; |
101 | | |
102 | | static int |
103 | | dissect_mpls_psc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
104 | 0 | { |
105 | 0 | proto_item *ti; |
106 | 0 | proto_tree *psc_tree; |
107 | 0 | uint32_t offset = 0; |
108 | 0 | uint8_t req; |
109 | 0 | uint8_t fpath; |
110 | 0 | uint8_t path; |
111 | |
|
112 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "PSC"); |
113 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
114 | | |
115 | | /* build cinfo */ |
116 | 0 | req = (tvb_get_uint8(tvb, offset) & 0x3C) >> 2; |
117 | 0 | fpath = tvb_get_uint8(tvb, offset + 2); |
118 | 0 | path = tvb_get_uint8(tvb, offset + 3); |
119 | |
|
120 | 0 | col_add_fstr(pinfo->cinfo, COL_INFO, |
121 | 0 | "%s(%u,%u)", |
122 | 0 | val_to_str_const(req, mpls_psc_req_short_vals, "Unknown-Request"), |
123 | 0 | fpath, path); |
124 | |
|
125 | 0 | if (!tree) { |
126 | 0 | return tvb_captured_length(tvb); |
127 | 0 | } |
128 | | |
129 | | /* create display subtree for the protocol */ |
130 | 0 | ti = proto_tree_add_item(tree, proto_mpls_psc, tvb, 0, -1, ENC_NA); |
131 | 0 | psc_tree = proto_item_add_subtree(ti, ett_mpls_psc); |
132 | | /* version */ |
133 | 0 | proto_tree_add_item(psc_tree, hf_mpls_psc_ver, tvb, offset, 1, ENC_BIG_ENDIAN); |
134 | | /* request */ |
135 | 0 | proto_tree_add_item(psc_tree, hf_mpls_psc_req, tvb, offset, 1, ENC_BIG_ENDIAN); |
136 | | /* prot type */ |
137 | 0 | proto_tree_add_item(psc_tree, hf_mpls_psc_pt, tvb, offset, 1, ENC_BIG_ENDIAN); |
138 | 0 | offset += 1; |
139 | | /* prot type */ |
140 | 0 | proto_tree_add_item(psc_tree, hf_mpls_psc_rev, tvb, offset, 1, ENC_BIG_ENDIAN); |
141 | | /* skip reserved1 */ |
142 | 0 | offset += 1; |
143 | | /* fpath */ |
144 | 0 | proto_tree_add_item(psc_tree, hf_mpls_psc_fpath, tvb, offset, 1, ENC_BIG_ENDIAN); |
145 | 0 | offset += 1; |
146 | | /* path */ |
147 | 0 | proto_tree_add_item(psc_tree, hf_mpls_psc_dpath, tvb, offset, 1, ENC_BIG_ENDIAN); |
148 | 0 | offset += 1; |
149 | | /* tlv len */ |
150 | 0 | proto_tree_add_item(psc_tree, hf_mpls_psc_tlvlen, tvb, offset, 1, ENC_BIG_ENDIAN); |
151 | 0 | return tvb_captured_length(tvb); |
152 | 0 | } |
153 | | |
154 | | void |
155 | | proto_register_mpls_psc(void) |
156 | 14 | { |
157 | 14 | static hf_register_info hf[] = { |
158 | 14 | { |
159 | 14 | &hf_mpls_psc_ver, |
160 | 14 | { |
161 | 14 | "Version", "mpls_psc.ver", |
162 | 14 | FT_UINT8, BASE_DEC, NULL, 0xC0, |
163 | 14 | NULL, HFILL |
164 | 14 | } |
165 | 14 | }, |
166 | 14 | { |
167 | 14 | &hf_mpls_psc_req, |
168 | 14 | { |
169 | 14 | "Request", "mpls_psc.req", |
170 | 14 | FT_UINT8, BASE_RANGE_STRING | BASE_DEC, RVALS(mpls_psc_req_rvals), 0x3C, |
171 | 14 | NULL, HFILL |
172 | 14 | } |
173 | 14 | }, |
174 | 14 | { |
175 | 14 | &hf_mpls_psc_pt, |
176 | 14 | { |
177 | 14 | "Protection Type", "mpls_psc.pt", |
178 | 14 | FT_UINT8, BASE_RANGE_STRING | BASE_DEC, RVALS(mpls_psc_pt_rvals), 0x03, |
179 | 14 | NULL, HFILL |
180 | 14 | } |
181 | 14 | }, |
182 | 14 | { |
183 | 14 | &hf_mpls_psc_rev, |
184 | 14 | { |
185 | 14 | "R", "mpls_psc.rev", |
186 | 14 | FT_UINT8, BASE_RANGE_STRING | BASE_DEC, RVALS(mpls_psc_rev_rvals), 0x80, |
187 | 14 | NULL, HFILL |
188 | 14 | } |
189 | 14 | }, |
190 | 14 | { |
191 | 14 | &hf_mpls_psc_fpath, |
192 | 14 | { |
193 | 14 | "Fault Path", "mpls_psc.fpath", |
194 | 14 | FT_UINT8, BASE_RANGE_STRING | BASE_DEC, RVALS(mpls_psc_fpath_rvals), 0x0, |
195 | 14 | NULL, HFILL |
196 | 14 | } |
197 | 14 | }, |
198 | 14 | { |
199 | 14 | &hf_mpls_psc_dpath, |
200 | 14 | { |
201 | 14 | "Data Path", "mpls_psc.dpath", |
202 | 14 | FT_UINT8, BASE_RANGE_STRING | BASE_DEC, RVALS(mpls_psc_dpath_rvals), 0x0, |
203 | 14 | NULL, HFILL |
204 | 14 | } |
205 | 14 | }, |
206 | 14 | { |
207 | 14 | &hf_mpls_psc_tlvlen, |
208 | 14 | { |
209 | 14 | "TLV Length", "mpls_psc.tlvlen", |
210 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, |
211 | 14 | NULL, HFILL |
212 | 14 | } |
213 | 14 | }, |
214 | 14 | }; |
215 | | |
216 | 14 | static int *ett[] = { |
217 | 14 | &ett_mpls_psc, |
218 | 14 | }; |
219 | | |
220 | 14 | proto_mpls_psc = |
221 | 14 | proto_register_protocol("PSC", "MPLS[-TP] Protection State " |
222 | 14 | "Coordination (PSC) Protocol", |
223 | 14 | "mpls_psc"); |
224 | | |
225 | 14 | proto_register_field_array(proto_mpls_psc, hf, array_length(hf)); |
226 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
227 | | |
228 | 14 | mpls_psc_handle = register_dissector("mpls_psc", dissect_mpls_psc, proto_mpls_psc); |
229 | 14 | } |
230 | | |
231 | | void |
232 | | proto_reg_handoff_mpls_psc(void) |
233 | 14 | { |
234 | 14 | dissector_add_uint("pwach.channel_type", PW_ACH_TYPE_PSC, mpls_psc_handle); |
235 | 14 | } |
236 | | |
237 | | /* |
238 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
239 | | * |
240 | | * Local variables: |
241 | | * c-basic-offset: 4 |
242 | | * tab-width: 8 |
243 | | * indent-tabs-mode: nil |
244 | | * End: |
245 | | * |
246 | | * vi: set shiftwidth=4 tabstop=8 expandtab: |
247 | | * :indentSize=4:tabSize=8:noTabs=true: |
248 | | */ |