Philipp Maier | 3f4a4cb | 2021-07-26 13:20:05 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Pau Espin Pedrol | f45a9b9 | 2022-10-13 17:21:32 +0200 | [diff] [blame] | 3 | /* Struct to handle a pool of MGWs. (Use _pool functions) */ |
| 4 | struct mgcp_client_pool { |
| 5 | |
| 6 | /* A pointer to a 'single' mgcp client. This is a non-pooled MGCP client that is configured using |
| 7 | * mgcp_client_vty_init() and actively registered by the API user using mgcp_client_pool_register_single() */ |
| 8 | struct mgcp_client *mgcp_client_single; |
| 9 | |
| 10 | /* A list that manages the pool members (see mgcp_client_pool_member->list above) */ |
| 11 | struct llist_head member_list; |
| 12 | |
| 13 | /* String to use for indentation when writing the configuration file to the VTY. This field is populated by |
| 14 | * mgcp_client_pool_vty_init() */ |
| 15 | char *vty_indent; |
| 16 | |
| 17 | /* VTY node specification used with this pool. This field is populated by mgcp_client_pool_vty_init() */ |
| 18 | struct cmd_node *vty_node; |
| 19 | }; |
| 20 | |
Philipp Maier | 3f4a4cb | 2021-07-26 13:20:05 +0200 | [diff] [blame] | 21 | /* Struct to handle a member of a pool of MGWs. */ |
| 22 | struct mgcp_client_pool_member { |
Pau Espin Pedrol | d4707e2 | 2022-10-13 13:59:10 +0200 | [diff] [blame] | 23 | /* Entry in llist mgcp_client_pool->pool. */ |
Philipp Maier | 3f4a4cb | 2021-07-26 13:20:05 +0200 | [diff] [blame] | 24 | struct llist_head list; |
| 25 | |
Pau Espin Pedrol | 35bd252 | 2022-10-13 17:26:33 +0200 | [diff] [blame] | 26 | /* The pool managing this object: */ |
| 27 | struct mgcp_client_pool *pool; |
| 28 | |
Philipp Maier | 3f4a4cb | 2021-07-26 13:20:05 +0200 | [diff] [blame] | 29 | /* Reference number assinged by VTY. This number is used to manage the pool from the VTY and to identify it in |
| 30 | * the log. */ |
| 31 | unsigned int nr; |
| 32 | |
| 33 | /* MGCP client configuration, this is not the running configuration, when mgcp_client_init() is executed, a |
| 34 | * copy of this config is created. */ |
| 35 | struct mgcp_client_conf conf; |
| 36 | |
| 37 | /* MGCP client descriptor, will be automatically allocated when mgcp_client_pool_connect() is called. (the MGCP |
| 38 | * client is connected when this pointer is populated) */ |
| 39 | struct mgcp_client *client; |
| 40 | |
| 41 | /* A pool member may be set as 'blocked' from the VTY, this means that the pool member may still work and serve |
| 42 | * ongoing calls, but it won't be picked from the pool anymore. */ |
| 43 | bool blocked; |
| 44 | |
| 45 | /* Reference counter to count how often this pool member is currently picked. */ |
| 46 | unsigned int refcount; |
| 47 | }; |
| 48 | |
Pau Espin Pedrol | 6ddc79b | 2022-10-13 17:03:42 +0200 | [diff] [blame] | 49 | struct mgcp_client_pool_member *mgcp_client_pool_member_alloc(struct mgcp_client_pool *pool, unsigned int nr); |
| 50 | void mgcp_client_pool_member_free(struct mgcp_client_pool_member *pool_member); |
Pau Espin Pedrol | 35bd252 | 2022-10-13 17:26:33 +0200 | [diff] [blame] | 51 | int mgcp_client_pool_member_reinit_client(struct mgcp_client_pool_member *pool_member); |
Philipp Maier | df9192e | 2021-09-03 17:50:51 +0200 | [diff] [blame] | 52 | const char *mgcp_client_pool_member_name(const struct mgcp_client_pool_member *pool_member); |