Update minimum version requirement for GTK to 2.12.
[obnox/wireshark/wip.git] / plugins / docsis / packet-dscreq.c
1 /* packet-dscreq.c
2  * Routines for Dynamic Service Change Request dissection
3  * Copyright 2002, Anand V. Narwani <anand[AT]narwani.org>
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_dscreq = -1;
34 static int hf_docsis_dscreq_tranid = -1;
35 static dissector_handle_t docsis_tlv_handle;
36
37
38 /* Initialize the subtree pointers */
39 static gint ett_docsis_dscreq = -1;
40
41 /* Code to actually dissect the packets */
42 static void
43 dissect_dscreq (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
44 {
45
46   proto_item *it;
47   proto_tree *dscreq_tree = NULL;
48   guint16 transid;
49   tvbuff_t *next_tvb;
50
51
52   transid = tvb_get_ntohs (tvb, 0);
53
54   col_clear (pinfo->cinfo, COL_INFO);
55   col_add_fstr (pinfo->cinfo, COL_INFO,
56             "Dynamic Service Change Request Tran-id = %u", transid);
57
58   if (tree)
59     {
60       it =
61         proto_tree_add_protocol_format (tree, proto_docsis_dscreq, tvb, 0, -1,
62                                         "DSC Request");
63       dscreq_tree = proto_item_add_subtree (it, ett_docsis_dscreq);
64       proto_tree_add_item (dscreq_tree, hf_docsis_dscreq_tranid, tvb, 0, 2,
65                            ENC_BIG_ENDIAN);
66
67     }
68     /* Call dissector for Appendix C TLV's */
69     next_tvb = tvb_new_subset_remaining (tvb, 2);
70     call_dissector (docsis_tlv_handle, next_tvb, pinfo, dscreq_tree);
71
72 }
73
74
75
76
77 /* Register the protocol with Wireshark */
78
79 /* this format is require because a script is used to build the C function
80    that calls all the protocol registration.
81 */
82
83
84 void
85 proto_register_docsis_dscreq (void)
86 {
87
88 /* Setup list of header fields  See Section 1.6.1 for details*/
89   static hf_register_info hf[] = {
90     {&hf_docsis_dscreq_tranid,
91      {"Transaction Id", "docsis_dscreq.tranid",
92       FT_UINT16, BASE_DEC, NULL, 0x0,
93       NULL, HFILL}
94      },
95   };
96
97 /* Setup protocol subtree array */
98   static gint *ett[] = {
99     &ett_docsis_dscreq,
100   };
101
102 /* Register the protocol name and description */
103   proto_docsis_dscreq =
104     proto_register_protocol ("DOCSIS Dynamic Service Change Request",
105                              "DOCSIS DSC-REQ", "docsis_dscreq");
106
107 /* Required function calls to register the header fields and subtrees used */
108   proto_register_field_array (proto_docsis_dscreq, hf, array_length (hf));
109   proto_register_subtree_array (ett, array_length (ett));
110
111   register_dissector ("docsis_dscreq", dissect_dscreq, proto_docsis_dscreq);
112 }
113
114
115 /* If this dissector uses sub-dissector registration add a registration routine.
116    This format is required because a script is used to find these routines and
117    create the code that calls these routines.
118 */
119 void
120 proto_reg_handoff_docsis_dscreq (void)
121 {
122   dissector_handle_t docsis_dscreq_handle;
123
124   docsis_dscreq_handle = find_dissector ("docsis_dscreq");
125   docsis_tlv_handle = find_dissector ("docsis_tlv");
126   dissector_add_uint ("docsis_mgmt", 0x12, docsis_dscreq_handle);
127
128 }