Emeric Brun | 3bd697e | 2010-01-04 15:23:48 +0100 | [diff] [blame] | 1 | /* |
| 2 | * include/proto/stick_table.h |
| 3 | * Functions for stick tables management. |
| 4 | * |
| 5 | * Copyright (C) 2009-2010 EXCELIANCE, Emeric Brun <ebrun@exceliance.fr> |
Willy Tarreau | 08d5f98 | 2010-06-06 13:34:54 +0200 | [diff] [blame] | 6 | * Copyright (C) 2010 Willy Tarreau <w@1wt.eu> |
Emeric Brun | 3bd697e | 2010-01-04 15:23:48 +0100 | [diff] [blame] | 7 | * |
| 8 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Lesser General Public |
| 10 | * License as published by the Free Software Foundation, version 2.1 |
| 11 | * exclusively. |
| 12 | * |
| 13 | * This library is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * Lesser General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Lesser General Public |
| 19 | * License along with this library; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | */ |
| 22 | |
| 23 | #ifndef _PROTO_STICK_TABLE_H |
| 24 | #define _PROTO_STICK_TABLE_H |
| 25 | |
| 26 | #include <types/stick_table.h> |
| 27 | |
| 28 | struct stksess *stksess_new(struct stktable *t, struct stktable_key *key); |
Willy Tarreau | 393379c | 2010-06-06 12:11:37 +0200 | [diff] [blame] | 29 | void stksess_setkey(struct stktable *t, struct stksess *ts, struct stktable_key *key); |
Emeric Brun | 3bd697e | 2010-01-04 15:23:48 +0100 | [diff] [blame] | 30 | void stksess_free(struct stktable *t, struct stksess *ts); |
| 31 | |
| 32 | int stktable_init(struct stktable *t); |
| 33 | int stktable_parse_type(char **args, int *idx, unsigned long *type, size_t *key_size); |
Willy Tarreau | f16d2b8 | 2010-06-06 15:38:59 +0200 | [diff] [blame] | 34 | struct stksess *stktable_store(struct stktable *t, struct stksess *ts); |
| 35 | struct stksess *stktable_lookup(struct stktable *t, struct stksess *ts); |
| 36 | struct stksess *stktable_lookup_key(struct stktable *t, struct stktable_key *key); |
Willy Tarreau | f0b38bf | 2010-06-06 13:22:23 +0200 | [diff] [blame] | 37 | struct stktable_key *stktable_fetch_key(struct proxy *px, struct session *l4, |
| 38 | void *l7, int dir, struct pattern_expr *expr, |
| 39 | unsigned long table_type); |
| 40 | int stktable_compatible_pattern(struct pattern_expr *expr, unsigned long table_type); |
Willy Tarreau | 08d5f98 | 2010-06-06 13:34:54 +0200 | [diff] [blame] | 41 | int stktable_get_data_type(char *name); |
| 42 | |
| 43 | /* reserve some space for data type <type>. Return non-0 if OK, or 0 if already |
| 44 | * allocated (or impossible type). |
| 45 | */ |
| 46 | static inline int stktable_alloc_data_type(struct stktable *t, int type) |
| 47 | { |
| 48 | if (type >= STKTABLE_DATA_TYPES) |
| 49 | return 0; |
| 50 | |
| 51 | if (t->data_ofs[type]) |
| 52 | /* already allocated */ |
| 53 | return 0; |
Emeric Brun | 3bd697e | 2010-01-04 15:23:48 +0100 | [diff] [blame] | 54 | |
Willy Tarreau | 08d5f98 | 2010-06-06 13:34:54 +0200 | [diff] [blame] | 55 | t->data_size += stktable_data_types[type].data_length; |
| 56 | t->data_ofs[type] = -t->data_size; |
| 57 | return 1; |
| 58 | } |
Emeric Brun | 3bd697e | 2010-01-04 15:23:48 +0100 | [diff] [blame] | 59 | |
| 60 | #endif /* _PROTO_STICK_TABLE_H */ |