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 | struct tcp_rpc_client_functions { |
29 | void *info; |
30 | void *; |
31 | int (*execute)(connection_job_t c, int op, struct raw_message *raw); /* invoked from parse_execute() */ |
32 | int (*check_ready)(connection_job_t c); /* invoked from rpc_client_check_ready() */ |
33 | int (*flush_packet)(connection_job_t c); /* execute this to push query to server */ |
34 | int (*rpc_check_perm)(connection_job_t c); /* 1 = allow unencrypted, 2 = allow encrypted */ |
35 | int (*rpc_init_crypto)(connection_job_t c); /* 1 = ok; -1 = no crypto */ |
36 | int (*rpc_start_crypto)(connection_job_t c, char *nonce, int key_select, unsigned char *temp_key, int temp_key_len); /* 1 = ok; -1 = no crypto */ |
37 | int (*rpc_wakeup)(connection_job_t c); |
38 | int (*rpc_alarm)(connection_job_t c); |
39 | int (*rpc_ready)(connection_job_t c); |
40 | int (*rpc_close)(connection_job_t c, int who); |
41 | int max_packet_len; |
42 | int mode_flags; |
43 | }; |
44 | extern struct tcp_rpc_client_functions default_tcp_rpc_client; |
45 | |
46 | #define TCP_RPC_IGNORE_PID RPC_MF_IGNORE_PID |
47 | |
48 | extern conn_type_t ct_tcp_rpc_client; |
49 | int tcp_rpcc_parse_execute (connection_job_t c); |
50 | int tcp_rpcc_compact_parse_execute (connection_job_t c); |
51 | int tcp_rpcc_connected (connection_job_t c); |
52 | int tcp_rpcc_connected_nohs (connection_job_t c); |
53 | int tcp_rpcc_close_connection (connection_job_t c, int who); |
54 | int tcp_rpcc_init_outbound (connection_job_t c); |
55 | int tcp_rpc_client_check_ready (connection_job_t c); |
56 | void tcp_rpcc_flush_crypto (connection_job_t c); |
57 | int tcp_rpcc_flush (connection_job_t c); |
58 | // int tcp_rpcc_flush_packet (connection_job_t c); -- use tcp_rpc_flush_packet() instead |
59 | int tcp_rpcc_default_check_perm (connection_job_t c); |
60 | int tcp_rpcc_init_crypto (connection_job_t c); |
61 | int tcp_rpcc_start_crypto (connection_job_t c, char *nonce, int key_select, unsigned char *temp_key, int temp_key_len); |
62 | int tcp_rpcc_default_check_ready (connection_job_t c); |
63 | void tcp_force_enable_dh (void); |
64 | |
65 | #define TCP_RPCC_FUNC(c) ((struct tcp_rpc_client_functions *) (CONN_INFO(c)->extra)) |
66 | |
67 | |