1 /* 2 * common.h - Provide global definitions 3 * 4 * Copyright (C) 2013 - 2019, Max Lv <max.c.lv@gmail.com> 5 * 6 * This file is part of the shadowsocks-libev. 7 * shadowsocks-libev is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * shadowsocks-libev is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with shadowsocks-libev; see the file COPYING. If not, see 19 * <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef _COMMON_H 23 #define _COMMON_H 24 25 #ifndef SOL_TCP 26 #define SOL_TCP IPPROTO_TCP 27 #endif 28 29 #if defined(MODULE_TUNNEL) || defined(MODULE_REDIR) 30 #define MODULE_LOCAL 31 #endif 32 33 #include "crypto.h" 34 35 int init_udprelay(const char *server_host, const char *server_port, 36 #ifdef MODULE_LOCAL 37 const struct sockaddr *remote_addr, const int remote_addr_len, 38 #ifdef MODULE_TUNNEL 39 const ss_addr_t tunnel_addr, 40 #endif 41 #endif 42 int mtu, crypto_t *crypto, int timeout, const char *iface); 43 44 void free_udprelay(void); 45 46 #ifdef __ANDROID__ 47 int protect_socket(int fd); 48 int send_traffic_stat(uint64_t tx, uint64_t rx); 49 #endif 50 51 #define STAGE_ERROR -1 /* Error detected */ 52 #define STAGE_INIT 0 /* Initial stage */ 53 #define STAGE_HANDSHAKE 1 /* Handshake with client */ 54 #define STAGE_RESOLVE 4 /* Resolve the hostname */ 55 #define STAGE_STREAM 5 /* Stream between client and server */ 56 #define STAGE_STOP 6 /* Server stop to response */ 57 58 /* Vals for long options */ 59 enum { 60 GETOPT_VAL_HELP = 257, 61 GETOPT_VAL_REUSE_PORT, 62 GETOPT_VAL_FAST_OPEN, 63 GETOPT_VAL_NODELAY, 64 GETOPT_VAL_ACL, 65 GETOPT_VAL_MTU, 66 GETOPT_VAL_MPTCP, 67 GETOPT_VAL_PLUGIN, 68 GETOPT_VAL_PLUGIN_OPTS, 69 GETOPT_VAL_PASSWORD, 70 GETOPT_VAL_KEY, 71 GETOPT_VAL_MANAGER_ADDRESS, 72 GETOPT_VAL_EXECUTABLE, 73 GETOPT_VAL_WORKDIR, 74 }; 75 76 #endif // _COMMON_H 77