aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-03-04 14:39:22 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-03-04 14:57:09 +0100
commit5d9004bc9b6f486fff032aaa2a6cc10fca180de3 (patch)
treefeb1289dbede42ad3c7ec4a77df445be4421794d /openbsc/src
parenta4198d192234a8180a89be8b91e867a1cbc1f512 (diff)
gsm_subscriber_connection: further split between BSC and MSC
Move some Iu/A members into the MSC #ifdef. Have separate allocate and free functions for the two scopes.
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/libbsc/bsc_api.c16
-rw-r--r--openbsc/src/libmsc/gsm_subscriber.c28
-rw-r--r--openbsc/src/libmsc/iu_cs.c2
-rw-r--r--openbsc/src/libmsc/osmo_msc.c3
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_api.c2
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_bssap.c2
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_sccp.c4
7 files changed, 39 insertions, 18 deletions
diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c
index 9dc394c9c..ec3d92677 100644
--- a/openbsc/src/libbsc/bsc_api.c
+++ b/openbsc/src/libbsc/bsc_api.c
@@ -240,11 +240,7 @@ static int handle_new_assignment(struct gsm_subscriber_connection *conn, int cha
return 0;
}
-/* Allocate a subscriber connection for A-interface link. For Iu-CS see
- * subscr_con_allocate_iu(). */
-/* TODO this shall move to libmsc, behind an actual A-interface, and lchan will
- * not be involved. */
-struct gsm_subscriber_connection *subscr_con_allocate(struct gsm_lchan *lchan)
+struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_lchan *lchan)
{
struct gsm_subscriber_connection *conn;
struct gsm_network *network = lchan->ts->trx->bts->network;
@@ -256,15 +252,13 @@ struct gsm_subscriber_connection *subscr_con_allocate(struct gsm_lchan *lchan)
/* Configure the time and start it so it will be closed */
/* FIXME: above comment is weird in at least two ways */
conn->network = network;
- conn->via_iface = IFACE_A;
conn->lchan = lchan;
lchan->conn = conn;
llist_add_tail(&conn->entry, &network->subscr_conns);
return conn;
}
-/* TODO: move subscriber put here... */
-void subscr_con_free(struct gsm_subscriber_connection *conn)
+void bsc_subscr_con_free(struct gsm_subscriber_connection *conn)
{
if (!conn)
return;
@@ -688,7 +682,7 @@ int gsm0408_rcvmsg(struct msgb *msg, uint8_t link_id)
} else {
/* allocate a new connection */
rc = BSC_API_CONN_POL_REJECT;
- lchan->conn = subscr_con_allocate(msg->lchan);
+ lchan->conn = bsc_subscr_con_allocate(msg->lchan);
if (!lchan->conn) {
lchan_release(lchan, 1, RSL_REL_NORMAL);
return -1;
@@ -699,7 +693,7 @@ int gsm0408_rcvmsg(struct msgb *msg, uint8_t link_id)
if (rc != BSC_API_CONN_POL_ACCEPT) {
lchan->conn->lchan = NULL;
- subscr_con_free(lchan->conn);
+ bsc_subscr_con_free(lchan->conn);
lchan_release(lchan, 1, RSL_REL_NORMAL);
}
}
@@ -857,7 +851,7 @@ static void handle_release(struct gsm_subscriber_connection *conn,
gsm0808_clear(conn);
if (destruct)
- subscr_con_free(conn);
+ bsc_subscr_con_free(conn);
}
static void handle_chan_ack(struct gsm_subscriber_connection *conn,
diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c
index 9342a2972..7489b169f 100644
--- a/openbsc/src/libmsc/gsm_subscriber.c
+++ b/openbsc/src/libmsc/gsm_subscriber.c
@@ -370,3 +370,31 @@ void subscr_expire(struct gsm_subscriber_group *sgrp)
{
db_subscriber_expire(sgrp->net, subscr_expire_callback);
}
+
+struct gsm_subscriber_connection *msc_subscr_con_allocate(struct gsm_network *network)
+{
+ struct gsm_subscriber_connection *conn;
+
+ conn = talloc_zero(network, struct gsm_subscriber_connection);
+ if (!conn)
+ return NULL;
+
+ conn->network = network;
+ llist_add_tail(&conn->entry, &network->subscr_conns);
+ return conn;
+}
+
+void msc_subscr_con_free(struct gsm_subscriber_connection *conn)
+{
+ if (!conn)
+ return;
+
+
+ if (conn->subscr) {
+ subscr_put(conn->subscr);
+ conn->subscr = NULL;
+ }
+
+ llist_del(&conn->entry);
+ talloc_free(conn);
+}
diff --git a/openbsc/src/libmsc/iu_cs.c b/openbsc/src/libmsc/iu_cs.c
index 646235f7c..2aabf200f 100644
--- a/openbsc/src/libmsc/iu_cs.c
+++ b/openbsc/src/libmsc/iu_cs.c
@@ -95,7 +95,7 @@ int gsm0408_rcvmsg_iucs(struct gsm_network *network, struct msgb *msg)
rc = msc_compl_l3(conn, msg, 0);
if (rc != MSC_CONN_ACCEPT) {
- subscr_con_free(conn);
+ msc_subscr_con_free(conn);
rc = -1;
}
else
diff --git a/openbsc/src/libmsc/osmo_msc.c b/openbsc/src/libmsc/osmo_msc.c
index 8618b00f7..0e91512d7 100644
--- a/openbsc/src/libmsc/osmo_msc.c
+++ b/openbsc/src/libmsc/osmo_msc.c
@@ -151,6 +151,5 @@ void msc_release_connection(struct gsm_subscriber_connection *conn)
subscr_update_expire_lu(conn->network, conn->subscr);
conn->in_release = 1;
- gsm0808_clear(conn);
- subscr_con_free(conn);
+ msc_subscr_con_free(conn);
}
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c
index fbeed77b7..7e9894cdb 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_api.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c
@@ -330,7 +330,7 @@ static int move_to_msc(struct gsm_subscriber_connection *_conn,
_conn->sccp_con = NULL;
if (complete_layer3(_conn, msg, msc) != BSC_API_CONN_POL_ACCEPT) {
gsm0808_clear(_conn);
- subscr_con_free(_conn);
+ bsc_subscr_con_free(_conn);
return 1;
}
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c
index a60940d22..f38c97f19 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c
@@ -185,7 +185,7 @@ static int bssmap_handle_clear_command(struct osmo_bsc_sccp_con *conn,
if (conn->conn) {
LOGP(DMSC, LOGL_INFO, "Releasing all transactions on %p\n", conn);
gsm0808_clear(conn->conn);
- subscr_con_free(conn->conn);
+ bsc_subscr_con_free(conn->conn);
conn->conn = NULL;
}
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c
index 33c737f52..01af3d904 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c
@@ -84,7 +84,7 @@ static void msc_outgoing_sccp_state(struct sccp_connection *conn, int old_state)
LOGP(DMSC, LOGL_ERROR,
"ERROR: The lchan is still associated.\n");
gsm0808_clear(con_data->conn);
- subscr_con_free(con_data->conn);
+ bsc_subscr_con_free(con_data->conn);
con_data->conn = NULL;
}
@@ -107,7 +107,7 @@ static void bsc_sccp_force_free(struct osmo_bsc_sccp_con *data)
{
if (data->conn) {
gsm0808_clear(data->conn);
- subscr_con_free(data->conn);
+ bsc_subscr_con_free(data->conn);
data->conn = NULL;
}