aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2020-09-24 00:54:51 +0200
committerlaforge <laforge@osmocom.org>2020-09-25 09:46:31 +0000
commit130101283771741aa1566cb09cbe3d08dcb581f6 (patch)
tree48b94c0ae52461553b44bcdaf27d3e08a5acd7ce
parent1f0625f214d912d23c9bd7a6805492d2ce4d230f (diff)
ns2: refactor handle_nsip_read/handle_nsfrgre_read
Might be more readable. Change-Id: Ib2dbcae55a8c7a973cfa1123784f509708de7f3b
-rw-r--r--src/gb/gprs_ns2_frgre.c9
-rw-r--r--src/gb/gprs_ns2_udp.c9
2 files changed, 6 insertions, 12 deletions
diff --git a/src/gb/gprs_ns2_frgre.c b/src/gb/gprs_ns2_frgre.c
index 0903e46e..e2e0b29b 100644
--- a/src/gb/gprs_ns2_frgre.c
+++ b/src/gb/gprs_ns2_frgre.c
@@ -446,12 +446,11 @@ static int handle_nsfrgre_read(struct osmo_fd *bfd)
rc = ns2_create_vc(bind, msg, "newconnection", &reject, &nsvc);
switch (rc) {
case GPRS_NS2_CS_FOUND:
- rc = ns2_recv_vc(nsvc, msg);
break;
case GPRS_NS2_CS_ERROR:
case GPRS_NS2_CS_SKIPPED:
rc = 0;
- break;
+ goto out;
case GPRS_NS2_CS_REJECTED:
/* nsip_sendmsg will free reject */
frgre_sendmsg(bind, reject, &saddr);
@@ -459,13 +458,11 @@ static int handle_nsfrgre_read(struct osmo_fd *bfd)
case GPRS_NS2_CS_CREATED:
frgre_alloc_vc(bind, nsvc, &saddr, dlci);
gprs_ns2_vc_fsm_start(nsvc);
- rc = ns2_recv_vc(nsvc, msg);
break;
}
- } else {
- /* VC found */
- rc = ns2_recv_vc(nsvc, msg);
}
+
+ rc = ns2_recv_vc(nsvc, msg);
out:
msgb_free(msg);
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c
index 2f55f2a7..bda0acff 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -195,12 +195,11 @@ static int handle_nsip_read(struct osmo_fd *bfd)
rc = ns2_create_vc(bind, msg, "newconnection", &reject, &nsvc);
switch (rc) {
case GPRS_NS2_CS_FOUND:
- rc = ns2_recv_vc(nsvc, msg);
break;
case GPRS_NS2_CS_ERROR:
case GPRS_NS2_CS_SKIPPED:
rc = 0;
- break;
+ goto out;
case GPRS_NS2_CS_REJECTED:
/* nsip_sendmsg will free reject */
nsip_sendmsg(bind, reject, &saddr);
@@ -208,14 +207,12 @@ static int handle_nsip_read(struct osmo_fd *bfd)
case GPRS_NS2_CS_CREATED:
ns2_driver_alloc_vc(bind, nsvc, &saddr);
gprs_ns2_vc_fsm_start(nsvc);
- rc = ns2_recv_vc(nsvc, msg);
break;
}
- } else {
- /* VC found */
- rc = ns2_recv_vc(nsvc, msg);
}
+ rc = ns2_recv_vc(nsvc, msg);
+out:
msgb_free(msg);
return rc;