mgcp-client: Introduce APIs to manually select mgcp_client from pool
This will be used by osmo-bsc to implement MGW-pinning for specific BTS. This is useful for instance to keep all BTS connections targeting the same MGW in order to make use of Osmux trunking optimizations (AMR payload of different calls filling same underlaying UDP packet). Related: SYS#5987 Change-Id: I75ce3e04cd3f6d9cc20d7b4fc0f51083780786c8
This commit is contained in:
parent
35bd2523e2
commit
5d8b5b0935
|
@ -25,4 +25,5 @@
|
|||
#
|
||||
#library what description / commit summary line
|
||||
libosmo-netif >1.2.0 OSMUX_DEFAULT_PORT, osmux_xfrm_output_*, osmux_xfrm_input_*
|
||||
libosmocore >1.7.0 osmo_sockaddr_is_any()
|
||||
libosmocore >1.7.0 osmo_sockaddr_is_any()
|
||||
libmgcp-client NEW APIs mgcp_client_pool_member_...()
|
|
@ -2,10 +2,17 @@
|
|||
|
||||
struct mgcp_client;
|
||||
struct mgcp_client_pool;
|
||||
struct mgcp_client_pool_member;
|
||||
|
||||
struct mgcp_client_pool *mgcp_client_pool_alloc(void *talloc_ctx);
|
||||
|
||||
void mgcp_client_pool_vty_init(int parent_node, int mgw_node, const char *indent, struct mgcp_client_pool *pool);
|
||||
unsigned int mgcp_client_pool_connect(struct mgcp_client_pool *pool);
|
||||
void mgcp_client_pool_register_single(struct mgcp_client_pool *pool, struct mgcp_client *mgcp_client);
|
||||
|
||||
struct mgcp_client *mgcp_client_pool_get(struct mgcp_client_pool *pool);
|
||||
void mgcp_client_pool_put(struct mgcp_client *mgcp_client);
|
||||
|
||||
struct mgcp_client_pool_member *mgcp_client_pool_find_member_by_nr(struct mgcp_client_pool *pool, unsigned int nr);
|
||||
struct mgcp_client *mgcp_client_pool_member_get(struct mgcp_client_pool_member *pool_member);
|
||||
bool mgcp_client_pool_member_is_blocked(const struct mgcp_client_pool_member *pool_member);
|
||||
|
|
|
@ -18,9 +18,6 @@ struct mgcp_client_pool {
|
|||
struct cmd_node *vty_node;
|
||||
};
|
||||
|
||||
struct mgcp_client_pool_member *mgcp_client_pool_find_member_by_nr(struct mgcp_client_pool *pool, unsigned int nr);
|
||||
|
||||
|
||||
/* Struct to handle a member of a pool of MGWs. */
|
||||
struct mgcp_client_pool_member {
|
||||
/* Entry in llist mgcp_client_pool->pool. */
|
||||
|
|
|
@ -148,12 +148,10 @@ struct mgcp_client *mgcp_client_pool_get(struct mgcp_client_pool *pool)
|
|||
|
||||
/* Pick a suitable pool member */
|
||||
pool_member = mgcp_client_pool_pick(pool);
|
||||
if (pool_member) {
|
||||
pool_member->refcount++;
|
||||
return pool_member->client;
|
||||
}
|
||||
if (!pool_member)
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
return mgcp_client_pool_member_get(pool_member);
|
||||
}
|
||||
|
||||
/*! put an MGCP client back into the pool (decrement reference counter).
|
||||
|
@ -273,3 +271,22 @@ const char *mgcp_client_pool_member_name(const struct mgcp_client_pool_member *p
|
|||
|
||||
return name;
|
||||
}
|
||||
|
||||
/*! Get the MGCP client associated with the pool reference from the pool (increment reference counter).
|
||||
* \param[in] pool_member MGCP client pool descriptor.
|
||||
* \returns MGCP client descriptor, NULL if no member was not ready.
|
||||
*/
|
||||
struct mgcp_client *mgcp_client_pool_member_get(struct mgcp_client_pool_member *pool_member)
|
||||
{
|
||||
pool_member->refcount++;
|
||||
return pool_member->client;
|
||||
}
|
||||
|
||||
/*! Get whether the MGCP client associated with the pool reference is blocked by policy.
|
||||
* \param[in] pool_member MGCP client pool descriptor.
|
||||
* \returns true if blocked, false otherwise
|
||||
*/
|
||||
bool mgcp_client_pool_member_is_blocked(const struct mgcp_client_pool_member *pool_member)
|
||||
{
|
||||
return pool_member->blocked;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <osmocom/mgcp_client/mgcp_client.h>
|
||||
#include <osmocom/mgcp_client/mgcp_client_internal.h>
|
||||
#include <osmocom/mgcp_client/mgcp_client_pool_internal.h>
|
||||
#include <osmocom/mgcp_client/mgcp_client_pool.h>
|
||||
|
||||
#define MGW_STR MGCP_CLIENT_MGW_STR
|
||||
|
||||
|
|
Loading…
Reference in New Issue