1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 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 SECURITY_GUARD_KERNEL_INTERFACE_ADAPTER_H 17 #define SECURITY_GUARD_KERNEL_INTERFACE_ADAPTER_H 18 19 #include <cerrno> 20 #include <cstddef> 21 #include <cstdint> 22 #include <ctime> 23 #include <linux/netlink.h> 24 #include <poll.h> 25 #include <sys/socket.h> 26 #include <unistd.h> 27 28 namespace OHOS::Security::SecurityGuard { 29 class KernelInterfaceAdapter { 30 public: 31 KernelInterfaceAdapter() = default; 32 virtual ~KernelInterfaceAdapter() = default; Socket(int af,int type,int protocol)33 virtual int Socket(int af, int type, int protocol) { return 0; }; Bind(int fd,const struct sockaddr * addr,socklen_t addrLength)34 virtual int Bind(int fd, const struct sockaddr* addr, socklen_t addrLength) { return 0; }; Poll(struct pollfd * const fds,nfds_t fdCount,int timeout)35 virtual int Poll(struct pollfd* const fds, nfds_t fdCount, int timeout) { return 0; }; Recv(int socket,void * const buf,size_t len,int flags)36 virtual ssize_t Recv(int socket, void* const buf, size_t len, int flags) { return 0; }; Open(const char * const pathName,int flags)37 virtual int Open(const char* const pathName, int flags) { return 0; }; Write(int fd,const void * const buf,size_t count)38 virtual ssize_t Write(int fd, const void* const buf, size_t count) { return 0; }; 39 }; 40 } // namespace OHOS::Security::SecurityGuard 41 42 #endif // SECURITY_GUARD_KERNEL_INTERFACE_ADAPTER_H 43