aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2019-08-13 17:38:33 +0200
committerAlexander Couzens <lynxis@fe80.eu>2019-08-20 15:15:42 +0200
commit43fef76b76b80a1a3cec69e10f0942fff8073e4c (patch)
tree5bfda5acda0f63cecc5895eae995fd1f952a4e6b
parent89d7834e83b5e5880bf9e9922cf16a4280f2dc4a (diff)
iu_client: introduce a connection state
When the SCCP stack indicate a disconnect, save this in the UE connection to allow the application to free() the instance later. Change-Id: I77e01724be05ac488a4685ba367b7a71985b54e3
-rw-r--r--include/osmocom/ranap/iu_client.h6
-rw-r--r--src/iu_client.c6
2 files changed, 11 insertions, 1 deletions
diff --git a/include/osmocom/ranap/iu_client.h b/include/osmocom/ranap/iu_client.h
index 46a950a..3bc4a43 100644
--- a/include/osmocom/ranap/iu_client.h
+++ b/include/osmocom/ranap/iu_client.h
@@ -23,6 +23,11 @@ enum ranap_nsap_addr_enc {
RANAP_NSAP_ADDR_ENC_V4RAW,
};
+enum ranap_conn_state {
+ RANAP_CONN_STATE_CONNECTED,
+ RANAP_CONN_STATE_DISCONNECTED,
+};
+
struct ranap_ue_conn_ctx {
struct llist_head list;
struct ranap_iu_rnc *rnc;
@@ -30,6 +35,7 @@ struct ranap_ue_conn_ctx {
int integrity_active;
struct gprs_ra_id ra_id;
enum ranap_nsap_addr_enc rab_assign_addr_enc;
+ enum ranap_conn_state conn_state;
};
enum ranap_iu_event_type {
diff --git a/src/iu_client.c b/src/iu_client.c
index a0c0b8e..8436abb 100644
--- a/src/iu_client.c
+++ b/src/iu_client.c
@@ -116,6 +116,7 @@ static struct ranap_ue_conn_ctx *ue_conn_ctx_alloc(struct ranap_iu_rnc *rnc, uin
ctx->rnc = rnc;
ctx->conn_id = conn_id;
+ ctx->conn_state = RANAP_CONN_STATE_CONNECTED;
llist_add(&ctx->list, &ue_conn_ctx_list);
return ctx;
@@ -137,7 +138,9 @@ void ranap_iu_free_ue(struct ranap_ue_conn_ctx *ue_ctx)
if (!ue_ctx)
return;
- osmo_sccp_tx_disconn(g_scu, ue_ctx->conn_id, NULL, 0);
+ if (ue_ctx->conn_state == RANAP_CONN_STATE_CONNECTED)
+ osmo_sccp_tx_disconn(g_scu, ue_ctx->conn_id, NULL, 0);
+
llist_del(&ue_ctx->list);
talloc_free(ue_ctx);
}
@@ -814,6 +817,7 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *_scu)
if (msgb_l2len(oph->msg))
rc = ranap_cn_rx_co(cn_ranap_handle_co, ue, msgb_l2(oph->msg), msgb_l2len(oph->msg));
+ ue->conn_state = RANAP_CONN_STATE_DISCONNECTED;
global_iu_event_cb(ue, RANAP_IU_EVENT_LINK_INVALIDATED, NULL);
break;
case OSMO_PRIM(OSMO_SCU_PRIM_N_DATA, PRIM_OP_INDICATION):