aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/bsc_init.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-06-21 10:15:27 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-06-21 16:40:09 +0800
commit34949ae9242445a6047dd289e149aae0d41871cb (patch)
treefc38a4a52fb2335b6450793b0f2305c7d773ea3f /openbsc/src/bsc_init.c
parentad98128e65a5a9a64cd483e971358f0ae06d39fc (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/src/bsc_init.c')
-rw-r--r--openbsc/src/bsc_init.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/openbsc/src/bsc_init.c b/openbsc/src/bsc_init.c
index 787c0d5dd..51993dc41 100644
--- a/openbsc/src/bsc_init.c
+++ b/openbsc/src/bsc_init.c
@@ -850,6 +850,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
@@ -912,12 +922,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;