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 | #include <vnet/vnet.h> |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 17 | #include <vnet/session/session_table.h> |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 18 | |
| 19 | #ifndef SRC_VNET_SESSION_APPLICATION_NAMESPACE_H_ |
| 20 | #define SRC_VNET_SESSION_APPLICATION_NAMESPACE_H_ |
| 21 | |
| 22 | typedef struct _app_namespace |
| 23 | { |
| 24 | /** |
| 25 | * Local sw_if_index that supports transport connections for this namespace |
| 26 | */ |
| 27 | u32 sw_if_index; |
| 28 | |
| 29 | /** |
| 30 | * Network namespace (e.g., fib_index associated to the sw_if_index) |
| 31 | * wherein connections are to be established. Since v4 and v6 fibs are |
| 32 | * separate, we actually need to keep pointers to both. |
| 33 | */ |
| 34 | u32 ip4_fib_index; |
| 35 | u32 ip6_fib_index; |
| 36 | |
| 37 | /** |
| 38 | * Local session table associated to ns |
| 39 | */ |
| 40 | u32 local_table_index; |
| 41 | |
| 42 | /** |
| 43 | * Secret apps need to provide to authorize attachment to the namespace |
| 44 | */ |
| 45 | u64 ns_secret; |
| 46 | |
| 47 | /** |
| 48 | * Application namespace id |
| 49 | */ |
| 50 | u8 *ns_id; |
| 51 | } app_namespace_t; |
| 52 | |
| 53 | typedef struct _vnet_app_namespace_add_del_args |
| 54 | { |
| 55 | u8 *ns_id; |
| 56 | u64 secret; |
| 57 | u32 sw_if_index; |
| 58 | u32 ip4_fib_id; |
| 59 | u32 ip6_fib_id; |
| 60 | u8 is_add; |
| 61 | } vnet_app_namespace_add_del_args_t; |
| 62 | |
| 63 | #define APP_NAMESPACE_INVALID_INDEX ((u32)~0) |
| 64 | |
| 65 | app_namespace_t *app_namespace_alloc (u8 * ns_id); |
| 66 | app_namespace_t *app_namespace_get (u32 index); |
| 67 | app_namespace_t *app_namespace_get_from_id (const u8 * ns_id); |
| 68 | u32 app_namespace_index (app_namespace_t * app_ns); |
| 69 | const u8 *app_namespace_id (app_namespace_t * app_ns); |
| 70 | const u8 *app_namespace_id_from_index (u32 index); |
| 71 | u32 app_namespace_index_from_id (const u8 * ns_id); |
| 72 | void app_namespaces_init (void); |
| 73 | clib_error_t *vnet_app_namespace_add_del (vnet_app_namespace_add_del_args_t * |
| 74 | a); |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 75 | u32 app_namespace_get_fib_index (app_namespace_t * app_ns, u8 fib_proto); |
| 76 | session_table_t *app_namespace_get_local_table (app_namespace_t * app_ns); |
| 77 | |
| 78 | always_inline app_namespace_t * |
| 79 | app_namespace_get_default (void) |
| 80 | { |
| 81 | return app_namespace_get (0); |
| 82 | } |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 83 | |
| 84 | #endif /* SRC_VNET_SESSION_APPLICATION_NAMESPACE_H_ */ |
| 85 | |
| 86 | /* |
| 87 | * fd.io coding-style-patch-verification: ON |
| 88 | * |
| 89 | * Local Variables: |
| 90 | * eval: (c-set-style "gnu") |
| 91 | * End: |
| 92 | */ |