Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #ifndef SRC_VNET_SESSION_SESSION_TABLE_H_ |
| 17 | #define SRC_VNET_SESSION_SESSION_TABLE_H_ |
| 18 | |
| 19 | #include <vppinfra/bihash_16_8.h> |
| 20 | #include <vppinfra/bihash_48_8.h> |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 21 | #include <vnet/session/session_rules_table.h> |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 22 | |
| 23 | typedef struct _session_lookup_table |
| 24 | { |
| 25 | /** |
| 26 | * Lookup tables for established sessions and listeners |
| 27 | */ |
| 28 | clib_bihash_16_8_t v4_session_hash; |
| 29 | clib_bihash_48_8_t v6_session_hash; |
| 30 | |
| 31 | /** |
| 32 | * Lookup tables for half-open sessions |
| 33 | */ |
| 34 | clib_bihash_16_8_t v4_half_open_hash; |
| 35 | clib_bihash_48_8_t v6_half_open_hash; |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * Per fib proto and transport proto session rules tables |
| 39 | */ |
| 40 | session_rules_table_t session_rules; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 41 | } session_table_t; |
| 42 | |
| 43 | #define SESSION_TABLE_INVALID_INDEX ((u32)~0) |
| 44 | #define SESSION_LOCAL_TABLE_PREFIX ((u32)~0) |
| 45 | #define SESSION_INVALID_INDEX ((u32)~0) |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 46 | #define SESSION_INVALID_HANDLE ((u64)~0) |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 47 | |
| 48 | typedef int (*ip4_session_table_walk_fn_t) (clib_bihash_kv_16_8_t * kvp, |
| 49 | void *ctx); |
| 50 | |
| 51 | void ip4_session_table_walk_cb (clib_bihash_kv_16_8_t * kvp, void *arg); |
| 52 | void ip4_session_table_walk (clib_bihash_16_8_t * hash, |
| 53 | ip4_session_table_walk_fn_t fn, void *arg); |
| 54 | |
| 55 | session_table_t *session_table_alloc (void); |
| 56 | session_table_t *session_table_get (u32 table_index); |
| 57 | u32 session_table_index (session_table_t * slt); |
| 58 | void session_table_init (session_table_t * slt); |
| 59 | |
| 60 | #endif /* SRC_VNET_SESSION_SESSION_TABLE_H_ */ |
| 61 | /* *INDENT-ON* */ |
| 62 | /* |
| 63 | * fd.io coding-style-patch-verification: ON |
| 64 | * |
| 65 | * Local Variables: |
| 66 | * eval: (c-set-style "gnu") |
| 67 | * End: |
| 68 | */ |