2 * Routines for docsis Mac Management Header dissection
3 * Copyright 2002, Anand V. Narwani <anarwani@cisco.com>
5 * Ethereal - Network traffic analyzer
6 * By Gerald Combs <gerald@ethereal.com>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #include "plugins/plugin_api.h"
30 #include "plugins/plugin_api_defs.h"
31 #include "moduleinfo.h"
39 #include <epan/packet.h>
50 #define MGT_TRI_TCD 10
51 #define MGT_TRI_TSI 11
52 #define MGT_BPKM_REQ 12
53 #define MGT_BPKM_RSP 13
54 #define MGT_REG_ACK 14
55 #define MGT_DSA_REQ 15
56 #define MGT_DSA_RSP 16
57 #define MGT_DSA_ACK 17
58 #define MGT_DSC_REQ 18
59 #define MGT_DSC_RSP 19
60 #define MGT_DSC_ACK 20
61 #define MGT_DSD_REQ 21
62 #define MGT_DSD_RSP 22
63 #define MGT_DCC_REQ 23
64 #define MGT_DCC_RSP 24
65 #define MGT_DCC_ACK 25
66 #define MGT_DCI_REQ 26
67 #define MGT_DCI_RSP 27
71 /* Initialize the protocol and registered fields */
72 static int proto_docsis_mgmt = -1;
73 static int hf_docsis_mgt_hdr = -1;
74 static int hf_docsis_mgt_dst_addr = -1;
75 static int hf_docsis_mgt_src_addr = -1;
76 static int hf_docsis_mgt_msg_len = -1;
77 static int hf_docsis_mgt_dsap = -1;
78 static int hf_docsis_mgt_ssap = -1;
79 static int hf_docsis_mgt_control = -1;
80 static int hf_docsis_mgt_version = -1;
81 static int hf_docsis_mgt_type = -1;
82 static int hf_docsis_mgt_rsvd = -1;
84 static dissector_table_t docsis_mgmt_dissector_table;
85 static dissector_handle_t data_handle;
87 /* Initialize the subtree pointers */
88 static gint ett_docsis_mgmt = -1;
89 static gint ett_mgmt_pay = -1;
92 static const value_string mgmt_type_vals[] = {
93 {MGT_SYNC, "Timing Synchronisation"},
94 {MGT_UCD, "Upstream Channel Descriptor"},
95 {MGT_MAP, "Upstream Bandwidth Allocation"},
96 {MGT_RNG_REQ, "Ranging Request"},
97 {MGT_RNG_RSP, "Ranging Response"},
98 {MGT_REG_REQ, "Registration Request"},
99 {MGT_REG_RSP, "Registration Response"},
100 {MGT_UCC_REQ, "Upstream Channel Change Request"},
101 {MGT_UCC_RSP, "Upstream Channel Change Response"},
102 {MGT_TRI_TCD, "Telephony Channel Descriptor"},
103 {MGT_TRI_TSI, "Termination System Information"},
104 {MGT_BPKM_REQ, "Privacy Key Management Request"},
105 {MGT_BPKM_RSP, "Privacy Key Management Response"},
106 {MGT_REG_ACK, "Registration Acknowledge"},
107 {MGT_DSA_REQ, "Dynamic Service Addition Request"},
108 {MGT_DSA_RSP, "Dynamic Service Addition Response"},
109 {MGT_DSA_ACK, "Dynamic Service Addition Acknowledge"},
110 {MGT_DSC_REQ, "Dynamic Service Change Request"},
111 {MGT_DSC_RSP, "Dynamic Service Change Response"},
112 {MGT_DSC_ACK, "Dynamic Service Change Acknowledge"},
113 {MGT_DSD_REQ, "Dynamic Service Delete Request"},
114 {MGT_DSD_RSP, "Dynamic Service Delete Response"},
115 {MGT_DCC_REQ, "Dynamic Channel Change Request"},
116 {MGT_DCC_RSP, "Dynamic Channel Change Response"},
117 {MGT_DCC_ACK, "Dynamic Channel Change Acknowledge"},
118 {MGT_DCI_REQ, "Device Class Identification Request"},
119 {MGT_DCI_RSP, "Device Class Identification Response"},
120 {MGT_UP_DIS, "Upstream Channel Disable"},
124 /* Code to actually dissect the packets */
126 dissect_macmgmt (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
129 const guint8 *src, *dst;
131 proto_item *mgt_hdr_it;
132 proto_tree *mgt_hdr_tree;
133 tvbuff_t *payload_tvb;
135 if (check_col (pinfo->cinfo, COL_PROTOCOL))
136 col_set_str (pinfo->cinfo, COL_PROTOCOL, "DOCSIS MGMT");
138 if (check_col (pinfo->cinfo, COL_INFO))
139 col_clear (pinfo->cinfo, COL_INFO);
142 src = tvb_get_ptr (tvb, 6, 6);
143 dst = tvb_get_ptr (tvb, 0, 6);
144 SET_ADDRESS (&pinfo->dl_src, AT_ETHER, 6, src);
145 SET_ADDRESS (&pinfo->src, AT_ETHER, 6, src);
146 SET_ADDRESS (&pinfo->dl_dst, AT_ETHER, 6, dst);
147 SET_ADDRESS (&pinfo->dst, AT_ETHER, 6, dst);
152 proto_tree_add_protocol_format (tree, proto_docsis_mgmt, tvb, 0, 20,
154 mgt_hdr_tree = proto_item_add_subtree (mgt_hdr_it, ett_docsis_mgmt);
155 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_dst_addr, tvb, 0, 6,
157 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_src_addr, tvb, 6, 6,
159 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_msg_len, tvb, 12, 2,
161 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_dsap, tvb, 14, 1,
163 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_ssap, tvb, 15, 1,
165 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_control, tvb, 16, 1,
167 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_version, tvb, 17, 1,
169 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_type, tvb, 18, 1,
171 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_rsvd, tvb, 19, 1,
175 /* Code to Call subdissector */
176 /* sub-dissectors are based on the type field */
177 type = tvb_get_guint8 (tvb, 18);
178 msg_len = tvb_get_ntohs (tvb, 12);
179 payload_tvb = tvb_new_subset (tvb, 20, msg_len - 6, msg_len - 6);
181 if (dissector_try_port
182 (docsis_mgmt_dissector_table, type, payload_tvb, pinfo, tree))
185 call_dissector (data_handle, payload_tvb, pinfo, tree);
191 /* Register the protocol with Ethereal */
193 /* this format is require because a script is used to build the C function
194 that calls all the protocol registration.
199 proto_register_docsis_mgmt (void)
202 /* Setup list of header fields See Section 1.6.1 for details*/
203 static hf_register_info hf[] = {
205 {"Mac Management Header", "docsis.mgmt",
206 FT_BYTES, BASE_HEX, NULL, 0x0,
207 "Mac Management Header", HFILL}
209 {&hf_docsis_mgt_dst_addr,
210 {"Destination Address", "docsis.mgmt.dst",
211 FT_ETHER, BASE_HEX, NULL, 0x0,
212 "Destination Address", HFILL}
214 {&hf_docsis_mgt_src_addr,
215 {"Source Address", "docsis.mgmt.src",
216 FT_ETHER, BASE_HEX, NULL, 0x0,
217 "Source Address", HFILL}
219 {&hf_docsis_mgt_msg_len,
220 {"Message Length - DSAP to End (Bytes)", "docsis.mgmt.msglen",
221 FT_UINT16, BASE_DEC, NULL, 0x0,
222 "Message Length", HFILL}
224 {&hf_docsis_mgt_dsap,
225 {"DSAP [0x00]", "docsis.mgmt.dsap",
226 FT_UINT8, BASE_HEX, NULL, 0x0,
227 "Destination SAP", HFILL}
229 {&hf_docsis_mgt_ssap,
230 {"SSAP [0x00]", "docsis.mgmt.ssap",
231 FT_UINT8, BASE_HEX, NULL, 0x0,
234 {&hf_docsis_mgt_control,
235 {"Control [0x03]", "docsis.mgmt.control",
236 FT_UINT8, BASE_HEX, NULL, 0x0,
239 {&hf_docsis_mgt_version,
240 {"Version", "docsis.mgmt.version",
241 FT_UINT8, BASE_DEC, NULL, 0x0,
244 {&hf_docsis_mgt_type,
245 {"Type", "docsis.mgmt.type",
246 FT_UINT8, BASE_DEC, VALS (mgmt_type_vals), 0x0,
249 {&hf_docsis_mgt_rsvd,
250 {"Reserved [0x00]", "docsis.mgmt.rsvd",
251 FT_UINT8, BASE_DEC, NULL, 0x0,
257 /* Setup protocol subtree array */
258 static gint *ett[] = {
263 docsis_mgmt_dissector_table = register_dissector_table ("docsis_mgmt",
264 "DOCSIS Mac Management",
268 /* Register the protocol name and description */
269 proto_docsis_mgmt = proto_register_protocol ("DOCSIS Mac Management",
273 /* Required function calls to register the header fields and subtrees used */
274 proto_register_field_array (proto_docsis_mgmt, hf, array_length (hf));
275 proto_register_subtree_array (ett, array_length (ett));
277 register_dissector ("docsis_mgmt", dissect_macmgmt, proto_docsis_mgmt);
281 /* If this dissector uses sub-dissector registration add a registration routine.
282 This format is required because a script is used to find these routines and
283 create the code that calls these routines.
286 proto_reg_handoff_docsis_mgmt (void)
288 dissector_handle_t docsis_mgmt_handle;
290 docsis_mgmt_handle = find_dissector ("docsis_mgmt");
291 data_handle = find_dissector ("data");
293 dissector_add ("docsis", 0x03, docsis_mgmt_handle);