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