3 * Routines for MPLS-TP Lock Instruct Protocol : RFC 6435
4 * MPLS-TP Fault-Management Protocol : RFC 6427
7 * Krishnamurthy Mayya <krishnamurthymayya@gmail.com>
8 * Nikitha Malgi <nikitha01@gmail.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
18 #include <epan/packet.h>
19 #include "packet-bfd.h"
20 #include "packet-mpls.h"
22 void proto_register_mplstp_lock(void);
23 void proto_register_mplstp_fm(void);
24 void proto_reg_handoff_mplstp_lock(void);
25 void proto_reg_handoff_mplstp_fm(void);
27 static dissector_handle_t mplstp_lock_handle
;
28 static dissector_handle_t mplstp_fm_handle
;
30 /* MPLS-TP FM protocol specific variables */
31 static int proto_mplstp_fm
;
32 static int ett_mplstp_fm
;
33 static int ett_mplstp_fm_flags
;
34 static int ett_mplstp_fm_tlv_tree
;
36 static int hf_mplstp_fm_version
;
38 static int hf_mplstp_fm_reserved
;
39 static int hf_mplstp_fm_msg_type
;
40 static int hf_mplstp_fm_flags
;
41 static int hf_mplstp_fm_flags_l
;
42 static int hf_mplstp_fm_flags_r
;
43 static int hf_mplstp_fm_refresh_timer
;
44 static int hf_mplstp_fm_total_tlv_len
;
45 static int hf_mplstp_fm_if_tlv_type
;
46 static int hf_mplstp_fm_global_tlv_type
;
47 static int hf_mplstp_fm_tlv_len
;
48 static int hf_mplstp_fm_node_id
;
49 static int hf_mplstp_fm_if_num
;
50 static int hf_mplstp_fm_global_id
;
52 static const value_string fm_msg_type
[] = {
53 {0, "No Return Code"},
54 {1, "Alarm-Indication Signal(A)"},
55 {2, "Lock-Report(L)"},
59 /* MPLS-TP Lock protocol specific variables */
60 static int proto_mplstp_lock
;
61 static int ett_mplstp_lock
;
63 static int hf_mplstp_lock_version
;
64 static int hf_mplstp_lock_reserved
;
65 static int hf_mplstp_lock_refresh_timer
;
68 dissect_mplstp_fm_tlv (tvbuff_t
*tvb
, proto_tree
*tree
)
71 proto_tree
*fm_tlv_tree
;
78 ti
= proto_tree_add_protocol_format (tree
, proto_mplstp_fm
, tvb
, offset
, 16,
79 "Fault-Management TLVs");
81 fm_tlv_tree
= proto_item_add_subtree (ti
, ett_mplstp_fm_tlv_tree
);
83 proto_tree_add_item (fm_tlv_tree
, hf_mplstp_fm_if_tlv_type
, tvb
, offset
,
86 proto_tree_add_item (fm_tlv_tree
, hf_mplstp_fm_tlv_len
, tvb
, offset
,
89 proto_tree_add_item (fm_tlv_tree
, hf_mplstp_fm_node_id
, tvb
, offset
,
92 proto_tree_add_item (fm_tlv_tree
, hf_mplstp_fm_if_num
, tvb
, offset
,
95 proto_tree_add_item (fm_tlv_tree
, hf_mplstp_fm_global_tlv_type
, tvb
, offset
,
98 proto_tree_add_item (fm_tlv_tree
, hf_mplstp_fm_tlv_len
, tvb
, offset
,
101 proto_tree_add_item (fm_tlv_tree
, hf_mplstp_fm_global_id
, tvb
, offset
,
103 /* offset = offset + 4; */
108 /* Dissector for MPLS-TP LI protocol: RFC 6435 */
110 dissect_mplstp_lock(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
113 proto_tree
*lock_tree
;
118 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MPLS-TP LI");
119 col_clear(pinfo
->cinfo
, COL_INFO
);
122 return tvb_captured_length(tvb
);
124 ti
= proto_tree_add_item(tree
, proto_mplstp_lock
, tvb
, 0, -1, ENC_NA
);
126 lock_tree
= proto_item_add_subtree (ti
, ett_mplstp_lock
);
129 proto_tree_add_item (lock_tree
, hf_mplstp_lock_version
, tvb
, offset
,
133 proto_tree_add_item (lock_tree
, hf_mplstp_lock_reserved
, tvb
, offset
,
137 /* Refresh-Timer field */
138 proto_tree_add_item (lock_tree
, hf_mplstp_lock_refresh_timer
, tvb
, offset
,
142 /* Source-MEP TLVs */
143 next_tvb
= tvb_new_subset_remaining (tvb
, offset
);
144 dissect_bfd_mep (next_tvb
, tree
, proto_mplstp_lock
);
146 return tvb_captured_length(tvb
);
150 /* Dissector for MPLS-TP FM protocol: RFC 6427 */
152 dissect_mplstp_fm(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
154 proto_item
*ti
, *ti_flags
;
155 proto_tree
*fm_tree
, *fm_flags
;
160 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MPLS-TP FM");
161 col_clear(pinfo
->cinfo
, COL_INFO
);
163 tlv_len
= tvb_get_uint8 (tvb
, (offset
+ 4));
166 return tvb_captured_length(tvb
);
168 ti
= proto_tree_add_item(tree
, proto_mplstp_fm
, tvb
, 0, (tlv_len
+ 5), ENC_NA
);
169 fm_tree
= proto_item_add_subtree (ti
, ett_mplstp_fm
);
171 /* Version and Reserved fields */
172 proto_tree_add_item (fm_tree
, hf_mplstp_fm_version
, tvb
, offset
,
174 proto_tree_add_item (fm_tree
, hf_mplstp_fm_reserved
, tvb
, offset
,
178 /* FM-Message type field */
179 proto_tree_add_item (fm_tree
, hf_mplstp_fm_msg_type
, tvb
, offset
,
184 ti_flags
= proto_tree_add_item (fm_tree
, hf_mplstp_fm_flags
, tvb
,
185 offset
, 1, ENC_BIG_ENDIAN
);
186 fm_flags
= proto_item_add_subtree(ti_flags
, ett_mplstp_fm_flags
);
188 proto_tree_add_item (fm_flags
, hf_mplstp_fm_flags_l
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
189 proto_tree_add_item (fm_flags
, hf_mplstp_fm_flags_r
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
192 /* Refresh-Timer field */
193 proto_tree_add_item (fm_tree
, hf_mplstp_fm_refresh_timer
, tvb
, offset
,
197 /* FM-TLV Length field*/
198 proto_tree_add_item (fm_tree
, hf_mplstp_fm_total_tlv_len
, tvb
, offset
,
206 next_tvb
= tvb_new_subset_remaining (tvb
, offset
);
207 dissect_mplstp_fm_tlv (next_tvb
, tree
);
209 return tvb_captured_length(tvb
);
213 proto_register_mplstp_lock(void)
215 static hf_register_info hf
[] = {
217 {&hf_mplstp_lock_version
,
218 {"Version", "mplstp_lock.version", FT_UINT8
,
219 BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
221 {&hf_mplstp_lock_reserved
,
222 {"Reserved", "mplstp_lock.reserved", FT_UINT24
,
223 BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
225 {&hf_mplstp_lock_refresh_timer
,
226 {"Refresh-timer value", "mplstp_lock.refresh-timer", FT_UINT8
,
227 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
230 static int *ett
[] = {
235 proto_register_protocol("MPLS-TP Lock-Instruct", "MPLS[-TP] Lock-Instruct "
236 "Lock-Instruct (LI) Protocol",
239 proto_register_field_array(proto_mplstp_lock
, hf
, array_length(hf
));
240 proto_register_subtree_array(ett
, array_length(ett
));
242 mplstp_lock_handle
= register_dissector("mplstp_lock", dissect_mplstp_lock
, proto_mplstp_lock
);
246 proto_reg_handoff_mplstp_lock(void)
248 dissector_add_uint("pwach.channel_type", 0x0026, mplstp_lock_handle
); /* KM: MPLSTP LOCK, RFC 6435 */
252 proto_register_mplstp_fm(void)
254 static hf_register_info hf
[] = {
256 {&hf_mplstp_fm_version
,
257 {"Version", "mplstp_oam.version", FT_UINT8
,
258 BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
260 {&hf_mplstp_fm_reserved
,
261 {"Reserved", "mplstp_oam.reserved", FT_UINT8
,
262 BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
264 {&hf_mplstp_fm_refresh_timer
,
265 {"Refresh-timer value", "mplstp_oam.refresh.timer", FT_UINT8
,
266 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
268 {&hf_mplstp_fm_total_tlv_len
,
269 {"FM TLV Length", "mplstp_oam.total.tlv.len", FT_UINT8
,
270 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
272 {&hf_mplstp_fm_if_tlv_type
,
273 {"Type : IF-ID TLV", "mplstp_oam.if_id_tlv_type", FT_UINT8
,
274 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
276 {&hf_mplstp_fm_global_tlv_type
,
277 {"Type : GLOBAL-ID TLV", "mplstp_oam.global_id_tlv_type", FT_UINT8
,
278 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
280 {&hf_mplstp_fm_tlv_len
,
281 {"Length", "mplstp_oam.tlv_len", FT_UINT8
,
282 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
284 {&hf_mplstp_fm_node_id
,
285 {"Node id", "mplstp_oam.node_id", FT_IPv4
,
286 BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
288 {&hf_mplstp_fm_if_num
,
289 {"Interface Number", "mplstp_oam.if_num", FT_UINT32
,
290 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
292 {&hf_mplstp_fm_global_id
,
293 {"Global id", "mplstp_oam.global_id", FT_UINT32
,
294 BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
296 {&hf_mplstp_fm_msg_type
,
297 {"Message Type", "mplstp_oam.message.type", FT_UINT8
,
298 BASE_DEC
, VALS(fm_msg_type
), 0x0, "MPLS-TP FM Message Type", HFILL
}},
300 { &hf_mplstp_fm_flags
,
301 { "FM Flags", "mplstp_oam.flags",
302 FT_UINT8
, BASE_HEX
, NULL
, 0x0, "MPLS-TP FM Flags", HFILL
}
305 { &hf_mplstp_fm_flags_l
,
306 { "Link Down Indication", "mplstp_oam.flag_l",
307 FT_BOOLEAN
, 8, NULL
, 0x02, NULL
, HFILL
}
310 { &hf_mplstp_fm_flags_r
,
311 { "FM Condition Cleared", "mplstp_oam.flag_r",
312 FT_BOOLEAN
, 8, NULL
, 0x01, "Fault Condition Cleared", HFILL
}
316 static int *ett
[] = {
318 &ett_mplstp_fm_tlv_tree
,
319 &ett_mplstp_fm_flags
,
323 proto_register_protocol("MPLS-TP Fault-Management", "MPLS[-TP] Fault-Management "
324 "Fault-Management (FM) Protocol",
327 proto_register_field_array(proto_mplstp_fm
, hf
, array_length(hf
));
328 proto_register_subtree_array(ett
, array_length(ett
));
330 mplstp_fm_handle
= register_dissector("mplstp_fm", dissect_mplstp_fm
, proto_mplstp_fm
);
334 proto_reg_handoff_mplstp_fm(void)
336 dissector_add_uint("pwach.channel_type", PW_ACH_TYPE_MPLSTP_FM
, mplstp_fm_handle
);
340 * Editor modelines - https://www.wireshark.org/tools/modelines.html
345 * indent-tabs-mode: nil
348 * ex: set shiftwidth=2 tabstop=8 expandtab:
349 * :indentSize=2:tabSize=8:noTabs=true: