FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
socket_client.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_CLIENT_H_
19 #define SRC_VLIBMEMORY_SOCKET_CLIENT_H_
20 
21 #include <vppinfra/file.h>
22 #include <vppinfra/time.h>
24 
25 typedef struct
26 {
27  int socket_fd;
28  int socket_enable; /**< Can temporarily disable the connection
29  but still can keep it around... */
30  u32 client_index; /**< Client index allocated by VPP */
31 
33 
39 
40  u8 *name;
43 
46 
48 
49 #define SOCKET_CLIENT_DEFAULT_BUFFER_SIZE 4096
50 
51 int vl_socket_client_connect (char *socket_path, char *client_name,
52  u32 socket_buffer_size);
53 void vl_socket_client_disconnect (void);
54 void vl_socket_client_enable_disable (int enable);
55 int vl_socket_client_read (int wait);
56 int vl_socket_client_write (void);
57 void *vl_socket_client_msg_alloc (int nbytes);
59  int want_pthread);
60 clib_error_t *vl_socket_client_recv_fd_msg (int fds[], int n_fds, u32 wait);
61 
62 /*
63  * Socket client apis that explicitly pass socket main as an argument
64  */
65 
66 int vl_socket_client_connect2 (socket_client_main_t * scm, char *socket_path,
67  char *client_name, u32 socket_buffer_size);
70  int enable);
71 int vl_socket_client_read2 (socket_client_main_t * scm, int wait);
73 void *vl_socket_client_msg_alloc2 (socket_client_main_t * scm, int nbytes);
75  vl_api_shm_elem_config_t * config,
76  int want_pthread);
78  int fds[], int n_fds, u32 wait);
79 
80 #endif /* SRC_VLIBMEMORY_SOCKET_CLIENT_H_ */
81 
82 /*
83  * fd.io coding-style-patch-verification: ON
84  *
85  * Local Variables:
86  * eval: (c-set-style "gnu")
87  * End:
88  */
vl_socket_client_connect
int vl_socket_client_connect(char *socket_path, char *client_name, u32 socket_buffer_size)
Definition: socket_client.c:502
vl_socket_client_init_shm
int vl_socket_client_init_shm(vl_api_shm_elem_config_t *config, int want_pthread)
Definition: socket_client.c:561
socket_client_main_t::socket_rx_buffer
u8 * socket_rx_buffer
Definition: socket_client.h:36
socket_client_main_t::socket_tx_buffer
u8 * socket_tx_buffer
Definition: socket_client.h:35
socket_client_main_t::memfd_segment
ssvm_private_t memfd_segment
Definition: socket_client.h:42
socket_client_main_t::socket_enable
int socket_enable
Can temporarily disable the connection but still can keep it around...
Definition: socket_client.h:28
vl_socket_client_recv_fd_msg
clib_error_t * vl_socket_client_recv_fd_msg(int fds[], int n_fds, u32 wait)
Definition: socket_client.c:593
socket_client_main_t
Definition: socket_client.h:25
vl_socket_client_read
int vl_socket_client_read(int wait)
Definition: socket_client.c:157
socket_client_main_t::socket_fd
int socket_fd
Definition: socket_client.h:27
socket_client_main_t::socket_buffer_size
u32 socket_buffer_size
Definition: socket_client.h:34
socket_client_main_t::socket_tx_nbytes
u32 socket_tx_nbytes
Definition: socket_client.h:37
socket_client_main_t::clib_time
clib_time_t clib_time
Definition: socket_client.h:41
vl_socket_client_recv_fd_msg2
clib_error_t * vl_socket_client_recv_fd_msg2(socket_client_main_t *scm, int fds[], int n_fds, u32 wait)
Definition: socket_client.c:584
socket_client_main_t::client_socket
clib_socket_t client_socket
Definition: socket_client.h:32
socket_client_main_t::control_pings_outstanding
int control_pings_outstanding
Definition: socket_client.h:38
socket_client_main_t::want_shm_pthread
int want_shm_pthread
Definition: socket_client.h:44
vl_socket_client_write
int vl_socket_client_write(void)
Definition: socket_client.c:203
time.h
vl_socket_client_enable_disable
void vl_socket_client_enable_disable(int enable)
Definition: socket_client.c:259
vl_socket_client_disconnect2
void vl_socket_client_disconnect2(socket_client_main_t *scm)
Definition: socket_client.c:234
vl_socket_client_read2
int vl_socket_client_read2(socket_client_main_t *scm, int wait)
Definition: socket_client.c:163
vl_socket_client_msg_alloc
void * vl_socket_client_msg_alloc(int nbytes)
Definition: socket_client.c:228
clib_time_t
Definition: time.h:44
u32
unsigned int u32
Definition: types.h:88
memory_shared.h
vl_socket_client_connect2
int vl_socket_client_connect2(socket_client_main_t *scm, char *socket_path, char *client_name, u32 socket_buffer_size)
Definition: socket_client.c:510
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vl_socket_client_enable_disable2
void vl_socket_client_enable_disable2(socket_client_main_t *scm, int enable)
Definition: socket_client.c:253
vl_socket_client_init_shm2
int vl_socket_client_init_shm2(socket_client_main_t *scm, vl_api_shm_elem_config_t *config, int want_pthread)
Definition: socket_client.c:569
file.h
socket_client_main_t::name
u8 * name
Definition: socket_client.h:40
socket_client_main_t::client_index
u32 client_index
Client index allocated by VPP.
Definition: socket_client.h:30
ssvm_private_t
Definition: ssvm.h:81
clib_socket_t
struct _socket_t clib_socket_t
vl_socket_client_write2
int vl_socket_client_write2(socket_client_main_t *scm)
Definition: socket_client.c:209
socket_client_main
socket_client_main_t socket_client_main
Definition: socket_client.c:45
vl_api_shm_elem_config_
Definition: memory_shared.h:51
vl_socket_client_disconnect
void vl_socket_client_disconnect(void)
Definition: socket_client.c:247
vl_socket_client_msg_alloc2
void * vl_socket_client_msg_alloc2(socket_client_main_t *scm, int nbytes)
Definition: socket_client.c:221