move gsm_auth_tuple to vlr.h as vlr_auth_tuple
Along goes GSM_KEYSEQ_INVAL as VLR_*. It's where it logically belongs, and is almost the only reason why vlr.h includes gsm_data.h. The remaining reason, GSM_EXTENSION_LENGTH, will be moved by upcoming patch. Change-Id: I122feae7ee3cbc59e941daef35a954bce29fec76
This commit is contained in:
parent
df6d2e3838
commit
8b6e536007
|
@ -42,13 +42,6 @@ typedef int gsm_cbfn(unsigned int hooknum,
|
||||||
struct msgb *msg,
|
struct msgb *msg,
|
||||||
void *data, void *param);
|
void *data, void *param);
|
||||||
|
|
||||||
struct gsm_auth_tuple {
|
|
||||||
int use_count;
|
|
||||||
int key_seq;
|
|
||||||
struct osmo_auth_vector vec;
|
|
||||||
};
|
|
||||||
#define GSM_KEY_SEQ_INVAL 7 /* GSM 04.08 - 10.5.1.2 */
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MSC_CTR_LOC_UPDATE_TYPE_ATTACH,
|
MSC_CTR_LOC_UPDATE_TYPE_ATTACH,
|
||||||
MSC_CTR_LOC_UPDATE_TYPE_NORMAL,
|
MSC_CTR_LOC_UPDATE_TYPE_NORMAL,
|
||||||
|
|
|
@ -77,6 +77,14 @@ enum vlr_ciph_result_cause {
|
||||||
VLR_CIPH_COMPL,
|
VLR_CIPH_COMPL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct vlr_auth_tuple {
|
||||||
|
int use_count;
|
||||||
|
int key_seq;
|
||||||
|
struct osmo_auth_vector vec;
|
||||||
|
};
|
||||||
|
#define VLR_KEY_SEQ_INVAL 7 /* GSM 04.08 - 10.5.1.2 */
|
||||||
|
|
||||||
|
|
||||||
struct vlr_ciph_result {
|
struct vlr_ciph_result {
|
||||||
enum vlr_ciph_result_cause cause;
|
enum vlr_ciph_result_cause cause;
|
||||||
char imeisv[GSM48_MI_SIZE];
|
char imeisv[GSM48_MI_SIZE];
|
||||||
|
@ -122,8 +130,8 @@ struct vlr_subscr {
|
||||||
uint32_t age_indicator; /* 2.17.1 */
|
uint32_t age_indicator; /* 2.17.1 */
|
||||||
|
|
||||||
/* Authentication Data */
|
/* Authentication Data */
|
||||||
struct gsm_auth_tuple auth_tuples[5]; /* 2.3.1-2.3.4 */
|
struct vlr_auth_tuple auth_tuples[5]; /* 2.3.1-2.3.4 */
|
||||||
struct gsm_auth_tuple *last_tuple;
|
struct vlr_auth_tuple *last_tuple;
|
||||||
enum vlr_subscr_security_context sec_ctx;
|
enum vlr_subscr_security_context sec_ctx;
|
||||||
|
|
||||||
/* Data local to VLR is below */
|
/* Data local to VLR is below */
|
||||||
|
@ -205,7 +213,7 @@ struct vlr_ops {
|
||||||
* \param[in] at auth tuple providing rand, key_seq and autn.
|
* \param[in] at auth tuple providing rand, key_seq and autn.
|
||||||
* \param[in] send_autn True to send AUTN, for r99 UMTS auth.
|
* \param[in] send_autn True to send AUTN, for r99 UMTS auth.
|
||||||
*/
|
*/
|
||||||
int (*tx_auth_req)(void *msc_conn_ref, struct gsm_auth_tuple *at,
|
int (*tx_auth_req)(void *msc_conn_ref, struct vlr_auth_tuple *at,
|
||||||
bool send_autn);
|
bool send_autn);
|
||||||
/* encode + transmit an AUTH REJECT towards the MS */
|
/* encode + transmit an AUTH REJECT towards the MS */
|
||||||
int (*tx_auth_rej)(void *msc_conn_ref);
|
int (*tx_auth_rej)(void *msc_conn_ref);
|
||||||
|
|
|
@ -1514,7 +1514,7 @@ int gsm0408_dispatch(struct ran_conn *conn, struct msgb *msg)
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
/* VLR asks us to send an authentication request */
|
/* VLR asks us to send an authentication request */
|
||||||
static int msc_vlr_tx_auth_req(void *msc_conn_ref, struct gsm_auth_tuple *at,
|
static int msc_vlr_tx_auth_req(void *msc_conn_ref, struct vlr_auth_tuple *at,
|
||||||
bool send_autn)
|
bool send_autn)
|
||||||
{
|
{
|
||||||
struct ran_conn *conn = msc_conn_ref;
|
struct ran_conn *conn = msc_conn_ref;
|
||||||
|
@ -1600,7 +1600,7 @@ int ran_conn_geran_set_cipher_mode(struct ran_conn *conn, bool umts_aka, bool re
|
||||||
int i, j = 0;
|
int i, j = 0;
|
||||||
int request_classmark = 0;
|
int request_classmark = 0;
|
||||||
int request_classmark_for_a5_n = 0;
|
int request_classmark_for_a5_n = 0;
|
||||||
struct gsm_auth_tuple *tuple = conn->vsub->last_tuple;
|
struct vlr_auth_tuple *tuple = conn->vsub->last_tuple;
|
||||||
|
|
||||||
if (!conn || !conn->vsub || !conn->vsub->last_tuple) {
|
if (!conn || !conn->vsub || !conn->vsub->last_tuple) {
|
||||||
/* This should really never happen, because we checked this in msc_vlr_set_ciph_mode()
|
/* This should really never happen, because we checked this in msc_vlr_set_ciph_mode()
|
||||||
|
@ -1680,7 +1680,7 @@ int msc_vlr_set_ciph_mode(void *msc_conn_ref,
|
||||||
{
|
{
|
||||||
struct ran_conn *conn = msc_conn_ref;
|
struct ran_conn *conn = msc_conn_ref;
|
||||||
struct vlr_subscr *vsub;
|
struct vlr_subscr *vsub;
|
||||||
struct gsm_auth_tuple *tuple;
|
struct vlr_auth_tuple *tuple;
|
||||||
|
|
||||||
if (!conn || !conn->vsub) {
|
if (!conn || !conn->vsub) {
|
||||||
LOGP(DMM, LOGL_ERROR, "Cannot send Ciphering Mode Command to"
|
LOGP(DMM, LOGL_ERROR, "Cannot send Ciphering Mode Command to"
|
||||||
|
|
|
@ -602,7 +602,7 @@ static void subscr_dump_full_vty(struct vty *vty, struct vlr_subscr *vsub)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (vsub->last_tuple) {
|
if (vsub->last_tuple) {
|
||||||
struct gsm_auth_tuple *t = vsub->last_tuple;
|
struct vlr_auth_tuple *t = vsub->last_tuple;
|
||||||
vty_out(vty, " A3A8 last tuple (used %d times):%s",
|
vty_out(vty, " A3A8 last tuple (used %d times):%s",
|
||||||
t->use_count, VTY_NEWLINE);
|
t->use_count, VTY_NEWLINE);
|
||||||
vty_out(vty, " seq # : %d%s",
|
vty_out(vty, " seq # : %d%s",
|
||||||
|
|
|
@ -242,7 +242,7 @@ static struct vlr_subscr *_vlr_subscr_alloc(struct vlr_instance *vlr)
|
||||||
vsub->tmsi_new = GSM_RESERVED_TMSI;
|
vsub->tmsi_new = GSM_RESERVED_TMSI;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(vsub->auth_tuples); i++)
|
for (i = 0; i < ARRAY_SIZE(vsub->auth_tuples); i++)
|
||||||
vsub->auth_tuples[i].key_seq = GSM_KEY_SEQ_INVAL;
|
vsub->auth_tuples[i].key_seq = VLR_KEY_SEQ_INVAL;
|
||||||
|
|
||||||
INIT_LLIST_HEAD(&vsub->cs.requests);
|
INIT_LLIST_HEAD(&vsub->cs.requests);
|
||||||
INIT_LLIST_HEAD(&vsub->ps.pdp_list);
|
INIT_LLIST_HEAD(&vsub->ps.pdp_list);
|
||||||
|
@ -661,7 +661,7 @@ void vlr_subscr_update_tuples(struct vlr_subscr *vsub,
|
||||||
if (gsup->num_auth_vectors) {
|
if (gsup->num_auth_vectors) {
|
||||||
memset(&vsub->auth_tuples, 0, sizeof(vsub->auth_tuples));
|
memset(&vsub->auth_tuples, 0, sizeof(vsub->auth_tuples));
|
||||||
for (i = 0; i < ARRAY_SIZE(vsub->auth_tuples); i++)
|
for (i = 0; i < ARRAY_SIZE(vsub->auth_tuples); i++)
|
||||||
vsub->auth_tuples[i].key_seq = GSM_KEY_SEQ_INVAL;
|
vsub->auth_tuples[i].key_seq = VLR_KEY_SEQ_INVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
got_tuples = 0;
|
got_tuples = 0;
|
||||||
|
|
|
@ -65,13 +65,13 @@ struct auth_fsm_priv {
|
||||||
* least used auth tuple without enforcing a maximum use count. If there are
|
* least used auth tuple without enforcing a maximum use count. If there are
|
||||||
* no auth tuples, return NULL.
|
* no auth tuples, return NULL.
|
||||||
*/
|
*/
|
||||||
static struct gsm_auth_tuple *
|
static struct vlr_auth_tuple *
|
||||||
_vlr_subscr_next_auth_tuple(struct vlr_subscr *vsub, int max_reuse_count)
|
_vlr_subscr_next_auth_tuple(struct vlr_subscr *vsub, int max_reuse_count)
|
||||||
{
|
{
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
unsigned int idx;
|
unsigned int idx;
|
||||||
struct gsm_auth_tuple *at = NULL;
|
struct vlr_auth_tuple *at = NULL;
|
||||||
unsigned int key_seq = GSM_KEY_SEQ_INVAL;
|
unsigned int key_seq = VLR_KEY_SEQ_INVAL;
|
||||||
|
|
||||||
if (!vsub)
|
if (!vsub)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -79,7 +79,7 @@ _vlr_subscr_next_auth_tuple(struct vlr_subscr *vsub, int max_reuse_count)
|
||||||
if (vsub->last_tuple)
|
if (vsub->last_tuple)
|
||||||
key_seq = vsub->last_tuple->key_seq;
|
key_seq = vsub->last_tuple->key_seq;
|
||||||
|
|
||||||
if (key_seq == GSM_KEY_SEQ_INVAL)
|
if (key_seq == VLR_KEY_SEQ_INVAL)
|
||||||
/* Start with 0 after increment modulo array size */
|
/* Start with 0 after increment modulo array size */
|
||||||
idx = ARRAY_SIZE(vsub->auth_tuples) - 1;
|
idx = ARRAY_SIZE(vsub->auth_tuples) - 1;
|
||||||
else
|
else
|
||||||
|
@ -88,7 +88,7 @@ _vlr_subscr_next_auth_tuple(struct vlr_subscr *vsub, int max_reuse_count)
|
||||||
for (count = ARRAY_SIZE(vsub->auth_tuples); count > 0; count--) {
|
for (count = ARRAY_SIZE(vsub->auth_tuples); count > 0; count--) {
|
||||||
idx = (idx + 1) % ARRAY_SIZE(vsub->auth_tuples);
|
idx = (idx + 1) % ARRAY_SIZE(vsub->auth_tuples);
|
||||||
|
|
||||||
if (vsub->auth_tuples[idx].key_seq == GSM_KEY_SEQ_INVAL)
|
if (vsub->auth_tuples[idx].key_seq == VLR_KEY_SEQ_INVAL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!at || vsub->auth_tuples[idx].use_count < at->use_count)
|
if (!at || vsub->auth_tuples[idx].use_count < at->use_count)
|
||||||
|
@ -102,10 +102,10 @@ _vlr_subscr_next_auth_tuple(struct vlr_subscr *vsub, int max_reuse_count)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return an auth tuple and increment its use count. */
|
/* Return an auth tuple and increment its use count. */
|
||||||
static struct gsm_auth_tuple *
|
static struct vlr_auth_tuple *
|
||||||
vlr_subscr_get_auth_tuple(struct vlr_subscr *vsub, int max_reuse_count)
|
vlr_subscr_get_auth_tuple(struct vlr_subscr *vsub, int max_reuse_count)
|
||||||
{
|
{
|
||||||
struct gsm_auth_tuple *at = _vlr_subscr_next_auth_tuple(vsub,
|
struct vlr_auth_tuple *at = _vlr_subscr_next_auth_tuple(vsub,
|
||||||
max_reuse_count);
|
max_reuse_count);
|
||||||
if (!at)
|
if (!at)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -124,7 +124,7 @@ static bool check_auth_resp(struct vlr_subscr *vsub, bool is_r99,
|
||||||
bool is_utran, const uint8_t *res,
|
bool is_utran, const uint8_t *res,
|
||||||
uint8_t res_len)
|
uint8_t res_len)
|
||||||
{
|
{
|
||||||
struct gsm_auth_tuple *at = vsub->last_tuple;
|
struct vlr_auth_tuple *at = vsub->last_tuple;
|
||||||
struct osmo_auth_vector *vec = &at->vec;
|
struct osmo_auth_vector *vec = &at->vec;
|
||||||
bool check_umts;
|
bool check_umts;
|
||||||
bool res_is_umts_aka;
|
bool res_is_umts_aka;
|
||||||
|
@ -263,7 +263,7 @@ static int _vlr_subscr_authenticate(struct osmo_fsm_inst *fi)
|
||||||
{
|
{
|
||||||
struct auth_fsm_priv *afp = fi->priv;
|
struct auth_fsm_priv *afp = fi->priv;
|
||||||
struct vlr_subscr *vsub = afp->vsub;
|
struct vlr_subscr *vsub = afp->vsub;
|
||||||
struct gsm_auth_tuple *at;
|
struct vlr_auth_tuple *at;
|
||||||
bool use_umts_aka;
|
bool use_umts_aka;
|
||||||
|
|
||||||
/* Caller ensures we have vectors available */
|
/* Caller ensures we have vectors available */
|
||||||
|
|
|
@ -714,7 +714,7 @@ static int fake_vlr_tx_cm_serv_rej(void *msc_conn_ref, enum gsm48_reject_value c
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fake_vlr_tx_auth_req(void *msc_conn_ref, struct gsm_auth_tuple *at,
|
static int fake_vlr_tx_auth_req(void *msc_conn_ref, struct vlr_auth_tuple *at,
|
||||||
bool send_autn)
|
bool send_autn)
|
||||||
{
|
{
|
||||||
struct ran_conn *conn = msc_conn_ref;
|
struct ran_conn *conn = msc_conn_ref;
|
||||||
|
|
Loading…
Reference in New Issue