match_strval > try_val_to_str
[wireshark-wip.git] / plugins / docsis / packet-cmctrlrsp.c
blob60ec51ee873dba8f420dd9426f0db03db8da14fa
1 /* packet-cmctrlrsp.c
2 * Routines for DOCSIS 3.0 CM Control 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 #define RNGRSP_TIMING 1
31 #define RNGRSP_PWR_LEVEL_ADJ 2
32 #define RNGRSP_OFFSET_FREQ_ADJ 3
33 #define RNGRSP_TRANSMIT_EQ_ADJ 4
34 #define RNGRSP_RANGING_STATUS 5
35 #define RNGRSP_DOWN_FREQ_OVER 6
36 #define RNGRSP_UP_CHID_OVER 7
38 /* Initialize the protocol and registered fields */
39 static int proto_docsis_cmctrlrsp = -1;
40 static int hf_docsis_cmctrlrsp_tranid = -1;
41 static dissector_handle_t cmctrl_tlv_handle;
43 /* Initialize the subtree pointers */
44 static gint ett_docsis_cmctrlrsp = -1;
46 /* Code to actually dissect the packets */
47 static void
48 dissect_cmctrlrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
50 proto_item *it;
51 proto_tree *cmctrlrsp_tree = NULL;
52 guint16 transid;
53 tvbuff_t *next_tvb;
55 transid = tvb_get_ntohs (tvb, 0);
57 col_add_fstr (pinfo->cinfo, COL_INFO,
58 "CM Control Response: Transaction-Id = %u", transid);
60 if (tree)
62 it =
63 proto_tree_add_protocol_format (tree, proto_docsis_cmctrlrsp, tvb, 0, -1,
64 "CM Control Response");
65 cmctrlrsp_tree = proto_item_add_subtree (it, ett_docsis_cmctrlrsp);
66 proto_tree_add_item (cmctrlrsp_tree, hf_docsis_cmctrlrsp_tranid, tvb, 0, 2,
67 ENC_BIG_ENDIAN);
70 /* Call Dissector for Appendix C TLV's */
71 next_tvb = tvb_new_subset_remaining (tvb, 2);
72 call_dissector (cmctrl_tlv_handle, next_tvb, pinfo, cmctrlrsp_tree);
78 /* Register the protocol with Wireshark */
80 /* this format is require because a script is used to build the C function
81 that calls all the protocol registration.
84 void
85 proto_register_docsis_cmctrlrsp (void)
88 /* Setup list of header fields See Section 1.6.1 for details*/
89 static hf_register_info hf[] = {
90 {&hf_docsis_cmctrlrsp_tranid,
91 {"Transaction Id", "docsis_cmctrlrsp.tranid",
92 FT_UINT16, BASE_DEC, NULL, 0x0,
93 NULL, HFILL}
97 /* Setup protocol subtree array */
98 static gint *ett[] = {
99 &ett_docsis_cmctrlrsp,
102 /* Register the protocol name and description */
103 proto_docsis_cmctrlrsp =
104 proto_register_protocol ("DOCSIS CM Control Response",
105 "DOCSIS CM-CTRL-RSP", "docsis_cmctrlrsp");
107 /* Required function calls to register the header fields and subtrees used */
108 proto_register_field_array (proto_docsis_cmctrlrsp, hf, array_length (hf));
109 proto_register_subtree_array (ett, array_length (ett));
111 register_dissector ("docsis_cmctrlrsp", dissect_cmctrlrsp, proto_docsis_cmctrlrsp);
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_cmctrlrsp (void)
122 dissector_handle_t docsis_cmctrlrsp_handle;
124 docsis_cmctrlrsp_handle = find_dissector ("docsis_cmctrlrsp");
125 cmctrl_tlv_handle = find_dissector ("cmctrl_tlv");
126 dissector_add_uint ("docsis_mgmt", 0x2B, docsis_cmctrlrsp_handle);