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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef included_vppcom_h
17 #define included_vppcom_h
21 #include <sys/epoll.h>
24 * VPPCOM Public API Definitions, Enums, and Data Structures
26 #define INVALID_SESSION_ID (~0)
27 #define VPPCOM_VRF_DEFAULT 0
28 #define VPPCOM_CONF_DEFAULT "/etc/vpp/vcl.conf"
29 #define VPPCOM_ENV_CONF "VCL_CONFIG"
30 #define VPPCOM_ENV_DEBUG "VCL_DEBUG"
31 #define VPPCOM_ENV_APP_PROXY_TRANSPORT_TCP "VCL_APP_PROXY_TRANSPORT_TCP"
32 #define VPPCOM_ENV_APP_PROXY_TRANSPORT_UDP "VCL_APP_PROXY_TRANSPORT_UDP"
33 #define VPPCOM_ENV_APP_NAMESPACE_ID "VCL_APP_NAMESPACE_ID"
34 #define VPPCOM_ENV_APP_NAMESPACE_SECRET "VCL_APP_NAMESPACE_SECRET"
35 #define VPPCOM_ENV_APP_SCOPE_LOCAL "VCL_APP_SCOPE_LOCAL"
36 #define VPPCOM_ENV_APP_SCOPE_GLOBAL "VCL_APP_SCOPE_GLOBAL"
50 typedef struct vppcom_endpt_t_
62 VPPCOM_EAGAIN = -EAGAIN,
63 VPPCOM_ENOMEM = -ENOMEM,
64 VPPCOM_EINVAL = -EINVAL,
65 VPPCOM_EBADFD = -EBADFD,
66 VPPCOM_EAFNOSUPPORT = -EAFNOSUPPORT,
67 VPPCOM_ECONNABORTED = -ECONNABORTED,
68 VPPCOM_ECONNRESET = -ECONNRESET,
69 VPPCOM_ENOTCONN = -ENOTCONN,
70 VPPCOM_ECONNREFUSED = -ECONNREFUSED,
71 VPPCOM_ETIMEDOUT = -ETIMEDOUT,
76 VPPCOM_ATTR_GET_NREAD,
77 VPPCOM_ATTR_GET_NWRITE,
78 VPPCOM_ATTR_GET_FLAGS,
79 VPPCOM_ATTR_SET_FLAGS,
80 VPPCOM_ATTR_GET_LCL_ADDR,
81 VPPCOM_ATTR_GET_PEER_ADDR,
82 VPPCOM_ATTR_SET_REUSEADDR,
83 VPPCOM_ATTR_SET_BROADCAST,
84 VPPCOM_ATTR_SET_V6ONLY,
85 VPPCOM_ATTR_SET_KEEPALIVE,
86 VPPCOM_ATTR_SET_TCP_KEEPIDLE,
87 VPPCOM_ATTR_SET_TCP_KEEPINTVL,
91 * VPPCOM Public API Functions
93 static inline const char *
94 vppcom_retval_str (int retval)
105 st = "VPPCOM_EAGAIN";
109 st = "VPPCOM_ENOMEM";
113 st = "VPPCOM_EINVAL";
117 st = "VPPCOM_EBADFD";
120 case VPPCOM_EAFNOSUPPORT:
121 st = "VPPCOM_EAFNOSUPPORT";
124 case VPPCOM_ECONNABORTED:
125 st = "VPPCOM_ECONNABORTED";
128 case VPPCOM_ECONNRESET:
129 st = "VPPCOM_ECONNRESET";
132 case VPPCOM_ENOTCONN:
133 st = "VPPCOM_ENOTCONN";
136 case VPPCOM_ECONNREFUSED:
137 st = "VPPCOM_ECONNREFUSED";
140 case VPPCOM_ETIMEDOUT:
141 st = "VPPCOM_ETIMEDOUT";
145 st = "UNKNOWN_STATE";
152 /* TBD: make these constructor/destructor function */
153 extern int vppcom_app_create (char *app_name);
154 extern void vppcom_app_destroy (void);
156 extern int vppcom_session_create (uint32_t vrf, uint8_t proto,
157 uint8_t is_nonblocking);
158 extern int vppcom_session_close (uint32_t session_index);
160 extern int vppcom_session_bind (uint32_t session_index, vppcom_endpt_t * ep);
161 extern int vppcom_session_listen (uint32_t session_index, uint32_t q_len);
162 extern int vppcom_session_accept (uint32_t session_index,
163 vppcom_endpt_t * client_ep,
164 uint32_t flags, double wait_for_time);
166 extern int vppcom_session_connect (uint32_t session_index,
167 vppcom_endpt_t * server_ep);
168 extern int vppcom_session_read (uint32_t session_index, void *buf, int n);
169 extern int vppcom_session_write (uint32_t session_index, void *buf, int n);
171 extern int vppcom_select (unsigned long n_bits,
172 unsigned long *read_map,
173 unsigned long *write_map,
174 unsigned long *except_map, double wait_for_time);
176 extern int vppcom_epoll_create (void);
177 extern int vppcom_epoll_ctl (uint32_t vep_idx, int op,
178 uint32_t session_index,
179 struct epoll_event *event);
180 extern int vppcom_epoll_wait (uint32_t vep_idx, struct epoll_event *events,
181 int maxevents, double wait_for_time);
182 extern int vppcom_session_attr (uint32_t session_index, uint32_t op,
183 void *buffer, uint32_t * buflen);
184 extern int vppcom_session_recvfrom (uint32_t session_index, void *buffer,
185 uint32_t buflen, int flags,
186 vppcom_endpt_t * ep);
187 extern int vppcom_session_sendto (uint32_t session_index, void *buffer,
188 uint32_t buflen, int flags,
189 vppcom_endpt_t * ep);
191 #endif /* included_vppcom_h */
194 * fd.io coding-style-patch-verification: ON
197 * eval: (c-set-style "gnu")