3 * Routines for MPLS[-TP] Protection State Coordination (PSC) Protocol: it
4 * should conform to RFC 6378.
8 * Francesco Fondelli <francesco dot fondelli, gmail dot com>
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * SPDX-License-Identifier: GPL-2.0-or-later
19 #include <epan/packet.h>
20 #include "packet-mpls.h"
22 void proto_register_mpls_psc(void);
23 void proto_reg_handoff_mpls_psc(void);
25 static dissector_handle_t mpls_psc_handle
;
27 static int proto_mpls_psc
;
29 static int ett_mpls_psc
;
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
;
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'
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" },
62 static const value_string mpls_psc_req_short_vals
[] = {
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" },
82 static const range_string mpls_psc_rev_rvals
[] = {
83 { 0, 0, "non-revertive mode" },
84 { 1, 1, "revertive mode" },
88 static const range_string mpls_psc_fpath_rvals
[] = {
89 { 0, 0, "protection" },
91 { 2, 255, "for future extensions" },
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" },
103 dissect_mpls_psc(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
106 proto_tree
*psc_tree
;
112 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "PSC");
113 col_clear(pinfo
->cinfo
, COL_INFO
);
116 req
= (tvb_get_uint8(tvb
, offset
) & 0x3C) >> 2;
117 fpath
= tvb_get_uint8(tvb
, offset
+ 2);
118 path
= tvb_get_uint8(tvb
, offset
+ 3);
120 col_add_fstr(pinfo
->cinfo
, COL_INFO
,
122 val_to_str_const(req
, mpls_psc_req_short_vals
, "Unknown-Request"),
126 return tvb_captured_length(tvb
);
129 /* create display subtree for the protocol */
130 ti
= proto_tree_add_item(tree
, proto_mpls_psc
, tvb
, 0, -1, ENC_NA
);
131 psc_tree
= proto_item_add_subtree(ti
, ett_mpls_psc
);
133 proto_tree_add_item(psc_tree
, hf_mpls_psc_ver
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
135 proto_tree_add_item(psc_tree
, hf_mpls_psc_req
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
137 proto_tree_add_item(psc_tree
, hf_mpls_psc_pt
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
140 proto_tree_add_item(psc_tree
, hf_mpls_psc_rev
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
144 proto_tree_add_item(psc_tree
, hf_mpls_psc_fpath
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
147 proto_tree_add_item(psc_tree
, hf_mpls_psc_dpath
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
150 proto_tree_add_item(psc_tree
, hf_mpls_psc_tlvlen
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
151 return tvb_captured_length(tvb
);
155 proto_register_mpls_psc(void)
157 static hf_register_info hf
[] = {
161 "Version", "mpls_psc.ver",
162 FT_UINT8
, BASE_DEC
, NULL
, 0xC0,
169 "Request", "mpls_psc.req",
170 FT_UINT8
, BASE_RANGE_STRING
| BASE_DEC
, RVALS(mpls_psc_req_rvals
), 0x3C,
177 "Protection Type", "mpls_psc.pt",
178 FT_UINT8
, BASE_RANGE_STRING
| BASE_DEC
, RVALS(mpls_psc_pt_rvals
), 0x03,
186 FT_UINT8
, BASE_RANGE_STRING
| BASE_DEC
, RVALS(mpls_psc_rev_rvals
), 0x80,
193 "Fault Path", "mpls_psc.fpath",
194 FT_UINT8
, BASE_RANGE_STRING
| BASE_DEC
, RVALS(mpls_psc_fpath_rvals
), 0x0,
201 "Data Path", "mpls_psc.dpath",
202 FT_UINT8
, BASE_RANGE_STRING
| BASE_DEC
, RVALS(mpls_psc_dpath_rvals
), 0x0,
209 "TLV Length", "mpls_psc.tlvlen",
210 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
216 static int *ett
[] = {
221 proto_register_protocol("PSC", "MPLS[-TP] Protection State "
222 "Coordination (PSC) Protocol",
225 proto_register_field_array(proto_mpls_psc
, hf
, array_length(hf
));
226 proto_register_subtree_array(ett
, array_length(ett
));
228 mpls_psc_handle
= register_dissector("mpls_psc", dissect_mpls_psc
, proto_mpls_psc
);
232 proto_reg_handoff_mpls_psc(void)
234 dissector_add_uint("pwach.channel_type", PW_ACH_TYPE_PSC
, mpls_psc_handle
);
238 * Editor modelines - https://www.wireshark.org/tools/modelines.html
243 * indent-tabs-mode: nil
246 * vi: set shiftwidth=4 tabstop=8 expandtab:
247 * :indentSize=4:tabSize=8:noTabs=true: