[MERGED] libosmo-sccp[master]: Add osmo_ss7_find_free_rctx() function to get unused rctx

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Apr 10 11:26:59 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: Add osmo_ss7_find_free_rctx() function to get unused rctx
......................................................................


Add osmo_ss7_find_free_rctx() function to get unused rctx

Change-Id: I0186e25a1b3a325c6b0e3f50ef1590c4de6dbef6
---
M include/osmocom/sigtran/osmo_ss7.h
M src/osmo_ss7.c
2 files changed, 12 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h
index d765ae0..4eece3e 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -15,6 +15,7 @@
 struct osmo_mtp_prim;
 
 int osmo_ss7_init(void);
+int osmo_ss7_find_free_rctx(struct osmo_ss7_instance *inst);
 
 bool osmo_ss7_pc_is_local(struct osmo_ss7_instance *inst, uint32_t pc);
 int osmo_ss7_pointcode_parse(struct osmo_ss7_instance *inst, const char *str);
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index f7f2519..7909bfd 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -53,6 +53,7 @@
 
 static LLIST_HEAD(ss7_instances);
 static LLIST_HEAD(ss7_xua_servers);
+static int32_t next_rctx = 1;
 
 struct value_string osmo_ss7_as_traffic_mode_vals[] = {
 	{ OSMO_SS7_AS_TMOD_BCAST,	"broadcast" },
@@ -72,6 +73,16 @@
 #define LOGSS7(inst, level, fmt, args ...)	\
 	LOGP(DLSS7, level, "%u: " fmt, (inst)->cfg.id, ## args)
 
+int osmo_ss7_find_free_rctx(struct osmo_ss7_instance *inst)
+{
+	int32_t rctx;
+
+	for (rctx = next_rctx; rctx; rctx = ++next_rctx) {
+		if (!osmo_ss7_as_find_by_rctx(inst, next_rctx))
+			return rctx;
+	}
+	return -1;
+}
 
 /***********************************************************************
  * SS7 Point Code Parsing / Printing

-- 
To view, visit https://gerrit.osmocom.org/2258
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0186e25a1b3a325c6b0e3f50ef1590c4de6dbef6
Gerrit-PatchSet: 6
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list