3 * Routines for MPLS Media Access Control (MAC) Address Withdrawal over Static Pseudowire.
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include <epan/packet.h>
15 #include "packet-mpls.h"
17 void proto_register_mpls_mac(void);
18 void proto_reg_handoff_mpls_mac(void);
20 static dissector_handle_t mpls_mac_handle
;
22 static int proto_mpls_mac
;
24 static int ett_mpls_mac
;
25 static int ett_mpls_mac_flags
;
26 static int ett_mpls_mac_tlv
;
28 static int hf_mpls_mac_reserved
;
29 static int hf_mpls_mac_tlv_length_total
;
30 static int hf_mpls_mac_flags
;
31 static int hf_mpls_mac_flags_a
;
32 static int hf_mpls_mac_flags_r
;
33 static int hf_mpls_mac_flags_reserved
;
34 static int hf_mpls_mac_tlv
;
35 static int hf_mpls_mac_tlv_res
;
36 static int hf_mpls_mac_tlv_type
;
37 static int hf_mpls_mac_tlv_length
;
38 static int hf_mpls_mac_tlv_value
;
39 static int hf_mpls_mac_tlv_sequence_number
;
42 static int * const mpls_mac_flags
[] = {
45 &hf_mpls_mac_flags_reserved
,
50 dissect_mpls_mac(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
54 uint32_t offset
= 0, tlv_length
, offset_end
;
56 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MPLS-MAC");
57 col_clear(pinfo
->cinfo
, COL_INFO
);
59 ti
= proto_tree_add_item(tree
, proto_mpls_mac
, tvb
, 0, -1, ENC_NA
);
60 mac_tree
= proto_item_add_subtree(ti
, ett_mpls_mac
);
62 proto_tree_add_item(mac_tree
, hf_mpls_mac_reserved
, tvb
, offset
, 2, ENC_NA
);
65 proto_tree_add_item_ret_uint(mac_tree
, hf_mpls_mac_tlv_length_total
, tvb
, offset
, 1, ENC_BIG_ENDIAN
, &tlv_length
);
68 proto_tree_add_bitmask(mac_tree
, tvb
, offset
, hf_mpls_mac_flags
,
73 offset_end
= offset
+ tlv_length
;
75 while(offset
< offset_end
){
76 uint32_t type
, length
;
79 ti
= proto_tree_add_item(mac_tree
, hf_mpls_mac_tlv
, tvb
, offset
, 4, ENC_NA
);
81 tlv_tree
= proto_item_add_subtree(ti
, ett_mpls_mac_tlv
);
83 proto_tree_add_item(tlv_tree
, hf_mpls_mac_tlv_res
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
86 proto_tree_add_item_ret_uint(tlv_tree
, hf_mpls_mac_tlv_type
, tvb
, offset
, 2, ENC_BIG_ENDIAN
, &type
);
90 proto_tree_add_item_ret_uint(tlv_tree
, hf_mpls_mac_tlv_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
, &length
);
92 proto_item_set_len(ti
, 2+2+length
);
93 proto_item_append_text(ti
, " (t=0x%x, l=%u)", type
, length
);
96 proto_tree_add_item(tlv_tree
, hf_mpls_mac_tlv_value
, tvb
, offset
, length
, ENC_NA
);
100 proto_tree_add_item(tlv_tree
, hf_mpls_mac_tlv_sequence_number
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
113 proto_register_mpls_mac(void)
115 static hf_register_info hf
[] = {
117 &hf_mpls_mac_reserved
,
119 "Reserved", "mpls_mac.reserved",
120 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
125 &hf_mpls_mac_tlv_length_total
,
127 "TLV Length (Total)", "mpls_mac.tlv_length_total",
128 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
135 "Flags", "mpls_mac.flags",
136 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
141 &hf_mpls_mac_flags_a
,
143 "Flags A", "mpls_mac.flags.a",
144 FT_BOOLEAN
, 8, NULL
, 0x80,
145 "set by a receiver to acknowledge receipt and processing of a MAC Address Withdraw OAM Message", HFILL
149 &hf_mpls_mac_flags_r
,
151 "Flags R", "mpls_mac.flags.r",
152 FT_BOOLEAN
, 8, NULL
, 0x40,
153 "Set to indicate if the sender is requesting reset of the sequence numbers", HFILL
157 &hf_mpls_mac_flags_reserved
,
159 "Flags Reserved", "mpls_mac.flags.reserved",
160 FT_UINT8
, BASE_HEX
, NULL
, 0x3F,
167 "TLV", "mpls_mac.tlv",
168 FT_NONE
, BASE_NONE
, NULL
, 0x0,
173 &hf_mpls_mac_tlv_res
,
175 "Res(erved)", "mpls_mac.tlv.res",
176 FT_UINT16
, BASE_HEX
, NULL
, 0xC000,
181 &hf_mpls_mac_tlv_type
,
183 "TLV Type", "mpls_mac.tlv.type",
184 FT_UINT16
, BASE_HEX
, NULL
, 0x3FFF,
189 &hf_mpls_mac_tlv_length
,
191 "TLV Length", "mpls_mac.tlv.length",
192 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
197 &hf_mpls_mac_tlv_value
,
199 "TLV Value", "mpls_mac.tlv.value",
200 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
205 &hf_mpls_mac_tlv_sequence_number
,
207 "Sequence Number", "mpls_mac.tlv.sequence_number",
208 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
214 static int *ett
[] = {
221 proto_register_protocol("Media Access Control (MAC) Address Withdrawal over Static Pseudowire", "MPLS-MAC", "mpls_mac");
223 proto_register_field_array(proto_mpls_mac
, hf
, array_length(hf
));
224 proto_register_subtree_array(ett
, array_length(ett
));
226 mpls_mac_handle
= register_dissector("mpls_mac", dissect_mpls_mac
, proto_mpls_mac
);
230 proto_reg_handoff_mpls_mac(void)
232 dissector_add_uint("pwach.channel_type", PW_ACH_TYPE_MAC
, mpls_mac_handle
);
236 * Editor modelines - https://www.wireshark.org/tools/modelines.html
241 * indent-tabs-mode: nil
244 * vi: set shiftwidth=4 tabstop=8 expandtab:
245 * :indentSize=4:tabSize=8:noTabs=true: