Revert "In get_unicode_or_ascii_string(), check if the length is odd/even, not the...
[wireshark-wip.git] / plugins / docsis / packet-dsdrsp.c
blob4e71ec627ebcff3412f40f41a302c19205c15357
1 /* packet-dsdrsp.c
2 * Routines for Dynamic Service Delete Response dissection
3 * Copyright 2002, Anand V. Narwani <anand[AT]narwani.org>
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_dsdrsp = -1;
32 static int hf_docsis_dsdrsp_tranid = -1;
33 static int hf_docsis_dsdrsp_confcode = -1;
34 static int hf_docsis_dsdrsp_rsvd = -1;
36 extern value_string docsis_conf_code[];
38 /* Initialize the subtree pointers */
39 static gint ett_docsis_dsdrsp = -1;
41 /* Code to actually dissect the packets */
42 static void
43 dissect_dsdrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
46 proto_item *it;
47 proto_tree *dsdrsp_tree;
48 guint16 tranid;
49 guint8 confcode;
51 tranid = tvb_get_ntohs (tvb, 0);
52 confcode = tvb_get_guint8 (tvb, 2);
54 col_add_fstr (pinfo->cinfo, COL_INFO,
55 "Dynamic Service Delete Response Tran id = %u (%s)",
56 tranid, val_to_str (confcode, docsis_conf_code, "%d"));
58 if (tree)
60 it =
61 proto_tree_add_protocol_format (tree, proto_docsis_dsdrsp, tvb, 0, -1,
62 "DSD Response");
63 dsdrsp_tree = proto_item_add_subtree (it, ett_docsis_dsdrsp);
64 proto_tree_add_item (dsdrsp_tree, hf_docsis_dsdrsp_tranid, tvb, 0, 2,
65 ENC_BIG_ENDIAN);
66 proto_tree_add_item (dsdrsp_tree, hf_docsis_dsdrsp_confcode, tvb, 2, 1,
67 ENC_BIG_ENDIAN);
68 proto_tree_add_item (dsdrsp_tree, hf_docsis_dsdrsp_rsvd, tvb, 3, 1,
69 ENC_BIG_ENDIAN);
77 /* Register the protocol with Wireshark */
79 /* this format is require because a script is used to build the C function
80 that calls all the protocol registration.
84 void
85 proto_register_docsis_dsdrsp (void)
88 /* Setup list of header fields See Section 1.6.1 for details*/
89 static hf_register_info hf[] = {
90 {&hf_docsis_dsdrsp_tranid,
91 {"Transaction Id", "docsis_dsdrsp.tranid",
92 FT_UINT16, BASE_DEC, NULL, 0x0,
93 NULL, HFILL}
95 {&hf_docsis_dsdrsp_confcode,
96 {"Confirmation Code", "docsis_dsdrsp.confcode",
97 FT_UINT8, BASE_DEC, VALS (docsis_conf_code), 0x0,
98 NULL, HFILL}
100 {&hf_docsis_dsdrsp_rsvd,
101 {"Reserved", "docsis_dsdrsp.rsvd",
102 FT_UINT8, BASE_DEC, NULL, 0x0,
103 NULL, HFILL}
107 /* Setup protocol subtree array */
108 static gint *ett[] = {
109 &ett_docsis_dsdrsp,
112 /* Register the protocol name and description */
113 proto_docsis_dsdrsp =
114 proto_register_protocol ("DOCSIS Dynamic Service Delete Response",
115 "DOCSIS DSD-RSP", "docsis_dsdrsp");
117 /* Required function calls to register the header fields and subtrees used */
118 proto_register_field_array (proto_docsis_dsdrsp, hf, array_length (hf));
119 proto_register_subtree_array (ett, array_length (ett));
121 register_dissector ("docsis_dsdrsp", dissect_dsdrsp, proto_docsis_dsdrsp);
125 /* If this dissector uses sub-dissector registration add a registration routine.
126 This format is required because a script is used to find these routines and
127 create the code that calls these routines.
129 void
130 proto_reg_handoff_docsis_dsdrsp (void)
132 dissector_handle_t docsis_dsdrsp_handle;
134 docsis_dsdrsp_handle = find_dissector ("docsis_dsdrsp");
135 dissector_add_uint ("docsis_mgmt", 0x16, docsis_dsdrsp_handle);