diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-05-20 17:15:44 +0200 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-09-29 13:20:44 +0200 |
commit | 1cd730a3b55e707a022aba3e5d28e03059e93a8c (patch) | |
tree | ae61356d21c645e2bd823743e3303290a289edf5 /openbsc | |
parent | 7abc527d128f03619a975bc09139c4141061d034 (diff) |
split subscr_con_allocate()/_free() in bsc_ and msc_
Rename current subscr_con_allocate() and subscr_con_free to bsc_*,
and add two separate msc_subscr_con_allocate() and _free().
The msc_subscr_con_free() ignores all lchan members.
In libbsc use bsc_*, in libmsc use msc_*.
Change-Id: I3cf7c7cafdf4672ec7b26058bba8a77159855257
Future: there will be distinct subscr conns for libbsc and libmsc.
Diffstat (limited to 'openbsc')
-rw-r--r-- | openbsc/include/openbsc/gsm_data.h | 7 | ||||
-rw-r--r-- | openbsc/src/libbsc/bsc_api.c | 11 | ||||
-rw-r--r-- | openbsc/src/libmsc/gsm_04_08.c | 27 | ||||
-rw-r--r-- | openbsc/src/libmsc/osmo_msc.c | 2 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc/osmo_bsc_api.c | 2 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc/osmo_bsc_bssap.c | 2 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc/osmo_bsc_sccp.c | 4 |
7 files changed, 42 insertions, 13 deletions
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 17a976622..ecde2f0e9 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -506,8 +506,11 @@ struct gsm_meas_rep *lchan_next_meas_rep(struct gsm_lchan *lchan); int gsm_btsmodel_set_feature(struct gsm_bts_model *model, enum gsm_bts_features feat); int gsm_bts_model_register(struct gsm_bts_model *model); -struct gsm_subscriber_connection *subscr_con_allocate(struct gsm_lchan *lchan); -void subscr_con_free(struct gsm_subscriber_connection *conn); +struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_lchan *lchan); +void bsc_subscr_con_free(struct gsm_subscriber_connection *conn); + +struct gsm_subscriber_connection *msc_subscr_con_allocate(struct gsm_network *network); +void msc_subscr_con_free(struct gsm_subscriber_connection *conn); struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net, enum gsm_bts_type type, diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c index cc12e9f7e..eda736826 100644 --- a/openbsc/src/libbsc/bsc_api.c +++ b/openbsc/src/libbsc/bsc_api.c @@ -238,7 +238,7 @@ static int handle_new_assignment(struct gsm_subscriber_connection *conn, int cha return 0; } -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 *net = lchan->ts->trx->bts->network; @@ -255,8 +255,7 @@ struct gsm_subscriber_connection *subscr_con_allocate(struct gsm_lchan *lchan) 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; @@ -678,7 +677,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; @@ -689,7 +688,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); } } @@ -848,7 +847,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_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 09a0b515b..46d039fea 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -3649,6 +3649,33 @@ int gsm0408_new_conn(struct gsm_subscriber_connection *conn) return 0; } +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); +} + /* Main entry point for GSM 04.08/44.008 Layer 3 data (e.g. from the BSC). */ int gsm0408_dispatch(struct gsm_subscriber_connection *conn, struct msgb *msg) { diff --git a/openbsc/src/libmsc/osmo_msc.c b/openbsc/src/libmsc/osmo_msc.c index 604c100db..12a5117fa 100644 --- a/openbsc/src/libmsc/osmo_msc.c +++ b/openbsc/src/libmsc/osmo_msc.c @@ -173,5 +173,5 @@ void msc_release_connection(struct gsm_subscriber_connection *conn) 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 e7598057f..4742e8dd1 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 fa060da66..4bde1e96f 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; } |