1 /******************************************************************************
2  *
3  *  Copyright (C) 2022 Google, Inc.
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 #pragma once
20 
21 #include "hal/syscall_wrapper_interface.h"
22 
23 namespace bluetooth {
24 namespace hal {
25 
26 class SyscallWrapperImpl : public SyscallWrapperInterface {
27   int Socket(int domain, int type, int protocol);
28 
29   int Bind(int fd, const struct sockaddr* addr, socklen_t len);
30 
31   int Connect(int fd, const struct sockaddr* addr, socklen_t len);
32 
33   ssize_t Send(int fd, const void* buf, size_t n, int flags);
34 
35   ssize_t Recv(int fd, void* buf, size_t n, int flags);
36 
37   int Setsockopt(int fd, int level, int optname, const void* optval, socklen_t optlen);
38 
39   int Listen(int fd, int n);
40 
41   int Accept(int fd, struct sockaddr* addr, socklen_t* addr_len, int flags);
42 
43   ssize_t Write(int, const void*, size_t);
44 
45   int Close(int fd);
46 
47   int Pipe2(int* pipefd, int flags);
48 
49   int GetErrno() const;
50 
51   void FDSet(int fd, fd_set* set);
52 
53   void FDClr(int fd, fd_set* set);
54 
55   bool FDIsSet(int fd, fd_set* set);
56 
57   void FDZero(fd_set* set);
58 
59   int Select(int __nfds, fd_set* __readfds, fd_set* __writefds, fd_set* __exceptfds, struct timeval* __timeout);
60 
61  private:
62   int errno_;
63 };
64 
65 }  // namespace hal
66 }  // namespace bluetooth
67