summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2015-12-26 23:34:03 +0100
committerHarald Welte <laforge@gnumonks.org>2017-01-27 09:59:06 +0100
commit452b87285bbaa8f8a71edfe532c7437ea31f5d16 (patch)
tree067ff1b7823976535563d8675804c3db8d06b92a
parent8cfba6c1d3abdf14fb01cb42bd558a7f5f49bb38 (diff)
allow user to give private data to osmo_sua_user_create()
... which can be resolved from the primitive call back prim_cb() by calling osmo_sccp_link_get_user_priv(). Change-Id: If4c0f96f0621fb2adf4c78dc5994d3398431d92f
-rw-r--r--include/osmocom/sigtran/sua.h4
-rw-r--r--src/sua.c10
-rw-r--r--tests/sigtran/sua_client_test.c2
-rw-r--r--tests/sigtran/sua_server_test.c2
4 files changed, 14 insertions, 4 deletions
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 @@ struct osmo_sccp_link;
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 @@ struct osmo_sccp_link *osmo_sua_client_get_link(struct osmo_sccp_user *user);
/* 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 osmo_sccp_user {
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 @@ struct osmo_sccp_link *osmo_sua_client_get_link(struct osmo_sccp_user *user)
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 @@ struct osmo_sccp_user *osmo_sua_user_create(void *ctx, osmo_prim_cb prim_cb)
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 @@ int main(int argc, char **argv)
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 @@ int main(int argc, char **argv)
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) {