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/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. Change subject: reinvent connection_for_subscr() and move to libmsc ...................................................................... reinvent connection_for_subscr() and move to libmsc Implement connection_for_subscr() from a completely different angle: instead of looking up lchans in bts structs, look up the subscriber in the global list of gsm_subscriber_connection. static lchan_find() is thus obsoleted. All callers of connection_for_subscr() live in libmsc, so move to libmsc. The move and edit are done in a single commit since the old and new implementation have nothing in common. Future: osmo-cscn will use this, without bts being present. Remove implementation of connection_for_subscr() from channel_test.c -- it is possible that the abort() in there was intended for a regression test, but actually it seems the implementation was merely added for linking reasons, and the abort() added to guard against the NULL return value: no comment nor the commit log indicate that the abort() is test critical; the addition was the only change in channel_test.c for that commit; at the same time a connection_for_subscr() call was added in libmsc. Change-Id: I5e0ba0ecf1726ebd540800f4e98fdfc937c904ff --- M openbsc/src/libbsc/chan_alloc.c M openbsc/src/libmsc/gsm_subscriber.c M openbsc/tests/channel/channel_test.c 3 files changed, 14 insertions(+), 35 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c index 367139c..0f4d90a 100644 --- a/openbsc/src/libbsc/chan_alloc.c +++ b/openbsc/src/libbsc/chan_alloc.c @@ -481,39 +481,6 @@ return 1; } -static struct gsm_lchan* lchan_find(struct gsm_bts *bts, struct gsm_subscriber *subscr) { - struct gsm_bts_trx *trx; - int ts_no, lchan_no; - - llist_for_each_entry(trx, &bts->trx_list, list) { - for (ts_no = 0; ts_no < 8; ++ts_no) { - for (lchan_no = 0; lchan_no < TS_MAX_LCHAN; ++lchan_no) { - struct gsm_lchan *lchan = - &trx->ts[ts_no].lchan[lchan_no]; - if (lchan->conn && subscr == lchan->conn->subscr) - return lchan; - } - } - } - - return NULL; -} - -struct gsm_subscriber_connection *connection_for_subscr(struct gsm_subscriber *subscr) -{ - struct gsm_bts *bts; - struct gsm_network *net = subscr->group->net; - struct gsm_lchan *lchan; - - llist_for_each_entry(bts, &net->bts_list, list) { - lchan = lchan_find(bts, subscr); - if (lchan) - return lchan->conn; - } - - return NULL; -} - void bts_chan_load(struct pchan_load *cl, const struct gsm_bts *bts) { struct gsm_bts_trx *trx; diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c index 08198c7..4ec0ead 100644 --- a/openbsc/src/libmsc/gsm_subscriber.c +++ b/openbsc/src/libmsc/gsm_subscriber.c @@ -374,3 +374,17 @@ { db_subscriber_expire(sgrp->net, subscr_expire_callback); } + +struct gsm_subscriber_connection *connection_for_subscr(struct gsm_subscriber *subscr) +{ + /* FIXME: replace this with a backpointer in gsm_subscriber? */ + struct gsm_network *net = subscr->group->net; + struct gsm_subscriber_connection *conn; + + llist_for_each_entry(conn, &net->subscr_conns, entry) { + if (conn->subscr == subscr) + return conn; + } + + return NULL; +} diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c index 351bb5a..c69c701 100644 --- a/openbsc/tests/channel/channel_test.c +++ b/openbsc/tests/channel/channel_test.c @@ -138,8 +138,6 @@ void gsm48_secure_channel() {} void paging_request_stop() {} void vty_out() {} -void* connection_for_subscr(void) { abort(); return NULL; } - struct tlv_definition nm_att_tlvdef; -- To view, visit https://gerrit.osmocom.org/1136 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5e0ba0ecf1726ebd540800f4e98fdfc937c904ff Gerrit-PatchSet: 8 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder