diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-06-07 11:40:20 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-09-11 17:47:08 +0200 |
commit | 354c87cdfc4fefffeb04d5e554cc8618f19fad13 (patch) | |
tree | e05758e661b85e83b21c650d1edd482d901c983b /openbsc/src/osmo-bsc/osmo_bsc_api.c | |
parent | 8b902d74cf8b4e3c0fc2642ad144aa0dafd1ac63 (diff) |
bsc: Select a MSC in a round-robin fashion
Select a MSC, add it to the back of the list after we have
selected it.
Diffstat (limited to 'openbsc/src/osmo-bsc/osmo_bsc_api.c')
-rw-r--r-- | openbsc/src/osmo-bsc/osmo_bsc_api.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c index 04305c20f..8fa17e6ba 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_api.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c @@ -81,6 +81,25 @@ static void bsc_cipher_mode_compl(struct gsm_subscriber_connection *conn, queue_msg_or_return(resp); } +static struct osmo_msc_data *find_msc(struct gsm_subscriber_connection *conn, + struct msgb *msg) +{ + struct osmo_bsc_data *bsc; + struct osmo_msc_data *msc; + + bsc = conn->bts->network->bsc_data; + llist_for_each_entry(msc, &bsc->mscs, entry) { + if (!msc->msc_con->is_authenticated) + continue; + + /* force round robin by moving it to the end */ + llist_move_tail(&msc->entry, &bsc->mscs); + return msc; + } + + return NULL; +} + /* * Instruct to reserve data for a new connectiom, create the complete * layer three message, send it to open the connection. @@ -89,13 +108,21 @@ static int bsc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg uint16_t chosen_channel) { struct msgb *resp; + struct osmo_msc_data *msc; uint16_t network_code; uint16_t country_code; LOGP(DMSC, LOGL_INFO, "Tx MSC COMPL L3\n"); + /* find the MSC link we want to use */ + msc = find_msc(conn, msg); + if (!msc) { + LOGP(DMSC, LOGL_ERROR, "Failed to find a MSC for a connection.\n"); + return -1; + } + /* allocate resource for a new connection */ - if (bsc_create_new_connection(conn) != 0) + if (bsc_create_new_connection(conn, msc) != 0) return BSC_API_CONN_POL_REJECT; network_code = get_network_code_for_msc(conn->sccp_con->msc); |