In the hex dump, generate the offset at the beginning of each line in
[obnox/wireshark/wip.git] / packet-dcerpc-tapi.c
1 /* packet-dcerpc-tapi.c
2  * Routines for DCERPC TAPI packet disassembly
3  * Copyright 2002, Ronnie Sahlberg
4  *
5  * $Id: packet-dcerpc-tapi.c,v 1.1 2002/06/02 12:33:15 sahlberg Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@ethereal.com>
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 /* The IDL file for this interface can be extracted by grepping for idl 
26  * in capitals.
27  */
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33 #include <glib.h>
34 #include <epan/packet.h>
35 #include "packet-dcerpc.h"
36 #include "packet-dcerpc-nt.h"
37 #include "packet-dcerpc-tapi.h"
38 #include "smb.h"
39
40 static int proto_dcerpc_tapi = -1;
41 static int hf_tapi_rc = -1;
42 static int hf_tapi_hnd = -1;
43 static int hf_tapi_unknown_long = -1;
44 static int hf_tapi_unknown_string = -1;
45 static int hf_tapi_unknown_bytes = -1;
46
47 static gint ett_dcerpc_tapi = -1;
48
49 /*
50   IDL [ uuid(2f5f6520-ca46-1067-b319-00dd010662da),
51   IDL   version(1.0),
52   IDL   implicit_handle(handle_t rpc_binding)
53   IDL ] interface tapi
54   IDL {
55 */
56 static e_uuid_t uuid_dcerpc_tapi = {
57         0x2f5f6520, 0xca46, 0x1067,
58         { 0xb3, 0x19, 0x00, 0xdd, 0x01, 0x06, 0x62, 0xda }
59 };
60
61 static guint16 ver_dcerpc_tapi = 1;
62
63 /*
64   IDL   long Function_00(
65   IDL         [out] [context_handle] void *element_1,
66   IDL         [in] long element_2,
67   IDL         [out] long element_3,
68   IDL         [in] [string] [ref] wchar_t *element_4,
69   IDL         [in] [string] [ref] wchar_t *element_5
70   IDL   );
71 */
72 static int
73 dissect_tapi_UNKNOWN_00_rqst(tvbuff_t *tvb, int offset,
74                         packet_info *pinfo, proto_tree *tree,
75                         char *drep)
76 {
77         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
78                 hf_tapi_unknown_long, NULL);
79
80         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
81                         dissect_ndr_nt_UNICODE_STRING_str, NDR_POINTER_REF,
82                         "unknown string", hf_tapi_unknown_string, 0);
83
84         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
85                         dissect_ndr_nt_UNICODE_STRING_str, NDR_POINTER_REF,
86                         "unknown string", hf_tapi_unknown_string, 0);
87
88         return offset;
89 }
90 static int
91 dissect_tapi_UNKNOWN_00_reply(tvbuff_t *tvb, int offset,
92                         packet_info *pinfo, proto_tree *tree,
93                         char *drep)
94 {
95         offset = dissect_ndr_ctx_hnd(tvb, offset, pinfo, tree, drep,
96                         hf_tapi_hnd, NULL);
97
98         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
99                 hf_tapi_unknown_long, NULL);
100
101         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
102                 hf_tapi_rc, NULL);
103
104         return offset;
105 }
106
107 /*
108   IDL   long Function_01(
109   IDL         [in] [context_handle] void *element_6,
110   IDL     [in,out] [size_is(element_8)] [length_is(???)] char element_7[*],
111   IDL         [in] long element_8
112   IDL   );
113 */
114 static int
115 dissect_tapi_TYPE_1(tvbuff_t *tvb, int offset,
116                         packet_info *pinfo, proto_tree *tree,
117                         char *drep)
118 {
119         dcerpc_info *di;
120
121         di=pinfo->private_data;
122         if(di->conformant_run){
123                 /* this call is to make ethereal eat the array header for the conformant run */
124                 offset =dissect_ndr_ucvarray(tvb, offset, pinfo, tree, drep, NULL);
125
126                 return offset;
127         }
128
129         proto_tree_add_item(tree, hf_tapi_unknown_bytes, tvb, offset,
130                 di->array_actual_count, FALSE);
131         offset += di->array_actual_count;
132
133         return offset;
134 }       
135
136 static int
137 dissect_tapi_UNKNOWN_01_rqst(tvbuff_t *tvb, int offset,
138                         packet_info *pinfo, proto_tree *tree,
139                         char *drep)
140 {
141         offset = dissect_ndr_ctx_hnd(tvb, offset, pinfo, tree, drep,
142                         hf_tapi_hnd, NULL);
143
144         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
145                         dissect_tapi_TYPE_1, NDR_POINTER_REF,
146                         "unknown array", -1, 0);
147
148         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
149                 hf_tapi_unknown_long, NULL);
150
151         return offset;
152 }
153 static int
154 dissect_tapi_UNKNOWN_01_reply(tvbuff_t *tvb, int offset,
155                         packet_info *pinfo, proto_tree *tree,
156                         char *drep)
157 {
158         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
159                 hf_tapi_rc, NULL);
160
161         return offset;
162 }
163
164
165 /*
166   IDL   void Function_02(
167   IDL         void
168   IDL   );
169 */
170 static int
171 dissect_tapi_UNKNOWN_02_rqst(tvbuff_t *tvb _U_, int offset _U_,
172                         packet_info *pinfo _U_, proto_tree *tree _U_,
173                         char *drep _U_)
174 {
175         return offset;
176 }
177 static int
178 dissect_tapi_UNKNOWN_02_reply(tvbuff_t *tvb _U_, int offset _U_,
179                         packet_info *pinfo _U_, proto_tree *tree _U_,
180                         char *drep _U_)
181 {
182         return offset;
183 }
184
185 /*
186   IDL }
187 */
188 static dcerpc_sub_dissector dcerpc_tapi_dissectors[] = {
189         { TAPI_UNKNOWN_00, "TAPI_UNKNOWN_00",
190                 dissect_tapi_UNKNOWN_00_rqst,
191                 dissect_tapi_UNKNOWN_00_reply },
192         { TAPI_UNKNOWN_01, "TAPI_UNKNOWN_01",
193                 dissect_tapi_UNKNOWN_01_rqst,
194                 dissect_tapi_UNKNOWN_01_reply },
195         { TAPI_UNKNOWN_02, "TAPI_UNKNOWN_02",
196                 dissect_tapi_UNKNOWN_02_rqst,
197                 dissect_tapi_UNKNOWN_02_reply },
198
199         {0, NULL, NULL,  NULL }
200 };
201
202 void 
203 proto_register_dcerpc_tapi(void)
204 {
205 static hf_register_info hf[] = {
206         { &hf_tapi_rc, { 
207                 "Return code", "tapi.rc", FT_UINT32, BASE_HEX, 
208                 VALS(NT_errors), 0x0, "TAPI return code", HFILL }},
209         { &hf_tapi_hnd, {
210                 "Context Handle", "tapi.hnd", FT_BYTES, BASE_NONE,
211                 NULL, 0x0, "Context handle", HFILL }},
212         { &hf_tapi_unknown_long, { 
213                 "Unknown long", "tapi.unknown.long", FT_UINT32, BASE_HEX, 
214                 NULL, 0x0, "Unknown long. If you know what this is, contact ethereal developers.", HFILL }},
215         { &hf_tapi_unknown_string, { 
216                 "Unknown string", "tapi.unknown.string", FT_STRING, BASE_HEX, 
217                 NULL, 0x0, "Unknown string. If you know what this is, contact ethereal developers.", HFILL }},
218         { &hf_tapi_unknown_bytes, { 
219                 "Unknown bytes", "tapi.unknown.bytes", FT_BYTES, BASE_HEX, 
220                 NULL, 0x0, "Unknown bytes. If you know what this is, contact ethereal developers.", HFILL }}
221         };
222
223         static gint *ett[] = {
224                 &ett_dcerpc_tapi
225         };
226
227         proto_dcerpc_tapi = proto_register_protocol(
228                 "Microsoft Telephony API Service", "TAPI", "tapi");
229
230         proto_register_field_array(proto_dcerpc_tapi, hf, 
231                                    array_length(hf));
232
233         proto_register_subtree_array(ett, array_length(ett));
234 }
235
236 void
237 proto_reg_handoff_dcerpc_tapi(void)
238 {
239         /* Register protocol as dcerpc */
240
241         dcerpc_init_uuid(proto_dcerpc_tapi, ett_dcerpc_tapi, 
242                          &uuid_dcerpc_tapi, ver_dcerpc_tapi, 
243                          dcerpc_tapi_dissectors);
244 }