aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-01-23 10:02:58 +0100
committerHarald Welte <laforge@gnumonks.org>2012-01-26 22:42:16 +0100
commit07b625dd2c2d939c861d45d5838bc9bb32a00e30 (patch)
tree70c3650a8e9a432ee6df7ff851d844fc89073c4f
parent65c2d36005cbefab490896665d4c60501c987b4a (diff)
GSM 08.08: change gsm0808_create_classmark_update() prototype
The caller explicitly specifies CM2 and CM3, rather than one blob containing both.
-rw-r--r--include/osmocom/gsm/gsm0808.h3
-rw-r--r--src/gsm/gsm0808.c9
-rw-r--r--tests/gsm0808/gsm0808_test.c14
3 files changed, 19 insertions, 7 deletions
diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 38d88ef9..5380dd9e 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -30,7 +30,8 @@ struct msgb *gsm0808_create_clear_command(uint8_t reason);
struct msgb *gsm0808_create_clear_complete(void);
struct msgb *gsm0808_create_cipher_complete(struct msgb *layer3, uint8_t alg_id);
struct msgb *gsm0808_create_cipher_reject(uint8_t cause);
-struct msgb *gsm0808_create_classmark_update(const uint8_t *classmark, uint8_t length);
+struct msgb *gsm0808_create_classmark_update(const uint8_t *cm2, uint8_t cm2_len,
+ const uint8_t *cm3, uint8_t cm3_len);
struct msgb *gsm0808_create_sapi_reject(uint8_t link_id);
struct msgb *gsm0808_create_assignment_completed(uint8_t rr_cause,
uint8_t chosen_channel, uint8_t encr_alg_id,
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index 6c10177b..30098278 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -143,7 +143,8 @@ struct msgb *gsm0808_create_cipher_reject(uint8_t cause)
return msg;
}
-struct msgb *gsm0808_create_classmark_update(const uint8_t *classmark_data, uint8_t length)
+struct msgb *gsm0808_create_classmark_update(const uint8_t *cm2, uint8_t cm2_len,
+ const uint8_t *cm3, uint8_t cm3_len)
{
struct msgb *msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM,
"classmark-update");
@@ -151,8 +152,10 @@ struct msgb *gsm0808_create_classmark_update(const uint8_t *classmark_data, uint
return NULL;
msgb_v_put(msg, BSS_MAP_MSG_CLASSMARK_UPDATE);
- msg->l4h = msgb_put(msg, length);
- memcpy(msg->l4h, classmark_data, length);
+ msgb_tlv_put(msg, GSM0808_IE_CLASSMARK_INFORMATION_T2, cm2_len, cm2);
+ if (cm3)
+ msgb_tlv_put(msg, GSM0808_IE_CLASSMARK_INFORMATION_T3,
+ cm3_len, cm3);
msg->l3h = msgb_tv_push(msg, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg));
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 50838c84..7e5e97b5 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -136,13 +136,21 @@ static void test_create_cipher_reject()
static void test_create_cm_u()
{
- static const uint8_t res[] = { 0x00, 0x02, 0x54, 0x23 };
+ static const uint8_t res[] = {
+ 0x00, 0x07, 0x54, 0x12, 0x01, 0x23, 0x13, 0x01, 0x42 };
+ static const uint8_t res2o[] = {
+ 0x00, 0x04, 0x54, 0x12, 0x01, 0x23 };
struct msgb *msg;
- const uint8_t cm = 0x23;
+ const uint8_t cm2 = 0x23;
+ const uint8_t cm3 = 0x42;
printf("Testing creating CM U\n");
- msg = gsm0808_create_classmark_update(&cm, 1);
+ msg = gsm0808_create_classmark_update(&cm2, 1, &cm3, 1);
VERIFY(msg, res, ARRAY_SIZE(res));
+
+ msg = gsm0808_create_classmark_update(&cm2, 1, NULL, 0);
+ VERIFY(msg, res2o, ARRAY_SIZE(res2o));
+
msgb_free(msg);
}