/* * udprelay.h - Define UDP relay's buffers and callbacks * * Copyright (C) 2013 - 2015, Max Lv * * This file is part of the shadowsocks-libev. * * shadowsocks-libev is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * shadowsocks-libev is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with shadowsocks-libev; see the file COPYING. If not, see * . */ #ifndef _UDPRELAY_H #define _UDPRELAY_H #include #include #include "encrypt.h" #include "jconf.h" #ifdef UDPRELAY_REMOTE #include "resolv.h" #endif #include "cache.h" #include "common.h" #define MAX_UDP_PACKET_SIZE (64 * 1024) struct server_ctx { ev_io io; int fd; int method; int timeout; const char *iface; struct cache *conn_cache; #ifdef UDPRELAY_LOCAL const struct sockaddr *remote_addr; int remote_addr_len; #ifdef UDPRELAY_TUNNEL ss_addr_t tunnel_addr; #endif #endif #ifdef UDPRELAY_REMOTE struct ev_loop *loop; #endif }; #ifdef UDPRELAY_REMOTE struct query_ctx { struct ResolvQuery *query; struct sockaddr_storage src_addr; int buf_len; char *buf; // server send from, remote recv into int addr_header_len; char addr_header[384]; struct server_ctx *server_ctx; }; #endif struct remote_ctx { ev_io io; ev_timer watcher; int fd; int addr_header_len; char addr_header[384]; struct sockaddr_storage src_addr; struct sockaddr_storage dst_addr; struct server_ctx *server_ctx; }; #endif // _UDPRELAY_H