You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.0 KiB

12 years ago
11 years ago
12 years ago
  1. /*
  2. * local.h - Define the client's buffers and callbacks
  3. *
  4. * Copyright (C) 2013 - 2016, Max Lv <max.c.lv@gmail.com>
  5. *
  6. * This file is part of the shadowsocks-libev.
  7. *
  8. * shadowsocks-libev is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * shadowsocks-libev is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with shadowsocks-libev; see the file COPYING. If not, see
  20. * <http://www.gnu.org/licenses/>.
  21. */
  22. #ifndef _LOCAL_H
  23. #define _LOCAL_H
  24. #include <ev.h>
  25. #include <libcork/ds.h>
  26. #include "encrypt.h"
  27. #include "jconf.h"
  28. #include "protocol.h"
  29. #include "common.h"
  30. typedef struct listen_ctx {
  31. ev_io io;
  32. char *iface;
  33. int remote_num;
  34. int method;
  35. int timeout;
  36. int fd;
  37. int mptcp;
  38. struct sockaddr **remote_addr;
  39. } listen_ctx_t;
  40. typedef struct server_ctx {
  41. ev_io io;
  42. int connected;
  43. struct server *server;
  44. } server_ctx_t;
  45. typedef struct server {
  46. int fd;
  47. int stage;
  48. struct enc_ctx *e_ctx;
  49. struct enc_ctx *d_ctx;
  50. struct server_ctx *recv_ctx;
  51. struct server_ctx *send_ctx;
  52. struct listen_ctx *listener;
  53. struct remote *remote;
  54. buffer_t *buf;
  55. struct cork_dllist_item entries;
  56. } server_t;
  57. typedef struct remote_ctx {
  58. ev_io io;
  59. ev_timer watcher;
  60. int connected;
  61. struct remote *remote;
  62. } remote_ctx_t;
  63. typedef struct remote {
  64. int fd;
  65. int direct;
  66. int addr_len;
  67. uint32_t counter;
  68. buffer_t *buf;
  69. struct remote_ctx *recv_ctx;
  70. struct remote_ctx *send_ctx;
  71. struct server *server;
  72. struct sockaddr_storage addr;
  73. } remote_t;
  74. #endif // _LOCAL_H