3 * Routines for Pseudowire Status for static pseudowires : RFC 6478
5 * (c) Copyright 2012, Krishnamurthy Mayya <krishnamurthymayya@gmail.com>
6 * Nikitha Malgi <nikitha01@gmail.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * SPDX-License-Identifier: GPL-2.0-or-later
16 #include <epan/packet.h>
17 #include "packet-mpls.h"
19 void proto_register_pw_oam(void);
20 void proto_reg_handoff_pw_oam(void);
22 static dissector_handle_t pw_oam_handle
;
24 /* MPLS-TP FM protocol specific variables */
25 static int proto_pw_oam
;
26 static int ett_pw_oam
;
27 static int ett_pw_oam_flags
;
28 static int ett_pw_oam_tlv_tree
;
30 static int hf_pw_oam_tlv_reserved
;
31 static int hf_pw_oam_tlv_type
;
32 static int hf_pw_oam_total_tlv_len
;
33 static int hf_pw_oam_code
;
34 static int hf_pw_oam_flags
;
35 static int hf_pw_oam_flags_a
;
36 static int hf_pw_oam_refresh_timer
;
37 static int hf_pw_oam_tlv_len
;
39 static const value_string pw_oam_code
[] = {
40 {0x00000002, "Local Attachment Circuit(ingress) Receive Fault"},
41 {0x00000004, "Local Attachment Circuit(egress) Transmit Fault"},
42 {0x00000020, "PW Forwarding Standby"},
43 {0x00000040, "Request Switchover to this PW"},
47 /* PW-Status TLV dissector */
49 dissect_pw_status_tlv (tvbuff_t
*tvb
, proto_tree
*tree
, int offset
)
52 proto_tree
*pw_oam_tlv_tree
;
55 ti
= proto_tree_add_protocol_format (tree
, proto_pw_oam
, tvb
, offset
, 8,
56 "Pseudo-Wire Status TLV");
62 pw_oam_tlv_tree
= proto_item_add_subtree (ti
, ett_pw_oam_tlv_tree
);
64 proto_tree_add_item (pw_oam_tlv_tree
, hf_pw_oam_tlv_reserved
, tvb
, offset
,
66 proto_tree_add_item (pw_oam_tlv_tree
, hf_pw_oam_tlv_type
, tvb
, offset
,
70 proto_tree_add_item (pw_oam_tlv_tree
, hf_pw_oam_tlv_len
, tvb
, offset
,
73 proto_tree_add_item (pw_oam_tlv_tree
, hf_pw_oam_code
, tvb
, offset
,
75 /*offset = offset + 4;*/
80 /* Dissector for PW OAM protocol: RFC 6478 */
82 dissect_pw_oam(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
84 proto_item
*ti
= NULL
, *ti_flags
= NULL
;
85 proto_tree
*pw_oam_tree
= NULL
, *pw_oam_flags
= NULL
;
88 uint16_t pw_tlv_type
= 0;
90 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "PW OAM");
91 col_clear(pinfo
->cinfo
, COL_INFO
);
94 return tvb_captured_length(tvb
);
96 ti
= proto_tree_add_item(tree
, proto_pw_oam
, tvb
, 0, -1, ENC_NA
);
98 pw_oam_tree
= proto_item_add_subtree (ti
, ett_pw_oam
);
100 /* Refresh-Timer field */
101 proto_tree_add_item (pw_oam_tree
, hf_pw_oam_refresh_timer
, tvb
, offset
,
105 /* Total-TLV length */
106 proto_tree_add_item (pw_oam_tree
, hf_pw_oam_total_tlv_len
, tvb
, offset
,
111 ti_flags
= proto_tree_add_item (pw_oam_tree
, hf_pw_oam_flags
, tvb
,
112 offset
, 1, ENC_BIG_ENDIAN
);
113 pw_oam_flags
= proto_item_add_subtree(ti_flags
, ett_pw_oam_flags
);
114 proto_tree_add_item (pw_oam_flags
, hf_pw_oam_flags_a
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
117 pw_tlv_type
= tvb_get_ntohs (tvb
, offset
);
122 /* The switch cases below have to be based on the LDP-name space.
123 http://www.iana.org/assignments/ldp-namespaces/ldp-namespaces.xml */
125 case 0x096A: /* PW-Status TLV */
126 dissect_pw_status_tlv (tvb
, tree
, offset
);
133 return tvb_captured_length(tvb
);
137 proto_register_pw_oam(void)
139 static hf_register_info hf
[] = {
141 {&hf_pw_oam_refresh_timer
,
142 {"Refresh-Timer", "pw_oam.refresh-timer", FT_UINT16
,
143 BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
145 {&hf_pw_oam_total_tlv_len
,
146 {"TLV Length", "pw_oam.total-tlv-len", FT_UINT8
,
147 BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
150 {"Flags", "pw_oam.flags", FT_UINT8
,
151 BASE_HEX
, NULL
, 0x0, "OAM Flags", HFILL
}},
154 {"Acknowledgement", "pw_oam.flags_a",
155 FT_BOOLEAN
, 8, NULL
, 0x80, "ACK bit", HFILL
}
158 {&hf_pw_oam_tlv_reserved
,
159 {"Reserved", "pw_oam.tlv-reserved",
160 FT_UINT16
, BASE_HEX
, NULL
, 0xC000, NULL
, HFILL
}
163 {&hf_pw_oam_tlv_type
,
164 {"TLV Type", "pw_oam.tlv-type",
165 FT_UINT16
, BASE_HEX
, NULL
, 0x3FFF, NULL
, HFILL
}
169 {"TLV Length", "pw_oam.tlv-len",
170 FT_UINT16
, BASE_HEX
, NULL
, 0x00, NULL
, HFILL
}
174 {"Status code", "pw_oam.code", FT_UINT32
,
175 BASE_HEX
, VALS(pw_oam_code
), 0x0, "PW Status Code", HFILL
}
180 static int *ett
[] = {
182 &ett_pw_oam_tlv_tree
,
187 proto_register_protocol("Pseudo-Wire OAM", "PW-OAM "
188 "Pseudo-Wire OAM Protocol",
191 proto_register_field_array (proto_pw_oam
, hf
, array_length(hf
));
192 proto_register_subtree_array (ett
, array_length(ett
));
194 pw_oam_handle
= register_dissector ("pw_oam", dissect_pw_oam
, proto_pw_oam
);
198 proto_reg_handoff_pw_oam(void)
200 dissector_add_uint("pwach.channel_type", PW_ACH_TYPE_PW_OAM
, pw_oam_handle
);
204 * Editor modelines - https://www.wireshark.org/tools/modelines.html
209 * indent-tabs-mode: nil
212 * vi: set shiftwidth=2 tabstop=8 expandtab:
213 * :indentSize=2:tabSize=8:noTabs=true: