FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
socket_api.h
Go to the documentation of this file.
1
/*
2
*------------------------------------------------------------------
3
* Copyright (c) 2018 Cisco and/or its affiliates.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at:
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*------------------------------------------------------------------
16
*/
17
18
#ifndef SRC_VLIBMEMORY_SOCKET_API_H_
19
#define SRC_VLIBMEMORY_SOCKET_API_H_
20
21
#include <
vlibapi/api_common.h
>
22
#include <
svm/ssvm.h
>
23
#include <
vppinfra/file.h
>
24
25
/* Deprecated */
26
#define API_SOCKET_FILE "/run/vpp/api.sock"
27
28
#define API_SOCKET_FILENAME "api.sock"
29
30
typedef
struct
31
{
32
u32
reg_index
;
33
u8
*
data
;
34
}
vl_socket_args_for_process_t
;
35
36
typedef
struct
37
{
38
/* Server port number */
39
u8
*
socket_name
;
40
41
/* By default, localhost... */
42
u32
bind_address
;
43
44
/*
45
* (listen, server, client) registrations. Shared memory
46
* registrations are in shared memory
47
*/
48
vl_api_registration_t
*
registration_pool
;
49
/*
50
* Chain-drag variables, so message API handlers
51
* (generally) don't know whether they're talking to a socket
52
* or to a shared-memory connection.
53
*/
54
vl_api_registration_t
*
current_rp
;
55
/* One input buffer, shared across all sockets */
56
i8
*
input_buffer
;
57
58
/* pool of process args for socket clients */
59
vl_socket_args_for_process_t
*
process_args
;
60
61
/* Listen for API connections here */
62
clib_socket_t
socksvr_listen_socket
;
63
}
socket_main_t
;
64
65
extern
socket_main_t
socket_main
;
66
67
always_inline
vl_api_registration_t
*
68
vl_socket_get_registration
(
u32
reg_index)
69
{
70
if
(
pool_is_free_index
(
socket_main
.
registration_pool
, reg_index))
71
return
0;
72
return
pool_elt_at_index
(
socket_main
.
registration_pool
, reg_index);
73
}
74
75
void
vl_socket_free_registration_index
(
u32
pool_index);
76
clib_error_t
*
vl_socket_read_ready
(
struct
clib_file
*uf);
77
clib_error_t
*
vl_socket_write_ready
(
struct
clib_file
*uf);
78
void
vl_socket_api_send
(
vl_api_registration_t
* rp,
u8
* elem);
79
void
vl_socket_process_api_msg
(
vl_api_registration_t
* rp,
i8
* input_v);
80
void
vl_sock_api_dump_clients
(
vlib_main_t
*
vm
,
api_main_t
*
am
);
81
clib_error_t
*
vl_sock_api_init
(
vlib_main_t
*
vm
);
82
clib_error_t
*
vl_sock_api_send_fd_msg
(
int
socket_fd,
int
fds[],
int
n_fds);
83
clib_error_t
*
vl_sock_api_recv_fd_msg
(
int
socket_fd,
int
fds[],
int
n_fds,
84
u32
wait);
85
86
vl_api_registration_t
*
vl_socket_api_client_handle_to_registration
(
u32
idx);
87
u8
vl_socket_api_registration_handle_is_valid
(
u32
reg_index);
88
89
#endif
/* SRC_VLIBMEMORY_SOCKET_API_H_ */
90
91
/*
92
* fd.io coding-style-patch-verification: ON
93
*
94
* Local Variables:
95
* eval: (c-set-style "gnu")
96
* End:
97
*/
socket_main_t::process_args
vl_socket_args_for_process_t * process_args
Definition:
socket_api.h:59
vl_socket_api_client_handle_to_registration
vl_api_registration_t * vl_socket_api_client_handle_to_registration(u32 idx)
Definition:
socket_api.c:99
vl_socket_process_api_msg
void vl_socket_process_api_msg(vl_api_registration_t *rp, i8 *input_v)
Definition:
socket_api.c:197
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition:
pool.h:553
socket_main_t::socket_name
u8 * socket_name
Definition:
socket_api.h:39
socket_main_t
Definition:
socket_api.h:36
am
app_main_t * am
Definition:
application.c:489
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition:
nat44_ei.c:3047
vl_socket_api_send
void vl_socket_api_send(vl_api_registration_t *rp, u8 *elem)
Definition:
socket_api.c:114
socket_main_t::current_rp
vl_api_registration_t * current_rp
Definition:
socket_api.h:54
pool_is_free_index
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition:
pool.h:302
clib_file
Definition:
file.h:51
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition:
api_common.h:47
vl_sock_api_dump_clients
void vl_sock_api_dump_clients(vlib_main_t *vm, api_main_t *am)
Definition:
socket_api.c:72
socket_main_t::socksvr_listen_socket
clib_socket_t socksvr_listen_socket
Definition:
socket_api.h:62
vl_socket_args_for_process_t::data
u8 * data
Definition:
socket_api.h:33
vl_sock_api_init
clib_error_t * vl_sock_api_init(vlib_main_t *vm)
Definition:
socket_api.c:774
vl_socket_read_ready
clib_error_t * vl_socket_read_ready(struct clib_file *uf)
Definition:
socket_api.c:260
api_main_t
API main structure, used by both vpp and binary API clients.
Definition:
api_common.h:228
socket_main_t::bind_address
u32 bind_address
Definition:
socket_api.h:42
always_inline
#define always_inline
Definition:
rdma_mlx5dv.h:23
vl_socket_write_ready
clib_error_t * vl_socket_write_ready(struct clib_file *uf)
Definition:
socket_api.c:380
vl_socket_args_for_process_t
Definition:
socket_api.h:30
vl_sock_api_send_fd_msg
clib_error_t * vl_sock_api_send_fd_msg(int socket_fd, int fds[], int n_fds)
Definition:
socket_api.c:559
i8
signed char i8
Definition:
types.h:45
u32
unsigned int u32
Definition:
types.h:88
vl_socket_get_registration
static vl_api_registration_t * vl_socket_get_registration(u32 reg_index)
Definition:
socket_api.h:68
vl_socket_args_for_process_t::reg_index
u32 reg_index
Definition:
socket_api.h:32
socket_main_t::input_buffer
i8 * input_buffer
Definition:
socket_api.h:56
vlib_main_t
Definition:
main.h:102
vl_socket_api_registration_handle_is_valid
u8 vl_socket_api_registration_handle_is_valid(u32 reg_index)
Definition:
socket_api.c:66
u8
unsigned char u8
Definition:
types.h:56
clib_error_t
Definition:
clib_error.h:21
vl_sock_api_recv_fd_msg
clib_error_t * vl_sock_api_recv_fd_msg(int socket_fd, int fds[], int n_fds, u32 wait)
Definition:
socket_client.c:332
file.h
api_common.h
ssvm.h
clib_socket_t
struct _socket_t clib_socket_t
vl_socket_free_registration_index
void vl_socket_free_registration_index(u32 pool_index)
Definition:
socket_api.c:169
socket_main_t::registration_pool
vl_api_registration_t * registration_pool
Definition:
socket_api.h:48
socket_main
socket_main_t socket_main
Definition:
socket_api.c:48
src
vlibmemory
socket_api.h
Generated on Sat Jan 8 2022 10:04:37 for FD.io VPP by
1.8.17