aboutsummaryrefslogtreecommitdiffstats
path: root/ggsn/ggsn.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-01-30 16:01:27 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2018-01-30 22:49:26 +0100
commita4942e65660597e38405cd31b3f2cefc1260799a (patch)
tree46d4d203f8e16439b99f5a50f6ad9efa188f8844 /ggsn/ggsn.c
parent4e43ef5ab09b187903a74958a92ade0b6b06e352 (diff)
ggsn.c: cb_tun_ind: Convert ifelse to switch statement
Diffstat (limited to 'ggsn/ggsn.c')
-rw-r--r--ggsn/ggsn.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index de8090b..c7f6376 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -726,13 +726,15 @@ static int cb_tun_ind(struct tun_t *tun, void *pack, unsigned len)
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 @@ static int cb_tun_ind(struct tun_t *tun, void *pack, unsigned len)
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;
}