lib: modules: Change XXX_init interface from XXX_init(void) to XXX_init(TALLOC_CTX *)
[metze/samba-autobuild/.git] / source3 / include / smb_perfcount.h
1 /*
2    Unix SMB/CIFS implementation.
3    Portable SMB Messaging statistics interfaces
4    Copyright (C) Todd Stecher (2008)
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef _SMB_PERFCOUNT_H_
21 #define _SMB_PERFCOUNT_H_
22
23 /* Change to 2, loadable modules now take a TALLOC_CTX * parameter. */
24 #define SMB_PERFCOUNTER_INTERFACE_VERSION       2
25
26 struct smb_perfcount_data{
27         struct smb_perfcount_handlers *handlers;
28         void *context;
29 };
30
31 struct smb_perfcount_handlers {
32         void (*perfcount_start) (struct smb_perfcount_data *pcd);
33         void (*perfcount_add) (struct smb_perfcount_data *pcd);
34         void (*perfcount_set_op) (struct smb_perfcount_data *pcd, int op);
35         void (*perfcount_set_subop) (struct smb_perfcount_data *pcd, int subop);
36         void (*perfcount_set_ioctl) (struct smb_perfcount_data *pcd, int io_ctl);
37         void (*perfcount_set_msglen_in) (struct smb_perfcount_data *pcd,
38                                          uint64_t in_bytes);
39         void (*perfcount_set_msglen_out) (struct smb_perfcount_data *pcd,
40                                           uint64_t out_bytes);
41         void (*perfcount_copy_context) (struct smb_perfcount_data *pcd,
42                                         struct smb_perfcount_data *new_pcd);
43         void (*perfcount_defer_op) (struct smb_perfcount_data *pcd,
44                                     struct smb_perfcount_data *def_pcd);
45         void (*perfcount_end) (struct smb_perfcount_data *pcd);
46 };
47
48 bool smb_perfcount_init(void);
49
50 NTSTATUS smb_register_perfcounter(int interface_version, const char *name,
51                                   const struct smb_perfcount_handlers *handlers);
52
53 void smb_init_perfcount_data(struct smb_perfcount_data *pcd);
54
55 #define SMB_PERFCOUNT_START(_pcd_) \
56     do {if((_pcd_) && (_pcd_)->handlers) \
57             (_pcd_)->handlers->perfcount_start((_pcd_)); \
58     } while (0)
59
60 #define SMB_PERFCOUNT_ADD(_pcd_) \
61     do {if((_pcd_) && (_pcd_)->handlers) \
62             (_pcd_)->handlers->perfcount_add((_pcd_)); \
63     } while (0)
64
65 #define SMB_PERFCOUNT_SET_OP(_pcd_,_op_) \
66     do {if((_pcd_) && (_pcd_)->handlers) \
67             (_pcd_)->handlers->perfcount_set_op((_pcd_), (_op_)); \
68     } while (0)
69
70 #define SMB_PERFCOUNT_SET_SUBOP(_pcd_,_subop_) \
71     do {if((_pcd_) && (_pcd_)->handlers) \
72             (_pcd_)->handlers->perfcount_set_subop((_pcd_), (_subop_)); \
73     } while (0)
74
75 #define SMB_PERFCOUNT_SET_IOCTL(_pcd_,_subop_) \
76     do {if((_pcd_) && (_pcd_)->handlers) \
77             (_pcd_)->handlers->perfcount_set_ioctl((_pcd_), (_subop_)); \
78     } while (0)
79
80 #define SMB_PERFCOUNT_SET_MSGLEN_IN(_pcd_,_in_) \
81     do {if((_pcd_) && (_pcd_)->handlers) \
82             (_pcd_)->handlers->perfcount_set_msglen_in((_pcd_), (_in_));\
83     } while (0)
84
85 #define SMB_PERFCOUNT_SET_MSGLEN_OUT(_pcd_,_out_) \
86     do {if((_pcd_) && (_pcd_)->handlers) \
87             (_pcd_)->handlers->perfcount_set_msglen_out((_pcd_), (_out_));\
88     } while (0)
89
90 #define SMB_PERFCOUNT_COPY_CONTEXT(_pcd_, _new_pcd_) \
91     do {if((_pcd_) && (_pcd_)->handlers) \
92             (_pcd_)->handlers->perfcount_copy_context((_pcd_), (_new_pcd_)); \
93     } while (0)
94
95 #define SMB_PERFCOUNT_DEFER_OP(_pcd_, _def_pcd_) \
96     do {if((_pcd_) && (_pcd_)->handlers) \
97             (_pcd_)->handlers->perfcount_defer_op((_pcd_), (_def_pcd_)); \
98     } while (0)
99
100 #define SMB_PERFCOUNT_END(_pcd_) \
101     do {if((_pcd_) && (_pcd_)->handlers) \
102             (_pcd_)->handlers->perfcount_end((_pcd_));\
103     } while (0)
104
105 #endif /* _SMB_PERFCOUNT_H_ */