aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-07-23 18:20:02 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-07-23 18:20:02 +0800
commit06f795c56f7c839f5e410b5909ad3618ea96c205 (patch)
tree743ceaaa74065ec466775c859a7bb189f658b607
parentdd02a4723498d17cfca1d05a068cf434b17bbafa (diff)
gsm0808: Import unaligned mem access fix from on-waves/bsc-master
-rw-r--r--include/osmocore/gsm0808.h2
-rw-r--r--src/gsm0808.c13
2 files changed, 10 insertions, 5 deletions
diff --git a/include/osmocore/gsm0808.h b/include/osmocore/gsm0808.h
index 9166e54f..82f17cad 100644
--- a/include/osmocore/gsm0808.h
+++ b/include/osmocore/gsm0808.h
@@ -24,7 +24,7 @@
struct msgb;
-struct msgb *gsm0808_create_layer3(struct msgb *msg, uint16_t netcode, uint16_t countrycode, int lac, int ci);
+struct msgb *gsm0808_create_layer3(struct msgb *msg, uint16_t netcode, uint16_t countrycode, int lac, uint16_t ci);
struct msgb *gsm0808_create_reset(void);
struct msgb *gsm0808_create_clear_complete(void);
struct msgb *gsm0808_create_cipher_complete(struct msgb *layer3, uint8_t alg_id);
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);