Coverage Report

Created: 2026-01-02 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-pw-oam.c
Line
Count
Source
1
/* packet-pw-oam.c
2
 *
3
 * Routines for Pseudowire Status for static pseudowires : RFC 6478
4
 *
5
 * (c) Copyright 2012, Krishnamurthy Mayya <krishnamurthymayya@gmail.com>
6
 *                     Nikitha Malgi <nikitha01@gmail.com>
7
 *
8
 * Wireshark - Network traffic analyzer
9
 * By Gerald Combs <gerald@wireshark.org>
10
 * Copyright 1998 Gerald Combs
11
 *
12
 * SPDX-License-Identifier: GPL-2.0-or-later
13
 */
14
15
#include "config.h"
16
#include <epan/packet.h>
17
#include "packet-mpls.h"
18
19
void proto_register_pw_oam(void);
20
void proto_reg_handoff_pw_oam(void);
21
22
static dissector_handle_t pw_oam_handle;
23
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;
29
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;
38
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"},
44
  {0, NULL}
45
};
46
47
/* PW-Status TLV dissector */
48
static void
49
dissect_pw_status_tlv (tvbuff_t *tvb, proto_tree *tree, int offset)
50
0
{
51
0
  proto_item *ti;
52
0
  proto_tree *pw_oam_tlv_tree;
53
54
55
0
  ti = proto_tree_add_protocol_format (tree, proto_pw_oam, tvb, offset, 8,
56
0
                                       "Pseudo-Wire Status TLV");
57
58
59
0
  if (!tree)
60
0
    return;
61
62
0
  pw_oam_tlv_tree = proto_item_add_subtree (ti, ett_pw_oam_tlv_tree);
63
64
0
  proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_tlv_reserved, tvb, offset,
65
0
                                    2, ENC_BIG_ENDIAN);
66
0
  proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_tlv_type, tvb, offset,
67
0
                                    2, ENC_BIG_ENDIAN);
68
0
  offset = offset + 2;
69
70
0
  proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_tlv_len, tvb, offset,
71
0
                                    2, ENC_BIG_ENDIAN);
72
0
  offset = offset + 2;
73
0
  proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_code, tvb, offset,
74
0
                                    4, ENC_BIG_ENDIAN);
75
  /*offset = offset + 4;*/
76
77
0
  return ;
78
0
}
79
80
/* Dissector for PW OAM protocol: RFC 6478 */
81
static int
82
dissect_pw_oam(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
83
2
{
84
2
  proto_item  *ti = NULL, *ti_flags = NULL;
85
2
  proto_tree  *pw_oam_tree = NULL, *pw_oam_flags = NULL;
86
87
2
  uint8_t offset        = 0;
88
2
  uint16_t pw_tlv_type   = 0;
89
90
2
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "PW OAM");
91
2
  col_clear(pinfo->cinfo, COL_INFO);
92
93
2
  if (!tree)
94
0
    return tvb_captured_length(tvb);
95
96
2
  ti = proto_tree_add_item(tree, proto_pw_oam, tvb, 0, -1, ENC_NA);
97
98
2
  pw_oam_tree = proto_item_add_subtree (ti, ett_pw_oam);
99
100
  /* Refresh-Timer field */
101
2
  proto_tree_add_item (pw_oam_tree, hf_pw_oam_refresh_timer, tvb, offset,
102
2
                       2, ENC_BIG_ENDIAN);
103
2
  offset = offset + 2;
104
105
  /* Total-TLV length */
106
2
  proto_tree_add_item (pw_oam_tree, hf_pw_oam_total_tlv_len, tvb, offset,
107
2
                       1, ENC_BIG_ENDIAN);
108
2
  offset = offset + 1;
109
110
  /* Flags field */
111
2
  ti_flags = proto_tree_add_item (pw_oam_tree, hf_pw_oam_flags, tvb,
112
2
                                  offset, 1, ENC_BIG_ENDIAN);
113
2
  pw_oam_flags = proto_item_add_subtree(ti_flags, ett_pw_oam_flags);
114
2
  proto_tree_add_item (pw_oam_flags, hf_pw_oam_flags_a, tvb, offset, 1, ENC_BIG_ENDIAN);
115
116
2
  offset = offset + 1;
117
2
  pw_tlv_type = tvb_get_ntohs (tvb, offset);
118
119
  /* TLVs  */
120
2
  switch (pw_tlv_type)
121
2
    {
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 */
124
125
0
      case 0x096A: /* PW-Status TLV */
126
0
        dissect_pw_status_tlv (tvb, tree, offset);
127
0
        break;
128
129
2
      default:
130
2
        break;
131
2
    }
132
133
2
  return tvb_captured_length(tvb);
134
2
}
135
136
void
137
proto_register_pw_oam(void)
138
14
{
139
14
  static hf_register_info hf[] = {
140
141
14
    {&hf_pw_oam_refresh_timer,
142
14
      {"Refresh-Timer", "pw_oam.refresh-timer", FT_UINT16,
143
14
        BASE_HEX, NULL, 0x0, NULL, HFILL }},
144
145
14
    {&hf_pw_oam_total_tlv_len,
146
14
      {"TLV Length", "pw_oam.total-tlv-len", FT_UINT8,
147
14
        BASE_HEX, NULL, 0x0, NULL, HFILL }},
148
149
14
    {&hf_pw_oam_flags,
150
14
      {"Flags", "pw_oam.flags", FT_UINT8,
151
14
        BASE_HEX, NULL, 0x0, "OAM Flags", HFILL }},
152
153
14
    {&hf_pw_oam_flags_a,
154
14
      {"Acknowledgement", "pw_oam.flags_a",
155
14
        FT_BOOLEAN, 8, NULL, 0x80, "ACK bit", HFILL}
156
14
    },
157
158
14
    {&hf_pw_oam_tlv_reserved,
159
14
      {"Reserved", "pw_oam.tlv-reserved",
160
14
        FT_UINT16, BASE_HEX, NULL, 0xC000, NULL, HFILL}
161
14
    },
162
163
14
    {&hf_pw_oam_tlv_type,
164
14
      {"TLV Type", "pw_oam.tlv-type",
165
14
        FT_UINT16, BASE_HEX, NULL, 0x3FFF, NULL, HFILL}
166
14
    },
167
168
14
    {&hf_pw_oam_tlv_len,
169
14
      {"TLV Length", "pw_oam.tlv-len",
170
14
        FT_UINT16, BASE_HEX, NULL, 0x00, NULL, HFILL}
171
14
    },
172
173
14
    {&hf_pw_oam_code,
174
14
      {"Status code", "pw_oam.code", FT_UINT32,
175
14
        BASE_HEX, VALS(pw_oam_code), 0x0, "PW Status Code", HFILL }
176
14
    },
177
178
14
  };
179
180
14
  static int *ett[] = {
181
14
    &ett_pw_oam,
182
14
    &ett_pw_oam_tlv_tree,
183
14
    &ett_pw_oam_flags,
184
14
  };
185
186
14
  proto_pw_oam =
187
14
    proto_register_protocol("Pseudo-Wire OAM", "PW-OAM "
188
14
        "Pseudo-Wire OAM Protocol",
189
14
        "pw_oam");
190
191
14
  proto_register_field_array (proto_pw_oam, hf, array_length(hf));
192
14
  proto_register_subtree_array (ett, array_length(ett));
193
194
14
  pw_oam_handle = register_dissector ("pw_oam",  dissect_pw_oam, proto_pw_oam);
195
14
}
196
197
void
198
proto_reg_handoff_pw_oam(void)
199
14
{
200
14
  dissector_add_uint("pwach.channel_type", PW_ACH_TYPE_PW_OAM, pw_oam_handle);
201
14
}
202
203
/*
204
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
205
 *
206
 * Local variables:
207
 * c-basic-offset: 2
208
 * tab-width: 8
209
 * indent-tabs-mode: nil
210
 * End:
211
 *
212
 * vi: set shiftwidth=2 tabstop=8 expandtab:
213
 * :indentSize=2:tabSize=8:noTabs=true:
214
 */