aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmsc/a_iface.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-12-14 05:30:16 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2017-12-18 05:18:11 +0100
commit703638e79a7c78c5794acf6d1c15885e314354b2 (patch)
treee7e121eeb1d48c4863df5ae4925e941467ec3514 /src/libmsc/a_iface.c
parentcf30913c8e2a43606edff751268dacc4886d7e4c (diff)
cosmetic: move translation of vlr_ciph into msc_vlr_set_ciph_mode()
a_iface_tx_cipher_mode() is a bit too far away from the VLR to be handling its ciphering enums. Instead, construct the gsm0808_encrypt_info in the msc_vlr_set_ciph_mode() callback. Greatly simplify the sanity checking code: a_iface_tx_cipher_mode() no longer needs to re-verify the presence of the gsm0808_encrypt_info contents. Change-Id: Id46f9a513b555d0a481f7124c9984c2b5b196b3e
Diffstat (limited to 'src/libmsc/a_iface.c')
-rw-r--r--src/libmsc/a_iface.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/src/libmsc/a_iface.c b/src/libmsc/a_iface.c
index 69b4c0991..cdd8d892b 100644
--- a/src/libmsc/a_iface.c
+++ b/src/libmsc/a_iface.c
@@ -170,38 +170,18 @@ int a_iface_tx_dtap(struct msgb *msg)
/* Send Cipher mode command via A-interface */
int a_iface_tx_cipher_mode(const struct gsm_subscriber_connection *conn,
- int cipher, const uint8_t *key, int len, int include_imeisv)
+ struct gsm0808_encrypt_info *ei, int include_imeisv)
{
/* TODO generalize for A- and Iu interfaces, don't name after 08.08 */
struct msgb *msg_resp;
- struct gsm0808_encrypt_info ei;
-
- OSMO_ASSERT(conn);
-
uint8_t crm = 0x01;
- uint8_t *crm_ptr = NULL;
- LOGPCONN(conn, LOGL_DEBUG, "Cipher Mode Command to BSC, cipher=%d key=%s\n",
- cipher, osmo_hexdump_nospc(key, len));
-
- /* Setup encryption information */
- if (len > ENCRY_INFO_KEY_MAXLEN || !key) {
- LOGP(DMSC, LOGL_ERROR,
- "Cipher mode command message could not be generated due to invalid key! (conn_id=%i)\n",
- conn->a.conn_id);
- return -EINVAL;
- } else {
- memcpy(&ei.key, key, len);
- ei.key_len = len;
- }
-
- if (include_imeisv)
- crm_ptr = &crm;
-
- ei.perm_algo[0] = vlr_ciph_to_gsm0808_alg_id(cipher);
- ei.perm_algo_len = 1;
+ OSMO_ASSERT(conn);
+ LOGPCONN(conn, LOGL_DEBUG, "Cipher Mode Command to BSC, %u ciphers (%s)",
+ ei->perm_algo_len, osmo_hexdump_nospc(ei->perm_algo, ei->perm_algo_len));
+ LOGPC(DMSC, LOGL_DEBUG, " key %s\n", osmo_hexdump_nospc(ei->key, ei->key_len));
- msg_resp = gsm0808_create_cipher(&ei, crm_ptr);
+ msg_resp = gsm0808_create_cipher(ei, include_imeisv ? &crm : NULL);
LOGP(DMSC, LOGL_DEBUG, "N-DATA.req(%u, %s)\n", conn->a.conn_id, osmo_hexdump(msg_resp->data, msg_resp->len));
return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg_resp);