We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
[metze/wireshark/wip.git] / plugins / docsis / packet-intrngreq.c
1 /* packet-intrngreq.c
2  * Routines for Intial Ranging Request Message dissection
3  * Copyright 2003, Brian Wheeler <brian.wheeler[AT]arrisi.com>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 #include "config.h"
27
28 #include <epan/packet.h>
29
30
31 /* Initialize the protocol and registered fields */
32 static int proto_docsis_intrngreq = -1;
33 static int hf_docsis_intrngreq_down_chid = -1;
34 static int hf_docsis_intrngreq_sid = -1;
35 static int hf_docsis_intrngreq_up_chid = -1;
36
37
38 /* Initialize the subtree pointers */
39 static gint ett_docsis_intrngreq = -1;
40
41 /* Code to actually dissect the packets */
42 static void
43 dissect_intrngreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
44 {
45   proto_item *intrngreq_item;
46   proto_tree *intrngreq_tree;
47   guint16 sid;
48
49   sid = tvb_get_ntohs (tvb, 0);
50
51   col_clear (pinfo->cinfo, COL_INFO);
52   col_add_fstr (pinfo->cinfo, COL_INFO, "Ranging Request: SID = %u",sid);
53
54   if (tree)
55     {
56       intrngreq_item =
57         proto_tree_add_protocol_format (tree, proto_docsis_intrngreq, tvb, 0,
58                                         tvb_length_remaining (tvb, 0),
59                                         "Initial Ranging Request");
60       intrngreq_tree = proto_item_add_subtree (intrngreq_item, ett_docsis_intrngreq);
61       proto_tree_add_item (intrngreq_tree, hf_docsis_intrngreq_sid, tvb, 0, 2,
62                            ENC_BIG_ENDIAN);
63       proto_tree_add_item (intrngreq_tree, hf_docsis_intrngreq_down_chid, tvb, 2, 1,
64                            ENC_BIG_ENDIAN);
65       proto_tree_add_item (intrngreq_tree, hf_docsis_intrngreq_up_chid, tvb, 3,
66                            1, ENC_BIG_ENDIAN);
67     }
68
69
70 }
71
72
73
74
75 /* Register the protocol with Wireshark */
76
77 /* this format is require because a script is used to build the C function
78    that calls all the protocol registration.
79 */
80
81
82 void
83 proto_register_docsis_intrngreq (void)
84 {
85
86 /* Setup list of header fields  See Section 1.6.1 for details*/
87   static hf_register_info hf[] = {
88     {&hf_docsis_intrngreq_sid,
89      {"Service Identifier", "docsis_intrngreq.sid",
90       FT_UINT16, BASE_DEC, NULL, 0x0,
91       NULL, HFILL}
92      },
93     {&hf_docsis_intrngreq_down_chid,
94      {"Downstream Channel ID", "docsis_intrngreq.downchid",
95       FT_UINT8, BASE_DEC, NULL, 0x0,
96       NULL, HFILL}
97      },
98     {&hf_docsis_intrngreq_up_chid,
99      {"Upstream Channel ID", "docsis_intrngreq.upchid",
100       FT_UINT8, BASE_DEC, NULL, 0x0,
101       NULL, HFILL}
102      },
103
104   };
105
106 /* Setup protocol subtree array */
107   static gint *ett[] = {
108     &ett_docsis_intrngreq,
109   };
110
111 /* Register the protocol name and description */
112   proto_docsis_intrngreq = proto_register_protocol ("DOCSIS Initial Ranging Message",
113                                                  "DOCSIS INT-RNG-REQ",
114                                                  "docsis_intrngreq");
115
116 /* Required function calls to register the header fields and subtrees used */
117   proto_register_field_array (proto_docsis_intrngreq, hf, array_length (hf));
118   proto_register_subtree_array (ett, array_length (ett));
119
120   register_dissector ("docsis_intrngreq", dissect_intrngreq, proto_docsis_intrngreq);
121 }
122
123
124 /* If this dissector uses sub-dissector registration add a registration routine.
125    This format is required because a script is used to find these routines and
126    create the code that calls these routines.
127 */
128 void
129 proto_reg_handoff_docsis_intrngreq (void)
130 {
131   dissector_handle_t docsis_intrngreq_handle;
132
133   docsis_intrngreq_handle = find_dissector ("docsis_intrngreq");
134   dissector_add_uint ("docsis_mgmt", 0x1E, docsis_intrngreq_handle);
135
136 }