diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-06-21 10:15:27 +0800 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-06-21 16:57:14 +0800 |
commit | e9eb4d1ab862f6dc94a5acc680836d30b483c0b6 (patch) | |
tree | 14837251832b6cd1939d80d16ef0833122fead9a /openbsc | |
parent | c2b9bd202e4dc7a4db78e1f17b31f277f0b4ed8a (diff) |
bsc_init: Avoid unaligned access to nanobts_attr_nsvc0
nanobts_attr_nsvc0 + 10 is unlikely to be 32 bit aligned
and will trigger an alignment error on ARM..
Diffstat (limited to 'openbsc')
-rw-r--r-- | openbsc/src/bsc_init.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/openbsc/src/bsc_init.c b/openbsc/src/bsc_init.c index 9e3665cc8..35c861176 100644 --- a/openbsc/src/bsc_init.c +++ b/openbsc/src/bsc_init.c @@ -830,6 +830,16 @@ err_out: return rc; } +static void patch_16(uint8_t *data, const uint16_t val) +{ + memcpy(data, &val, sizeof(val)); +} + +static void patch_32(uint8_t *data, const uint32_t val) +{ + memcpy(data, &val, sizeof(val)); +} + /* * Patch the various SYSTEM INFORMATION tables to update * the LAI @@ -892,12 +902,12 @@ static void patch_nm_tables(struct gsm_bts *bts) nanobts_attr_nsvc0[4] = bts->gprs.nsvc[0].nsvci & 0xff; /* patch IP address as SGSN IP */ - *(u_int16_t *)(nanobts_attr_nsvc0+8) = - htons(bts->gprs.nsvc[0].remote_port); - *(u_int32_t *)(nanobts_attr_nsvc0+10) = - htonl(bts->gprs.nsvc[0].remote_ip); - *(u_int16_t *)(nanobts_attr_nsvc0+14) = - htons(bts->gprs.nsvc[0].local_port); + patch_16(nanobts_attr_nsvc0 + 8, + htons(bts->gprs.nsvc[0].remote_port)); + patch_32(nanobts_attr_nsvc0 + 10, + htonl(bts->gprs.nsvc[0].remote_ip)); + patch_16(nanobts_attr_nsvc0 + 14, + htons(bts->gprs.nsvc[0].local_port)); /* patch BVCI */ nanobts_attr_cell[12] = bts->gprs.cell.bvci >> 8; |