blob: 999c3efac66ff652b11cb2a144fef9a9109c4226 [file] [log] [blame]
Philipp Maier3f4a4cb2021-07-26 13:20:05 +02001#pragma once
2
Pau Espin Pedrolf45a9b92022-10-13 17:21:32 +02003/* Struct to handle a pool of MGWs. (Use _pool functions) */
4struct 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 Maier3f4a4cb2021-07-26 13:20:05 +020021/* Struct to handle a member of a pool of MGWs. */
22struct mgcp_client_pool_member {
Pau Espin Pedrold4707e22022-10-13 13:59:10 +020023 /* Entry in llist mgcp_client_pool->pool. */
Philipp Maier3f4a4cb2021-07-26 13:20:05 +020024 struct llist_head list;
25
Pau Espin Pedrol35bd2522022-10-13 17:26:33 +020026 /* The pool managing this object: */
27 struct mgcp_client_pool *pool;
28
Philipp Maier3f4a4cb2021-07-26 13:20:05 +020029 /* 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 Pedrol6ddc79b2022-10-13 17:03:42 +020049struct mgcp_client_pool_member *mgcp_client_pool_member_alloc(struct mgcp_client_pool *pool, unsigned int nr);
50void mgcp_client_pool_member_free(struct mgcp_client_pool_member *pool_member);
Pau Espin Pedrol35bd2522022-10-13 17:26:33 +020051int mgcp_client_pool_member_reinit_client(struct mgcp_client_pool_member *pool_member);
Philipp Maierdf9192e2021-09-03 17:50:51 +020052const char *mgcp_client_pool_member_name(const struct mgcp_client_pool_member *pool_member);