diff options
author | Alexander Couzens <lynxis@fe80.eu> | 2021-04-26 20:39:46 +0200 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2021-06-07 12:39:47 +0000 |
commit | 6608ce9525d0447e1159f66bf2a0cf6278993c12 (patch) | |
tree | 2187ad771fc9637c6699ecf31395ebf453807d48 | |
parent | 05047b7f270048a31af786461161ad07fb24e25a (diff) |
gprs_ns2_sns: move selection of the next bind into own function
It will be also used by del_bind() when removing an active bind
Related: OS#5036
Change-Id: Ic39f0e5474ecc055d9a1b6a7b30777574d8b741d
-rw-r--r-- | src/gb/gprs_ns2_sns.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c index 296a2e72..5d85ec08 100644 --- a/src/gb/gprs_ns2_sns.c +++ b/src/gb/gprs_ns2_sns.c @@ -883,6 +883,15 @@ static void ns2_sns_compute_local_ep_from_binds(struct osmo_fsm_inst *fi) } } +static void ns2_sns_choose_next_bind(struct ns2_sns_state *gss) +{ + /* take the first bind or take the next bind */ + if (!gss->initial_bind || gss->initial_bind->list.next == &gss->binds) + gss->initial_bind = llist_first_entry_or_null(&gss->binds, struct ns2_sns_bind, list); + else + gss->initial_bind = llist_entry(gss->initial_bind->list.next, struct ns2_sns_bind, list); +} + /* setup all dynamic SNS settings, create a new nsvc and send the SIZE */ static void ns2_sns_st_bss_size_onenter(struct osmo_fsm_inst *fi, uint32_t old_state) { @@ -899,18 +908,7 @@ static void ns2_sns_st_bss_size_onenter(struct osmo_fsm_inst *fi, uint32_t old_s gss->alive = false; ns2_sns_compute_local_ep_from_binds(fi); - - /* take the first bind or take the next bind */ - if (!gss->initial_bind) { - gss->initial_bind = llist_first_entry(&gss->binds, struct ns2_sns_bind, list); - } else { - if (gss->initial_bind->list.next != &gss->binds) { - gss->initial_bind = llist_entry(gss->initial_bind->list.next, struct ns2_sns_bind, list); - } else { - gss->initial_bind = llist_first_entry(&gss->binds, struct ns2_sns_bind, list); - } - } - + ns2_sns_choose_next_bind(gss); /* setup the NSVC */ if (!gss->sns_nsvc) { |