| 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 2013 Vkontakte Ltd |
| 18 | 2013 Vitaliy Valtman |
| 19 | |
| 20 | Copyright 2014-2016 Telegram Messenger Inc |
| 21 | 2015-2016 Vitaly Valtman |
| 22 | */ |
| 23 | |
| 24 | #pragma once |
| 25 | #include "net/net-connections.h" |
| 26 | #include "net/net-tcp-rpc-common.h" |
| 27 | |
| 28 | typedef job_t rpc_target_job_t; |
| 29 | |
| 30 | struct tree_connection; |
| 31 | struct rpc_target_info { |
| 32 | struct event_timer timer; |
| 33 | int a, b; |
| 34 | //connection_job_t first, last; |
| 35 | //conn_target_job_t target; |
| 36 | struct tree_connection *conn_tree; |
| 37 | struct process_id PID; |
| 38 | }; |
| 39 | |
| 40 | #define RPC_TARGET_INFO(_c) ((struct rpc_target_info *)(_c)->j_custom) |
| 41 | |
| 42 | rpc_target_job_t rpc_target_lookup (struct process_id *PID); |
| 43 | rpc_target_job_t rpc_target_lookup_hp (unsigned host, int port); |
| 44 | rpc_target_job_t rpc_target_lookup_target (conn_target_job_t targ); |
| 45 | |
| 46 | connection_job_t rpc_target_choose_connection (rpc_target_job_t S, struct process_id *PID); |
| 47 | int rpc_target_choose_random_connections (rpc_target_job_t S, struct process_id *PID, int limit, connection_job_t buf[]); |
| 48 | |
| 49 | void rpc_target_insert_conn (connection_job_t c); |
| 50 | void rpc_target_insert_target (conn_target_job_t t); |
| 51 | void rpc_target_insert_target_ext (conn_target_job_t t, unsigned host); |
| 52 | void rpc_target_delete_conn (connection_job_t c); |
| 53 | |
| 54 | int rpc_target_get_state (rpc_target_job_t S, struct process_id *PID); |
| 55 | void rpc_target_delete (rpc_target_job_t S); |
| 56 | |