Intercept.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * ZeroTier One - Network Virtualization Everywhere
  3. * Copyright (C) 2011-2015 ZeroTier, Inc.
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * --
  19. *
  20. * ZeroTier may be used and distributed under the terms of the GPLv3, which
  21. * are available at: http://www.gnu.org/licenses/gpl-3.0.html
  22. *
  23. * If you would like to embed ZeroTier into a commercial application or
  24. * redistribute it in a modified binary form, please contact ZeroTier Networks
  25. * LLC. Start here: http://www.zerotier.com/
  26. */
  27. #ifndef _INTERCEPT_H
  28. #define _INTERCEPT_H 1
  29. #include <sys/socket.h>
  30. #define CLOSE_SIG int fd
  31. #define READ_SIG int __fd, void *__buf, size_t __nbytes
  32. #define BIND_SIG int sockfd, const struct sockaddr *addr, socklen_t addrlen
  33. #define CONNECT_SIG int __fd, const struct sockaddr * __addr, socklen_t __len
  34. #define WRITE_SIG int __fd, const void *__buf, size_t __n
  35. #define LISTEN_SIG int sockfd, int backlog
  36. #define SOCKET_SIG int socket_family, int socket_type, int protocol
  37. #define ACCEPT4_SIG int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags
  38. #define ACCEPT_SIG int sockfd, struct sockaddr *addr, socklen_t *addrlen
  39. #define SHUTDOWN_SIG int socket, int how
  40. #define CONNECT_SOCKARG struct sockaddr *
  41. #define IOCTL_SIG int __fd, unsigned long int __request, ...
  42. #define FCNTL_SIG int __fd, int __cmd, ...
  43. #define DAEMON_SIG int nochdir, int noclose
  44. #define SETSOCKOPT_SIG int socket, int level, int option_name, const void *option_value, socklen_t option_len
  45. #define GETSOCKOPT_SIG int sockfd, int level, int optname, void *optval, socklen_t *optlen
  46. #define SYSCALL_SIG long number, ...
  47. #define CLONE_SIG int (*fn)(void *), void *child_stack, int flags, void *arg, ...
  48. #define GETSOCKNAME_SIG int sockfd, struct sockaddr *addr, socklen_t *addrlen
  49. #define DUP2_SIG int oldfd, int newfd
  50. #define DUP3_SIG int oldfd, int newfd, int flags
  51. void my_init(void);
  52. int connect(CONNECT_SIG);
  53. int bind(BIND_SIG);
  54. int accept(ACCEPT_SIG);
  55. int listen(LISTEN_SIG);
  56. int socket(SOCKET_SIG);
  57. int setsockopt(SETSOCKOPT_SIG);
  58. int getsockopt(GETSOCKOPT_SIG);
  59. int accept4(ACCEPT4_SIG);
  60. long syscall(SYSCALL_SIG);
  61. int close(CLOSE_SIG);
  62. int clone(CLONE_SIG);
  63. int dup2(DUP2_SIG);
  64. int dup3(DUP3_SIG);
  65. int getsockname(GETSOCKNAME_SIG);
  66. static int (*realconnect)(CONNECT_SIG) = 0;
  67. static int (*realbind)(BIND_SIG) = 0;
  68. static int (*realaccept)(ACCEPT_SIG) = 0;
  69. static int (*reallisten)(LISTEN_SIG) = 0;
  70. static int (*realsocket)(SOCKET_SIG) = 0;
  71. static int (*realsetsockopt)(SETSOCKOPT_SIG) = 0;
  72. static int (*realgetsockopt)(GETSOCKOPT_SIG) = 0;
  73. static int (*realaccept4)(ACCEPT4_SIG) = 0;
  74. static long (*realsyscall)(SYSCALL_SIG) = 0;
  75. static int (*realclose)(CLOSE_SIG) = 0;
  76. static int (*realgetsockname)(GETSOCKNAME_SIG) = 0;
  77. #endif