[PATCH] osmo-ggsn[master]: ggsn.c: cb_tun_ind: Convert ifelse to switch statement

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/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Tue Jan 30 15:19:03 UTC 2018


Review at  https://gerrit.osmocom.org/6200

ggsn.c: cb_tun_ind: Convert ifelse to switch statement

Change-Id: I4fc97f367ae615cdf0a9501f89419990c2fd4599
---
M ggsn/ggsn.c
1 file changed, 7 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/00/6200/1

diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index de8090b..37a2fca 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -726,13 +726,15 @@
 	struct ip6_hdr *ip6h = (struct ip6_hdr *)pack;
 	struct ippool_t *pool;
 
-	if (iph->version == 4) {
+	switch (iph->version) {
+	case 4:
 		if (len < sizeof(*iph) || len < 4*iph->ihl)
 			return -1;
 		dst.len = 4;
 		dst.v4.s_addr = iph->daddr;
 		pool = apn->v4.pool;
-	} else if (iph->version == 6) {
+		break;
+	case 6:
 		/* Due to the fact that 3GPP requires an allocation of a
 		 * /64 prefix to each MS, we must instruct
 		 * ippool_getip() below to match only the leading /64
@@ -740,7 +742,8 @@
 		dst.len = 8;
 		dst.v6 = ip6h->ip6_dst;
 		pool = apn->v6.pool;
-	} else {
+		break;
+	default:
 		LOGP(DTUN, LOGL_NOTICE, "non-IPv%u packet received from tun\n", iph->version);
 		return -1;
 	}
@@ -752,7 +755,7 @@
 	DEBUGP(DTUN, "Received packet for APN(%s) from tun %s", apn->cfg.name, tun->devname);
 
 	if (ippool_getip(pool, &ipm, &dst)) {
-		DEBUGPC(DTUN, " with no PDP contex!!\n");
+		DEBUGPC(DTUN, " with no PDP contex! (%s)\n", );
 		return 0;
 	}
 	DEBUGPC(DTUN, "\n");

-- 
To view, visit https://gerrit.osmocom.org/6200
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4fc97f367ae615cdf0a9501f89419990c2fd4599
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list