[PATCH] libosmo-sccp[master]: allow user to give private data to osmo_sua_user_create()

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Jan 25 21:40:14 UTC 2017


Review at  https://gerrit.osmocom.org/1665

allow user to give private data to osmo_sua_user_create()

... which can be resolved from the prim_cb() by calling
osmo_sccp_link_get_user_priv().

Change-Id: If4c0f96f0621fb2adf4c78dc5994d3398431d92f
---
M include/osmocom/sigtran/sua.h
M src/sua.c
M tests/sigtran/sua_client_test.c
M tests/sigtran/sua_server_test.c
4 files changed, 14 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/65/1665/1

diff --git a/include/osmocom/sigtran/sua.h b/include/osmocom/sigtran/sua.h
index 935a4c0..766b488 100644
--- a/include/osmocom/sigtran/sua.h
+++ b/include/osmocom/sigtran/sua.h
@@ -8,7 +8,8 @@
 
 void osmo_sua_set_log_area(int area);
 
-struct osmo_sccp_user *osmo_sua_user_create(void *ctx, osmo_prim_cb prim_cb);
+struct osmo_sccp_user *osmo_sua_user_create(void *ctx, osmo_prim_cb prim_cb,
+					    void *priv);
 void osmo_sua_user_destroy(struct osmo_sccp_user *user);
 
 int osmo_sua_server_listen(struct osmo_sccp_user *user, const char *hostname, uint16_t port);
@@ -19,3 +20,4 @@
 /* user hands us a SCCP-USER SAP primitive down into the stack */
 int osmo_sua_user_link_down(struct osmo_sccp_link *link, struct osmo_prim_hdr *oph);
 
+void *osmo_sccp_link_get_user_priv(struct osmo_sccp_link *slink);
diff --git a/src/sua.c b/src/sua.c
index 442b2a0..5af8c18 100644
--- a/src/sua.c
+++ b/src/sua.c
@@ -59,6 +59,7 @@
 	struct llist_head links;
 	/* user call-back function in case of incoming primitives */
 	osmo_prim_cb prim_cb;
+	void *priv;
 };
 
 struct osmo_sccp_link {
@@ -1401,11 +1402,13 @@
 
 static LLIST_HEAD(sua_users);
 
-struct osmo_sccp_user *osmo_sua_user_create(void *ctx, osmo_prim_cb prim_cb)
+struct osmo_sccp_user *osmo_sua_user_create(void *ctx, osmo_prim_cb prim_cb,
+					    void *priv)
 {
 	struct osmo_sccp_user *user = talloc_zero(ctx, struct osmo_sccp_user);
 
 	user->prim_cb = prim_cb;
+	user->priv = priv;
 	INIT_LLIST_HEAD(&user->links);
 
 	llist_add_tail(&user->list, &sua_users);
@@ -1413,6 +1416,11 @@
 	return user;
 }
 
+void *osmo_sccp_link_get_user_priv(struct osmo_sccp_link *slink)
+{
+	return slink->user->priv;
+}
+
 void osmo_sua_user_destroy(struct osmo_sccp_user *user)
 {
 	struct osmo_sccp_link *link;
diff --git a/tests/sigtran/sua_client_test.c b/tests/sigtran/sua_client_test.c
index 5ea7714..3cbd937 100644
--- a/tests/sigtran/sua_client_test.c
+++ b/tests/sigtran/sua_client_test.c
@@ -36,7 +36,7 @@
 
 	osmo_init_logging(&test_log_info);
 
-	g_user = osmo_sua_user_create(ctx, sccp_sap_up);
+	g_user = osmo_sua_user_create(ctx, sccp_sap_up, NULL);
 
 	rc = osmo_sua_client_connect(g_user, "127.0.0.1", 2342);
 	if (rc < 0) {
diff --git a/tests/sigtran/sua_server_test.c b/tests/sigtran/sua_server_test.c
index 0e8d9ca..97b2baf 100644
--- a/tests/sigtran/sua_server_test.c
+++ b/tests/sigtran/sua_server_test.c
@@ -65,7 +65,7 @@
 
 	osmo_init_logging(&test_log_info);
 
-	user = osmo_sua_user_create(ctx, sccp_sap_up);
+	user = osmo_sua_user_create(ctx, sccp_sap_up, NULL);
 
 	rc = osmo_sua_server_listen(user, "127.0.0.1", 2342);
 	if (rc < 0) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If4c0f96f0621fb2adf4c78dc5994d3398431d92f
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>


More information about the gerrit-log mailing list