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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #include <vnet/session/transport_interface.h>
17 #include <vnet/session/session.h>
20 * Per-type vector of transport protocol virtual function tables
22 transport_proto_vft_t *tp_vfts;
25 transport_endpoint_lookup (transport_endpoint_table_t * ht,
26 ip46_address_t * ip, u16 port)
28 clib_bihash_kv_24_8_t kv;
31 kv.key[0] = ip->as_u64[0];
32 kv.key[1] = ip->as_u64[1];
35 rv = clib_bihash_search_inline_24_8 (ht, &kv);
39 return TRANSPORT_ENDPOINT_INVALID_INDEX;
43 transport_endpoint_table_add (transport_endpoint_table_t * ht,
44 transport_endpoint_t * te, u32 value)
46 clib_bihash_kv_24_8_t kv;
48 kv.key[0] = te->ip.as_u64[0];
49 kv.key[1] = te->ip.as_u64[1];
53 clib_bihash_add_del_24_8 (ht, &kv, 1);
57 transport_endpoint_table_del (transport_endpoint_table_t * ht,
58 transport_endpoint_t * te)
60 clib_bihash_kv_24_8_t kv;
62 kv.key[0] = te->ip.as_u64[0];
63 kv.key[1] = te->ip.as_u64[1];
66 clib_bihash_add_del_24_8 (ht, &kv, 0);
70 * Register transport virtual function table.
72 * @param type - session type (not protocol type)
73 * @param vft - virtual function table
76 session_register_transport (transport_proto_t transport_proto, u8 is_ip4,
77 const transport_proto_vft_t * vft)
80 session_type = session_type_from_proto_and_ip (transport_proto, is_ip4);
82 vec_validate (tp_vfts, session_type);
83 tp_vfts[session_type] = *vft;
85 /* If an offset function is provided, then peek instead of dequeue */
86 session_manager_set_transport_rx_fn (session_type,
87 vft->tx_fifo_offset != 0);
91 * Get transport virtual function table
93 * @param type - session type (not protocol type)
95 transport_proto_vft_t *
96 session_get_transport_vft (u8 session_type)
98 if (session_type >= vec_len (tp_vfts))
100 return &tp_vfts[session_type];
104 * fd.io coding-style-patch-verification: ON
107 * eval: (c-set-style "gnu")