change the signature that asn2wrs generates for functions to marm all parameters...
[obnox/wireshark/wip.git] / epan / dissectors / packet-dcerpc-rpriv.c
1 /* packet-dcerpc-rpriv.c
2  *
3  * Routines for DCERPC Privilege Server operations
4  * Copyright 2002, Jaime Fournier <Jaime.Fournier@hush.com>
5  * This information is based off the released idl files from opengroup.
6  * ftp://ftp.opengroup.org/pub/dce122/dce/src/security.tar.gz  security/idl/rpriv.idl
7  *
8  * $Id$
9  *
10  * Wireshark - Network traffic analyzer
11  * By Gerald Combs <gerald@wireshark.org>
12  * Copyright 1998 Gerald Combs
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
27  */
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33
34 #ifdef HAVE_SYS_TYPES_H
35 #include <sys/types.h>
36 #endif
37
38 #include <string.h>
39
40 #include <glib.h>
41 #include <epan/packet.h>
42 #include "packet-dcerpc.h"
43
44
45 static int proto_rpriv = -1;
46 static int hf_rpriv_opnum = -1;
47 static int hf_rpriv_get_eptgt_rqst_authn_svc = -1;
48 static int hf_rpriv_get_eptgt_rqst_authz_svc = -1;
49 static int hf_rpriv_get_eptgt_rqst_var1 = -1;
50 static int hf_rpriv_get_eptgt_rqst_key_size = -1;
51 static int hf_rpriv_get_eptgt_rqst_key_size2 = -1;
52 static int hf_rpriv_get_eptgt_rqst_key_t = -1;
53 static int hf_rpriv_get_eptgt_rqst_key_t2 = -1;
54
55 static gint ett_rpriv = -1;
56
57
58 static e_uuid_t uuid_rpriv = { 0xb1e338f8, 0x9533, 0x11c9, { 0xa3, 0x4a, 0x08, 0x00, 0x1e, 0x01, 0x9c, 0x1e } };
59 static guint16  ver_rpriv = 1;
60
61
62 static int
63 rpriv_dissect_get_eptgt_rqst (tvbuff_t *tvb, int offset,
64                          packet_info *pinfo, proto_tree *tree,
65                          guint8 *drep)
66 {
67         /*        [in]        handle_t         handle,
68          *        [in]        unsigned32       authn_svc,
69          *        [in]        unsigned32       authz_svc,
70          *        [in]        rpriv_pickle_t   *ptgt_req,
71          *                    unsigned32          num_bytes;
72          *                    [size_is(num_bytes)]
73          *                    byte            bytes[];
74          */                                 
75
76    guint32 authn_svc, authz_svc, key_size, key_size2, var1;
77    const char *key_t = NULL;
78    const char *key_t2 = NULL;
79
80    offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep, hf_rpriv_get_eptgt_rqst_authn_svc, &authn_svc);
81    offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep, hf_rpriv_get_eptgt_rqst_authz_svc, &authz_svc);
82    offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep, hf_rpriv_get_eptgt_rqst_var1, &var1);
83    offset += 276;
84    offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep, hf_rpriv_get_eptgt_rqst_key_size2, &key_size);
85    /* advance to get size of cell, and princ */
86
87    proto_tree_add_string (tree, hf_rpriv_get_eptgt_rqst_key_t, tvb, offset, hf_rpriv_get_eptgt_rqst_key_size, tvb_get_ptr (tvb, offset, key_size));
88    key_t = (const char *)tvb_get_ptr(tvb,offset,key_size);
89    offset += key_size;
90
91    offset += 8;
92    offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep, hf_rpriv_get_eptgt_rqst_key_size2, &key_size2);
93    proto_tree_add_string (tree, hf_rpriv_get_eptgt_rqst_key_t2, tvb, offset, hf_rpriv_get_eptgt_rqst_key_size2, tvb_get_ptr (tvb, offset, key_size2));
94    key_t2 = (const char *)tvb_get_ptr(tvb,offset,key_size2);
95    offset += key_size2;
96
97
98    if (check_col(pinfo->cinfo, COL_INFO)) {
99                col_append_fstr(pinfo->cinfo, COL_INFO,
100                    " Request for: %s in %s ", key_t2, key_t);
101    }
102
103    return offset;
104
105 }
106
107
108 static dcerpc_sub_dissector rpriv_dissectors[] = {
109     { 0, "get_ptgt", NULL,NULL},
110     { 1, "become_delegate", NULL, NULL},
111     { 2, "become_impersonator", NULL, NULL},
112     { 3, "get_eptgt", rpriv_dissect_get_eptgt_rqst , NULL},
113     { 0, NULL, NULL, NULL }
114 };
115
116 void
117 proto_register_rpriv (void)
118 {
119         static hf_register_info hf[] = {
120       { &hf_rpriv_opnum,
121          { "Operation", "rpriv.opnum", FT_UINT16, BASE_DEC, NULL, 0x0, "Operation", HFILL }},
122       { &hf_rpriv_get_eptgt_rqst_authn_svc,
123          { "Authn_Svc", "rpriv.get_eptgt_rqst_authn_svc", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }},
124       { &hf_rpriv_get_eptgt_rqst_authz_svc,
125          { "Authz_Svc", "rpriv.get_eptgt_rqst_authz_svc", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }},
126       { &hf_rpriv_get_eptgt_rqst_key_size,
127          { "Key_Size", "rpriv.get_eptgt_rqst_key_size", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }},
128       { &hf_rpriv_get_eptgt_rqst_var1,
129          { "Var1", "rpriv.get_eptgt_rqst_var1", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }},
130       { &hf_rpriv_get_eptgt_rqst_key_size2,
131          { "Key_Size", "rpriv.get_eptgt_rqst_key_size2", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }},
132       { &hf_rpriv_get_eptgt_rqst_key_t,
133          { "Key_t", "rpriv.get_eptgt_rqst_key_t", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }},
134       { &hf_rpriv_get_eptgt_rqst_key_t2,
135          { "Key_t2", "rpriv.get_eptgt_rqst_key_t2", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }},
136                                          
137         };
138
139         static gint *ett[] = {
140                 &ett_rpriv,
141         };
142         proto_rpriv = proto_register_protocol ("Privilege Server operations", "rpriv", "rpriv");
143         proto_register_field_array (proto_rpriv, hf, array_length (hf));
144         proto_register_subtree_array (ett, array_length (ett));
145 }
146
147 void
148 proto_reg_handoff_rpriv (void)
149 {
150         /* Register the protocol as dcerpc */
151         dcerpc_init_uuid (proto_rpriv, ett_rpriv, &uuid_rpriv, ver_rpriv, rpriv_dissectors, hf_rpriv_opnum);
152 }