summaryrefslogtreecommitdiffstats
path: root/src/gsm
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2012-11-05 10:47:59 +0100
committerHarald Welte <laforge@gnumonks.org>2012-11-05 12:30:09 +0100
commitd430ef443acf02d52ed4945ef272c9f49066647c (patch)
tree62ff7b26897d7ed9f50c1d90e887b47ab37ad251 /src/gsm
parent6ad25f290e8cb697115a4170d6fbff66f3128528 (diff)
GSM48: Avoid unaligned access in gsm48_construct_ra
This avoids an unaligned access on platforms that don't support them, such as ARMv4/ARMv5.
Diffstat (limited to 'src/gsm')
-rw-r--r--src/gsm/gsm48.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index fe62dee7..ea05d450 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -416,6 +416,7 @@ int gsm48_construct_ra(uint8_t *buf, const struct gprs_ra_id *raid)
{
uint16_t mcc = raid->mcc;
uint16_t mnc = raid->mnc;
+ uint16_t _lac;
buf[0] = ((mcc / 100) % 10) | (((mcc / 10) % 10) << 4);
buf[1] = (mcc % 10);
@@ -430,7 +431,8 @@ int gsm48_construct_ra(uint8_t *buf, const struct gprs_ra_id *raid)
buf[2] = ((mnc / 100) % 10) | (((mnc / 10) % 10) << 4);
}
- *(uint16_t *)(buf+3) = htons(raid->lac);
+ _lac = htons(raid->lac);
+ memcpy(buf + 3, &_lac, 2);
buf[5] = raid->rac;