Coverage Report

Created: 2026-05-14 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-maap.c
Line
Count
Source
1
/* packet-maap.c
2
 * Routines for 802.3 MAC Address Allocation Protocol defined by IEEE1722
3
 * Copyright 2012, Jason Damori, Biamp Systems <jdamori at biamp dot com>
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1998 Gerald Combs
8
 *
9
 * SPDX-License-Identifier: GPL-2.0-or-later
10
 *
11
 */
12
13
14
#include "config.h"
15
16
#include <epan/packet.h>
17
#include <epan/to_str.h>
18
19
void proto_register_maap(void);
20
void proto_reg_handoff_maap(void);
21
22
static dissector_handle_t maap_handle;
23
24
/* MAAP starts after common 1722 header */
25
0
#define MAAP_START_OFFSET                   1
26
27
/* MAAP Field Offsets */
28
0
#define MAAP_MSG_TYPE_OFFSET                0+MAAP_START_OFFSET
29
0
#define MAAP_VERSION_OFFSET                 1+MAAP_START_OFFSET
30
0
#define MAAP_STREAM_ID_OFFSET               3+MAAP_START_OFFSET
31
0
#define MAAP_REQ_START_ADDR_OFFSET          11+MAAP_START_OFFSET
32
0
#define MAAP_REQ_COUNT_OFFSET               17+MAAP_START_OFFSET
33
0
#define MAAP_CONFLICT_START_ADDR_OFFSET     19+MAAP_START_OFFSET
34
0
#define MAAP_CONFLICT_COUNT_OFFSET          25+MAAP_START_OFFSET
35
36
/* Bit Field Masks */
37
15
#define MAAP_MSG_TYPE_MASK                  0x0f
38
15
#define MAAP_VERSION_MASK                   0xf8
39
15
#define MAAP_DATA_LEN_MASK                  0x07ff
40
41
/* MAAP message_type */
42
#define MAAP_MSG_TYPE_RESERVED_0            0x00
43
0
#define MAAP_MSG_TYPE_PROBE                 0x01
44
0
#define MAAP_MSG_TYPE_DEFEND                0x02
45
0
#define MAAP_MSG_TYPE_ANNOUNCE              0x03
46
#define MAAP_MSG_TYPE_RESERVED_4            0x04
47
#define MAAP_MSG_TYPE_RESERVED_5            0x05
48
49
static const value_string maap_msg_type_vals [] = {
50
    {MAAP_MSG_TYPE_PROBE,       "MAAP_PROBE"},
51
    {MAAP_MSG_TYPE_DEFEND,      "MAAP_DEFEND"},
52
    {MAAP_MSG_TYPE_ANNOUNCE,    "MAAP_ANNOUNCE"},
53
    {0,                         NULL}
54
};
55
56
/**********************************************************/
57
/* Initialize the protocol and registered fields          */
58
/**********************************************************/
59
static int proto_maap;
60
61
/* MAAP PDU */
62
static int hf_maap_message_type;
63
static int hf_maap_version;
64
static int hf_maap_data_length;
65
static int hf_maap_stream_id;
66
static int hf_maap_req_start_addr;
67
static int hf_maap_req_count;
68
static int hf_maap_conflict_start_addr;
69
static int hf_maap_conflict_count;
70
71
/* Initialize the subtree pointers */
72
static int ett_maap;
73
74
static int
75
dissect_maap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
76
0
{
77
0
    uint8_t     maap_msg_type;
78
0
    proto_item *maap_item     = NULL;
79
0
    proto_tree *maap_tree     = NULL;
80
81
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "MAAP");
82
0
    col_clear(pinfo->cinfo, COL_INFO);
83
84
    /* The maap msg type will be handy in a moment */
85
0
    maap_msg_type = tvb_get_uint8(tvb, MAAP_MSG_TYPE_OFFSET);
86
0
    maap_msg_type &= 0x0f;
87
88
    /* Display the name of the packet type in the info column. */
89
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "%s:",
90
0
                val_to_str(pinfo->pool, maap_msg_type, maap_msg_type_vals,
91
0
                            "Unknown Type(0x%02x)"));
92
93
    /* Now, we'll add the start and conflict addresses and counts to the info column as appropriate */
94
0
    switch (maap_msg_type)
95
0
    {
96
0
    case MAAP_MSG_TYPE_PROBE:
97
0
    case MAAP_MSG_TYPE_ANNOUNCE:
98
0
        col_append_fstr(pinfo->cinfo, COL_INFO, " req_start=%s, cnt=%d",
99
0
                        tvb_ether_to_str(pinfo->pool, tvb, MAAP_REQ_START_ADDR_OFFSET),
100
0
                        tvb_get_ntohs(tvb, MAAP_REQ_COUNT_OFFSET));
101
102
0
        break;
103
0
    case MAAP_MSG_TYPE_DEFEND:
104
0
        col_append_fstr(pinfo->cinfo, COL_INFO, " conflict_start=%s, cnt=%d",
105
0
                        tvb_ether_to_str(pinfo->pool, tvb, MAAP_CONFLICT_START_ADDR_OFFSET),
106
0
                        tvb_get_ntohs(tvb, MAAP_CONFLICT_COUNT_OFFSET));
107
0
        break;
108
0
    default:
109
        /* no info for reserved or unknown msg types */
110
0
        break;
111
0
    }
112
113
114
0
    if (tree) {
115
0
        maap_item = proto_tree_add_item(tree, proto_maap, tvb, MAAP_START_OFFSET, -1, ENC_NA);
116
0
        maap_tree = proto_item_add_subtree(maap_item, ett_maap);
117
118
0
        proto_tree_add_item(maap_tree, hf_maap_message_type,        tvb, MAAP_MSG_TYPE_OFFSET,            1, ENC_BIG_ENDIAN);
119
0
        proto_tree_add_item(maap_tree, hf_maap_version,             tvb, MAAP_VERSION_OFFSET,             1, ENC_BIG_ENDIAN);
120
0
        proto_tree_add_item(maap_tree, hf_maap_data_length,         tvb, MAAP_VERSION_OFFSET,             2, ENC_BIG_ENDIAN);
121
0
        proto_tree_add_item(maap_tree, hf_maap_stream_id,           tvb, MAAP_STREAM_ID_OFFSET,           8, ENC_BIG_ENDIAN);
122
0
        proto_tree_add_item(maap_tree, hf_maap_req_start_addr,      tvb, MAAP_REQ_START_ADDR_OFFSET,      6, ENC_NA);
123
0
        proto_tree_add_item(maap_tree, hf_maap_req_count,           tvb, MAAP_REQ_COUNT_OFFSET,           2, ENC_BIG_ENDIAN);
124
0
        proto_tree_add_item(maap_tree, hf_maap_conflict_start_addr, tvb, MAAP_CONFLICT_START_ADDR_OFFSET, 6, ENC_NA);
125
0
        proto_tree_add_item(maap_tree, hf_maap_conflict_count,      tvb, MAAP_CONFLICT_COUNT_OFFSET,      2, ENC_BIG_ENDIAN);
126
0
    }
127
128
0
    return tvb_captured_length(tvb);
129
0
} /* end dissect_maap() */
130
131
/* Register the protocol with Wireshark */
132
void
133
proto_register_maap(void)
134
15
{
135
15
    static hf_register_info hf[] = {
136
15
        { &hf_maap_message_type,
137
15
            { "Message Type", "maap.message_type",
138
15
                FT_UINT8, BASE_HEX,
139
15
                VALS(maap_msg_type_vals), MAAP_MSG_TYPE_MASK,
140
15
                NULL, HFILL }},
141
142
15
        { &hf_maap_version,
143
15
            { "MAAP Version", "maap.version",
144
15
                FT_UINT8, BASE_HEX,
145
15
                NULL, MAAP_VERSION_MASK,
146
15
                NULL, HFILL }},
147
148
15
        { &hf_maap_data_length,
149
15
            { "Data Length", "maap.data_length",
150
15
                FT_UINT16, BASE_HEX,
151
15
                NULL, MAAP_DATA_LEN_MASK,
152
15
                NULL, HFILL }},
153
154
15
        { &hf_maap_stream_id,
155
15
            { "Stream ID", "maap.stream_id",
156
15
                FT_UINT64, BASE_HEX,
157
15
                NULL, 0x00,
158
15
                NULL, HFILL }},
159
160
15
        { &hf_maap_req_start_addr,
161
15
            { "Requested Start Address", "maap.req_start_addr",
162
15
                FT_ETHER, BASE_NONE,
163
15
                NULL, 0x00,
164
15
                NULL, HFILL }},
165
166
15
        { &hf_maap_req_count,
167
15
            { "Request Count", "maap.req_count",
168
15
                FT_UINT16, BASE_HEX,
169
15
                NULL, 0x00,
170
15
                NULL, HFILL }},
171
172
15
        { &hf_maap_conflict_start_addr,
173
15
            { "Conflict Start Address", "maap.conflict_start_addr",
174
15
                FT_ETHER, BASE_NONE,
175
15
                NULL, 0x00,
176
15
                NULL, HFILL }},
177
178
15
        { &hf_maap_conflict_count,
179
15
            { "Conflict Count", "maap.conflict_count",
180
15
                FT_UINT16, BASE_HEX,
181
15
                NULL, 0x00,
182
15
                NULL, HFILL }}
183
15
    }; /* end of static hf_register_info hf[] = */
184
185
    /* Setup protocol subtree array */
186
15
    static int *ett[] = { &ett_maap };
187
188
    /* Register the protocol name and description */
189
15
    proto_maap = proto_register_protocol ("IEEE 1722 MAAP Protocol", "MAAP", "maap");
190
191
    /* Required function calls to register the header fields and subtrees used */
192
15
    proto_register_field_array(proto_maap, hf, array_length(hf));
193
15
    proto_register_subtree_array(ett, array_length(ett));
194
195
    /* Register the dissector */
196
15
    maap_handle = register_dissector("maap", dissect_maap, proto_maap);
197
198
15
} /* end proto_register_maap() */
199
200
void
201
proto_reg_handoff_maap(void)
202
15
{
203
15
    dissector_add_uint("ieee1722.subtype", 0xFE, maap_handle);
204
15
}
205
206
/*
207
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
208
 *
209
 * Local variables:
210
 * c-basic-offset: 4
211
 * tab-width: 8
212
 * indent-tabs-mode: nil
213
 * End:
214
 *
215
 * vi: set shiftwidth=4 tabstop=8 expandtab:
216
 * :indentSize=4:tabSize=8:noTabs=true:
217
 */