1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
|
/* packet-mplstp-oam.c
*
* Routines for MPLS-TP Lock Instruct Protocol : RFC 6435
* MPLS-TP Fault-Management Protocol : RFC 6427
*
* Authors:
* Krishnamurthy Mayya <krishnamurthymayya@gmail.com>
* Nikitha Malgi <nikitha01@gmail.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include "packet-bfd.h"
#include "packet-mpls.h"
void proto_register_mplstp_lock(void);
void proto_register_mplstp_fm(void);
void proto_reg_handoff_mplstp_lock(void);
void proto_reg_handoff_mplstp_fm(void);
/* MPLS-TP FM protocol specific variables */
static gint proto_mplstp_fm = -1;
static gint ett_mplstp_fm = -1;
static gint ett_mplstp_fm_flags = -1;
static gint ett_mplstp_fm_tlv_tree = -1;
static int hf_mplstp_fm_version = -1;
static int hf_mplstp_fm_reserved = -1;
static int hf_mplstp_fm_msg_type = -1;
static int hf_mplstp_fm_flags = -1;
static int hf_mplstp_fm_flags_l = -1;
static int hf_mplstp_fm_flags_r = -1;
static int hf_mplstp_fm_refresh_timer = -1;
static int hf_mplstp_fm_total_tlv_len = -1;
static int hf_mplstp_fm_if_tlv_type = -1;
static int hf_mplstp_fm_global_tlv_type = -1;
static int hf_mplstp_fm_tlv_len = -1;
static int hf_mplstp_fm_node_id = -1;
static int hf_mplstp_fm_if_num = -1;
static int hf_mplstp_fm_global_id = -1;
static const value_string fm_msg_type[] = {
{0, "No Return Code"},
{1, "Alarm-Indication Signal(A)"},
{2, "Lock-Report(L)"},
{0, NULL}
};
/* MPLS-TP Lock protocol specific variables */
static gint proto_mplstp_lock = -1;
static gint ett_mplstp_lock = -1;
static int hf_mplstp_lock_version = -1;
static int hf_mplstp_lock_reserved = -1;
static int hf_mplstp_lock_refresh_timer = -1;
static void
dissect_mplstp_fm_tlv (tvbuff_t *tvb, proto_tree *tree)
{
proto_item *ti;
proto_tree *fm_tlv_tree;
guint offset = 0;
if (!tree)
return;
ti = proto_tree_add_protocol_format (tree, proto_mplstp_fm, tvb, offset, 16,
"Fault-Management TLVs");
fm_tlv_tree = proto_item_add_subtree (ti, ett_mplstp_fm_tlv_tree);
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_if_tlv_type , tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_tlv_len, tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_node_id, tvb, offset,
4, ENC_BIG_ENDIAN);
offset = offset + 4;
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_if_num, tvb, offset,
4, ENC_BIG_ENDIAN);
offset = offset + 4;
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_global_tlv_type , tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_tlv_len, tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_global_id, tvb, offset,
4, ENC_BIG_ENDIAN);
/* offset = offset + 4; */
return;
}
/* Dissector for MPLS-TP LI protocol: RFC 6435 */
static int
dissect_mplstp_lock(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_item *ti;
proto_tree *lock_tree;
tvbuff_t *next_tvb;
guint8 offset = 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPLS-TP LI");
col_clear(pinfo->cinfo, COL_INFO);
if (!tree)
return tvb_captured_length(tvb);
ti = proto_tree_add_item(tree, proto_mplstp_lock, tvb, 0, -1, ENC_NA);
lock_tree = proto_item_add_subtree (ti, ett_mplstp_lock);
/* Version field */
proto_tree_add_item (lock_tree, hf_mplstp_lock_version , tvb, offset,
1, ENC_BIG_ENDIAN);
/* Reserved field */
proto_tree_add_item (lock_tree, hf_mplstp_lock_reserved, tvb, offset,
3, ENC_BIG_ENDIAN);
offset = offset + 3;
/* Refresh-Timer field */
proto_tree_add_item (lock_tree, hf_mplstp_lock_refresh_timer, tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
/* Source-MEP TLVs */
next_tvb = tvb_new_subset_remaining (tvb, offset);
dissect_bfd_mep (next_tvb, tree, proto_mplstp_lock);
return tvb_captured_length(tvb);
}
/* Dissector for MPLS-TP FM protocol: RFC 6427 */
static int
dissect_mplstp_fm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_item *ti, *ti_flags;
proto_tree *fm_tree, *fm_flags;
guint8 offset = 0;
guint8 tlv_len;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPLS-TP FM");
col_clear(pinfo->cinfo, COL_INFO);
tlv_len = tvb_get_guint8 (tvb, (offset + 4));
if (!tree)
return tvb_captured_length(tvb);
ti = proto_tree_add_item(tree, proto_mplstp_fm, tvb, 0, (tlv_len + 5), ENC_NA);
fm_tree = proto_item_add_subtree (ti, ett_mplstp_fm);
/* Version and Reserved fields */
proto_tree_add_item (fm_tree, hf_mplstp_fm_version , tvb, offset,
1, ENC_BIG_ENDIAN);
proto_tree_add_item (fm_tree, hf_mplstp_fm_reserved, tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
/* FM-Message type field */
proto_tree_add_item (fm_tree, hf_mplstp_fm_msg_type, tvb, offset,
1,ENC_BIG_ENDIAN);
offset = offset + 1;
/* Flags field */
ti_flags = proto_tree_add_item (fm_tree, hf_mplstp_fm_flags, tvb,
offset, 1, ENC_BIG_ENDIAN);
fm_flags = proto_item_add_subtree(ti_flags, ett_mplstp_fm_flags);
proto_tree_add_item (fm_flags, hf_mplstp_fm_flags_l, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (fm_flags, hf_mplstp_fm_flags_r, tvb, offset, 1, ENC_BIG_ENDIAN);
offset = offset + 1;
/* Refresh-Timer field */
proto_tree_add_item (fm_tree, hf_mplstp_fm_refresh_timer, tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
/* FM-TLV Length field*/
proto_tree_add_item (fm_tree, hf_mplstp_fm_total_tlv_len, tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
if (tlv_len != 0)
{
tvbuff_t *next_tvb;
/* FM TLVs*/
next_tvb = tvb_new_subset_remaining (tvb, offset);
dissect_mplstp_fm_tlv (next_tvb, tree);
}
return tvb_captured_length(tvb);
}
void
proto_register_mplstp_lock(void)
{
static hf_register_info hf[] = {
{&hf_mplstp_lock_version,
{"Version", "mplstp_lock.version", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_lock_reserved,
{"Reserved", "mplstp_lock.reserved", FT_UINT24,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_lock_refresh_timer,
{"Refresh-timer value", "mplstp_lock.refresh-timer", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_mplstp_lock,
};
proto_mplstp_lock =
proto_register_protocol("MPLS-TP Lock-Instruct", "MPLS[-TP] Lock-Instruct "
"Lock-Instruct (LI) Protocol",
"mplstp_lock");
proto_register_field_array(proto_mplstp_lock, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_mplstp_lock(void)
{
dissector_handle_t mplstp_lock_handle;
mplstp_lock_handle = create_dissector_handle( dissect_mplstp_lock, proto_mplstp_lock );
dissector_add_uint("pwach.channel_type", 0x0026, mplstp_lock_handle); /* KM: MPLSTP LOCK, RFC 6435 */
}
void
proto_register_mplstp_fm(void)
{
static hf_register_info hf[] = {
{&hf_mplstp_fm_version,
{"Version", "mplstp_oam.version", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_reserved,
{"Reserved", "mplstp_oam.reserved", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_refresh_timer,
{"Refresh-timer value", "mplstp_oam.refresh.timer", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_total_tlv_len,
{"FM TLV Length", "mplstp_oam.total.tlv.len", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_if_tlv_type,
{"Type : IF-ID TLV", "mplstp_oam.if_id_tlv_type", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_global_tlv_type,
{"Type : GLOBAL-ID TLV", "mplstp_oam.global_id_tlv_type", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_tlv_len,
{"Length", "mplstp_oam.tlv_len", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_node_id,
{"Node id", "mplstp_oam.node_id", FT_IPv4,
BASE_NONE, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_if_num,
{"Interface Number", "mplstp_oam.if_num", FT_UINT32,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_global_id,
{"Global id", "mplstp_oam.global_id", FT_UINT32,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_msg_type,
{"Message Type", "mplstp_oam.message.type", FT_UINT8,
BASE_DEC, VALS(fm_msg_type), 0x0, "MPLS-TP FM Message Type", HFILL }},
{ &hf_mplstp_fm_flags,
{ "FM Flags", "mplstp_oam.flags",
FT_UINT8, BASE_HEX, NULL, 0x0000, "MPLS-TP FM Flags", HFILL}
},
{ &hf_mplstp_fm_flags_l,
{ "Link Down Indication", "mplstp_oam.flag_l",
FT_BOOLEAN, 8, NULL, 0x0002, NULL, HFILL}
},
{ &hf_mplstp_fm_flags_r,
{ "FM Condition Cleared", "mplstp_oam.flag_r",
FT_BOOLEAN, 8, NULL, 0x0001, "Fault Condition Cleared", HFILL}
},
};
static gint *ett[] = {
&ett_mplstp_fm,
&ett_mplstp_fm_tlv_tree,
&ett_mplstp_fm_flags,
};
proto_mplstp_fm =
proto_register_protocol("MPLS-TP Fault-Management", "MPLS[-TP] Fault-Management "
"Fault-Management (FM) Protocol",
"mplstp_fm");
proto_register_field_array(proto_mplstp_fm, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_mplstp_fm(void)
{
dissector_handle_t mplstp_fm_handle;
mplstp_fm_handle = create_dissector_handle( dissect_mplstp_fm, proto_mplstp_fm );
dissector_add_uint("pwach.channel_type", PW_ACH_TYPE_MPLSTP_FM, mplstp_fm_handle);
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|