This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
neels gerrit-no-reply at lists.osmocom.orgneels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/20356 ) Change subject: LCS: SCCP next conn id: prepare Lb-interface ...................................................................... LCS: SCCP next conn id: prepare Lb-interface When adding the Lb interface, it is necessary to determine an unused conn id across *all* SCCP users. Prepare adding Lb by moving conn id creation out of the gscon code and generalizing. Change-Id: I12fcb18f6e4380f72929cfe7681bac05330a8c9a --- M include/osmocom/bsc/gsm_data.h M src/osmo-bsc/Makefile.am A src/osmo-bsc/bsc_sccp.c M src/osmo-bsc/osmo_bsc_sigtran.c 4 files changed, 62 insertions(+), 24 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/56/20356/1 diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 90ab8ea..1ea0172 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -50,6 +50,7 @@ struct bsc_subscr; struct gprs_ra_id; struct handover; +struct osmo_sccp_instance; #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] @@ -1246,4 +1247,6 @@ enum gsm48_rr_cause bsc_gsm48_rr_cause_from_gsm0808_cause(enum gsm0808_cause c); enum gsm48_rr_cause bsc_gsm48_rr_cause_from_rsl_cause(uint8_t c); +int bsc_sccp_inst_next_conn_id(struct osmo_sccp_instance *sccp); + #endif /* _GSM_DATA_H */ diff --git a/src/osmo-bsc/Makefile.am b/src/osmo-bsc/Makefile.am index c19d01b..b0fc181 100644 --- a/src/osmo-bsc/Makefile.am +++ b/src/osmo-bsc/Makefile.am @@ -40,6 +40,7 @@ bsc_init.c \ bsc_rf_ctrl.c \ bsc_rll.c \ + bsc_sccp.c \ bsc_subscr_conn_fsm.c \ bsc_subscriber.c \ bsc_vty.c \ diff --git a/src/osmo-bsc/bsc_sccp.c b/src/osmo-bsc/bsc_sccp.c new file mode 100644 index 0000000..9d4289f --- /dev/null +++ b/src/osmo-bsc/bsc_sccp.c @@ -0,0 +1,57 @@ +/* Generic SCCP handling across all OsmoBSC users */ +/* + * (C) 2020 by sysmocom - s.f.m.c. GmbH <info at sysmocom.de> + * + * All Rights Reserved + * + * Author: Neels Hofmeyr <neels at hofmeyr.de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <osmocom/bsc/gsm_data.h> +#include <osmocom/bsc/bsc_msc_data.h> + +/* We need an unused SCCP conn_id across all SCCP users. */ +int bsc_sccp_inst_next_conn_id(struct osmo_sccp_instance *sccp) +{ + static uint32_t next_id = 1; + int i; + + /* This looks really suboptimal, but in most cases the static next_id should indicate exactly the next unused + * conn_id, and we only iterate all conns once to make super sure that it is not already in use. */ + + for (i = 0; i < 0xFFFFFF; i++) { + struct gsm_subscriber_connection *conn; + uint32_t conn_id = next_id; + bool conn_id_already_used = false; + next_id = (next_id + 1) & 0xffffff; + + llist_for_each_entry(conn, &bsc_gsmnet->subscr_conns, entry) { + if (conn->sccp.msc && conn->sccp.msc->a.sccp == sccp) { + if (conn_id == conn->sccp.conn_id) { + conn_id_already_used = true; + break; + } + } + + /* Future for LCS: also check Lb-interface conn IDs here */ + } + + if (!conn_id_already_used) + return conn_id; + } + return -1; +} diff --git a/src/osmo-bsc/osmo_bsc_sigtran.c b/src/osmo-bsc/osmo_bsc_sigtran.c index e0c24ef..6853fac 100644 --- a/src/osmo-bsc/osmo_bsc_sigtran.c +++ b/src/osmo-bsc/osmo_bsc_sigtran.c @@ -44,11 +44,6 @@ #define DEFAULT_ASP_LOCAL_IP "localhost" #define DEFAULT_ASP_REMOTE_IP "localhost" -/* The SCCP stack will not assign connection IDs to us automatically, we - * will do this ourselves using a counter variable, that counts one up - * for every new connection */ -static uint32_t conn_id_counter; - /* Helper function to Check if the given connection id is already assigned */ static struct gsm_subscriber_connection *get_bsc_conn_by_conn_id(int conn_id) { @@ -76,24 +71,6 @@ return NULL; } -/* Pick a free connection id */ -static int pick_free_conn_id(const struct bsc_msc_data *msc) -{ - int conn_id = conn_id_counter; - int i; - - for (i = 0; i < 0xFFFFFF; i++) { - conn_id++; - conn_id &= 0xFFFFFF; - if (get_bsc_conn_by_conn_id(conn_id) == false) { - conn_id_counter = conn_id; - return conn_id; - } - } - - return -1; -} - /* Patch regular BSSMAP RESET to add extra T to announce Osmux support (osmocom extension) */ static void _gsm0808_extend_announce_osmux(struct msgb *msg) { @@ -353,7 +330,7 @@ return -EINVAL; } - conn->sccp.conn_id = conn_id = pick_free_conn_id(msc); + conn->sccp.conn_id = conn_id = bsc_sccp_inst_next_conn_id(conn->sccp.msc->a.sccp); if (conn->sccp.conn_id < 0) { LOGP(DMSC, LOGL_ERROR, "Unable to allocate SCCP Connection ID\n"); return -1; -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/20356 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: I12fcb18f6e4380f72929cfe7681bac05330a8c9a Gerrit-Change-Number: 20356 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofmeyr at sysmocom.de> Gerrit-CC: Jenkins Builder Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201001/22e3e123/attachment.htm>