Rename the routines that handle dissector tables with unsigned integer
[obnox/wireshark/wip.git] / plugins / docsis / packet-dpvrsp.c
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>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
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.
15  *
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.
20  *
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 #include <epan/packet.h>
31
32 /* Initialize the protocol and registered fields */
33 static int proto_docsis_dpvrsp = -1;
34 static int hf_docsis_dpvrsp_tranid = -1;
35 static int hf_docsis_dpvrsp_dschan = -1;
36 static int hf_docsis_dpvrsp_flags = -1;
37 static int hf_docsis_dpvrsp_us_sf = -1;
38 static int hf_docsis_dpvrsp_n = -1;
39 static int hf_docsis_dpvrsp_start = -1;
40 static int hf_docsis_dpvrsp_end = -1;
41 static int hf_docsis_dpvrsp_ts_start = -1;
42 static int hf_docsis_dpvrsp_ts_end = -1;
43
44 /* Initialize the subtree pointers */
45 static gint ett_docsis_dpvrsp = -1;
46
47 /* Code to actually dissect the packets */
48 static void
49 dissect_dpvrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
50 {
51   proto_item *it;
52   proto_tree *dpvrsp_tree = NULL;
53   guint16 transid;
54   guint8 dschan;
55
56   transid = tvb_get_ntohs (tvb, 0);
57   dschan = tvb_get_guint8 (tvb, 2);
58
59   col_clear (pinfo->cinfo, COL_INFO);
60   col_add_fstr (pinfo->cinfo, COL_INFO,
61             "DOCSIS Path Verify Response: Transaction-Id = %u DS-Ch %d", 
62                 transid, dschan);
63
64   if (tree)
65     {
66       it =
67         proto_tree_add_protocol_format (tree, proto_docsis_dpvrsp, tvb, 0, -1,
68                                         "DPV Response");
69       dpvrsp_tree = proto_item_add_subtree (it, ett_docsis_dpvrsp);
70       proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_tranid, tvb, 
71                           0, 2, FALSE);
72       proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_dschan, tvb, 
73                           2, 1, FALSE);
74       proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_flags, tvb, 
75                           3, 1, FALSE);
76       proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_us_sf, tvb, 
77                           4, 4, FALSE);
78       proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_n, tvb, 
79                           8, 2, FALSE);
80       proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_start, tvb, 
81                           10, 1, FALSE);
82       proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_end, tvb, 
83                           11, 1, FALSE);
84       proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_ts_start, tvb, 
85                           12, 4, FALSE);
86       proto_tree_add_item (dpvrsp_tree, hf_docsis_dpvrsp_ts_end, tvb, 
87                           16, 4, FALSE);
88     }
89 }
90
91
92
93
94 /* Register the protocol with Wireshark */
95
96 /* this format is require because a script is used to build the C function
97    that calls all the protocol registration.
98 */
99
100 void
101 proto_register_docsis_dpvrsp (void)
102 {
103
104 /* Setup list of header fields  See Section 1.6.1 for details*/
105   static hf_register_info hf[] = {
106     {&hf_docsis_dpvrsp_tranid,
107      {"Transaction Id", "docsis_dpvrsp.tranid",
108       FT_UINT16, BASE_DEC, NULL, 0x0,
109       NULL, HFILL}
110      },
111     {&hf_docsis_dpvrsp_dschan,
112      {"Downstream Channel ID", "docsis_dpvrsp.dschan",
113       FT_UINT8, BASE_DEC, NULL, 0x0,
114       NULL, HFILL}
115      },
116     {&hf_docsis_dpvrsp_flags,
117      {"Flags", "docsis_dpvrsp.flags",
118       FT_UINT8, BASE_DEC, NULL, 0x0,
119       NULL, HFILL}
120      },
121     {&hf_docsis_dpvrsp_us_sf,
122      {"Upstream Service Flow ID", "docsis_dpvrsp.us_sf",
123       FT_UINT32, BASE_DEC, NULL, 0x0,
124       NULL, HFILL}
125      },
126     {&hf_docsis_dpvrsp_n,
127      {"N (Measurement avaraging factor)", "docsis_dpvrsp.n",
128       FT_UINT16, BASE_DEC, NULL, 0x0,
129       NULL, HFILL}
130      },
131     {&hf_docsis_dpvrsp_start,
132      {"Start Reference Point", "docsis_dpvrsp.start",
133       FT_UINT8, BASE_DEC, NULL, 0x0,
134       NULL, HFILL}
135      },
136     {&hf_docsis_dpvrsp_end,
137      {"End Reference Point", "docsis_dpvrsp.end",
138       FT_UINT8, BASE_DEC, NULL, 0x0,
139       NULL, HFILL}
140      },
141     {&hf_docsis_dpvrsp_ts_start,
142      {"Timestamp Start", "docsis_dpvrsp.ts_start",
143       FT_UINT32, BASE_DEC, NULL, 0x0,
144       NULL, HFILL}
145      },
146     {&hf_docsis_dpvrsp_ts_end,
147      {"Timestamp End", "docsis_dpvrsp.ts_end",
148       FT_UINT32, BASE_DEC, NULL, 0x0,
149       NULL, HFILL}
150      },
151   };
152
153 /* Setup protocol subtree array */
154   static gint *ett[] = {
155     &ett_docsis_dpvrsp,
156   };
157
158 /* Register the protocol name and description */
159   proto_docsis_dpvrsp =
160     proto_register_protocol ("DOCSIS Path Verify Response",
161                              "DOCSIS DPV-RSP", "docsis_dpvrsp");
162
163 /* Required function calls to register the header fields and subtrees used */
164   proto_register_field_array (proto_docsis_dpvrsp, hf, array_length (hf));
165   proto_register_subtree_array (ett, array_length (ett));
166
167   register_dissector ("docsis_dpvrsp", dissect_dpvrsp, proto_docsis_dpvrsp);
168 }
169
170
171 /* If this dissector uses sub-dissector registration add a registration routine.
172    This format is required because a script is used to find these routines and
173    create the code that calls these routines.
174 */
175 void
176 proto_reg_handoff_docsis_dpvrsp (void)
177 {
178   dissector_handle_t docsis_dpvrsp_handle;
179
180   docsis_dpvrsp_handle = find_dissector ("docsis_dpvrsp");
181   dissector_add_uint ("docsis_mgmt", 0x28, docsis_dpvrsp_handle);
182 }