summaryrefslogtreecommitdiffstats
path: root/openbsc/src/gprs/sgsn_libgtp.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-05-01 15:29:52 +0200
committerHarald Welte <laforge@gnumonks.org>2016-05-01 15:35:59 +0200
commitfc68c83ddbda55fc2aaa908a3a6a6fca2af71761 (patch)
treed995eff26ca8eacf5a5f6b24a0b4b3f47399bf46 /openbsc/src/gprs/sgsn_libgtp.c
parent74101106a1114d819dfce83cd5a50837c8bd5d0e (diff)
Support raw IPv4 address in RAB Assignment Response
There are different Iu dialects in terms of encoding the transport layer address inside RAB Assignment req + resp. Let's be liberal in what we accept, and simply use the length as an indicator of the format. Wireshark uses similar heuristics.
Diffstat (limited to 'openbsc/src/gprs/sgsn_libgtp.c')
-rw-r--r--openbsc/src/gprs/sgsn_libgtp.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c
index a41d6d71c..2a3ee01f0 100644
--- a/openbsc/src/gprs/sgsn_libgtp.c
+++ b/openbsc/src/gprs/sgsn_libgtp.c
@@ -414,7 +414,25 @@ int sgsn_ranap_rab_ass_resp(struct sgsn_mm_ctx *ctx, RANAP_RAB_SetupOrModifiedIt
if (item->transportLayerAddress) {
LOGPC(DRANAP, LOGL_INFO, " Setup: (%u/%s)", rab_id, osmo_hexdump(item->transportLayerAddress->buf,
item->transportLayerAddress->size));
- memcpy(pdp->lib->gsnlu.v, &item->transportLayerAddress->buf[3], 4);
+ switch (item->transportLayerAddress->size) {
+ case 7:
+ /* It must be IPv4 inside a X213 NSAP */
+ memcpy(pdp->lib->gsnlu.v, &item->transportLayerAddress->buf[3], 4);
+ break;
+ case 4:
+ /* It must be a raw IPv4 address */
+ memcpy(pdp->lib->gsnlu.v, item->transportLayerAddress->buf, 4);
+ break;
+ case 16:
+ /* TODO: It must be a raw IPv6 address */
+ case 19:
+ /* TODO: It must be IPv6 inside a X213 NSAP */
+ default:
+ LOGP(DRANAP, LOGL_ERROR, "RAB Assignment Resp: Unknown "
+ "transport layer address size %u\n",
+ item->transportLayerAddress->size);
+ return -1;
+ }
require_pdp_update = true;
}