mirror of
				https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
				synced 2025-11-03 21:43:32 +00:00 
			
		
		
		
	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.
This commit is contained in:
		@@ -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,
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user