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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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 *------------------------------------------------------------------
18 #ifndef SRC_VLIBMEMORY_SOCKET_API_H_
19 #define SRC_VLIBMEMORY_SOCKET_API_H_
21 #include <vlibapi/api_common.h>
23 #include <vppinfra/file.h>
26 #define API_SOCKET_FILE "/run/vpp/api.sock"
28 #define API_SOCKET_FILENAME "api.sock"
34 } vl_socket_args_for_process_t;
38 /* Server port number */
41 /* By default, localhost... */
45 * (listen, server, client) registrations. Shared memory
46 * registrations are in shared memory
48 vl_api_registration_t *registration_pool;
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.
54 vl_api_registration_t *current_rp;
55 /* One input buffer, shared across all sockets */
58 /* pool of process args for socket clients */
59 vl_socket_args_for_process_t *process_args;
61 /* Listen for API connections here */
62 clib_socket_t socksvr_listen_socket;
65 extern socket_main_t socket_main;
67 always_inline vl_api_registration_t *
68 vl_socket_get_registration (u32 reg_index)
70 if (pool_is_free_index (socket_main.registration_pool, reg_index))
72 return pool_elt_at_index (socket_main.registration_pool, reg_index);
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,
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);
89 #endif /* SRC_VLIBMEMORY_SOCKET_API_H_ */
92 * fd.io coding-style-patch-verification: ON
95 * eval: (c-set-style "gnu")