diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-07-23 18:20:02 +0800 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-07-23 18:20:02 +0800 |
commit | 06f795c56f7c839f5e410b5909ad3618ea96c205 (patch) | |
tree | 743ceaaa74065ec466775c859a7bb189f658b607 /src | |
parent | dd02a4723498d17cfca1d05a068cf434b17bbafa (diff) |
gsm0808: Import unaligned mem access fix from on-waves/bsc-master
Diffstat (limited to 'src')
-rw-r--r-- | src/gsm0808.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/gsm0808.c b/src/gsm0808.c index 1dc035b3..51c10ca0 100644 --- a/src/gsm0808.c +++ b/src/gsm0808.c @@ -27,10 +27,15 @@ #define BSSMAP_MSG_SIZE 512 #define BSSMAP_MSG_HEADROOM 128 -struct msgb *gsm0808_create_layer3(struct msgb *msg_l3, uint16_t nc, uint16_t cc, int lac, int _ci) +static void put_data_16(uint8_t *data, const uint16_t val) +{ + memcpy(data, &val, sizeof(val)); +} + +struct msgb *gsm0808_create_layer3(struct msgb *msg_l3, uint16_t nc, uint16_t cc, int lac, uint16_t _ci) { uint8_t *data; - uint16_t *ci; + uint8_t *ci; struct msgb* msg; struct gsm48_loc_area_id *lai; @@ -56,8 +61,8 @@ struct msgb *gsm0808_create_layer3(struct msgb *msg_l3, uint16_t nc, uint16_t cc lai = (struct gsm48_loc_area_id *) msgb_put(msg, sizeof(*lai)); gsm48_generate_lai(lai, cc, nc, lac); - ci = (uint16_t *) msgb_put(msg, 2); - *ci = htons(_ci); + ci = msgb_put(msg, 2); + put_data_16(ci, htons(_ci)); /* copy the layer3 data */ data = msgb_put(msg, msgb_l3len(msg_l3) + 2); |