1 /*- 2 * Copyright (c) 2005 Andrey Simonenko 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * @(#)$Id: ipastat_st.h,v 1.2 2011/01/23 18:42:35 simon Exp $ 27 */ 28 29 #ifndef IPASTAT_ST_H 30 #define IPASTAT_ST_H 31 32 /* 33 * Statistics module, "st_mod" parameter. 34 */ 35 struct st_mod { 36 SLIST_ENTRY(st_mod) link; /* All st_mod list. */ 37 char *mod_file; /* Module's file name. */ 38 dl_handle mod_handle; /* dl-handle. */ 39 struct ipa_st_mod *ipa_st_mod; /* Module's struct ipa_st_mod{}. */ 40 struct conf_sect_hash *conf_sect_hash; /* Section lookup hash. */ 41 struct conf_param_hash *conf_param_hash; /* Parameter lookup hash. */ 42 }; 43 44 /* 45 * List of all statistics modules. 46 */ 47 SLIST_HEAD(st_mod_list, st_mod); 48 49 /* 50 * One element in "st_list" parameter. 51 */ 52 struct st_elem { 53 STAILQ_ENTRY(st_elem) link; /* All elements of one "st_list". */ 54 const char *mod_file; /* The same as st_mod { mod_file } */ 55 const struct ipa_st_mod *ipa_st_mod; /* st_mod { ipa_st_mod } */ 56 }; 57 58 /* 59 * "st_list" parameter. 60 */ 61 STAILQ_HEAD(st_list, st_elem); 62 63 /* 64 * List of all "st_list" parameters. 65 */ 66 struct st_set { 67 SLIST_ENTRY(st_set) link; /* All "st_list" parameters. */ 68 struct st_list list; /* One "st_list" parameter. */ 69 }; 70 71 /* 72 * List of all st_set. 73 */ 74 SLIST_HEAD(st_sets, st_set); 75 76 /* 77 * -s "name1 name2 ..." 78 */ 79 struct opt_st { 80 STAILQ_ENTRY(opt_st) link; /* Linked list of all -s ... -s ... */ 81 char *st_names; /* -s "name1 name2 ..." */ 82 const struct st_list *st_list; /* Pointer to corresponding st_list. */ 83 }; 84 85 /* 86 * List of all opt_st structures. 87 */ 88 STAILQ_HEAD(opt_st_list, opt_st); 89 90 extern struct opt_st *cur_opt_st; 91 extern struct opt_st_list opt_st_list; 92 93 extern struct st_mod_list st_mod_list; 94 95 extern struct st_sets st_sets; 96 97 extern const struct st_list *global_st_list; 98 99 extern signed char debug_st_null; 100 101 extern struct st_list st_list_null; 102 103 extern struct st_mod *st_mod_by_prefix(const char *); 104 extern struct st_mod *st_mod_by_name(const char *); 105 106 extern void free_st_lists(void); 107 108 extern int pre_init_st_mods(void); 109 extern int init_st_mods(void); 110 extern int deinit_st_mods(void); 111 112 extern int st_init_rule(const struct rule *); 113 extern int st_deinit_rule(const struct rule *); 114 extern int st_get_rules_list(const struct st_list *, unsigned int *, 115 struct ipa_entity_desc **); 116 extern int st_get_rule_stat(const struct rule *, const ipa_tm *, 117 const ipa_tm *, int, unsigned int *, 118 struct ipa_rule_stat **); 119 extern int st_get_rule_info(const struct rule *, char **); 120 121 #ifdef WITH_LIMITS 122 extern int st_init_limit(const struct rule *, const struct limit *); 123 extern int st_deinit_limit(const struct rule *, const struct limit *); 124 extern int st_get_limits_list(const struct rule *, unsigned int *, 125 struct ipa_entity_desc **); 126 extern int st_get_limit_stat(const struct rule *, const struct limit *, 127 const ipa_tm *, const ipa_tm *, unsigned int *, 128 struct ipa_limit_state **); 129 extern int st_get_limit_info(const struct rule *, const struct limit *, 130 char **); 131 #endif 132 133 #ifdef WITH_THRESHOLDS 134 extern int st_init_threshold(const struct rule *, 135 const struct threshold *); 136 extern int st_deinit_threshold(const struct rule *, 137 const struct threshold *); 138 extern int st_get_thresholds_list(const struct rule *, unsigned int *, 139 struct ipa_entity_desc **); 140 extern int st_get_threshold_stat(const struct rule *, 141 const struct threshold *, int *reged, 142 struct ipa_threshold_state *); 143 extern int st_get_threshold_info(const struct rule *, 144 const struct threshold *, char **); 145 #endif 146 147 extern int opt_st_add(char *); 148 extern void opt_st_free(void); 149 extern int opt_st_parse(void); 150 151 #endif /* !IPASTAT_ST_H */ 152