match_strval > try_val_to_str
[wireshark-wip.git] / plugins / docsis / packet-dbcreq.c
blob89b65836cc2771024c4b71c0c18452e101c7d510
1 /* packet-dbcreq.c
2 * Routines for DOCSIS 3.0 Dynamic Bonding Change Request 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 /* Initialize the protocol and registered fields */
31 static int proto_docsis_dbcreq = -1;
32 static int hf_docsis_dbcreq_tranid = -1;
33 static int hf_docsis_dbcreq_number_of_fragments = -1;
34 static int hf_docsis_dbcreq_fragment_sequence_number = -1;
35 static dissector_handle_t docsis_tlv_handle;
37 /* Initialize the subtree pointers */
38 static gint ett_docsis_dbcreq = -1;
40 /* Code to actually dissect the packets */
41 static void
42 dissect_dbcreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
44 proto_item *dbcreq_item;
45 proto_tree *dbcreq_tree = NULL;
46 guint16 transid;
47 tvbuff_t *next_tvb;
49 transid = tvb_get_ntohs (tvb, 0);
51 col_add_fstr (pinfo->cinfo, COL_INFO,
52 "Dynamic Bonding Change Request: Tran-Id = %u", transid);
54 if (tree)
56 dbcreq_item = proto_tree_add_protocol_format (tree, proto_docsis_dbcreq,
57 tvb, 0, -1,
58 "Dynamic Bonding Change Request");
59 dbcreq_tree = proto_item_add_subtree (dbcreq_item, ett_docsis_dbcreq);
60 proto_tree_add_item (dbcreq_tree, hf_docsis_dbcreq_tranid,
61 tvb, 0, 2, ENC_BIG_ENDIAN);
62 proto_tree_add_item( dbcreq_tree, hf_docsis_dbcreq_number_of_fragments,
63 tvb, 2, 1, ENC_BIG_ENDIAN );
64 proto_tree_add_item( dbcreq_tree, hf_docsis_dbcreq_fragment_sequence_number ,
65 tvb, 3, 1, ENC_BIG_ENDIAN );
67 /* Call Dissector for Appendix C TLV's */
68 next_tvb = tvb_new_subset_remaining (tvb, 4);
69 call_dissector (docsis_tlv_handle, next_tvb, pinfo, dbcreq_tree);
72 /* Register the protocol with Wireshark */
75 * this format is required because a script is used to build the C function
76 * that calls all the protocol registration.
78 void
79 proto_register_docsis_dbcreq (void)
81 /* Setup list of header fields See Section 1.6.1 for details*/
82 static hf_register_info hf[] = {
83 {&hf_docsis_dbcreq_tranid,
84 {"Transaction Id", "docsis_dbcreq.tranid",
85 FT_UINT16, BASE_DEC, NULL, 0x0,
86 NULL, HFILL}
88 {&hf_docsis_dbcreq_number_of_fragments,
89 {"Number of Fragments", "docsis_dbcreq.number_of_fragments",
90 FT_UINT8, BASE_HEX_DEC, NULL, 0x0,
91 NULL, HFILL}
93 {&hf_docsis_dbcreq_fragment_sequence_number,
94 {"Fragment Seq No", "docsis_dbcreq.fragment_sequence_number",
95 FT_UINT8, BASE_HEX_DEC, NULL, 0x0,
96 NULL, HFILL}
100 /* Setup protocol subtree array */
101 static gint *ett[] = {
102 &ett_docsis_dbcreq,
105 /* Register the protocol name and description */
106 proto_docsis_dbcreq = proto_register_protocol ("DOCSIS Dynamic Bonding Change Request",
107 "DOCSIS DBC-REQ",
108 "docsis_dbcreq");
110 /* Required function calls to register the header fields and subtrees used */
111 proto_register_field_array (proto_docsis_dbcreq, hf, array_length (hf));
112 proto_register_subtree_array (ett, array_length (ett));
114 register_dissector ("docsis_dbcreq", dissect_dbcreq, proto_docsis_dbcreq);
118 /* If this dissector uses sub-dissector registration add a registration routine.
119 This format is required because a script is used to find these routines and
120 create the code that calls these routines.
122 void
123 proto_reg_handoff_docsis_dbcreq (void)
125 dissector_handle_t docsis_dbcreq_handle;
127 docsis_dbcreq_handle = find_dissector ("docsis_dbcreq");
128 docsis_tlv_handle = find_dissector ("docsis_tlv");
129 dissector_add_uint ("docsis_mgmt", 0x24, docsis_dbcreq_handle);