2 * Routines for 802.3 MAC Address Allocation Protocol defined by IEEE1722
3 * Copyright 2012, Jason Damori, Biamp Systems <jdamori at biamp dot com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <epan/packet.h>
31 #include <epan/to_str.h>
32 #include <epan/etypes.h>
34 /* MAAP starts after common 1722 header */
35 #define MAAP_START_OFFSET 1
37 /* MAAP Field Offsets */
38 #define MAAP_MSG_TYPE_OFFSET 0+MAAP_START_OFFSET
39 #define MAAP_VERSION_OFFSET 1+MAAP_START_OFFSET
40 #define MAAP_STREAM_ID_OFFSET 3+MAAP_START_OFFSET
41 #define MAAP_REQ_START_ADDR_OFFSET 11+MAAP_START_OFFSET
42 #define MAAP_REQ_COUNT_OFFSET 17+MAAP_START_OFFSET
43 #define MAAP_CONFLICT_START_ADDR_OFFSET 19+MAAP_START_OFFSET
44 #define MAAP_CONFLICT_COUNT_OFFSET 25+MAAP_START_OFFSET
47 #define MAAP_MSG_TYPE_MASK 0x0f
48 #define MAAP_VERSION_MASK 0xf8
49 #define MAAP_DATA_LEN_MASK 0x07ff
51 /* MAAP message_type */
52 #define MAAP_MSG_TYPE_RESERVED_0 0x00
53 #define MAAP_MSG_TYPE_PROBE 0x01
54 #define MAAP_MSG_TYPE_DEFEND 0x02
55 #define MAAP_MSG_TYPE_ANNOUNCE 0x03
56 #define MAAP_MSG_TYPE_RESERVED_4 0x04
57 #define MAAP_MSG_TYPE_RESERVED_5 0x05
59 static const value_string maap_msg_type_vals
[] = {
60 {MAAP_MSG_TYPE_PROBE
, "MAAP_PROBE"},
61 {MAAP_MSG_TYPE_DEFEND
, "MAAP_DEFEND"},
62 {MAAP_MSG_TYPE_ANNOUNCE
, "MAAP_ANNOUNCE"},
66 /**********************************************************/
67 /* Initialize the protocol and registered fields */
68 /**********************************************************/
69 static int proto_maap
= -1;
72 static int hf_maap_message_type
= -1;
73 static int hf_maap_version
= -1;
74 static int hf_maap_data_length
= -1;
75 static int hf_maap_stream_id
= -1;
76 static int hf_maap_req_start_addr
= -1;
77 static int hf_maap_req_count
= -1;
78 static int hf_maap_conflict_start_addr
= -1;
79 static int hf_maap_conflict_count
= -1;
81 /* Initialize the subtree pointers */
82 static int ett_maap
= -1;
85 dissect_maap(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
88 proto_item
*maap_item
= NULL
;
89 proto_tree
*maap_tree
= NULL
;
91 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MAAP");
92 col_clear(pinfo
->cinfo
, COL_INFO
);
94 /* The maap msg type will be handy in a moment */
95 maap_msg_type
= tvb_get_guint8(tvb
, MAAP_MSG_TYPE_OFFSET
);
96 maap_msg_type
&= 0x0f;
98 /* Display the name of the packet type in the info column. */
99 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s:",
100 val_to_str(maap_msg_type
, maap_msg_type_vals
,
101 "Unknown Type(0x%02x)"));
103 /* Now, we'll add the start and conflict addresses and counts to the info column as appropriate */
104 switch (maap_msg_type
)
106 case MAAP_MSG_TYPE_PROBE
:
107 case MAAP_MSG_TYPE_ANNOUNCE
:
108 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " req_start=%s, cnt=%d",
109 tvb_ether_to_str(tvb
, MAAP_REQ_START_ADDR_OFFSET
),
110 tvb_get_ntohs(tvb
, MAAP_REQ_COUNT_OFFSET
));
113 case MAAP_MSG_TYPE_DEFEND
:
114 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " conflict_start=%s, cnt=%d",
115 tvb_ether_to_str(tvb
, MAAP_CONFLICT_START_ADDR_OFFSET
),
116 tvb_get_ntohs(tvb
, MAAP_CONFLICT_COUNT_OFFSET
));
119 /* no info for reserved or unknown msg types */
125 maap_item
= proto_tree_add_item(tree
, proto_maap
, tvb
, MAAP_START_OFFSET
, -1, ENC_NA
);
126 maap_tree
= proto_item_add_subtree(maap_item
, ett_maap
);
128 proto_tree_add_item(maap_tree
, hf_maap_message_type
, tvb
, MAAP_MSG_TYPE_OFFSET
, 1, ENC_BIG_ENDIAN
);
129 proto_tree_add_item(maap_tree
, hf_maap_version
, tvb
, MAAP_VERSION_OFFSET
, 1, ENC_BIG_ENDIAN
);
130 proto_tree_add_item(maap_tree
, hf_maap_data_length
, tvb
, MAAP_VERSION_OFFSET
, 2, ENC_BIG_ENDIAN
);
131 proto_tree_add_item(maap_tree
, hf_maap_stream_id
, tvb
, MAAP_STREAM_ID_OFFSET
, 8, ENC_BIG_ENDIAN
);
132 proto_tree_add_item(maap_tree
, hf_maap_req_start_addr
, tvb
, MAAP_REQ_START_ADDR_OFFSET
, 6, ENC_NA
);
133 proto_tree_add_item(maap_tree
, hf_maap_req_count
, tvb
, MAAP_REQ_COUNT_OFFSET
, 2, ENC_BIG_ENDIAN
);
134 proto_tree_add_item(maap_tree
, hf_maap_conflict_start_addr
, tvb
, MAAP_CONFLICT_START_ADDR_OFFSET
, 6, ENC_NA
);
135 proto_tree_add_item(maap_tree
, hf_maap_conflict_count
, tvb
, MAAP_CONFLICT_COUNT_OFFSET
, 2, ENC_BIG_ENDIAN
);
137 } /* end dissect_maap() */
139 /* Register the protocol with Wireshark */
141 proto_register_maap(void)
143 static hf_register_info hf
[] = {
144 { &hf_maap_message_type
,
145 { "Message Type", "maap.message_type",
147 VALS(maap_msg_type_vals
), MAAP_MSG_TYPE_MASK
,
151 { "MAAP Version", "maap.version",
153 NULL
, MAAP_VERSION_MASK
,
156 { &hf_maap_data_length
,
157 { "Data Length", "maap.data_length",
159 NULL
, MAAP_DATA_LEN_MASK
,
162 { &hf_maap_stream_id
,
163 { "Stream ID", "maap.stream_id",
168 { &hf_maap_req_start_addr
,
169 { "Requested Start Address", "maap.req_start_addr",
174 { &hf_maap_req_count
,
175 { "Request Count", "maap.req_count",
180 { &hf_maap_conflict_start_addr
,
181 { "Conflict Start Address", "maap.conflict_start_addr",
186 { &hf_maap_conflict_count
,
187 { "Conflict Count", "maap.conflict_count",
191 }; /* end of static hf_register_info hf[] = */
193 /* Setup protocol subtree array */
194 static gint
*ett
[] = { &ett_maap
};
196 /* Register the protocol name and description */
197 proto_maap
= proto_register_protocol (
198 "IEEE 1722 MAAP Protocol", /* name */
199 "MAAP", /* short name */
203 /* Required function calls to register the header fields and subtrees used */
204 proto_register_field_array(proto_maap
, hf
, array_length(hf
));
205 proto_register_subtree_array(ett
, array_length(ett
));
207 } /* end proto_register_maap() */
210 proto_reg_handoff_maap(void)
212 dissector_handle_t maap_handle
;
214 maap_handle
= create_dissector_handle(dissect_maap
, proto_maap
);
215 dissector_add_uint("ieee1722.subtype", 0x7E, maap_handle
);