2 * Routines for 802.3 MAC Address Allocation Protocol defined by IEEE1722
3 * Copyright 2012, Jason Damori, Biamp Systems <jdamori at biamp dot com>
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
16 #include <epan/packet.h>
17 #include <epan/to_str.h>
19 void proto_register_maap(void);
20 void proto_reg_handoff_maap(void);
22 /* MAAP starts after common 1722 header */
23 #define MAAP_START_OFFSET 1
25 /* MAAP Field Offsets */
26 #define MAAP_MSG_TYPE_OFFSET 0+MAAP_START_OFFSET
27 #define MAAP_VERSION_OFFSET 1+MAAP_START_OFFSET
28 #define MAAP_STREAM_ID_OFFSET 3+MAAP_START_OFFSET
29 #define MAAP_REQ_START_ADDR_OFFSET 11+MAAP_START_OFFSET
30 #define MAAP_REQ_COUNT_OFFSET 17+MAAP_START_OFFSET
31 #define MAAP_CONFLICT_START_ADDR_OFFSET 19+MAAP_START_OFFSET
32 #define MAAP_CONFLICT_COUNT_OFFSET 25+MAAP_START_OFFSET
35 #define MAAP_MSG_TYPE_MASK 0x0f
36 #define MAAP_VERSION_MASK 0xf8
37 #define MAAP_DATA_LEN_MASK 0x07ff
39 /* MAAP message_type */
40 #define MAAP_MSG_TYPE_RESERVED_0 0x00
41 #define MAAP_MSG_TYPE_PROBE 0x01
42 #define MAAP_MSG_TYPE_DEFEND 0x02
43 #define MAAP_MSG_TYPE_ANNOUNCE 0x03
44 #define MAAP_MSG_TYPE_RESERVED_4 0x04
45 #define MAAP_MSG_TYPE_RESERVED_5 0x05
47 static const value_string maap_msg_type_vals [] = {
48 {MAAP_MSG_TYPE_PROBE, "MAAP_PROBE"},
49 {MAAP_MSG_TYPE_DEFEND, "MAAP_DEFEND"},
50 {MAAP_MSG_TYPE_ANNOUNCE, "MAAP_ANNOUNCE"},
54 /**********************************************************/
55 /* Initialize the protocol and registered fields */
56 /**********************************************************/
57 static int proto_maap = -1;
60 static int hf_maap_message_type = -1;
61 static int hf_maap_version = -1;
62 static int hf_maap_data_length = -1;
63 static int hf_maap_stream_id = -1;
64 static int hf_maap_req_start_addr = -1;
65 static int hf_maap_req_count = -1;
66 static int hf_maap_conflict_start_addr = -1;
67 static int hf_maap_conflict_count = -1;
69 /* Initialize the subtree pointers */
70 static int ett_maap = -1;
73 dissect_maap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
76 proto_item *maap_item = NULL;
77 proto_tree *maap_tree = NULL;
79 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MAAP");
80 col_clear(pinfo->cinfo, COL_INFO);
82 /* The maap msg type will be handy in a moment */
83 maap_msg_type = tvb_get_guint8(tvb, MAAP_MSG_TYPE_OFFSET);
84 maap_msg_type &= 0x0f;
86 /* Display the name of the packet type in the info column. */
87 col_add_fstr(pinfo->cinfo, COL_INFO, "%s:",
88 val_to_str(maap_msg_type, maap_msg_type_vals,
89 "Unknown Type(0x%02x)"));
91 /* Now, we'll add the start and conflict addresses and counts to the info column as appropriate */
92 switch (maap_msg_type)
94 case MAAP_MSG_TYPE_PROBE:
95 case MAAP_MSG_TYPE_ANNOUNCE:
96 col_append_fstr(pinfo->cinfo, COL_INFO, " req_start=%s, cnt=%d",
97 tvb_ether_to_str(tvb, MAAP_REQ_START_ADDR_OFFSET),
98 tvb_get_ntohs(tvb, MAAP_REQ_COUNT_OFFSET));
101 case MAAP_MSG_TYPE_DEFEND:
102 col_append_fstr(pinfo->cinfo, COL_INFO, " conflict_start=%s, cnt=%d",
103 tvb_ether_to_str(tvb, MAAP_CONFLICT_START_ADDR_OFFSET),
104 tvb_get_ntohs(tvb, MAAP_CONFLICT_COUNT_OFFSET));
107 /* no info for reserved or unknown msg types */
113 maap_item = proto_tree_add_item(tree, proto_maap, tvb, MAAP_START_OFFSET, -1, ENC_NA);
114 maap_tree = proto_item_add_subtree(maap_item, ett_maap);
116 proto_tree_add_item(maap_tree, hf_maap_message_type, tvb, MAAP_MSG_TYPE_OFFSET, 1, ENC_BIG_ENDIAN);
117 proto_tree_add_item(maap_tree, hf_maap_version, tvb, MAAP_VERSION_OFFSET, 1, ENC_BIG_ENDIAN);
118 proto_tree_add_item(maap_tree, hf_maap_data_length, tvb, MAAP_VERSION_OFFSET, 2, ENC_BIG_ENDIAN);
119 proto_tree_add_item(maap_tree, hf_maap_stream_id, tvb, MAAP_STREAM_ID_OFFSET, 8, ENC_BIG_ENDIAN);
120 proto_tree_add_item(maap_tree, hf_maap_req_start_addr, tvb, MAAP_REQ_START_ADDR_OFFSET, 6, ENC_NA);
121 proto_tree_add_item(maap_tree, hf_maap_req_count, tvb, MAAP_REQ_COUNT_OFFSET, 2, ENC_BIG_ENDIAN);
122 proto_tree_add_item(maap_tree, hf_maap_conflict_start_addr, tvb, MAAP_CONFLICT_START_ADDR_OFFSET, 6, ENC_NA);
123 proto_tree_add_item(maap_tree, hf_maap_conflict_count, tvb, MAAP_CONFLICT_COUNT_OFFSET, 2, ENC_BIG_ENDIAN);
126 return tvb_captured_length(tvb);
127 } /* end dissect_maap() */
129 /* Register the protocol with Wireshark */
131 proto_register_maap(void)
133 static hf_register_info hf[] = {
134 { &hf_maap_message_type,
135 { "Message Type", "maap.message_type",
137 VALS(maap_msg_type_vals), MAAP_MSG_TYPE_MASK,
141 { "MAAP Version", "maap.version",
143 NULL, MAAP_VERSION_MASK,
146 { &hf_maap_data_length,
147 { "Data Length", "maap.data_length",
149 NULL, MAAP_DATA_LEN_MASK,
152 { &hf_maap_stream_id,
153 { "Stream ID", "maap.stream_id",
158 { &hf_maap_req_start_addr,
159 { "Requested Start Address", "maap.req_start_addr",
164 { &hf_maap_req_count,
165 { "Request Count", "maap.req_count",
170 { &hf_maap_conflict_start_addr,
171 { "Conflict Start Address", "maap.conflict_start_addr",
176 { &hf_maap_conflict_count,
177 { "Conflict Count", "maap.conflict_count",
181 }; /* end of static hf_register_info hf[] = */
183 /* Setup protocol subtree array */
184 static gint *ett[] = { &ett_maap };
186 /* Register the protocol name and description */
187 proto_maap = proto_register_protocol (
188 "IEEE 1722 MAAP Protocol", /* name */
189 "MAAP", /* short name */
193 /* Required function calls to register the header fields and subtrees used */
194 proto_register_field_array(proto_maap, hf, array_length(hf));
195 proto_register_subtree_array(ett, array_length(ett));
197 } /* end proto_register_maap() */
200 proto_reg_handoff_maap(void)
202 dissector_handle_t maap_handle;
204 maap_handle = create_dissector_handle(dissect_maap, proto_maap);
205 dissector_add_uint("ieee1722.subtype", 0xFE, maap_handle);
209 * Editor modelines - https://www.wireshark.org/tools/modelines.html
214 * indent-tabs-mode: nil
217 * vi: set shiftwidth=4 tabstop=8 expandtab:
218 * :indentSize=4:tabSize=8:noTabs=true: