FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
transport_interface.c
Go to the documentation of this file.
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 
17 #include <vnet/session/session.h>
18 
19 /**
20  * Per-type vector of transport protocol virtual function tables
21  */
23 
24 u32
26  ip46_address_t * ip, u16 port)
27 {
29  int rv;
30 
31  kv.key[0] = ip->as_u64[0];
32  kv.key[1] = ip->as_u64[1];
33  kv.key[2] = port;
34 
35  rv = clib_bihash_search_inline_24_8 (ht, &kv);
36  if (rv == 0)
37  return kv.value;
38 
40 }
41 
42 void
44  transport_endpoint_t * te, u32 value)
45 {
47 
48  kv.key[0] = te->ip.as_u64[0];
49  kv.key[1] = te->ip.as_u64[1];
50  kv.key[2] = te->port;
51  kv.value = value;
52 
53  clib_bihash_add_del_24_8 (ht, &kv, 1);
54 }
55 
56 void
59 {
61 
62  kv.key[0] = te->ip.as_u64[0];
63  kv.key[1] = te->ip.as_u64[1];
64  kv.key[2] = te->port;
65 
66  clib_bihash_add_del_24_8 (ht, &kv, 0);
67 }
68 
69 /**
70  * Register transport virtual function table.
71  *
72  * @param type - session type (not protocol type)
73  * @param vft - virtual function table
74  */
75 void
77  const transport_proto_vft_t * vft)
78 {
79  u8 session_type;
80  session_type = session_type_from_proto_and_ip (transport_proto, is_ip4);
81 
82  vec_validate (tp_vfts, session_type);
83  tp_vfts[session_type] = *vft;
84 
85  /* If an offset function is provided, then peek instead of dequeue */
87  vft->tx_fifo_offset != 0);
88 }
89 
90 /**
91  * Get transport virtual function table
92  *
93  * @param type - session type (not protocol type)
94  */
97 {
98  if (session_type >= vec_len (tp_vfts))
99  return 0;
100  return &tp_vfts[session_type];
101 }
102 
103 /*
104  * fd.io coding-style-patch-verification: ON
105  *
106  * Local Variables:
107  * eval: (c-set-style "gnu")
108  * End:
109  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:432
void session_register_transport(transport_proto_t transport_proto, u8 is_ip4, const transport_proto_vft_t *vft)
Register transport virtual function table.
struct _transport_proto_vft transport_proto_vft_t
u32 transport_endpoint_lookup(transport_endpoint_table_t *ht, ip46_address_t *ip, u16 port)
clib_bihash_24_8_t transport_endpoint_table_t
void transport_endpoint_table_add(transport_endpoint_table_t *ht, transport_endpoint_t *te, u32 value)
#define TRANSPORT_ENDPOINT_INVALID_INDEX
void transport_endpoint_table_del(transport_endpoint_table_t *ht, transport_endpoint_t *te)
static void session_manager_set_transport_rx_fn(u8 type, u8 is_peek)
Definition: session.h:412
unsigned int u32
Definition: types.h:88
session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
Definition: session.c:820
unsigned short u16
Definition: types.h:57
enum _transport_proto transport_proto_t
transport_proto_vft_t * session_get_transport_vft(u8 session_type)
Get transport virtual function table.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
transport_proto_vft_t * tp_vfts
Per-type vector of transport protocol virtual function tables.
struct _transport_endpoint transport_endpoint_t