Revert "In get_unicode_or_ascii_string(), check if the length is odd/even, not the...
[wireshark-wip.git] / plugins / docsis / packet-regreqmp.c
blobfc1692151788c322d02a2c1ffc6462f9855c92fa
1 /* packet-regreqmp.c
2 * $Id$
3 * Routines for REG-REQ-MP Message dissection
4 * Copyright 2007, Bruno Verstuyft <bruno.verstuyft@excentis.com>
6 * Based on packet-regreq.c (by Anand V. Narwani <anand[AT]narwani.org>)
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "config.h"
29 #include <epan/packet.h>
32 /* Initialize the protocol and registered fields */
33 static int proto_docsis_regreqmp = -1;
35 static int hf_docsis_regreqmp_sid = -1;
37 static int hf_docsis_regreqmp_number_of_fragments = -1;
38 static int hf_docsis_regreqmp_fragment_sequence_number = -1;
40 static dissector_handle_t docsis_tlv_handle;
44 /* Initialize the subtree pointers */
45 static gint ett_docsis_regreqmp = -1;
47 static void
48 dissect_regreqmp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
51 proto_item *it;
52 proto_tree *regreqmp_tree = NULL;
53 tvbuff_t *next_tvb;
55 col_set_str(pinfo->cinfo, COL_INFO, "REG-REQ-MP Message:");
57 if (tree)
59 it = proto_tree_add_protocol_format (tree, proto_docsis_regreqmp, tvb, 0, -1,"REG-REQ-MP Message");
60 regreqmp_tree = proto_item_add_subtree (it, ett_docsis_regreqmp);
62 proto_tree_add_item (regreqmp_tree, hf_docsis_regreqmp_sid, tvb, 0, 2, ENC_BIG_ENDIAN);
63 proto_tree_add_item (regreqmp_tree, hf_docsis_regreqmp_number_of_fragments, tvb, 2, 1, ENC_BIG_ENDIAN);
64 proto_tree_add_item (regreqmp_tree, hf_docsis_regreqmp_fragment_sequence_number, 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, regreqmp_tree);
75 /* Register the protocol with Wireshark */
77 /* this format is require because a script is used to build the C function
78 that calls all the protocol registration.
82 void
83 proto_register_docsis_regreqmp (void)
85 /* Setup list of header fields See Section 1.6.1 for details*/
86 static hf_register_info hf[] = {
87 {&hf_docsis_regreqmp_sid,
88 {"Sid", "docsis_regreqmp.sid",
89 FT_UINT16, BASE_DEC, NULL, 0x0,
90 "Reg-Req-Mp Sid", HFILL}
92 {&hf_docsis_regreqmp_number_of_fragments,
93 {"Number of Fragments", "docsis_regreqmp.number_of_fragments",
94 FT_UINT8, BASE_DEC, NULL, 0x0,
95 "Reg-Req-Mp Number of Fragments", HFILL}
97 {&hf_docsis_regreqmp_fragment_sequence_number,
98 {"Fragment Sequence Number", "docsis_regreqmp.fragment_sequence_number",
99 FT_UINT8, BASE_DEC, NULL, 0x0,
100 "Reg-Req-Mp Fragment Sequence Number", HFILL}
104 /* Setup protocol subtree array */
105 static gint *ett[] = {
106 &ett_docsis_regreqmp,
109 /* Register the protocol name and description */
110 proto_docsis_regreqmp =
111 proto_register_protocol ("DOCSIS Registration Request Multipart",
112 "DOCSIS Reg-Req-Mp", "docsis_regreqmp");
114 /* Required function calls to register the header fields and subtrees used */
115 proto_register_field_array (proto_docsis_regreqmp, hf, array_length (hf));
116 proto_register_subtree_array (ett, array_length (ett));
118 register_dissector ("docsis_regreqmp", dissect_regreqmp, proto_docsis_regreqmp);
122 /* If this dissector uses sub-dissector registration add a registration routine.
123 This format is required because a script is used to find these routines and
124 create the code that calls these routines.
126 void
127 proto_reg_handoff_docsis_regreqmp (void)
129 dissector_handle_t docsis_regreqmp_handle;
131 docsis_tlv_handle = find_dissector ("docsis_tlv");
132 docsis_regreqmp_handle = find_dissector ("docsis_regreqmp");
133 dissector_add_uint ("docsis_mgmt", 44, docsis_regreqmp_handle);