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_thresholds.h,v 1.2 2011/01/23 18:42:35 simon Exp $ 27 */ 28 29 #ifndef IPASTAT_THRESHOLDS_H 30 #define IPASTAT_THRESHOLDS_H 31 32 #ifdef WITH_THRESHOLDS 33 34 #ifndef THRESHOLD_NSIZE 35 # define THRESHOLD_NSIZE 30 36 #endif 37 38 #ifndef THRESHOLD_NALLOC 39 # define THRESHOLD_NALLOC 20 40 #endif 41 42 struct rule; 43 struct opt_rule; 44 45 #define THRESHOLD_FREE_NAME 0x01 /* Free 'name' in struct threshold{} */ 46 47 /* 48 * threshold{} section. 49 */ 50 struct threshold { 51 STAILQ_ENTRY(threshold) link; /* Link for list of thresholds. */ 52 53 char *name; /* Name of this threshold. */ 54 char *info; /* Info for this threshold. */ 55 unsigned int no; /* Threshold ordinal number. */ 56 57 const struct st_list *st_list; /* { st_list } */ 58 59 unsigned int free_mask; /* THRESHOLD_FREE_xxx bits. */ 60 61 int inited; /* Set if threshold was initialized. */ 62 }; 63 64 /* 65 * List of all thresholds in one rule. 66 */ 67 STAILQ_HEAD(thresholds_list, threshold); 68 69 /* 70 * Threshold in query: -q ... -t <name> 71 */ 72 struct opt_threshold { 73 STAILQ_ENTRY(opt_threshold) link; /* For list building. */ 74 75 const char *name; /* -t <name> */ 76 struct threshold *threshold; /* Corresponding threshold structure. */ 77 78 const struct opt_st *opt_st; /* Corresponding -s ... */ 79 80 int reged; /* Set if threshold has state. */ 81 struct ipa_threshold_state state;/* Threshold state. */ 82 }; 83 84 /* 85 * Several thresholds in query: -q ... -t <name1> -t <name2> ... 86 */ 87 STAILQ_HEAD(opt_thresholds, opt_threshold); 88 89 extern signed char dynamic_thresholds; 90 91 extern ipa_mzone *threshold_mzone; 92 93 extern struct threshold *alloc_threshold(void); 94 95 extern int init_thresholds(const struct opt_rule *); 96 extern int deinit_thresholds(const struct opt_rule *); 97 98 extern void free_thresholds(struct thresholds_list *); 99 extern int copy_thresholds(struct rule *, const struct thresholds_list *); 100 101 extern int opt_threshold_add(const char *); 102 extern int opt_thresholds_parse(const struct opt_rule *); 103 extern void opt_thresholds_free(const struct opt_thresholds *); 104 105 extern struct threshold *threshold_by_name(const struct rule *, const char *); 106 107 #endif /* WITH_THRESHOLDS */ 108 109 extern char has_opt_thresholds; 110 111 #endif /* !IPASTAT_THRESHOLDS_H */ 112