MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / plugins / docsis / packet-dbcrsp.c
blobf40c2dac542f2c12a39ce810fc001aa172f50530
1 /* packet-dbcrsp.c
2 * Routines for DOCSIS 3.0 Dynamic Bonding Change Response Message dissection.
3 * Copyright 2010, Guido Reismueller <g.reismueller[AT]avm.de>
5 * $Id$
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.
26 #include "config.h"
28 #include <epan/packet.h>
30 extern value_string docsis_conf_code[];
32 /* Initialize the protocol and registered fields */
33 static int proto_docsis_dbcrsp = -1;
34 static int hf_docsis_dbcrsp_tranid = -1;
35 static int hf_docsis_dbcrsp_conf_code = -1;
36 static dissector_handle_t docsis_tlv_handle;
38 /* Initialize the subtree pointers */
39 static gint ett_docsis_dbcrsp = -1;
41 /* Code to actually dissect the packets */
42 static void
43 dissect_dbcrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
45 proto_item *dbcrsp_item;
46 proto_tree *dbcrsp_tree = NULL;
47 guint16 transid;
48 guint8 confcode;
49 tvbuff_t *next_tvb;
51 transid = tvb_get_ntohs (tvb, 0);
52 confcode = tvb_get_guint8 (tvb, 2);
54 col_add_fstr (pinfo->cinfo, COL_INFO,
55 "Dynamic Bonding Change Response: Tran-Id = %u (%s)", transid,
56 val_to_str (confcode, docsis_conf_code, "%d"));
58 if (tree)
60 dbcrsp_item = proto_tree_add_protocol_format (tree, proto_docsis_dbcrsp,
61 tvb, 0, -1,
62 "Dynamic Bonding Change Response");
63 dbcrsp_tree = proto_item_add_subtree (dbcrsp_item, ett_docsis_dbcrsp);
64 proto_tree_add_item (dbcrsp_tree, hf_docsis_dbcrsp_tranid,
65 tvb, 0, 2, ENC_BIG_ENDIAN);
66 proto_tree_add_item( dbcrsp_tree, hf_docsis_dbcrsp_conf_code,
67 tvb, 2, 1, ENC_BIG_ENDIAN );
69 /* Call Dissector for Appendix C TLV's */
70 next_tvb = tvb_new_subset_remaining (tvb, 3);
71 call_dissector (docsis_tlv_handle, next_tvb, pinfo, dbcrsp_tree);
74 /* Register the protocol with Wireshark */
77 * this format is required because a script is used to build the C function
78 * that calls all the protocol registration.
80 void
81 proto_register_docsis_dbcrsp (void)
83 /* Setup list of header fields See Section 1.6.1 for details*/
84 static hf_register_info hf[] = {
85 {&hf_docsis_dbcrsp_tranid,
86 {"Transaction Id", "docsis_dbcrsp.tranid",
87 FT_UINT16, BASE_DEC, NULL, 0x0,
88 NULL, HFILL}
90 {&hf_docsis_dbcrsp_conf_code,
91 {"Confirmation Code", "docsis_dbcrsp.conf_code",
92 FT_UINT8, BASE_DEC, VALS (docsis_conf_code), 0x0,
93 NULL, HFILL}
97 /* Setup protocol subtree array */
98 static gint *ett[] = {
99 &ett_docsis_dbcrsp,
102 /* Register the protocol name and description */
103 proto_docsis_dbcrsp = proto_register_protocol ("DOCSIS Dynamic Bonding Change Response",
104 "DOCSIS DBC-RSP",
105 "docsis_dbcrsp");
107 /* Required function calls to register the header fields and subtrees used */
108 proto_register_field_array (proto_docsis_dbcrsp, hf, array_length (hf));
109 proto_register_subtree_array (ett, array_length (ett));
111 register_dissector ("docsis_dbcrsp", dissect_dbcrsp, proto_docsis_dbcrsp);
115 /* If this dissector uses sub-dissector registration add a registration routine.
116 This format is required because a script is used to find these routines and
117 create the code that calls these routines.
119 void
120 proto_reg_handoff_docsis_dbcrsp (void)
122 dissector_handle_t docsis_dbcrsp_handle;
124 docsis_dbcrsp_handle = find_dissector ("docsis_dbcrsp");
125 docsis_tlv_handle = find_dissector ("docsis_tlv");
126 dissector_add_uint ("docsis_mgmt", 0x25, docsis_dbcrsp_handle);