blob: 5612a9809a55b51501c1f0319b1f298b57bd8033 [file] [log] [blame]
Florin Corase86a8ed2018-01-05 03:20:25 -08001/*
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>
23#include <vlibmemory/memory_shared.h>
24
25typedef struct
26{
27 int socket_fd;
28 /* Temporarily disable the connection, so we can keep it around... */
29 int socket_enable;
30
31 clib_socket_t client_socket;
32
33 u32 socket_buffer_size;
34 u8 *socket_tx_buffer;
35 u8 *socket_rx_buffer;
36 u32 socket_tx_nbytes;
37 int control_pings_outstanding;
38
39 u8 *name;
40 clib_time_t clib_time;
Florin Corasb384b542018-01-15 01:08:33 -080041 ssvm_private_t memfd_segment;
Florin Corase86a8ed2018-01-05 03:20:25 -080042} socket_client_main_t;
43
44extern socket_client_main_t socket_client_main;
45
46#define SOCKET_CLIENT_DEFAULT_BUFFER_SIZE 4096
47
48int vl_socket_client_connect (char *socket_path, char *client_name,
49 u32 socket_buffer_size);
50void vl_socket_client_disconnect (void);
51int vl_socket_client_read (int wait);
52int vl_socket_client_write (void);
53void vl_socket_client_enable_disable (int enable);
54void *vl_socket_client_msg_alloc (int nbytes);
55int vl_socket_client_init_shm (vl_api_shm_elem_config_t * config);
Florin Coras466f2892018-08-03 02:50:43 -070056clib_error_t *vl_socket_client_recv_fd_msg (int fds[], int n_fds, u32 wait);
Florin Corase86a8ed2018-01-05 03:20:25 -080057
58#endif /* SRC_VLIBMEMORY_SOCKET_CLIENT_H_ */
59
60/*
61 * fd.io coding-style-patch-verification: ON
62 *
63 * Local Variables:
64 * eval: (c-set-style "gnu")
65 * End:
66 */