Make subscr_conn_get_next_id RAN specific

Instead of having RAN/CN as parameter, make the function a bit simpler
and only allow RAN. The motivation for this change is, that for MGW a
similar function is required, and it was recommended in code review to
rather duplicate the short function instead of making it more complex.
I'm dropping the CN part here since it wasn't used anyway, and if used
in the future, the function could be duplicated for CN as well.

Related: SYS#5560
Change-Id: I77b0ef33f94c401d24f38eb8d79e1007234e0ab4
This commit is contained in:
Oliver Smith 2022-04-08 17:15:10 +02:00
parent ea079426ef
commit 1d20ac48fc
3 changed files with 5 additions and 12 deletions

View File

@ -36,7 +36,7 @@ struct subscr_conn {
} ran;
};
int subscr_conn_get_next_id(enum bsc_nat_net net);
int subscr_conn_get_next_id_ran();
struct subscr_conn *subscr_conn_alloc(struct msc *msc, struct bsc *bsc, uint32_t id_cn, uint32_t id_ran);

View File

@ -200,7 +200,7 @@ static int sccp_sap_up_ran(struct osmo_prim_hdr *oph, void *scu)
goto error;
}
subscr_conn = subscr_conn_alloc(msc, bsc, subscr_conn_get_next_id(BSC_NAT_NET_CN), prim->u.connect.conn_id);
subscr_conn = subscr_conn_alloc(msc, bsc, subscr_conn_get_next_id_ran(), prim->u.connect.conn_id);
LOGP(DMAIN, LOGL_DEBUG, "Fwd via %s\n", talloc_get_name(subscr_conn));

View File

@ -26,15 +26,9 @@
#include <osmocom/bsc_nat/subscr_conn.h>
#include <osmocom/bsc_nat/logging.h>
/* Get the next available id in either CN or RAN. */
int subscr_conn_get_next_id(enum bsc_nat_net net)
int subscr_conn_get_next_id_ran()
{
uint32_t *id;
if (net == BSC_NAT_NET_RAN)
id = &g_bsc_nat->ran.subscr_conn_id_next;
else
id = &g_bsc_nat->cn.subscr_conn_id_next;
uint32_t *id = &g_bsc_nat->ran.subscr_conn_id_next;
for (int i = 0; i < 0xFFFFFF; i++) {
struct subscr_conn *subscr_conn;
@ -43,8 +37,7 @@ int subscr_conn_get_next_id(enum bsc_nat_net net)
*id = (*id + 1) & 0xffffff;
llist_for_each_entry(subscr_conn, &g_bsc_nat->subscr_conns, list) {
if ((net == BSC_NAT_NET_RAN && subscr_conn->ran.id == *id)
|| (net == BSC_NAT_NET_CN && subscr_conn->cn.id == *id)) {
if (*id == subscr_conn->ran.id) {
already_used = true;
break;
}