From Didier Gautheron:
[obnox/wireshark/wip.git] / epan / dissectors / packet-stat-notify.c
1 /* packet-stat.c
2  * Routines for async NSM stat callback dissection
3  * 2001 Ronnie Sahlberg <See AUTHORS for email>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
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 #include "packet-rpc.h"
32 #include "packet-stat-notify.h"
33
34 static int proto_statnotify = -1;
35 static int hf_statnotify_procedure_v1 = -1;
36 static int hf_statnotify_name = -1;
37 static int hf_statnotify_state = -1;
38 static int hf_statnotify_priv = -1;
39
40 static gint ett_statnotify = -1;
41
42
43 static int
44 dissect_statnotify_mon(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
45 {
46
47         offset = dissect_rpc_string(tvb,tree,hf_statnotify_name,offset,NULL);
48
49         offset = dissect_rpc_uint32(tvb,tree,hf_statnotify_state,offset);
50
51         proto_tree_add_item(tree,hf_statnotify_priv,tvb,offset,16,FALSE);
52         offset += 16;
53
54         return offset;
55 }
56
57 /* proc number, "proc name", dissect_request, dissect_reply */
58 /* NULL as function pointer means: type of arguments is "void". */
59
60 static const vsff statnotify1_proc[] = {
61     { 0, "NULL", NULL, NULL },
62     { STATNOTIFYPROC_MON,   "MON-CALLBACK",
63                 dissect_statnotify_mon, NULL },
64     { 0, NULL, NULL, NULL }
65 };
66 static const value_string statnotify1_proc_vals[] = {
67     { 0, "NULL" },
68     { STATNOTIFYPROC_MON,   "MON-CALLBACK" },
69     { 0, NULL }
70 };
71 /* end of stat-notify version 1 */
72
73
74 void
75 proto_register_statnotify(void)
76 {
77         static hf_register_info hf[] = {
78                 { &hf_statnotify_procedure_v1, {
79                         "V1 Procedure", "statnotify.procedure_v1", FT_UINT32, BASE_DEC,
80                         VALS(statnotify1_proc_vals), 0, NULL, HFILL }},
81                 { &hf_statnotify_name, {
82                         "Name", "statnotify.name", FT_STRING, BASE_NONE,
83                         NULL, 0, "Name of client that changed", HFILL }},
84                 { &hf_statnotify_state, {
85                         "State", "statnotify.state", FT_UINT32, BASE_DEC,
86                         NULL, 0, "New state of client that changed", HFILL }},
87                 { &hf_statnotify_priv, {
88                         "Priv", "statnotify.priv", FT_BYTES, BASE_NONE,
89                         NULL, 0, "Client supplied opaque data", HFILL }},
90         };
91
92         static gint *ett[] = {
93                 &ett_statnotify,
94         };
95
96         proto_statnotify = proto_register_protocol("Network Status Monitor CallBack Protocol", "STAT-CB", "statnotify");
97         proto_register_field_array(proto_statnotify, hf, array_length(hf));
98         proto_register_subtree_array(ett, array_length(ett));
99 }
100
101 void
102 proto_reg_handoff_statnotify(void)
103 {
104         /* Register the protocol as RPC */
105         rpc_init_prog(proto_statnotify, STATNOTIFY_PROGRAM, ett_statnotify);
106         /* Register the procedure tables */
107         rpc_init_proc_table(STATNOTIFY_PROGRAM, 1, statnotify1_proc, hf_statnotify_procedure_v1);
108 }