Factor our osmo_ss7_as allocation to its own function
This makes it easier to find out where the AS struct is allocated, plus also split between inst code looking up + checking + allocating and the code doing the allocation and initialization of the AS. Change-Id: Ie237ec8ac4b2e15b76fce3b3a56f47a59fdcc76e
This commit is contained in:
parent
adbf243e1b
commit
e39a104727
|
@ -954,6 +954,37 @@ struct osmo_ss7_as *osmo_ss7_as_find_by_proto(struct osmo_ss7_instance *inst,
|
|||
return as_without_asp;
|
||||
}
|
||||
|
||||
/*! \brief Allocate an Application Server
|
||||
* \param[in] inst SS7 Instance on which we operate
|
||||
* \param[in] name Name of Application Server
|
||||
* \param[in] proto Protocol of Application Server
|
||||
* \returns pointer to Application Server on success; NULL otherwise */
|
||||
struct osmo_ss7_as *ss7_as_alloc(struct osmo_ss7_instance *inst, const char *name,
|
||||
enum osmo_ss7_asp_protocol proto)
|
||||
{
|
||||
struct osmo_ss7_as *as;
|
||||
|
||||
as = talloc_zero(inst, struct osmo_ss7_as);
|
||||
if (!as)
|
||||
return NULL;
|
||||
as->ctrg = rate_ctr_group_alloc(as, &ss7_as_rcgd, g_ss7_as_rcg_idx++);
|
||||
if (!as->ctrg) {
|
||||
talloc_free(as);
|
||||
return NULL;
|
||||
}
|
||||
rate_ctr_group_set_name(as->ctrg, name);
|
||||
as->inst = inst;
|
||||
as->cfg.name = talloc_strdup(as, name);
|
||||
as->cfg.proto = proto;
|
||||
as->cfg.mode = OSMO_SS7_AS_TMOD_OVERRIDE;
|
||||
as->cfg.recovery_timeout_msec = 2000;
|
||||
as->cfg.routing_key.l_rk_id = find_free_l_rk_id(inst);
|
||||
as->fi = xua_as_fsm_start(as, LOGL_DEBUG);
|
||||
llist_add_tail(&as->list, &inst->as_list);
|
||||
|
||||
return as;
|
||||
}
|
||||
|
||||
/*! \brief Find or Create Application Server
|
||||
* \param[in] inst SS7 Instance on which we operate
|
||||
* \param[in] name Name of Application Server
|
||||
|
@ -972,23 +1003,9 @@ osmo_ss7_as_find_or_create(struct osmo_ss7_instance *inst, const char *name,
|
|||
return NULL;
|
||||
|
||||
if (!as) {
|
||||
as = talloc_zero(inst, struct osmo_ss7_as);
|
||||
as = ss7_as_alloc(inst, name, proto);
|
||||
if (!as)
|
||||
return NULL;
|
||||
as->ctrg = rate_ctr_group_alloc(as, &ss7_as_rcgd, g_ss7_as_rcg_idx++);
|
||||
if (!as->ctrg) {
|
||||
talloc_free(as);
|
||||
return NULL;
|
||||
}
|
||||
rate_ctr_group_set_name(as->ctrg, name);
|
||||
as->inst = inst;
|
||||
as->cfg.name = talloc_strdup(as, name);
|
||||
as->cfg.proto = proto;
|
||||
as->cfg.mode = OSMO_SS7_AS_TMOD_OVERRIDE;
|
||||
as->cfg.recovery_timeout_msec = 2000;
|
||||
as->cfg.routing_key.l_rk_id = find_free_l_rk_id(inst);
|
||||
as->fi = xua_as_fsm_start(as, LOGL_DEBUG);
|
||||
llist_add_tail(&as->list, &inst->as_list);
|
||||
LOGPAS(as, DLSS7, LOGL_INFO, "Created AS\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@ extern bool ss7_initialized;
|
|||
|
||||
bool ss7_ipv6_sctp_supported(const char *host, bool bind);
|
||||
|
||||
struct osmo_ss7_as *ss7_as_alloc(struct osmo_ss7_instance *inst, const char *name,
|
||||
enum osmo_ss7_asp_protocol proto);
|
||||
|
||||
struct osmo_ss7_asp *ss7_asp_alloc(struct osmo_ss7_instance *inst, const char *name,
|
||||
uint16_t remote_port, uint16_t local_port,
|
||||
enum osmo_ss7_asp_protocol proto);
|
||||
|
|
Loading…
Reference in New Issue