|
|
@ -532,7 +532,7 @@ hss::resync_sqn(uint64_t imsi, uint8_t *auts)
|
|
|
|
ret = resync_sqn_milenage(imsi, auts);
|
|
|
|
ret = resync_sqn_milenage(imsi, auts);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
increment_ue_sqn(imsi);
|
|
|
|
increment_seq_after_resync(imsi);
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -625,21 +625,86 @@ hss::increment_ue_sqn(uint64_t imsi)
|
|
|
|
void
|
|
|
|
void
|
|
|
|
hss::increment_sqn(uint8_t *sqn, uint8_t *next_sqn)
|
|
|
|
hss::increment_sqn(uint8_t *sqn, uint8_t *next_sqn)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Awkward 48 bit sqn and doing arithmetic
|
|
|
|
// The following SQN incrementation function is implemented according to 3GPP TS 33.102 version 11.5.1 Annex C
|
|
|
|
uint64_t tmp_sqn = 0;
|
|
|
|
|
|
|
|
uint8_t *p = (uint8_t *)&tmp_sqn;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < 6; i++) {
|
|
|
|
uint64_t seq;
|
|
|
|
p[5-i] = sqn[i];
|
|
|
|
uint64_t ind;
|
|
|
|
|
|
|
|
uint64_t sqn64;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sqn64 =0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<6; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sqn64 |= (uint64_t)sqn[i] << (5-i)*8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tmp_sqn++;
|
|
|
|
seq = sqn64 >> LTE_FDD_ENB_IND_HE_N_BITS;
|
|
|
|
for(int i = 0; i < 6; i++){
|
|
|
|
ind = sqn64 & LTE_FDD_ENB_IND_HE_MASK;
|
|
|
|
next_sqn[i] = p[5-i];
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t nextseq;
|
|
|
|
|
|
|
|
uint64_t nextind;
|
|
|
|
|
|
|
|
uint64_t nextsqn;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nextseq = (seq + 1) % LTE_FDD_ENB_SEQ_HE_MAX_VALUE;
|
|
|
|
|
|
|
|
nextind = (ind + 1) % LTE_FDD_ENB_IND_HE_MAX_VALUE;
|
|
|
|
|
|
|
|
nextsqn = (nextseq << LTE_FDD_ENB_IND_HE_N_BITS) | nextind;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<6; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
next_sqn[i] = (nextsqn >> (5-i)*8) & 0xFF;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
hss::increment_seq_after_resync(uint64_t imsi)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This function only increment the SEQ part of the SQN for resynchronization purpose
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hss_ue_ctx_t *ue_ctx = NULL;
|
|
|
|
|
|
|
|
bool ret = get_ue_ctx(imsi, &ue_ctx);
|
|
|
|
|
|
|
|
if(ret == false)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t *sqn = ue_ctx->sqn;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t seq;
|
|
|
|
|
|
|
|
uint64_t ind;
|
|
|
|
|
|
|
|
uint64_t sqn64;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sqn64 =0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<6; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sqn64 |= (uint64_t)sqn[i] << (5-i)*8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
seq = sqn64 >> LTE_FDD_ENB_IND_HE_N_BITS;
|
|
|
|
|
|
|
|
ind = sqn64 & LTE_FDD_ENB_IND_HE_MASK;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t nextseq;
|
|
|
|
|
|
|
|
uint64_t nextsqn;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nextseq = (seq + 1) % LTE_FDD_ENB_SEQ_HE_MAX_VALUE;
|
|
|
|
|
|
|
|
nextsqn = (nextseq << LTE_FDD_ENB_IND_HE_N_BITS) | ind;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<6; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sqn[i] = (nextsqn >> (5-i)*8) & 0xFF;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
hss::set_sqn(uint64_t imsi, uint8_t *sqn)
|
|
|
|
hss::set_sqn(uint64_t imsi, uint8_t *sqn)
|
|
|
|
{
|
|
|
|
{
|
|
|
|