aboutsummaryrefslogtreecommitdiffstats
path: root/src/gb/gprs_ns2_sns.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-03-04 13:03:27 +0100
committerHarald Welte <laforge@osmocom.org>2021-03-05 17:08:03 +0100
commit24920e2c9747ef73e9233d11fb91acccb8f0beb6 (patch)
treee665cee70f5e1b0d8004c55964e0f91155b0cc83 /src/gb/gprs_ns2_sns.c
parent2230a917118bee515298450da45af8309f45f120 (diff)
gprs_ns2_sns: refactor ns2_sns_st_size_onenter()
Let's move computing of the local IP endpoints to a separate function, so it can not only be used when entering the SNS_SIZE state. Preparation for SGSN-side IP-SNS. Change-Id: I5d7ce419135a8ef538cf9abcb76a49049ed7d5f9 Related: OS#3373
Diffstat (limited to 'src/gb/gprs_ns2_sns.c')
-rw-r--r--src/gb/gprs_ns2_sns.c71
1 files changed, 40 insertions, 31 deletions
diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c
index 04cebf49..1d4d0692 100644
--- a/src/gb/gprs_ns2_sns.c
+++ b/src/gb/gprs_ns2_sns.c
@@ -723,8 +723,7 @@ static void ns2_sns_st_size(struct osmo_fsm_inst *fi, uint32_t event, void *data
}
}
-/* setup all dynamic SNS settings, create a new nsvc and send the SIZE */
-static void ns2_sns_st_size_onenter(struct osmo_fsm_inst *fi, uint32_t old_state)
+static void ns2_sns_compute_local_ep_from_binds(struct osmo_fsm_inst *fi)
{
struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv;
struct gprs_ns_ie_ip4_elem *ip4_elems;
@@ -736,14 +735,6 @@ static void ns2_sns_st_size_onenter(struct osmo_fsm_inst *fi, uint32_t old_state
struct osmo_sockaddr local;
int count;
- /* on a generic failure, the timer callback will recover */
- if (old_state != GPRS_SNS_ST_UNCONFIGURED)
- ns2_prim_status_ind(gss->nse, NULL, 0, GPRS_NS2_AFF_CAUSE_SNS_FAILURE);
- if (old_state != GPRS_SNS_ST_SIZE)
- gss->N = 0;
-
-
- gss->alive = false;
ns2_clear_ipv46_entries(gss);
/* no initial available */
@@ -759,27 +750,6 @@ static void ns2_sns_st_size_onenter(struct osmo_fsm_inst *fi, uint32_t old_state
return;
}
- /* 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);
- }
- }
-
- bind = gss->initial_bind->bind;
-
- /* setup the NSVC */
- if (!gss->sns_nsvc) {
- gss->sns_nsvc = ns2_ip_bind_connect(bind, gss->nse, remote);
- if (!gss->sns_nsvc)
- return;
- gss->sns_nsvc->sns_only = true;
- }
-
switch (gss->ip) {
case IPv4:
ip4_elems = talloc_zero_size(fi, sizeof(struct gprs_ns_ie_ip4_elem) * count);
@@ -854,6 +824,45 @@ static void ns2_sns_st_size_onenter(struct osmo_fsm_inst *fi, uint32_t old_state
gss->num_max_nsvcs = OSMO_MAX(gss->num_max_ip6_remote * gss->num_ip6_local, 8);
break;
}
+}
+
+/* setup all dynamic SNS settings, create a new nsvc and send the SIZE */
+static void ns2_sns_st_size_onenter(struct osmo_fsm_inst *fi, uint32_t old_state)
+{
+ struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv;
+
+ /* on a generic failure, the timer callback will recover */
+ if (old_state != GPRS_SNS_ST_UNCONFIGURED)
+ ns2_prim_status_ind(gss->nse, NULL, 0, GPRS_NS2_AFF_CAUSE_SNS_FAILURE);
+ if (old_state != GPRS_SNS_ST_SIZE)
+ gss->N = 0;
+
+ 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);
+ }
+ }
+
+
+ /* setup the NSVC */
+ if (!gss->sns_nsvc) {
+ struct gprs_ns2_vc_bind *bind = gss->initial_bind->bind;
+ struct osmo_sockaddr *remote = &gss->initial->saddr;
+ gss->sns_nsvc = ns2_ip_bind_connect(bind, gss->nse, remote);
+ if (!gss->sns_nsvc)
+ return;
+ gss->sns_nsvc->sns_only = true;
+ }
+
if (gss->num_max_ip4_remote > 0)
ns2_tx_sns_size(gss->sns_nsvc, true, gss->num_max_nsvcs, gss->num_max_ip4_remote, -1);