MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / plugins / docsis / packet-dpvrsp.c
blobd2af746a9f10966999516b30aa26028578eb87bd
1 /* packet-dpvrsp.c
2 * Routines for DOCSIS 3.0 DOCSIS Path Verify 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_dpvrsp = -1;
32 static int hf_docsis_dpvrsp_tranid = -1;
33 static int hf_docsis_dpvrsp_dschan = -1;
34 static int hf_docsis_dpvrsp_flags = -1;
35 static int hf_docsis_dpvrsp_us_sf = -1;
36 static int hf_docsis_dpvrsp_n = -1;
37 static int hf_docsis_dpvrsp_start = -1;
38 static int hf_docsis_dpvrsp_end = -1;
39 static int hf_docsis_dpvrsp_ts_start = -1;
40 static int hf_docsis_dpvrsp_ts_end = -1;
42 /* Initialize the subtree pointers */
43 static gint ett_docsis_dpvrsp = -1;
45 /* Code to actually dissect the packets */
46 static void
47 dissect_dpvrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
49 proto_item *it;
50 proto_tree *dpvrsp_tree = NULL;
51 guint16 transid;
52 guint8 dschan;
54 transid = tvb_get_ntohs (tvb, 0);
55 dschan = tvb_get_guint8 (tvb, 2);
57 col_add_fstr (pinfo->cinfo, COL_INFO,
58 "DOCSIS Path Verify Response: Transaction-Id = %u DS-Ch %d",
59 transid, dschan);
61 if (tree)
63 it =
64 proto_tree_add_protocol_format (tree, proto_docsis_dpvrsp, tvb, 0, -1,
65 "DPV Response");
66 dpvrsp_tree = proto_item_add_subtree (it, ett_docsis_dpvrsp);
67 proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_tranid, tvb,
68 0, 2, ENC_BIG_ENDIAN);
69 proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_dschan, tvb,
70 2, 1, ENC_BIG_ENDIAN);
71 proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_flags, tvb,
72 3, 1, ENC_BIG_ENDIAN);
73 proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_us_sf, tvb,
74 4, 4, ENC_BIG_ENDIAN);
75 proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_n, tvb,
76 8, 2, ENC_BIG_ENDIAN);
77 proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_start, tvb,
78 10, 1, ENC_BIG_ENDIAN);
79 proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_end, tvb,
80 11, 1, ENC_BIG_ENDIAN);
81 proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_ts_start, tvb,
82 12, 4, ENC_BIG_ENDIAN);
83 proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_ts_end, tvb,
84 16, 4, ENC_BIG_ENDIAN);
91 /* Register the protocol with Wireshark */
93 /* this format is require because a script is used to build the C function
94 that calls all the protocol registration.
97 void
98 proto_register_docsis_dpvrsp (void)
101 /* Setup list of header fields See Section 1.6.1 for details*/
102 static hf_register_info hf[] = {
103 {&hf_docsis_dpvrsp_tranid,
104 {"Transaction Id", "docsis_dpvrsp.tranid",
105 FT_UINT16, BASE_DEC, NULL, 0x0,
106 NULL, HFILL}
108 {&hf_docsis_dpvrsp_dschan,
109 {"Downstream Channel ID", "docsis_dpvrsp.dschan",
110 FT_UINT8, BASE_DEC, NULL, 0x0,
111 NULL, HFILL}
113 {&hf_docsis_dpvrsp_flags,
114 {"Flags", "docsis_dpvrsp.flags",
115 FT_UINT8, BASE_DEC, NULL, 0x0,
116 NULL, HFILL}
118 {&hf_docsis_dpvrsp_us_sf,
119 {"Upstream Service Flow ID", "docsis_dpvrsp.us_sf",
120 FT_UINT32, BASE_DEC, NULL, 0x0,
121 NULL, HFILL}
123 {&hf_docsis_dpvrsp_n,
124 {"N (Measurement avaraging factor)", "docsis_dpvrsp.n",
125 FT_UINT16, BASE_DEC, NULL, 0x0,
126 NULL, HFILL}
128 {&hf_docsis_dpvrsp_start,
129 {"Start Reference Point", "docsis_dpvrsp.start",
130 FT_UINT8, BASE_DEC, NULL, 0x0,
131 NULL, HFILL}
133 {&hf_docsis_dpvrsp_end,
134 {"End Reference Point", "docsis_dpvrsp.end",
135 FT_UINT8, BASE_DEC, NULL, 0x0,
136 NULL, HFILL}
138 {&hf_docsis_dpvrsp_ts_start,
139 {"Timestamp Start", "docsis_dpvrsp.ts_start",
140 FT_UINT32, BASE_DEC, NULL, 0x0,
141 NULL, HFILL}
143 {&hf_docsis_dpvrsp_ts_end,
144 {"Timestamp End", "docsis_dpvrsp.ts_end",
145 FT_UINT32, BASE_DEC, NULL, 0x0,
146 NULL, HFILL}
150 /* Setup protocol subtree array */
151 static gint *ett[] = {
152 &ett_docsis_dpvrsp,
155 /* Register the protocol name and description */
156 proto_docsis_dpvrsp =
157 proto_register_protocol ("DOCSIS Path Verify Response",
158 "DOCSIS DPV-RSP", "docsis_dpvrsp");
160 /* Required function calls to register the header fields and subtrees used */
161 proto_register_field_array (proto_docsis_dpvrsp, hf, array_length (hf));
162 proto_register_subtree_array (ett, array_length (ett));
164 register_dissector ("docsis_dpvrsp", dissect_dpvrsp, proto_docsis_dpvrsp);
168 /* If this dissector uses sub-dissector registration add a registration routine.
169 This format is required because a script is used to find these routines and
170 create the code that calls these routines.
172 void
173 proto_reg_handoff_docsis_dpvrsp (void)
175 dissector_handle_t docsis_dpvrsp_handle;
177 docsis_dpvrsp_handle = find_dissector ("docsis_dpvrsp");
178 dissector_add_uint ("docsis_mgmt", 0x28, docsis_dpvrsp_handle);