Change in libosmo-sccp[master]: sccp_scoc: conn_create{, _id}() user arg, not inst

osmith gerrit-no-reply at lists.osmocom.org
Thu Apr 11 08:08:18 UTC 2019


osmith has submitted this change and it was merged. ( https://gerrit.osmocom.org/13508 )

Change subject: sccp_scoc: conn_create{,_id}() user arg, not inst
......................................................................

sccp_scoc: conn_create{,_id}() user arg, not inst

Accept the osmo_sccp_user instead of calling conn_create() and setting
conn->user afterwards. Prepare for generating a local_ref inside
conn_create_id() in the future.

Related: OS#3871
Change-Id: I2fb47c8ba6c0ce7cd92c9ac31f15c67eb67fb66e
---
M src/sccp_scoc.c
1 file changed, 11 insertions(+), 13 deletions(-)

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



diff --git a/src/sccp_scoc.c b/src/sccp_scoc.c
index 82590a0..91a1ab7 100644
--- a/src/sccp_scoc.c
+++ b/src/sccp_scoc.c
@@ -459,16 +459,16 @@
 #define INIT_TIMER(x, fn, priv)		do { (x)->cb = fn; (x)->data = priv; } while (0)
 
 /* allocate + init a SCCP Connection with given ID */
-static struct sccp_connection *conn_create_id(struct osmo_sccp_instance *inst,
-					      uint32_t conn_id)
+static struct sccp_connection *conn_create_id(struct osmo_sccp_user *user, uint32_t conn_id)
 {
-	struct sccp_connection *conn = talloc_zero(inst, struct sccp_connection);
+	struct sccp_connection *conn = talloc_zero(user->inst, struct sccp_connection);
 	char name[16];
 
 	conn->conn_id = conn_id;
-	conn->inst = inst;
+	conn->inst = user->inst;
+	conn->user = user;
 
-	llist_add_tail(&conn->list, &inst->connections);
+	llist_add_tail(&conn->list, &user->inst->connections);
 
 	INIT_TIMER(&conn->t_conn, conn_tmr_cb, conn);
 	INIT_TIMER(&conn->t_ias, tx_inact_tmr_cb, conn);
@@ -494,15 +494,15 @@
 }
 
 /* Search for next free connection ID and allocate conn */
-static struct sccp_connection *conn_create(struct osmo_sccp_instance *inst)
+static struct sccp_connection *conn_create(struct osmo_sccp_user *user)
 {
 	uint32_t conn_id;
 
 	do {
-		conn_id = inst->next_id++;
-	} while (conn_find_by_id(inst, conn_id));
+		conn_id = user->inst->next_id++;
+	} while (conn_find_by_id(user->inst, conn_id));
 
-	return conn_create_id(inst, conn_id);
+	return conn_create_id(user, conn_id);
 }
 
 /* destroy a SCCP connection state, releasing all timers, terminating
@@ -1623,8 +1623,7 @@
 			return;
 		}
 		/* Allocate new connection */
-		conn = conn_create(inst);
-		conn->user = scu;
+		conn = conn_create(scu);
 		conn->incoming = true;
 	} else {
 		uint32_t conn_id;
@@ -1718,14 +1717,13 @@
 		return sccp_sclc_user_sap_down(scu, oph);
 	case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_REQUEST):
 		/* Allocate new connection structure */
-		conn = conn_create_id(inst, prim->u.connect.conn_id);
+		conn = conn_create_id(scu, prim->u.connect.conn_id);
 		if (!conn) {
 			/* FIXME: inform SCCP user with proper reply */
 			LOGP(DLSCCP, LOGL_ERROR, "Cannot create conn-id for primitive %s\n",
 			     osmo_scu_prim_name(&prim->oph));
 			goto out;
 		}
-		conn->user = scu;
 		break;
 	case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_RESPONSE):
 	case OSMO_PRIM(OSMO_SCU_PRIM_N_DATA, PRIM_OP_REQUEST):

-- 
To view, visit https://gerrit.osmocom.org/13508
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I2fb47c8ba6c0ce7cd92c9ac31f15c67eb67fb66e
Gerrit-Change-Number: 13508
Gerrit-PatchSet: 3
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190411/38cfdf4c/attachment.html>


More information about the gerrit-log mailing list