Florin Coras | 04e5344 | 2017-07-16 17:12:15 -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_LOOKUP_H_ |
| 17 | #define SRC_VNET_SESSION_SESSION_LOOKUP_H_ |
| 18 | |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 19 | #include <vnet/session/session_table.h> |
Florin Coras | 04e5344 | 2017-07-16 17:12:15 -0700 | [diff] [blame] | 20 | #include <vnet/session/stream_session.h> |
| 21 | #include <vnet/session/transport.h> |
| 22 | |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 23 | stream_session_t *session_lookup_safe4 (u32 fib_index, ip4_address_t * lcl, |
| 24 | ip4_address_t * rmt, u16 lcl_port, |
| 25 | u16 rmt_port, u8 proto); |
| 26 | stream_session_t *session_lookup_safe6 (u32 fib_index, ip6_address_t * lcl, |
| 27 | ip6_address_t * rmt, u16 lcl_port, |
| 28 | u16 rmt_port, u8 proto); |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 29 | transport_connection_t *session_lookup_connection_wt4 (u32 fib_index, |
| 30 | ip4_address_t * lcl, |
| 31 | ip4_address_t * rmt, |
| 32 | u16 lcl_port, |
| 33 | u16 rmt_port, u8 proto, |
| 34 | u32 thread_index); |
| 35 | transport_connection_t *session_lookup_connection4 (u32 fib_index, |
| 36 | ip4_address_t * lcl, |
| 37 | ip4_address_t * rmt, |
| 38 | u16 lcl_port, |
| 39 | u16 rmt_port, u8 proto); |
| 40 | transport_connection_t *session_lookup_connection_wt6 (u32 fib_index, |
| 41 | ip6_address_t * lcl, |
| 42 | ip6_address_t * rmt, |
| 43 | u16 lcl_port, |
| 44 | u16 rmt_port, u8 proto, |
| 45 | u32 thread_index); |
| 46 | transport_connection_t *session_lookup_connection6 (u32 fib_index, |
| 47 | ip6_address_t * lcl, |
| 48 | ip6_address_t * rmt, |
| 49 | u16 lcl_port, |
| 50 | u16 rmt_port, u8 proto); |
| 51 | stream_session_t *session_lookup_listener4 (u32 fib_index, |
| 52 | ip4_address_t * lcl, u16 lcl_port, |
| 53 | u8 proto); |
| 54 | stream_session_t *session_lookup_listener6 (u32 fib_index, |
| 55 | ip6_address_t * lcl, u16 lcl_port, |
| 56 | u8 proto); |
| 57 | stream_session_t *session_lookup_listener (u32 table_index, |
| 58 | session_endpoint_t * sep); |
| 59 | int session_lookup_add_connection (transport_connection_t * tc, u64 value); |
| 60 | int session_lookup_del_connection (transport_connection_t * tc); |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 61 | u64 session_lookup_session_endpoint (u32 table_index, |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 62 | session_endpoint_t * sep); |
| 63 | u32 session_lookup_local_session_endpoint (u32 table_index, |
| 64 | session_endpoint_t * sep); |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 65 | stream_session_t *session_lookup_global_session_endpoint (session_endpoint_t |
| 66 | *); |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 67 | int session_lookup_add_session_endpoint (u32 table_index, |
| 68 | session_endpoint_t * sep, u64 value); |
| 69 | int session_lookup_del_session_endpoint (u32 table_index, |
| 70 | session_endpoint_t * sep); |
| 71 | int session_lookup_del_session (stream_session_t * s); |
| 72 | int session_lookup_del_half_open (transport_connection_t * tc); |
| 73 | int session_lookup_add_half_open (transport_connection_t * tc, u64 value); |
| 74 | u64 session_lookup_half_open_handle (transport_connection_t * tc); |
| 75 | transport_connection_t *session_lookup_half_open_connection (u64 handle, |
Florin Coras | 04e5344 | 2017-07-16 17:12:15 -0700 | [diff] [blame] | 76 | u8 proto, |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 77 | u8 is_ip4); |
| 78 | u32 session_lookup_get_index_for_fib (u32 fib_proto, u32 fib_index); |
Florin Coras | 04e5344 | 2017-07-16 17:12:15 -0700 | [diff] [blame] | 79 | |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 80 | u64 session_lookup_local_listener_make_handle (session_endpoint_t * sep); |
| 81 | u8 session_lookup_local_is_handle (u64 handle); |
| 82 | int session_lookup_local_listener_parse_handle (u64 handle, |
| 83 | session_endpoint_t * sep); |
Florin Coras | 04e5344 | 2017-07-16 17:12:15 -0700 | [diff] [blame] | 84 | |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 85 | void session_lookup_show_table_entries (vlib_main_t * vm, |
| 86 | session_table_t * table, u8 type, |
| 87 | u8 is_local); |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame^] | 88 | |
| 89 | enum _session_rule_scope |
| 90 | { |
| 91 | SESSION_RULE_SCOPE_GLOBAL = 1, |
| 92 | SESSION_RULE_SCOPE_LOCAL = 2, |
| 93 | } session_rule_scope_e; |
| 94 | |
| 95 | typedef struct _session_rule_add_del_args |
| 96 | { |
| 97 | /** |
| 98 | * Actual arguments to adding the rule to a session rules table |
| 99 | */ |
| 100 | session_rule_table_add_del_args_t table_args; |
| 101 | /** |
| 102 | * Application namespace where rule should be applied. If 0, |
| 103 | * default namespace is used. |
| 104 | */ |
| 105 | u32 appns_index; |
| 106 | /** |
| 107 | * Rule scope flag. |
| 108 | */ |
| 109 | u8 scope; |
| 110 | } session_rule_add_del_args_t; |
| 111 | |
| 112 | clib_error_t *vnet_session_rule_add_del (session_rule_add_del_args_t * args); |
| 113 | |
Florin Coras | 04e5344 | 2017-07-16 17:12:15 -0700 | [diff] [blame] | 114 | void session_lookup_init (void); |
| 115 | |
| 116 | #endif /* SRC_VNET_SESSION_SESSION_LOOKUP_H_ */ |
| 117 | |
| 118 | /* |
| 119 | * fd.io coding-style-patch-verification: ON |
| 120 | * |
| 121 | * Local Variables: |
| 122 | * eval: (c-set-style "gnu") |
| 123 | * End: |
| 124 | */ |