blob: 9a78b718f8e75658ded1a38cceac501a6c2e3eb8 [file] [log] [blame]
Keith Burns (alagalah)b327c2b2017-10-09 08:52:59 -07001/*
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:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
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.
14 */
15
16#ifndef included_vcom_h
17#define included_vcom_h
18
Dave Wallacee695cb42017-11-02 22:04:42 -040019#if (CLIB_DEBUG > 0)
20/* Set VCOM_DEBUG 2 for connection debug, 3 for read/write debug output */
21#define VCOM_DEBUG 1
22#else
Keith Burns (alagalah)b327c2b2017-10-09 08:52:59 -070023#define VCOM_DEBUG 0
24#endif
25
Dave Wallace5c7cf1c2017-10-24 04:12:18 -040026#include <vcl/vcom_glibc_socket.h>
Keith Burns (alagalah)b327c2b2017-10-09 08:52:59 -070027
28#define MAX_VCOM_APP_NAME 256
29
30/* Returns 0 on success or -1 on error. */
31extern int vcom_set_app_name (char *__app_name);
32
33/*
34 *
35 * File descriptor based APIs
36 *
37 */
38
39/*
40 * vpp implementation of glibc APIs from <unistd.h>
41 */
42extern int vcom_close (int __fd);
43
44extern ssize_t __wur vcom_read (int __fd, void *__buf, size_t __nbytes);
45
46extern ssize_t __wur vcom_write (int __fd, const void *__buf, size_t __n);
47
48extern ssize_t __wur vcom_readv (int __fd, const struct iovec *__iov,
49 int __iovcnt);
50
51extern ssize_t __wur vcom_writev (int __fd, const struct iovec *__iov,
52 int __iovcnt);
53
54/*
55 * vpp implementation of glibc APIs from <fcntl.h>
56 */
57extern int vcom_fcntl (int __fd, int __cmd, ...);
58
59/*
Stevenb59f2272017-10-12 17:10:33 -070060 * VPP implementation of glibc APIs ioctl
61 */
62extern int vcom_ioctl (int __fd, unsigned long int __cmd, ...);
63
64/*
Keith Burns (alagalah)b327c2b2017-10-09 08:52:59 -070065 * vpp implementation of glibc APIs from <sys/select.h>
66 */
67extern int
68vcom_select (int __nfds, fd_set * __restrict __readfds,
69 fd_set * __restrict __writefds,
70 fd_set * __restrict __exceptfds,
71 struct timeval *__restrict __timeout);
72
73#ifdef __USE_XOPEN2K
74extern int
75vcom_pselect (int __nfds, fd_set * __restrict __readfds,
76 fd_set * __restrict __writefds,
77 fd_set * __restrict __exceptfds,
78 const struct timespec *__restrict __timeout,
79 const __sigset_t * __restrict __sigmask);
80#endif
81
82/*
83 * vpp implementation of glibc APIs from <sys/socket.h>
84 */
85extern int __THROW vcom_socket (int __domain, int __type, int __protocol);
86
87/* On Linux, the only supported domain for this call is AF_UNIX
88* (or synonymously, AF_LOCAL). Most implementations have the
89* same restriction.
90* vpp does not implement AF_UNIX domain in this release.
91* */
92extern int __THROW
93vcom_socketpair (int __domain, int __type, int __protocol, int __fds[2]);
94
95extern int __THROW
96vcom_bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
97
98extern int __THROW
99vcom_getsockname (int __fd, __SOCKADDR_ARG __addr,
100 socklen_t * __restrict __len);
101
102extern int
103vcom_connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
104
105extern int __THROW
106vcom_getpeername (int __fd, __SOCKADDR_ARG __addr,
107 socklen_t * __restrict __len);
108
109extern ssize_t
110vcom_send (int __fd, const void *__buf, size_t __n, int __flags);
111
112extern ssize_t vcom_recv (int __fd, void *__buf, size_t __n, int __flags);
113
114extern ssize_t
115vcom_sendto (int __fd, const void *__buf, size_t __n,
116 int __flags, __CONST_SOCKADDR_ARG __addr, socklen_t __addr_len);
117
118extern ssize_t
119vcom_recvfrom (int __fd, void *__restrict __buf,
120 size_t __n, int __flags,
121 __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len);
122
123extern ssize_t
124vcom_sendmsg (int __fd, const struct msghdr *__message, int __flags);
125
126#ifdef __USE_GNU
127extern int
128sendmmsg (int __fd, struct mmsghdr *__vmessages,
129 unsigned int __vlen, int __flags);
130#endif
131
132extern ssize_t vcom_recvmsg (int __fd, struct msghdr *__message, int __flags);
133
134#ifdef __USE_GNU
135extern int
136vcom_recvmmsg (int __fd, struct mmsghdr *__vmessages,
137 unsigned int __vlen, int __flags, struct timespec *__tmo);
138#endif
139
140extern int __THROW
141vcom_getsockopt (int __fd, int __level, int __optname,
142 void *__restrict __optval, socklen_t * __restrict __optlen);
143
144extern int __THROW
145vcom_setsockopt (int __fd, int __level, int __optname,
146 const void *__optval, socklen_t __optlen);
147
148extern int __THROW vcom_listen (int __fd, int __n);
149
150extern int
151vcom_accept (int __fd, __SOCKADDR_ARG __addr,
152 socklen_t * __restrict __addr_len);
153
154#ifdef __USE_GNU
155/*
156 * Similar to 'accept' but takes an additional parameter to specify
157 * flags.
158 * */
159/* TBD: implemented later */
160extern int
161vcom_accept4 (int __fd, __SOCKADDR_ARG __addr,
162 socklen_t * __restrict __addr_len, int __flags);
163#endif
164
165extern int __THROW vcom_shutdown (int __fd, int __how);
166
167extern int __THROW vcom_epoll_create (int __size);
168
169extern int __THROW vcom_epoll_create1 (int __flags);
170
171extern int __THROW
172vcom_epoll_ctl (int __epfd, int __op, int __fd, struct epoll_event *__event);
173
174extern int
175vcom_epoll_wait (int __epfd, struct epoll_event *__events,
176 int __maxevents, int __timeout);
177
178extern int
179vcom_epoll_pwait (int __epfd, struct epoll_event *__events,
180 int __maxevents, int __timeout, const __sigset_t * __ss);
181
shrinivasan ganapathy1d359632017-10-15 15:46:09 -0700182/*
183 * NOTE: observed __nfds is less than 128 from kubecon strace files
184 * for the POC, it's fair to assume that nfds is less than 1024.
185 * TBD: make it thread safe and design to scale.
186 * */
187#define MAX_POLL_NFDS_DEFAULT 1024
Keith Burns (alagalah)b327c2b2017-10-09 08:52:59 -0700188extern int vcom_poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
189
190#ifdef __USE_GNU
191extern int
192vcom_ppoll (struct pollfd *__fds, nfds_t __nfds,
193 const struct timespec *__timeout, const __sigset_t * __ss);
194#endif
195
196
197#endif /* included_vcom_h */
198
199/*
200 * fd.io coding-style-patch-verification: ON
201 *
202 * Local Variables:
203 * eval: (c-set-style "gnu")
204 * End:
205 */