Update Free Software Foundation address.
[metze/wireshark/wip.git] / epan / dissectors / packet-dcerpc-rs_acct.c
1 /* packet-dcerpc-rs_acct.c
2  *
3  * Routines for DFS/RS_ACCT
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/rs_acct.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27  */
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33
34 #include <glib.h>
35 #include <epan/packet.h>
36 #include "packet-dcerpc.h"
37
38
39 static int proto_rs_acct = -1;
40 static int hf_rs_acct_opnum = -1;
41 static int hf_rs_acct_lookup_rqst_var = -1;
42 static int hf_rs_acct_lookup_rqst_key_size = -1;
43 static int hf_rs_acct_lookup_rqst_key_t = -1;
44 static int hf_rs_acct_get_projlist_rqst_var1 = -1;
45 static int hf_rs_acct_get_projlist_rqst_key_size = -1;
46 static int hf_rs_acct_get_projlist_rqst_key_t = -1;
47
48
49 static gint ett_rs_acct = -1;
50
51
52
53 static e_uuid_t uuid_rs_acct = { 0x4c878280, 0x2000, 0x0000, { 0x0d, 0x00, 0x02, 0x87, 0x14, 0x00, 0x00, 0x00 } };
54 static guint16  ver_rs_acct = 1;
55
56
57 static int
58 rs_acct_dissect_lookup_rqst (tvbuff_t *tvb, int offset,
59                 packet_info *pinfo, proto_tree *tree, guint8 *drep)
60 {
61         guint32 key_size;
62         const char *keyx_t = NULL;
63
64         offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
65                         hf_rs_acct_lookup_rqst_var, NULL);
66         offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
67                         hf_rs_acct_lookup_rqst_key_size, &key_size);
68
69         if (key_size){ /* Not able to yet decipher the OTHER versions of this call just yet. */
70                 proto_tree_add_item (tree, hf_rs_acct_lookup_rqst_key_t, tvb, offset, key_size, ENC_ASCII|ENC_NA);
71                 keyx_t = tvb_get_ephemeral_string(tvb, offset, key_size);
72                 offset += key_size;
73
74                 if (check_col(pinfo->cinfo, COL_INFO)) {
75                         col_append_fstr(pinfo->cinfo, COL_INFO,
76                                 " Request for: %s ", keyx_t);
77                 }
78         } else {
79                 col_append_str(pinfo->cinfo, COL_INFO,
80                                 " Request (other)");
81         }
82
83         return offset;
84 }
85
86
87
88 static int
89 rs_acct_dissect_get_projlist_rqst (tvbuff_t *tvb, int offset,
90                 packet_info *pinfo, proto_tree *tree, guint8 *drep)
91 {
92         guint32 key_size;
93         const char *keyx_t = NULL;
94
95         offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
96                         hf_rs_acct_get_projlist_rqst_var1, NULL);
97         offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
98                         hf_rs_acct_get_projlist_rqst_key_size, &key_size);
99
100         proto_tree_add_item (tree, hf_rs_acct_get_projlist_rqst_key_t,
101                              tvb, offset, key_size, ENC_ASCII|ENC_NA);
102         keyx_t = tvb_get_ephemeral_string(tvb, offset, key_size);
103         offset += key_size;
104
105         if (check_col(pinfo->cinfo, COL_INFO)) {
106                 col_append_fstr(pinfo->cinfo, COL_INFO,
107                         " Request for: %s", keyx_t);
108         }
109
110         return offset;
111 }
112
113
114 static dcerpc_sub_dissector rs_acct_dissectors[] = {
115         { 0, "add", NULL, NULL},
116         { 1, "delete", NULL, NULL},
117         { 2, "rename", NULL, NULL},
118         { 3, "lookup", rs_acct_dissect_lookup_rqst, NULL},
119         { 4, "replace", NULL, NULL},
120         { 5, "get_projlist", rs_acct_dissect_get_projlist_rqst, NULL},
121         { 0, NULL, NULL, NULL }
122 };
123
124 void
125 proto_register_rs_acct (void)
126 {
127         static hf_register_info hf[] = {
128         { &hf_rs_acct_opnum,
129                 { "Operation", "rs_acct.opnum", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
130         { &hf_rs_acct_lookup_rqst_var,
131                 { "Var", "rs_acct.lookup_rqst_var", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
132         { &hf_rs_acct_lookup_rqst_key_size,
133                 { "Key Size", "rs_acct.lookup_rqst_key_size", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
134         { &hf_rs_acct_lookup_rqst_key_t,
135                 { "Key", "rs_acct.lookup_rqst_key_t", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
136         { &hf_rs_acct_get_projlist_rqst_var1,
137                 { "Var1", "rs_acct.get_projlist_rqst_var1", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
138         { &hf_rs_acct_get_projlist_rqst_key_size,
139                 { "Var1", "rs_acct.get_projlist_rqst_key_size", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
140         { &hf_rs_acct_get_projlist_rqst_key_t,
141                 { "Var1", "rs_acct.get_projlist_rqst_key_t", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}
142         };
143
144         static gint *ett[] = {
145                 &ett_rs_acct,
146         };
147         proto_rs_acct = proto_register_protocol ("DCE/RPC RS_ACCT", "RS_ACCT", "rs_acct");
148         proto_register_field_array (proto_rs_acct, hf, array_length (hf));
149         proto_register_subtree_array (ett, array_length (ett));
150 }
151
152
153
154 void
155 proto_reg_handoff_rs_acct (void)
156 {
157         /* Register the protocol as dcerpc */
158         dcerpc_init_uuid (proto_rs_acct, ett_rs_acct, &uuid_rs_acct, ver_rs_acct, rs_acct_dissectors, hf_rs_acct_opnum);
159 }