pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-sccp/+/34589?usp=email )
Change subject: Factor our osmo_ss7_as allocation to its own function
......................................................................
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
---
M src/osmo_ss7.c
M src/ss7_internal.h
2 files changed, 48 insertions(+), 15 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/89/34589/1
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index 9265898..1e8bcfb 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -954,6 +954,37 @@
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 @@
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");
}
diff --git a/src/ss7_internal.h b/src/ss7_internal.h
index d05b16e..4539609 100644
--- a/src/ss7_internal.h
+++ b/src/ss7_internal.h
@@ -9,6 +9,9 @@
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);
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sccp/+/34589?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: Ie237ec8ac4b2e15b76fce3b3a56f47a59fdcc76e
Gerrit-Change-Number: 34589
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange