2 * Routines for docsis Mac Management Header dissection
3 * Copyright 2002, Anand V. Narwani <anand[AT]narwani.org>
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #include "moduleinfo.h"
38 #include <epan/packet.h>
49 #define MGT_TRI_TCD 10
50 #define MGT_TRI_TSI 11
51 #define MGT_BPKM_REQ 12
52 #define MGT_BPKM_RSP 13
53 #define MGT_REG_ACK 14
54 #define MGT_DSA_REQ 15
55 #define MGT_DSA_RSP 16
56 #define MGT_DSA_ACK 17
57 #define MGT_DSC_REQ 18
58 #define MGT_DSC_RSP 19
59 #define MGT_DSC_ACK 20
60 #define MGT_DSD_REQ 21
61 #define MGT_DSD_RSP 22
62 #define MGT_DCC_REQ 23
63 #define MGT_DCC_RSP 24
64 #define MGT_DCC_ACK 25
65 #define MGT_DCI_REQ 26
66 #define MGT_DCI_RSP 27
68 #define MGT_TYPE29UCD 29
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_TYPE29UCD, "Upstream Channel Descriptor Type 29"},
96 {MGT_MAP, "Upstream Bandwidth Allocation"},
97 {MGT_RNG_REQ, "Ranging Request"},
98 {MGT_RNG_RSP, "Ranging Response"},
99 {MGT_REG_REQ, "Registration Request"},
100 {MGT_REG_RSP, "Registration Response"},
101 {MGT_UCC_REQ, "Upstream Channel Change Request"},
102 {MGT_UCC_RSP, "Upstream Channel Change Response"},
103 {MGT_TRI_TCD, "Telephony Channel Descriptor"},
104 {MGT_TRI_TSI, "Termination System Information"},
105 {MGT_BPKM_REQ, "Privacy Key Management Request"},
106 {MGT_BPKM_RSP, "Privacy Key Management Response"},
107 {MGT_REG_ACK, "Registration Acknowledge"},
108 {MGT_DSA_REQ, "Dynamic Service Addition Request"},
109 {MGT_DSA_RSP, "Dynamic Service Addition Response"},
110 {MGT_DSA_ACK, "Dynamic Service Addition Acknowledge"},
111 {MGT_DSC_REQ, "Dynamic Service Change Request"},
112 {MGT_DSC_RSP, "Dynamic Service Change Response"},
113 {MGT_DSC_ACK, "Dynamic Service Change Acknowledge"},
114 {MGT_DSD_REQ, "Dynamic Service Delete Request"},
115 {MGT_DSD_RSP, "Dynamic Service Delete Response"},
116 {MGT_DCC_REQ, "Dynamic Channel Change Request"},
117 {MGT_DCC_RSP, "Dynamic Channel Change Response"},
118 {MGT_DCC_ACK, "Dynamic Channel Change Acknowledge"},
119 {MGT_DCI_REQ, "Device Class Identification Request"},
120 {MGT_DCI_RSP, "Device Class Identification Response"},
121 {MGT_UP_DIS, "Upstream Channel Disable"},
125 /* Code to actually dissect the packets */
127 dissect_macmgmt (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
130 const guint8 *src, *dst;
132 proto_item *mgt_hdr_it;
133 proto_tree *mgt_hdr_tree;
134 tvbuff_t *payload_tvb;
136 if (check_col (pinfo->cinfo, COL_PROTOCOL))
137 col_set_str (pinfo->cinfo, COL_PROTOCOL, "DOCSIS MGMT");
139 if (check_col (pinfo->cinfo, COL_INFO))
140 col_clear (pinfo->cinfo, COL_INFO);
143 src = tvb_get_ptr (tvb, 6, 6);
144 dst = tvb_get_ptr (tvb, 0, 6);
145 SET_ADDRESS (&pinfo->dl_src, AT_ETHER, 6, src);
146 SET_ADDRESS (&pinfo->src, AT_ETHER, 6, src);
147 SET_ADDRESS (&pinfo->dl_dst, AT_ETHER, 6, dst);
148 SET_ADDRESS (&pinfo->dst, AT_ETHER, 6, dst);
153 proto_tree_add_protocol_format (tree, proto_docsis_mgmt, tvb, 0, 20,
155 mgt_hdr_tree = proto_item_add_subtree (mgt_hdr_it, ett_docsis_mgmt);
156 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_dst_addr, tvb, 0, 6,
158 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_src_addr, tvb, 6, 6,
160 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_msg_len, tvb, 12, 2,
162 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_dsap, tvb, 14, 1,
164 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_ssap, tvb, 15, 1,
166 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_control, tvb, 16, 1,
168 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_version, tvb, 17, 1,
170 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_type, tvb, 18, 1,
172 proto_tree_add_item (mgt_hdr_tree, hf_docsis_mgt_rsvd, tvb, 19, 1,
176 /* Code to Call subdissector */
177 /* sub-dissectors are based on the type field */
178 type = tvb_get_guint8 (tvb, 18);
179 msg_len = tvb_get_ntohs (tvb, 12);
180 payload_tvb = tvb_new_subset (tvb, 20, msg_len - 6, msg_len - 6);
182 if (dissector_try_port
183 (docsis_mgmt_dissector_table, type, payload_tvb, pinfo, tree))
186 call_dissector (data_handle, payload_tvb, pinfo, tree);
192 /* Register the protocol with Wireshark */
194 /* this format is require because a script is used to build the C function
195 that calls all the protocol registration.
200 proto_register_docsis_mgmt (void)
203 /* Setup list of header fields See Section 1.6.1 for details*/
204 static hf_register_info hf[] = {
206 {"Mac Management Header", "docsis.mgmt",
207 FT_BYTES, BASE_HEX, NULL, 0x0,
208 "Mac Management Header", HFILL}
210 {&hf_docsis_mgt_dst_addr,
211 {"Destination Address", "docsis.mgmt.dst",
212 FT_ETHER, BASE_HEX, NULL, 0x0,
213 "Destination Address", HFILL}
215 {&hf_docsis_mgt_src_addr,
216 {"Source Address", "docsis.mgmt.src",
217 FT_ETHER, BASE_HEX, NULL, 0x0,
218 "Source Address", HFILL}
220 {&hf_docsis_mgt_msg_len,
221 {"Message Length - DSAP to End (Bytes)", "docsis.mgmt.msglen",
222 FT_UINT16, BASE_DEC, NULL, 0x0,
223 "Message Length", HFILL}
225 {&hf_docsis_mgt_dsap,
226 {"DSAP [0x00]", "docsis.mgmt.dsap",
227 FT_UINT8, BASE_HEX, NULL, 0x0,
228 "Destination SAP", HFILL}
230 {&hf_docsis_mgt_ssap,
231 {"SSAP [0x00]", "docsis.mgmt.ssap",
232 FT_UINT8, BASE_HEX, NULL, 0x0,
235 {&hf_docsis_mgt_control,
236 {"Control [0x03]", "docsis.mgmt.control",
237 FT_UINT8, BASE_HEX, NULL, 0x0,
240 {&hf_docsis_mgt_version,
241 {"Version", "docsis.mgmt.version",
242 FT_UINT8, BASE_DEC, NULL, 0x0,
245 {&hf_docsis_mgt_type,
246 {"Type", "docsis.mgmt.type",
247 FT_UINT8, BASE_DEC, VALS (mgmt_type_vals), 0x0,
250 {&hf_docsis_mgt_rsvd,
251 {"Reserved [0x00]", "docsis.mgmt.rsvd",
252 FT_UINT8, BASE_DEC, NULL, 0x0,
258 /* Setup protocol subtree array */
259 static gint *ett[] = {
264 docsis_mgmt_dissector_table = register_dissector_table ("docsis_mgmt",
265 "DOCSIS Mac Management",
269 /* Register the protocol name and description */
270 proto_docsis_mgmt = proto_register_protocol ("DOCSIS Mac Management",
274 /* Required function calls to register the header fields and subtrees used */
275 proto_register_field_array (proto_docsis_mgmt, hf, array_length (hf));
276 proto_register_subtree_array (ett, array_length (ett));
278 register_dissector ("docsis_mgmt", dissect_macmgmt, proto_docsis_mgmt);
282 /* If this dissector uses sub-dissector registration add a registration routine.
283 This format is required because a script is used to find these routines and
284 create the code that calls these routines.
287 proto_reg_handoff_docsis_mgmt (void)
289 dissector_handle_t docsis_mgmt_handle;
291 docsis_mgmt_handle = find_dissector ("docsis_mgmt");
292 data_handle = find_dissector ("data");
294 dissector_add ("docsis", 0x03, docsis_mgmt_handle);