Do the standard "next entry offset" stuff in NT NOTIFY replies, so as to
[obnox/wireshark/wip.git] / packet-spray.c
1 /* packet-spray.c
2  * 2001  Ronnie Sahlberg   <See AUTHORS for email>
3  *
4  * $Id: packet-spray.c,v 1.8 2002/04/03 13:24:13 girlich Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28
29
30 #ifdef HAVE_SYS_TYPES_H
31 #include <sys/types.h>
32 #endif
33
34
35 #include "packet-rpc.h"
36 #include "packet-spray.h"
37
38 static int proto_spray = -1;
39 static int hf_spray_sprayarr = -1;
40 static int hf_spray_counter = -1;
41 static int hf_spray_clock = -1;
42 static int hf_spray_sec = -1;
43 static int hf_spray_usec = -1;
44
45 static gint ett_spray = -1;
46 static gint ett_spray_clock = -1;
47
48
49 static int
50 dissect_get_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
51 {
52         proto_item* lock_item = NULL;
53         proto_tree* lock_tree = NULL;
54
55         offset = dissect_rpc_uint32(tvb, tree, 
56                         hf_spray_counter, offset);
57
58         lock_item = proto_tree_add_item(tree, hf_spray_clock, tvb,
59                         offset, -1, FALSE);
60
61         lock_tree = proto_item_add_subtree(lock_item, ett_spray_clock);
62
63         offset = dissect_rpc_uint32(tvb, lock_tree, 
64                         hf_spray_sec, offset);
65
66         offset = dissect_rpc_uint32(tvb, lock_tree, 
67                         hf_spray_usec, offset);
68
69         return offset;
70 }
71
72 static int
73 dissect_spray_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
74 {
75         offset = dissect_rpc_data(tvb, tree, 
76                         hf_spray_sprayarr, offset);
77
78         return offset;
79 }
80
81 /* proc number, "proc name", dissect_request, dissect_reply */
82 /* NULL as function pointer means: type of arguments is "void". */
83 static const vsff spray1_proc[] = {
84         { SPRAYPROC_NULL,       "NULL",
85                 NULL,   NULL },
86         { SPRAYPROC_SPRAY,      "SPRAY",
87                 dissect_spray_call,     NULL },
88         { SPRAYPROC_GET,        "GET",
89                 NULL,   dissect_get_reply },
90         { SPRAYPROC_CLEAR,      "CLEAR",
91                 NULL,   NULL },
92         { 0,    NULL,           NULL,                           NULL }
93 };
94
95 void
96 proto_register_spray(void)
97 {
98         static hf_register_info hf[] = {
99                 { &hf_spray_sprayarr, {
100                         "Data", "spray.sprayarr", FT_BYTES, BASE_DEC,
101                         NULL, 0, "Sprayarr data", HFILL }},
102
103                 { &hf_spray_counter, {
104                         "counter", "spray.counter", FT_UINT32, BASE_DEC,
105                         NULL, 0, "Counter", HFILL }},
106
107                 { &hf_spray_clock, {
108                         "clock", "spray.clock", FT_NONE, BASE_NONE,
109                         NULL, 0, "Clock", HFILL }},
110
111                 { &hf_spray_sec, {
112                         "sec", "spray.sec", FT_UINT32, BASE_DEC,
113                         NULL, 0, "Seconds", HFILL }},
114
115                 { &hf_spray_usec, {
116                         "usec", "spray.usec", FT_UINT32, BASE_DEC,
117                         NULL, 0, "Microseconds", HFILL }},
118
119         };
120
121         static gint *ett[] = {
122                 &ett_spray,
123                 &ett_spray_clock,
124         };
125
126         proto_spray = proto_register_protocol("SPRAY",
127             "SPRAY", "spray");
128         proto_register_field_array(proto_spray, hf, array_length(hf));
129         proto_register_subtree_array(ett, array_length(ett));
130 }
131
132 void
133 proto_reg_handoff_spray(void)
134 {
135         /* Register the protocol as RPC */
136         rpc_init_prog(proto_spray, SPRAY_PROGRAM, ett_spray);
137         /* Register the procedure tables */
138         rpc_init_proc_table(SPRAY_PROGRAM, 1, spray1_proc);
139 }
140