blob: d71deaf19be9e728ac5e05d08895acfe2934a595 [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
21struct mgcp_client_pool_member *mgcp_client_pool_find_member_by_nr(struct mgcp_client_pool *pool, unsigned int nr);
22
23
Philipp Maier3f4a4cb2021-07-26 13:20:05 +020024/* Struct to handle a member of a pool of MGWs. */
25struct mgcp_client_pool_member {
Pau Espin Pedrold4707e22022-10-13 13:59:10 +020026 /* Entry in llist mgcp_client_pool->pool. */
Philipp Maier3f4a4cb2021-07-26 13:20:05 +020027 struct llist_head list;
28
Pau Espin Pedrol35bd2522022-10-13 17:26:33 +020029 /* The pool managing this object: */
30 struct mgcp_client_pool *pool;
31
Philipp Maier3f4a4cb2021-07-26 13:20:05 +020032 /* Reference number assinged by VTY. This number is used to manage the pool from the VTY and to identify it in
33 * the log. */
34 unsigned int nr;
35
36 /* MGCP client configuration, this is not the running configuration, when mgcp_client_init() is executed, a
37 * copy of this config is created. */
38 struct mgcp_client_conf conf;
39
40 /* MGCP client descriptor, will be automatically allocated when mgcp_client_pool_connect() is called. (the MGCP
41 * client is connected when this pointer is populated) */
42 struct mgcp_client *client;
43
44 /* A pool member may be set as 'blocked' from the VTY, this means that the pool member may still work and serve
45 * ongoing calls, but it won't be picked from the pool anymore. */
46 bool blocked;
47
48 /* Reference counter to count how often this pool member is currently picked. */
49 unsigned int refcount;
50};
51
Pau Espin Pedrol6ddc79b2022-10-13 17:03:42 +020052struct mgcp_client_pool_member *mgcp_client_pool_member_alloc(struct mgcp_client_pool *pool, unsigned int nr);
53void mgcp_client_pool_member_free(struct mgcp_client_pool_member *pool_member);
Pau Espin Pedrol35bd2522022-10-13 17:26:33 +020054int mgcp_client_pool_member_reinit_client(struct mgcp_client_pool_member *pool_member);
Philipp Maierdf9192e2021-09-03 17:50:51 +020055const char *mgcp_client_pool_member_name(const struct mgcp_client_pool_member *pool_member);