aboutsummaryrefslogtreecommitdiffstats
path: root/vcl-ldpreload/src/libvcl-ldpreload/vcom.h
blob: 445d8af95ad89d39329b2f16f02cd2fa523fb835 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
 * Copyright (c) 2017 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef included_vcom_h
#define included_vcom_h

/* VCOM DEBUG flag.  Setting this to 1 or 0 turns off
   ASSERT & other debugging code. */
#ifndef VCOM_DEBUG
#define VCOM_DEBUG 0
#endif

#include <libvcl-ldpreload/vcom_glibc_socket.h>

#define MAX_VCOM_APP_NAME  256

/* Returns 0 on success or -1 on error. */
extern int vcom_set_app_name (char *__app_name);

/*
 *
 * File descriptor based APIs
 *
 */

/*
 * vpp implementation of glibc APIs from <unistd.h>
 */
extern int vcom_close (int __fd);

extern ssize_t __wur vcom_read (int __fd, void *__buf, size_t __nbytes);

extern ssize_t __wur vcom_write (int __fd, const void *__buf, size_t __n);

/*
 * vpp implementation of glibc APIs from <fcntl.h>
 */
extern int vcom_fcntl (int __fd, int __cmd, ...);

/*
 * vpp implementation of glibc APIs from <sys/select.h>
 */
extern int
vcom_select (int __nfds, fd_set * __restrict __readfds,
	     fd_set * __restrict __writefds,
	     fd_set * __restrict __exceptfds,
	     struct timeval *__restrict __timeout);

#ifdef __USE_XOPEN2K
extern int
vcom_pselect (int __nfds, fd_set * __restrict __readfds,
	      fd_set * __restrict __writefds,
	      fd_set * __restrict __exceptfds,
	      const struct timespec *__restrict __timeout,
	      const __sigset_t * __restrict __sigmask);
#endif

/*
 * vpp implementation of glibc APIs from <sys/socket.h>
 */
extern int __THROW vcom_socket (int __domain, int __type, int __protocol);

/* On Linux, the only supported domain for this call is AF_UNIX
* (or synonymously, AF_LOCAL). Most implementations have the
* same restriction.
* vpp does not implement AF_UNIX domain in this release.
* */
extern int __THROW
vcom_socketpair (int __domain, int __type, int __protocol, int __fds[2]);

extern int __THROW
vcom_bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);

extern int __THROW
vcom_getsockname (int __fd, __SOCKADDR_ARG __addr,
		  socklen_t * __restrict __len);

extern int
vcom_connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);

extern int __THROW
vcom_getpeername (int __fd, __SOCKADDR_ARG __addr,
		  socklen_t * __restrict __len);

extern ssize_t
vcom_send (int __fd, const void *__buf, size_t __n, int __flags);

extern ssize_t vcom_recv (int __fd, void *__buf, size_t __n, int __flags);

extern ssize_t
vcom_sendto (int __fd, const void *__buf, size_t __n,
	     int __flags, __CONST_SOCKADDR_ARG __addr, socklen_t __addr_len);

extern ssize_t
vcom_recvfrom (int __fd, void *__restrict __buf,
	       size_t __n, int __flags,
	       __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len);

extern ssize_t
vcom_sendmsg (int __fd, const struct msghdr *__message, int __flags);

#ifdef __USE_GNU
extern int
sendmmsg (int __fd, struct mmsghdr *__vmessages,
	  unsigned int __vlen, int __flags);
#endif

extern ssize_t vcom_recvmsg (int __fd, struct msghdr *__message, int __flags);

#ifdef __USE_GNU
extern int
vcom_recvmmsg (int __fd, struct mmsghdr *__vmessages,
	       unsigned int __vlen, int __flags, struct timespec *__tmo);
#endif

extern int __THROW
vcom_getsockopt (int __fd, int __level, int __optname,
		 void *__restrict __optval, socklen_t * __restrict __optlen);

extern int __THROW
vcom_setsockopt (int __fd, int __level, int __optname,
		 const void *__optval, socklen_t __optlen);

extern int __THROW vcom_listen (int __fd, int __n);

extern int
vcom_accept (int __fd, __SOCKADDR_ARG __addr,
	     socklen_t * __restrict __addr_len);

#ifdef __USE_GNU
/*
 * Similar to 'accept' but takes an additional parameter to specify
 * flags.
 * */
/* TBD: implemented later */
extern int
vcom_accept4 (int __fd, __SOCKADDR_ARG __addr,
	      socklen_t * __restrict __addr_len, int __flags);
#endif

extern int __THROW vcom_shutdown (int __fd, int __how);

#endif /* included_vcom_h */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */