diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-03-04 14:39:22 +0100 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-03-04 14:57:09 +0100 |
commit | 5d9004bc9b6f486fff032aaa2a6cc10fca180de3 (patch) | |
tree | feb1289dbede42ad3c7ec4a77df445be4421794d | |
parent | a4198d192234a8180a89be8b91e867a1cbc1f512 (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.
-rw-r--r-- | openbsc/include/openbsc/gsm_data.h | 30 | ||||
-rw-r--r-- | openbsc/src/libbsc/bsc_api.c | 16 | ||||
-rw-r--r-- | openbsc/src/libmsc/gsm_subscriber.c | 28 | ||||
-rw-r--r-- | openbsc/src/libmsc/iu_cs.c | 2 | ||||
-rw-r--r-- | openbsc/src/libmsc/osmo_msc.c | 3 | ||||
-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 |
8 files changed, 59 insertions, 28 deletions
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 4b0f37245..ce16c72b5 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -135,14 +135,6 @@ struct gsm_subscriber_connection { /* back pointers */ struct gsm_network *network; - /* 2G or 3G? See enum interface_type */ - int via_iface; - - /* which Iu-CS connection, if any. */ - struct { - struct ue_conn_ctx *ue_ctx; - } iu; - /* The BSC used to be an integral part of OsmoNITB. In OsmoCSCN, the * BSC and/or RNC is a separate entity, and no back pointers to the bts * and lchan structures are available. To facilitate separation of the @@ -152,6 +144,15 @@ struct gsm_subscriber_connection { int in_release; uint16_t lac; struct gsm_encr encr; + + /* 2G or 3G? See enum interface_type */ + int via_iface; + + /* which Iu-CS connection, if any. */ + struct { + struct ue_conn_ctx *ue_ctx; + } iu; + #else struct gsm_bts *bts; struct gsm_lchan *lchan; @@ -243,6 +244,12 @@ struct gsm_tz { }; struct gsm_network { + /* TODO MSCSPLIT the gsm_network struct is basically a kitchen sink for + * global settings and variables, "madly" mixing BSC and MSC stuff. Split + * this in e.g. struct osmo_bsc and struct osmo_msc, with the things + * these have in common, like country and network code, put in yet + * separate structs and placed as members in osmo_bsc and osmo_msc. */ + /* global parameters */ uint16_t country_code; uint16_t network_code; @@ -477,8 +484,11 @@ void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts); 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 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; } |