1 2 /** 3 * Tencent is pleased to support the open source community by making MSEC available. 4 * 5 * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 6 * 7 * Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. You may 9 * obtain a copy of the License at 10 * 11 * https://opensource.org/licenses/GPL-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software distributed under the 14 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 * either express or implied. See the License for the specific language governing permissions 16 * and limitations under the License. 17 */ 18 19 20 #ifndef __FF_HOOK_H__ 21 #define __FF_HOOK_H__ 22 23 #include <stdint.h> 24 25 #define FF_FD_BITS 16 26 #define CHK_FD_BIT(fd) (fd & (1 << FF_FD_BITS)) 27 #define CLR_FD_BIT(fd) (fd & ~(1 << FF_FD_BITS)) 28 29 void ff_hook_new_fd(int fd); 30 bool ff_hook_find_fd(int fd); 31 32 void ff_hook_free_fd(int fd); 33 int ff_hook_socket(int domain, int type, int protocol); 34 int ff_hook_close(int fd); 35 36 int ff_hook_connect(int fd, const struct sockaddr *address, socklen_t addrlen_len); 37 38 ssize_t ff_hook_read(int fd, void *buf, size_t nbyte); 39 40 ssize_t ff_hook_write(int fd, const void *buf, size_t nbyte); 41 ssize_t ff_hook_sendto(int fd, const void *message, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len); 42 ssize_t ff_hook_recvfrom(int fd, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len); 43 ssize_t ff_hook_recv(int fd, void *buffer, size_t length, int flags); 44 ssize_t ff_hook_send(int fd, const void *buf, size_t nbyte, int flags); 45 int ff_hook_setsockopt(int fd, int level, int option_name, const void *option_value, socklen_t option_len); 46 int ff_hook_ioctl(int fd, int cmd, void *arg); 47 48 int ff_hook_fcntl(int fd, int cmd, void *arg); 49 50 int ff_hook_listen(int fd, int backlog); 51 52 int ff_hook_bind(int fd, const struct sockaddr *addr, socklen_t addrlen); 53 int ff_hook_accept(int fd, struct sockaddr *addr, socklen_t *addrlen); 54 55 #endif 56 57