blob: 31b1f647e23387841f1cfc283f50a4bab0280435 [file] [log] [blame]
Florin Corascea194d2017-10-02 00:18:51 -07001/*
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 Coras1c710452017-10-17 00:03:13 -070021#include <vnet/session/session_rules_table.h>
Florin Corascea194d2017-10-02 00:18:51 -070022
23typedef 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 Coras1c710452017-10-17 00:03:13 -070036
37 /**
38 * Per fib proto and transport proto session rules tables
39 */
Florin Corasc97a7392017-11-05 23:07:07 -080040 session_rules_table_t session_rules[TRANSPORT_N_PROTO];
Florin Coras6c36f532017-11-03 18:32:34 -070041
42 /** Flag that indicates if table has local scope */
43 u8 is_local;
44
45 /** Namespace this table belongs to */
46 u32 appns_index;
47
48 /** For global tables only one fib proto is active. This is a
49 * byproduct of fib table ids not necessarily being the same for
50 * identical fib idices of v4 and v6 fib protos */
51 u8 active_fib_proto;
Florin Corascea194d2017-10-02 00:18:51 -070052} session_table_t;
53
54#define SESSION_TABLE_INVALID_INDEX ((u32)~0)
55#define SESSION_LOCAL_TABLE_PREFIX ((u32)~0)
56#define SESSION_INVALID_INDEX ((u32)~0)
Florin Coras3cbc04b2017-10-02 00:18:51 -070057#define SESSION_INVALID_HANDLE ((u64)~0)
Florin Corasf8f516a2018-02-08 15:10:09 -080058#define SESSION_DROP_HANDLE (((u64)~0) - 1)
Florin Corascea194d2017-10-02 00:18:51 -070059
60typedef int (*ip4_session_table_walk_fn_t) (clib_bihash_kv_16_8_t * kvp,
61 void *ctx);
62
63void ip4_session_table_walk_cb (clib_bihash_kv_16_8_t * kvp, void *arg);
64void ip4_session_table_walk (clib_bihash_16_8_t * hash,
65 ip4_session_table_walk_fn_t fn, void *arg);
66
67session_table_t *session_table_alloc (void);
68session_table_t *session_table_get (u32 table_index);
69u32 session_table_index (session_table_t * slt);
Florin Coras6c36f532017-11-03 18:32:34 -070070void session_table_init (session_table_t * slt, u8 fib_proto);
71
72/* Internal, try not to use it! */
73session_table_t *_get_session_tables ();
74
75#define session_table_foreach(VAR, BODY) \
76 pool_foreach(VAR, _get_session_tables (), BODY)
Florin Corascea194d2017-10-02 00:18:51 -070077
78#endif /* SRC_VNET_SESSION_SESSION_TABLE_H_ */
79/* *INDENT-ON* */
80/*
81 * fd.io coding-style-patch-verification: ON
82 *
83 * Local Variables:
84 * eval: (c-set-style "gnu")
85 * End:
86 */