Maybe the problem is that the compilers used on AIX weren't defining
[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.8 2003/10/22 01:55:04 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_opnum = -1;
42 static int hf_tapi_rc = -1;
43 static int hf_tapi_hnd = -1;
44 static int hf_tapi_unknown_long = -1;
45 static int hf_tapi_unknown_string = -1;
46 static int hf_tapi_unknown_bytes = -1;
47
48 static gint ett_dcerpc_tapi = -1;
49
50 /*
51   IDL [ uuid(2f5f6520-ca46-1067-b319-00dd010662da),
52   IDL   version(1.0),
53   IDL   implicit_handle(handle_t rpc_binding)
54   IDL ] interface tapi
55   IDL {
56 */
57 static e_uuid_t uuid_dcerpc_tapi = {
58         0x2f5f6520, 0xca46, 0x1067,
59         { 0xb3, 0x19, 0x00, 0xdd, 0x01, 0x06, 0x62, 0xda }
60 };
61
62 static guint16 ver_dcerpc_tapi = 1;
63
64 /*
65   IDL   long ClientAttach(
66   IDL         [out] [context_handle] void *element_1,
67   IDL         [in] long element_2,
68   IDL         [out] long element_3,
69   IDL         [in] [string] [ref] wchar_t *element_4,
70   IDL         [in] [string] [ref] wchar_t *element_5
71   IDL   );
72 */
73 static int
74 dissect_tapi_client_attach_rqst(tvbuff_t *tvb, int offset,
75                         packet_info *pinfo, proto_tree *tree,
76                         char *drep)
77 {
78         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
79                 hf_tapi_unknown_long, NULL);
80
81         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
82                         NDR_POINTER_REF, "unknown string", 
83                          hf_tapi_unknown_string, 0);
84
85         offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, drep,
86                         NDR_POINTER_REF, "unknown string", 
87                          hf_tapi_unknown_string, 0);
88
89         return offset;
90 }
91 static int
92 dissect_tapi_client_attach_reply(tvbuff_t *tvb, int offset,
93                         packet_info *pinfo, proto_tree *tree,
94                         char *drep)
95 {
96         offset = dissect_ndr_ctx_hnd(tvb, offset, pinfo, tree, drep,
97                         hf_tapi_hnd, NULL);
98
99         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
100                 hf_tapi_unknown_long, NULL);
101
102         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
103                 hf_tapi_rc, NULL);
104
105         return offset;
106 }
107
108 /*
109   IDL   long ClientRequest(
110   IDL         [in] [context_handle] void *element_6,
111   IDL     [in,out] [size_is(element_8)] [length_is(???)] char element_7[*],
112   IDL         [in] long element_8
113   IDL   );
114 */
115 static int
116 dissect_tapi_TYPE_1(tvbuff_t *tvb, int offset,
117                         packet_info *pinfo, proto_tree *tree,
118                         char *drep)
119 {
120         dcerpc_info *di;
121
122         di=pinfo->private_data;
123         if(di->conformant_run){
124                 /* this call is to make ethereal eat the array header for the conformant run */
125                 offset =dissect_ndr_ucvarray(tvb, offset, pinfo, tree, drep, NULL);
126
127                 return offset;
128         }
129
130         proto_tree_add_item(tree, hf_tapi_unknown_bytes, tvb, offset,
131                 di->array_actual_count, FALSE);
132         offset += di->array_actual_count;
133
134         return offset;
135 }
136
137 static int
138 dissect_tapi_client_request_rqst(tvbuff_t *tvb, int offset,
139                         packet_info *pinfo, proto_tree *tree,
140                         char *drep)
141 {
142         offset = dissect_ndr_ctx_hnd(tvb, offset, pinfo, tree, drep,
143                         hf_tapi_hnd, NULL);
144
145         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
146                         dissect_tapi_TYPE_1, NDR_POINTER_REF,
147                         "unknown array", -1);
148
149         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
150                 hf_tapi_unknown_long, NULL);
151
152         return offset;
153 }
154 static int
155 dissect_tapi_client_request_reply(tvbuff_t *tvb, int offset,
156                         packet_info *pinfo, proto_tree *tree,
157                         char *drep)
158 {
159         offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep,
160                 hf_tapi_rc, NULL);
161
162         return offset;
163 }
164
165
166 /*
167   IDL   void ClientDetach(
168   IDL         void
169   IDL   );
170 */
171 static int
172 dissect_tapi_client_detach_rqst(tvbuff_t *tvb _U_, int offset _U_,
173                         packet_info *pinfo _U_, proto_tree *tree _U_,
174                         char *drep _U_)
175 {
176         return offset;
177 }
178 static int
179 dissect_tapi_client_detach_reply(tvbuff_t *tvb _U_, int offset _U_,
180                         packet_info *pinfo _U_, proto_tree *tree _U_,
181                         char *drep _U_)
182 {
183         return offset;
184 }
185
186 /*
187   IDL }
188 */
189 static dcerpc_sub_dissector dcerpc_tapi_dissectors[] = {
190         { TAPI_CLIENT_ATTACH, "ClientAttach",
191                 dissect_tapi_client_attach_rqst,
192                 dissect_tapi_client_attach_reply },
193         { TAPI_CLIENT_REQUEST, "ClientRequest",
194                 dissect_tapi_client_request_rqst,
195                 dissect_tapi_client_request_reply },
196         { TAPI_CLIENT_DETACH, "ClientDetach",
197                 dissect_tapi_client_detach_rqst,
198                 dissect_tapi_client_detach_reply },
199
200         {0, NULL, NULL,  NULL }
201 };
202
203 void
204 proto_register_dcerpc_tapi(void)
205 {
206 static hf_register_info hf[] = {
207         { &hf_tapi_opnum, { 
208                 "Operation", "tapi.opnum", FT_UINT16, BASE_DEC,
209                 NULL, 0x0, "", HFILL }},
210         { &hf_tapi_rc, {
211                 "Return code", "tapi.rc", FT_UINT32, BASE_HEX,
212                 VALS(NT_errors), 0x0, "TAPI return code", HFILL }},
213         { &hf_tapi_hnd, {
214                 "Context Handle", "tapi.hnd", FT_BYTES, BASE_NONE,
215                 NULL, 0x0, "Context handle", HFILL }},
216         { &hf_tapi_unknown_long, {
217                 "Unknown long", "tapi.unknown.long", FT_UINT32, BASE_HEX,
218                 NULL, 0x0, "Unknown long. If you know what this is, contact ethereal developers.", HFILL }},
219         { &hf_tapi_unknown_string, {
220                 "Unknown string", "tapi.unknown.string", FT_STRING, BASE_HEX,
221                 NULL, 0x0, "Unknown string. If you know what this is, contact ethereal developers.", HFILL }},
222         { &hf_tapi_unknown_bytes, {
223                 "Unknown bytes", "tapi.unknown.bytes", FT_BYTES, BASE_HEX,
224                 NULL, 0x0, "Unknown bytes. If you know what this is, contact ethereal developers.", HFILL }}
225         };
226
227         static gint *ett[] = {
228                 &ett_dcerpc_tapi
229         };
230
231         proto_dcerpc_tapi = proto_register_protocol(
232                 "Microsoft Telephony API Service", "TAPI", "tapi");
233
234         proto_register_field_array(proto_dcerpc_tapi, hf,
235                                    array_length(hf));
236
237         proto_register_subtree_array(ett, array_length(ett));
238 }
239
240 void
241 proto_reg_handoff_dcerpc_tapi(void)
242 {
243         /* Register protocol as dcerpc */
244
245         dcerpc_init_uuid(proto_dcerpc_tapi, ett_dcerpc_tapi,
246                          &uuid_dcerpc_tapi, ver_dcerpc_tapi,
247                          dcerpc_tapi_dissectors, hf_tapi_opnum);
248 }