This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgNeels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/11118 Change subject: cosmetic: allocate ss7->sccp in one common function ...................................................................... cosmetic: allocate ss7->sccp in one common function Instead of allocating ss7->sccp in various places, unify that in one common function. We shouldn't spread the decision what to pass as priv pointer around everywhere. There is no functional difference. This is preparation for a patch where the sccp_instance gets allocated from the telnet VTY: I would prefer to hide all allocation details from that code; which also makes sense for the other callers of osmo_sccp_instance_create(). Change-Id: Ie912898c66d31ce4ac8eeeea5a6ddc3f821c06f7 --- M include/osmocom/sigtran/osmo_ss7.h M src/osmo_ss7.c M src/sccp_user.c 3 files changed, 20 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/18/11118/1 diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index a93c663..34d5408 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -111,6 +111,8 @@ int osmo_ss7_instance_bind(struct osmo_ss7_instance *inst); int osmo_ss7_bind_all_instances(); +struct osmo_sccp_instance *osmo_ss7_ensure_sccp(struct osmo_ss7_instance *inst); + /*********************************************************************** * MTP Users (Users of MTP, such as SCCP or ISUP) ***********************************************************************/ diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index 025c21c..9805b3b 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -460,6 +460,18 @@ return rc; } +/*! Allocate an SCCP instance, if not present yet. + * \returns inst->sccp. */ +struct osmo_sccp_instance *osmo_ss7_ensure_sccp(struct osmo_ss7_instance *inst) +{ + if (inst->sccp) + return inst->sccp; + + LOGSS7(inst, LOGL_NOTICE, "Creating SCCP instance\n"); + inst->sccp = osmo_sccp_instance_create(inst, NULL); + return inst->sccp; +} + /*********************************************************************** * MTP Users (Users of MTP, such as SCCP or ISUP) ***********************************************************************/ @@ -1169,8 +1181,8 @@ llist_add_tail(&asp->list, &inst->asp_list); /* The SUA code internally needs SCCP to work */ - if (proto == OSMO_SS7_ASP_PROT_SUA && !inst->sccp) - inst->sccp = osmo_sccp_instance_create(inst, NULL); + if (proto == OSMO_SS7_ASP_PROT_SUA) + osmo_ss7_ensure_sccp(inst); } return asp; @@ -1817,8 +1829,8 @@ llist_add_tail(&oxs->list, &inst->xua_servers); /* The SUA code internally needs SCCP to work */ - if (proto == OSMO_SS7_ASP_PROT_SUA && !inst->sccp) - inst->sccp = osmo_sccp_instance_create(inst, NULL); + if (proto == OSMO_SS7_ASP_PROT_SUA) + osmo_ss7_ensure_sccp(inst); return oxs; } diff --git a/src/sccp_user.c b/src/sccp_user.c index 99ed96e..020166d 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -480,9 +480,7 @@ LOGP(DLSCCP, LOGL_NOTICE, "%s: Using ASP instance %s\n", name, asp->cfg.name); - /* Allocate SCCP instance */ - LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating SCCP instance\n", name); - ss7->sccp = osmo_sccp_instance_create(ss7, NULL); + osmo_ss7_ensure_sccp(ss7); if (!ss7->sccp) goto out_asp; @@ -562,7 +560,7 @@ goto out_xs; /* Allocate SCCP stack */ - ss7->sccp = osmo_sccp_instance_create(ss7, NULL); + osmo_ss7_ensure_sccp(ss7); if (!ss7->sccp) goto out_xs; -- To view, visit https://gerrit.osmocom.org/11118 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: Ie912898c66d31ce4ac8eeeea5a6ddc3f821c06f7 Gerrit-Change-Number: 11118 Gerrit-PatchSet: 1 Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180927/f1621124/attachment.htm>