Rename "stat.priv" to "statnotify.priv", to avoid colliding with the NSM
[obnox/wireshark/wip.git] / packet-stat-notify.c
1 /* packet-stat.c
2  * Routines for async NSM stat callback dissection
3  * 2001 Ronnie Sahlberg <rsahlber@bigpond.net.au>
4  *
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@zing.org>
8  * Copyright 1998 Gerald Combs
9  *
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30
31 #ifdef HAVE_SYS_TYPES_H
32 #include <sys/types.h>
33 #endif
34
35 #include "packet-rpc.h"
36 #include "packet-stat-notify.h"
37
38 static int proto_statnotify = -1;
39 static int hf_statnotify_name = -1;
40 static int hf_statnotify_state = -1;
41 static int hf_statnotify_priv = -1;
42
43 static gint ett_statnotify = -1;
44
45
46 static int
47 dissect_statnotify_mon(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
48 {
49
50         offset = dissect_rpc_string_tvb(tvb,pinfo,tree,hf_statnotify_name,offset,NULL);
51
52         offset = dissect_rpc_uint32_tvb(tvb,pinfo,tree,hf_statnotify_state,offset);
53
54         proto_tree_add_item(tree,hf_statnotify_priv,tvb,offset,16,FALSE);
55         offset += 16;
56
57         return offset;
58 }
59
60 /* proc number, "proc name", dissect_request, dissect_reply */
61 /* NULL as function pointer means: type of arguments is "void". */
62
63 static const vsff statnotify_proc[] = {
64     { 0, "NULL", NULL, NULL },
65     { STATNOTIFYPROC_MON,   "MON-CALLBACK",      
66                 dissect_statnotify_mon, NULL },
67     { 0, NULL, NULL, NULL }
68 };
69 /* end of stat-notify version 1 */
70
71
72 void
73 proto_register_statnotify(void)
74 {
75         static hf_register_info hf[] = {
76                 { &hf_statnotify_name, {
77                         "Name", "statnotify.name", FT_STRING, BASE_DEC,
78                         NULL, 0, "Name of client that changed" }},
79                 { &hf_statnotify_state, {
80                         "State", "statnotify.state", FT_UINT32, BASE_DEC,
81                         NULL, 0, "New state of client that changed" }},
82                 { &hf_statnotify_priv, {
83                         "Priv", "statnotify.priv", FT_BYTES, BASE_HEX,
84                         NULL, 0, "Client supplied opaque data" }},
85         };
86         
87         static gint *ett[] = {
88                 &ett_statnotify,
89         };
90
91         proto_statnotify = proto_register_protocol("Network Status Monitor CallBack Protocol", "STAT-CB", "stat-cb");
92         proto_register_field_array(proto_statnotify, hf, array_length(hf));
93         proto_register_subtree_array(ett, array_length(ett));
94 }
95
96 void
97 proto_reg_handoff_statnotify(void)
98 {
99         /* Register the protocol as RPC */
100         rpc_init_prog(proto_statnotify, STATNOTIFY_PROGRAM, ett_statnotify);
101         /* Register the procedure tables */
102         rpc_init_proc_table(STATNOTIFY_PROGRAM, 1, statnotify_proc);
103 }