summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);