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_limits.h,v 1.2 2011/01/23 18:42:35 simon Exp $ 27 */ 28 29 #ifndef IPASTAT_LIMITS_H 30 #define IPASTAT_LIMITS_H 31 32 #ifdef WITH_LIMITS 33 34 #ifndef LIMIT_NSIZE 35 # define LIMIT_NSIZE 30 36 #endif 37 38 #ifndef LIMIT_NALLOC 39 # define LIMIT_NALLOC 20 40 #endif 41 42 struct rule; 43 struct opt_rule; 44 45 #define LIMIT_FREE_NAME 0x01 /* Free 'name' in struct limit{} */ 46 47 /* 48 * limit{} section 49 */ 50 struct limit { 51 STAILQ_ENTRY(limit) link; /* Link for list of limits. */ 52 53 char *name; /* Name of this limit. */ 54 char *info; /* Info for this limit. */ 55 unsigned int no; /* Limit ordinal number. */ 56 57 const struct st_list *st_list; /* { st_list } */ 58 59 unsigned int free_mask; /* LIMIT_FREE_xxx bits. */ 60 61 int inited; /* Set if limit was initialized. */ 62 }; 63 64 /* 65 * List of all limits in one rule. 66 */ 67 STAILQ_HEAD(limits_list, limit); 68 69 /* 70 * Limit in query: -q ... -l <name> 71 */ 72 struct opt_limit { 73 STAILQ_ENTRY(opt_limit) link; /* For list building. */ 74 75 const char *name; /* -l <name> */ 76 struct limit *limit; /* Corresponding limit structure. */ 77 78 const struct opt_st *opt_st; /* Corresponding -s ... */ 79 80 void *data; /* Opaque data. */ 81 }; 82 83 /* 84 * Several limits in query: -q ... -l <name1> -l <name2> ... 85 */ 86 STAILQ_HEAD(opt_limits, opt_limit); 87 88 extern signed char dynamic_limits; 89 90 extern ipa_mzone *limit_mzone; 91 92 extern struct limit *alloc_limit(void); 93 94 extern int init_limits(const struct opt_rule *); 95 extern int deinit_limits(const struct opt_rule *); 96 97 extern void free_limits(struct limits_list *); 98 extern int copy_limits(struct rule *, const struct limits_list *); 99 100 extern int opt_limit_add(const char *); 101 extern int opt_limits_parse(const struct opt_rule *); 102 extern void opt_limits_free(const struct opt_limits *); 103 104 extern struct limit *limit_by_name(const struct rule *, const char *); 105 106 #endif /* WITH_LIMITS */ 107 108 extern char has_opt_limits; 109 110 #endif /* !IPASTAT_LIMITS_H */ 111