Browse Source

libmsc/gsm_04_08: refactor require ciphering into an own function

Make it more readable.

Change-Id: I9e407f65b282e645feabe714f7f4c3e44fae21e9
changes/08/26108/5
Alexander Couzens 10 months ago
parent
commit
2c5e46104e
  1. 1
      include/osmocom/msc/gsm_data.h
  2. 1
      include/osmocom/msc/msc_a.h
  3. 8
      src/libmsc/gsm_04_08.c
  4. 10
      src/libmsc/msc_a.c

1
include/osmocom/msc/gsm_data.h

@ -13,6 +13,7 @@
#include <osmocom/core/stat_item.h>
#include <osmocom/gsm/gsm48.h>
#include <osmocom/crypt/auth.h>
#include <osmocom/crypt/utran_cipher.h>
#include <osmocom/mgcp_client/mgcp_client.h>

1
include/osmocom/msc/msc_a.h

@ -180,6 +180,7 @@ struct msc_a *msc_a_for_vsub(const struct vlr_subscr *vsub, bool valid_conn_only
void msc_a_pending_cm_service_req_add(struct msc_a *msc_a, enum osmo_cm_service_type type);
unsigned int msc_a_pending_cm_service_req_count(struct msc_a *msc_a, enum osmo_cm_service_type type);
void msc_a_pending_cm_service_req_del(struct msc_a *msc_a, enum osmo_cm_service_type type);
bool msc_a_require_ciphering(const struct msc_a *msc_a);
#define msc_a_ran_down(A,B,C) \
_msc_a_ran_down(A,B,C, __FILE__, __LINE__)

8
src/libmsc/gsm_04_08.c

@ -415,7 +415,7 @@ static int mm_rx_loc_upd_req(struct msc_a *msc_a, struct msgb *msg)
net->vlr, msc_a, vlr_lu_type, tmsi, imsi,
&old_lai, &msc_a->via_cell.lai,
is_utran || net->authentication_required,
is_utran ? net->uea_encryption_mask > (1 << OSMO_UTRAN_UEA0) : net->a5_encryption_mask > 0x01,
msc_a_require_ciphering(msc_a),
lu->key_seq,
osmo_gsm48_classmark1_is_r99(&lu->classmark1),
is_utran,
@ -806,7 +806,7 @@ int gsm48_rx_mm_serv_req(struct msc_a *msc_a, struct msgb *msg)
req->cm_service_type,
&mi, &msc_a->via_cell.lai,
is_utran || net->authentication_required,
is_utran ? net->uea_encryption_mask > (1 << OSMO_UTRAN_UEA0) : net->a5_encryption_mask > 0x01,
msc_a_require_ciphering(msc_a),
req->cipher_key_seq,
osmo_gsm48_classmark2_is_r99(cm2, cm2_len),
is_utran);
@ -932,7 +932,7 @@ static int gsm48_rx_cm_reest_req(struct msc_a *msc_a, struct msgb *msg)
VLR_PR_ARQ_T_CM_RE_ESTABLISH_REQ, 0,
&mi, &msc_a->via_cell.lai,
is_utran || net->authentication_required,
is_utran ? net->uea_encryption_mask > (1 << OSMO_UTRAN_UEA0) : net->a5_encryption_mask > 0x01,
msc_a_require_ciphering(msc_a),
req->cipher_key_seq,
osmo_gsm48_classmark2_is_r99(cm2, cm2_len),
is_utran);
@ -1294,7 +1294,7 @@ static int gsm48_rx_rr_pag_resp(struct msc_a *msc_a, struct msgb *msg)
net->vlr, msc_a,
VLR_PR_ARQ_T_PAGING_RESP, 0, &mi, &msc_a->via_cell.lai,
is_utran || net->authentication_required,
is_utran ? net->uea_encryption_mask > (1 << OSMO_UTRAN_UEA0) : net->a5_encryption_mask > 0x01,
msc_a_require_ciphering(msc_a),
pr->key_seq,
osmo_gsm48_classmark2_is_r99(cm2, classmark2_len),
is_utran);

10
src/libmsc/msc_a.c

@ -106,6 +106,16 @@ struct msc_a *msc_a_fi_priv(struct osmo_fsm_inst *fi)
return fi->priv;
}
bool msc_a_require_ciphering(const struct msc_a *msc_a)
{
struct gsm_network *net = msc_a_net(msc_a);
bool is_utran = (msc_a->c.ran->type == OSMO_RAT_UTRAN_IU);
if (is_utran)
return net->uea_encryption_mask > (1 << OSMO_UTRAN_UEA0);
else
return net->a5_encryption_mask > 0x1;
}
static void update_counters(struct osmo_fsm_inst *fi, bool conn_accepted)
{
struct msc_a *msc_a = fi->priv;

Loading…
Cancel
Save