diff options
author | Philipp Maier <pmaier@sysmocom.de> | 2017-03-29 15:50:05 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-04-08 07:44:46 +0000 |
commit | b478dd38d29b0dfdf9d9c4d6f22ec4a24e4c8fcd (patch) | |
tree | 74f3d450b5d58906e05efe9d2349d4b47cd20191 /src | |
parent | 783047e86ec64677f3894bd22576315eee631275 (diff) |
gsm0808: Add create functions for CIPHER MODE COMMAND
gsm0808.h/c lacks functionality to generate CIPHER MODE COMMAND messages. These
messages are required if the code is used in an MSC implementation.
This commit adds a gsm0808_create_cipher() function, that generates an A/AoiP
CIPHER MODE COMMAND message.
Change-Id: I8eb1c357860c3e740b0f5d17e1c256bc87920958
Diffstat (limited to 'src')
-rw-r--r-- | src/gsm/gsm0808.c | 33 | ||||
-rw-r--r-- | src/gsm/libosmogsm.map | 1 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c index b8ab79b1..c952a9f8 100644 --- a/src/gsm/gsm0808.c +++ b/src/gsm/gsm0808.c @@ -131,6 +131,39 @@ struct msgb *gsm0808_create_clear_command(uint8_t reason) return msg; } +struct msgb *gsm0808_create_cipher(const struct gsm0808_encrypt_info *ei, + const uint8_t *cipher_response_mode) +{ + /* See also: 3GPP TS 48.008 3.2.1.30 CIPHER MODE COMMAND */ + struct msgb *msg; + + /* Mandatory emelent! */ + OSMO_ASSERT(ei); + + msg = + msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, + "cipher-mode-command"); + if (!msg) + return NULL; + + /* Message Type 3.2.2.1 */ + msgb_v_put(msg, BSS_MAP_MSG_CIPHER_MODE_CMD); + + /* Encryption Information 3.2.2.10 */ + gsm0808_enc_encrypt_info(msg, ei); + + /* Cipher Response Mode 3.2.2.34 */ + if (cipher_response_mode) + msgb_tv_put(msg, GSM0808_IE_CIPHER_RESPONSE_MODE, + *cipher_response_mode); + + /* pre-pend the header */ + msg->l3h = + msgb_tv_push(msg, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg)); + + return msg; +} + struct msgb *gsm0808_create_cipher_complete(struct msgb *layer3, uint8_t alg_id) { struct msgb *msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index cf0a7fee..786bf08b 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -128,6 +128,7 @@ gsm0808_create_assignment_completed; gsm0808_create_ass_compl; gsm0808_create_assignment_failure; gsm0808_create_ass_fail; +gsm0808_create_cipher; gsm0808_create_cipher_complete; gsm0808_create_cipher_reject; gsm0808_create_classmark_update; |