Removed trailing whitespaces from .h and .c files using the
[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.9 2002/08/02 23:36:03 jmayer 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
31 #include "packet-rpc.h"
32 #include "packet-spray.h"
33
34 static int proto_spray = -1;
35 static int hf_spray_sprayarr = -1;
36 static int hf_spray_counter = -1;
37 static int hf_spray_clock = -1;
38 static int hf_spray_sec = -1;
39 static int hf_spray_usec = -1;
40
41 static gint ett_spray = -1;
42 static gint ett_spray_clock = -1;
43
44
45 static int
46 dissect_get_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
47 {
48         proto_item* lock_item = NULL;
49         proto_tree* lock_tree = NULL;
50
51         offset = dissect_rpc_uint32(tvb, tree, 
52                         hf_spray_counter, offset);
53
54         lock_item = proto_tree_add_item(tree, hf_spray_clock, tvb,
55                         offset, -1, FALSE);
56
57         lock_tree = proto_item_add_subtree(lock_item, ett_spray_clock);
58
59         offset = dissect_rpc_uint32(tvb, lock_tree, 
60                         hf_spray_sec, offset);
61
62         offset = dissect_rpc_uint32(tvb, lock_tree, 
63                         hf_spray_usec, offset);
64
65         return offset;
66 }
67
68 static int
69 dissect_spray_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
70 {
71         offset = dissect_rpc_data(tvb, tree, 
72                         hf_spray_sprayarr, offset);
73
74         return offset;
75 }
76
77 /* proc number, "proc name", dissect_request, dissect_reply */
78 /* NULL as function pointer means: type of arguments is "void". */
79 static const vsff spray1_proc[] = {
80         { SPRAYPROC_NULL,       "NULL",
81                 NULL,   NULL },
82         { SPRAYPROC_SPRAY,      "SPRAY",
83                 dissect_spray_call,     NULL },
84         { SPRAYPROC_GET,        "GET",
85                 NULL,   dissect_get_reply },
86         { SPRAYPROC_CLEAR,      "CLEAR",
87                 NULL,   NULL },
88         { 0,    NULL,           NULL,                           NULL }
89 };
90
91 void
92 proto_register_spray(void)
93 {
94         static hf_register_info hf[] = {
95                 { &hf_spray_sprayarr, {
96                         "Data", "spray.sprayarr", FT_BYTES, BASE_DEC,
97                         NULL, 0, "Sprayarr data", HFILL }},
98
99                 { &hf_spray_counter, {
100                         "counter", "spray.counter", FT_UINT32, BASE_DEC,
101                         NULL, 0, "Counter", HFILL }},
102
103                 { &hf_spray_clock, {
104                         "clock", "spray.clock", FT_NONE, BASE_NONE,
105                         NULL, 0, "Clock", HFILL }},
106
107                 { &hf_spray_sec, {
108                         "sec", "spray.sec", FT_UINT32, BASE_DEC,
109                         NULL, 0, "Seconds", HFILL }},
110
111                 { &hf_spray_usec, {
112                         "usec", "spray.usec", FT_UINT32, BASE_DEC,
113                         NULL, 0, "Microseconds", HFILL }},
114
115         };
116
117         static gint *ett[] = {
118                 &ett_spray,
119                 &ett_spray_clock,
120         };
121
122         proto_spray = proto_register_protocol("SPRAY",
123             "SPRAY", "spray");
124         proto_register_field_array(proto_spray, hf, array_length(hf));
125         proto_register_subtree_array(ett, array_length(ett));
126 }
127
128 void
129 proto_reg_handoff_spray(void)
130 {
131         /* Register the protocol as RPC */
132         rpc_init_prog(proto_spray, SPRAY_PROGRAM, ett_spray);
133         /* Register the procedure tables */
134         rpc_init_proc_table(SPRAY_PROGRAM, 1, spray1_proc);
135 }
136