1 | /* |
2 | This file is part of Mtproto-proxy Library. |
3 | |
4 | Mtproto-proxy Library is free software: you can redistribute it and/or modify |
5 | it under the terms of the GNU Lesser General Public License as published by |
6 | the Free Software Foundation, either version 2 of the License, or |
7 | (at your option) any later version. |
8 | |
9 | Mtproto-proxy Library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | GNU Lesser General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Lesser General Public License |
15 | along with Mtproto-proxy Library. If not, see <http://www.gnu.org/licenses/>. |
16 | |
17 | Copyright 2010-2013 Vkontakte Ltd |
18 | 2010-2013 Nikolai Durov |
19 | 2010-2013 Andrey Lopatin |
20 | 2013 Vitaliy Valtman |
21 | |
22 | Copyright 2014-2016 Telegram Messenger Inc |
23 | 2015-2016 Vitaly Valtman |
24 | */ |
25 | |
26 | #pragma once |
27 | |
28 | #include "net/net-tcp-rpc-common.h" |
29 | #include "net/net-connections.h" |
30 | |
31 | struct tcp_rpc_server_functions { |
32 | void *info; |
33 | void *; |
34 | int (*execute)(connection_job_t c, int op, struct raw_message *raw);/* invoked from parse_execute() */ |
35 | int (*check_ready)(connection_job_t c); /* invoked from rpc_client_check_ready() */ |
36 | int (*flush_packet)(connection_job_t c); /* execute this to push response to client */ |
37 | int (*rpc_check_perm)(connection_job_t c); /* 1 = allow unencrypted, 2 = allow encrypted */ |
38 | int (*rpc_init_crypto)(connection_job_t c, struct tcp_rpc_nonce_packet *P); /* 1 = ok; -1 = no crypto */ |
39 | void *nop; |
40 | int (*rpc_wakeup)(connection_job_t c); |
41 | int (*rpc_alarm)(connection_job_t c); |
42 | int (*rpc_ready)(connection_job_t c); |
43 | int (*rpc_close)(connection_job_t c, int who); |
44 | int max_packet_len; |
45 | int mode_flags; /* 1 = ignore PID mismatch */ |
46 | void *memcache_fallback_type, *; |
47 | void *http_fallback_type, *; |
48 | }; |
49 | |
50 | #define TCP_RPC_IGNORE_PID RPC_MF_IGNORE_PID |
51 | |
52 | extern conn_type_t ct_tcp_rpc_server; |
53 | extern struct tcp_rpc_server_functions default_tcp_rpc_server; |
54 | |
55 | int tcp_rpcs_wakeup (connection_job_t c); |
56 | int tcp_rpcs_parse_execute (connection_job_t c); |
57 | int tcp_rpcs_alarm (connection_job_t c); |
58 | int tcp_rpcs_do_wakeup (connection_job_t c); |
59 | int tcp_rpcs_init_accepted (connection_job_t c); |
60 | int tcp_rpcs_close_connection (connection_job_t c, int who); |
61 | int tcp_rpcs_flush (connection_job_t c); |
62 | int tcp_rpcs_init_accepted_nohs (connection_job_t c); |
63 | // int tcp_rpcs_flush_packet (connection_job_t c); -- use tcp_rpc_flush_packet () instead |
64 | int tcp_rpcs_default_check_perm (connection_job_t c); |
65 | int tcp_rpcs_init_crypto (connection_job_t c, struct tcp_rpc_nonce_packet *P); |
66 | |
67 | #define TCP_RPCS_FUNC(c) ((struct tcp_rpc_server_functions *) (CONN_INFO(c)->extra)) |
68 | |