From Todd Sabin: allocate the buffer for the decrypted payload, rather
[obnox/wireshark/wip.git] / packet-rstat.c
1 /* packet-rstat.c
2  * Stubs for Sun's remote statistics RPC service
3  *
4  * Guy Harris <guy@alum.mit.edu>
5  *
6  * $Id: packet-rstat.c,v 1.4 2002/11/01 00:48:38 sahlberg Exp $
7  *
8  * Ethereal - Network traffic analyzer
9  * By Gerald Combs <gerald@ethereal.com>
10  * Copyright 1998 Gerald Combs
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
31
32
33 #include "packet-rpc.h"
34
35 static int proto_rstat = -1;
36 static int hf_rstat_procedure_v1 = -1;
37 static int hf_rstat_procedure_v2 = -1;
38 static int hf_rstat_procedure_v3 = -1;
39 static int hf_rstat_procedure_v4 = -1;
40
41 static gint ett_rstat = -1;
42
43 #define RSTAT_PROGRAM   100001
44
45 #define RSTATPROC_NULL          0
46 #define RSTATPROC_STATS         1
47 #define RSTATPROC_HAVEDISK      2
48
49 /* proc number, "proc name", dissect_request, dissect_reply */
50 /* NULL as function pointer means: type of arguments is "void". */
51 static const vsff rstat1_proc[] = {
52         { RSTATPROC_NULL,       "NULL",
53                 NULL,   NULL },
54         { RSTATPROC_STATS,      "STATS",
55                 NULL,   NULL },
56         { RSTATPROC_HAVEDISK,   "HAVEDISK",
57                 NULL,   NULL },
58         { 0,    NULL,   NULL,   NULL }
59 };
60 static const value_string rstat1_proc_vals[] = {
61         { RSTATPROC_NULL,       "NULL" },
62         { RSTATPROC_STATS,      "STATS" },
63         { RSTATPROC_HAVEDISK,   "HAVEDISK" },
64         { 0,    NULL }
65 };
66
67 static const vsff rstat2_proc[] = {
68         { RSTATPROC_NULL,       "NULL",
69                 NULL,   NULL },
70         { RSTATPROC_STATS,      "STATS",
71                 NULL,   NULL },
72         { RSTATPROC_HAVEDISK,   "HAVEDISK",
73                 NULL,   NULL },
74         { 0,    NULL,   NULL,   NULL }
75 };
76 static const value_string rstat2_proc_vals[] = {
77         { RSTATPROC_NULL,       "NULL" },
78         { RSTATPROC_STATS,      "STATS" },
79         { RSTATPROC_HAVEDISK,   "HAVEDISK" },
80         { 0,    NULL }
81 };
82
83 static const vsff rstat3_proc[] = {
84         { RSTATPROC_NULL,       "NULL",
85                 NULL,   NULL },
86         { RSTATPROC_STATS,      "STATS",
87                 NULL,   NULL },
88         { RSTATPROC_HAVEDISK,   "HAVEDISK",
89                 NULL,   NULL },
90         { 0,    NULL,   NULL,   NULL }
91 };
92 static const value_string rstat3_proc_vals[] = {
93         { RSTATPROC_NULL,       "NULL" },
94         { RSTATPROC_STATS,      "STATS" },
95         { RSTATPROC_HAVEDISK,   "HAVEDISK" },
96         { 0,    NULL }
97 };
98
99 static const vsff rstat4_proc[] = {
100         { RSTATPROC_NULL,       "NULL",
101                 NULL,   NULL },
102         { RSTATPROC_STATS,      "STATS",
103                 NULL,   NULL },
104         { RSTATPROC_HAVEDISK,   "HAVEDISK",
105                 NULL,   NULL },
106         { 0,    NULL,   NULL,   NULL }
107 };
108 static const value_string rstat4_proc_vals[] = {
109         { RSTATPROC_NULL,       "NULL" },
110         { RSTATPROC_STATS,      "STATS" },
111         { RSTATPROC_HAVEDISK,   "HAVEDISK" },
112         { 0,    NULL }
113 };
114
115 void
116 proto_register_rstat(void)
117 {
118         static hf_register_info hf[] = {
119                 { &hf_rstat_procedure_v1, {
120                         "V1 Procedure", "rstat.procedure_v1", FT_UINT32, BASE_DEC,
121                         VALS(rstat1_proc_vals), 0, "V1 Procedure", HFILL }},
122                 { &hf_rstat_procedure_v2, {
123                         "V2 Procedure", "rstat.procedure_v2", FT_UINT32, BASE_DEC,
124                         VALS(rstat2_proc_vals), 0, "V2 Procedure", HFILL }},
125                 { &hf_rstat_procedure_v3, {
126                         "V3 Procedure", "rstat.procedure_v3", FT_UINT32, BASE_DEC,
127                         VALS(rstat3_proc_vals), 0, "V3 Procedure", HFILL }},
128                 { &hf_rstat_procedure_v4, {
129                         "V4 Procedure", "rstat.procedure_v4", FT_UINT32, BASE_DEC,
130                         VALS(rstat4_proc_vals), 0, "V4 Procedure", HFILL }}
131         };
132
133         static gint *ett[] = {
134                 &ett_rstat,
135         };
136
137         proto_rstat = proto_register_protocol("RSTAT", "RSTAT", "rstat");
138         proto_register_field_array(proto_rstat, hf, array_length(hf));
139         proto_register_subtree_array(ett, array_length(ett));
140 }
141
142 void
143 proto_reg_handoff_rstat(void)
144 {
145         /* Register the protocol as RPC */
146         rpc_init_prog(proto_rstat, RSTAT_PROGRAM, ett_rstat);
147         /* Register the procedure tables */
148         rpc_init_proc_table(RSTAT_PROGRAM, 1, rstat1_proc, hf_rstat_procedure_v1);
149         rpc_init_proc_table(RSTAT_PROGRAM, 2, rstat2_proc, hf_rstat_procedure_v2);
150         rpc_init_proc_table(RSTAT_PROGRAM, 3, rstat3_proc, hf_rstat_procedure_v3);
151         rpc_init_proc_table(RSTAT_PROGRAM, 4, rstat3_proc, hf_rstat_procedure_v4);
152 }