Commit 49a601c4 authored by Ben Wojtowicz's avatar Ben Wojtowicz

Version 0.16.0: Added more MME decoding and encoding and security functions...

Version 0.16.0: Added more MME decoding and encoding and security functions for key generation and EIA2 to the LTE library and added authentication, security mode, and sequence number resynch support to MME/HSS, added read only parameters for UL EARFCN, DL center frequency, and UL center frequency, fixed bugs with stop and t_poll_retransmit, and combined the contention resolution identity and first DL RLC message in LTE_fdd_enodeb.
parent 84dc50e7
......@@ -23,7 +23,7 @@
########################################################################
cmake_minimum_required(VERSION 2.6)
project(openLTE CXX C)
set(openLTE_version 0.15.0)
set(openLTE_version 0.16.0)
enable_testing()
#select the release build type by default to get optimization flags
......
......@@ -123,3 +123,10 @@ v00.15.00 Added make requirement for polarSSL, common, pdcp, and security
HSS interface support, message parsers/senders and state machines
for MME, RRC command messages, transmit functionality for PDCP,
RLC, and RRC, and refactoring of user identities).
v00.16.00 Added more MME decoding and encoding and security functions for
key generation and EIA2 to the LTE library. Added authentication,
security mode, and sequence number resynch support to MME/HSS,
added read only parameters for UL EARFCN, DL center frequency, and
UL center frequency, fixed bugs with stop and t_poll_retransmit,
and combined the contention resolution identity and first DL RLC
message in LTE_fdd_enodeb.
......@@ -28,6 +28,7 @@
01/18/2014 Ben Wojtowicz Added set/get routines for uint32 values.
03/26/2014 Ben Wojtowicz Using the latest LTE library.
08/03/2014 Ben Wojtowicz Added support for limiting PCAP output.
09/03/2014 Ben Wojtowicz Added better MCC/MNC support.
*******************************************************************************/
......@@ -80,6 +81,8 @@ typedef struct{
uint32 N_sc_rb_ul;
uint32 si_periodicity_T;
uint32 si_win_len;
uint16 mcc;
uint16 mnc;
bool sib3_present;
bool sib4_present;
bool sib5_present;
......
......@@ -26,6 +26,7 @@
---------- ------------- --------------------------------------------
06/15/2014 Ben Wojtowicz Created file
08/03/2014 Ben Wojtowicz Added authentication vector support.
09/03/2014 Ben Wojtowicz Added sequence number resynch.
*******************************************************************************/
......@@ -45,6 +46,7 @@
*******************************************************************************/
#define LTE_FDD_ENB_IND_HE_N_BITS 5
#define LTE_FDD_ENB_IND_HE_MASK 0x1FUL
#define LTE_FDD_ENB_IND_HE_MAX_VALUE 31
#define LTE_FDD_ENB_SEQ_HE_MAX_VALUE 0x7FFFFFFFFFFFUL
......@@ -59,17 +61,8 @@
typedef struct{
uint8 k[16];
uint8 amf[2];
}LTE_FDD_ENB_STORED_DATA_STRUCT;
typedef struct{
uint8 rand[16];
uint8 res[8];
uint8 ck[16];
uint8 ik[16];
uint8 autn[16];
}LTE_FDD_ENB_AUTHENTICATION_VECTOR_STRUCT;
typedef struct{
LTE_FDD_ENB_AUTHENTICATION_VECTOR_STRUCT auth_vec;
uint64 sqn_he;
......@@ -77,6 +70,11 @@ typedef struct{
uint8 ak[6];
uint8 mac[8];
uint8 k_asme[32];
uint8 k_enb[32];
uint8 k_rrc_enc[32];
uint8 k_rrc_int[32];
uint8 k_up_enc[32];
uint8 k_up_int[32];
uint8 ind_he;
}LTE_FDD_ENB_GENERATED_DATA_STRUCT;
......@@ -98,7 +96,7 @@ public:
static void cleanup(void);
// External interface
LTE_FDD_ENB_ERROR_ENUM add_user(std::string imsi, std::string imei, std::string k, std::string amf);
LTE_FDD_ENB_ERROR_ENUM add_user(std::string imsi, std::string imei, std::string k);
LTE_FDD_ENB_ERROR_ENUM del_user(std::string imsi);
std::string print_all_users(void);
bool is_imsi_allowed(uint64 imsi);
......@@ -106,6 +104,7 @@ public:
LTE_FDD_ENB_USER_ID_STRUCT* get_user_id_from_imsi(uint64 imsi);
LTE_FDD_ENB_USER_ID_STRUCT* get_user_id_from_imei(uint64 imei);
void generate_security_data(LTE_FDD_ENB_USER_ID_STRUCT *id, uint16 mcc, uint16 mnc);
void security_resynch(LTE_FDD_ENB_USER_ID_STRUCT *id, uint16 mcc, uint16 mnc, uint8 *auts);
LTE_FDD_ENB_AUTHENTICATION_VECTOR_STRUCT* get_auth_vec(LTE_FDD_ENB_USER_ID_STRUCT *id);
private:
......
......@@ -35,6 +35,8 @@
07/22/2014 Ben Wojtowicz Added clock source as a configurable
parameter.
08/03/2014 Ben Wojtowicz Added HSS support.
09/03/2014 Ben Wojtowicz Added read only parameters for UL EARFCN,
DL center frequency and UL center frequency.
*******************************************************************************/
......@@ -89,6 +91,7 @@ typedef enum{
LTE_FDD_ENB_ERROR_TIMER_NOT_FOUND,
LTE_FDD_ENB_ERROR_CANT_REASSEMBLE_SDU,
LTE_FDD_ENB_ERROR_DUPLICATE_ENTRY,
LTE_FDD_ENB_ERROR_READ_ONLY,
LTE_FDD_ENB_ERROR_N_ITEMS,
}LTE_FDD_ENB_ERROR_ENUM;
static const char LTE_fdd_enb_error_text[LTE_FDD_ENB_ERROR_N_ITEMS][100] = {"none",
......@@ -112,7 +115,8 @@ static const char LTE_fdd_enb_error_text[LTE_FDD_ENB_ERROR_N_ITEMS][100] = {"non
"RB already setup",
"timer not found",
"cant reassemble SDU",
"duplicate entry"};
"duplicate entry",
"read only"};
typedef enum{
LTE_FDD_ENB_DEBUG_TYPE_ERROR = 0,
......@@ -173,6 +177,8 @@ typedef enum{
LTE_FDD_ENB_PARAM_FREQ_BAND,
LTE_FDD_ENB_PARAM_DL_EARFCN,
LTE_FDD_ENB_PARAM_UL_EARFCN,
LTE_FDD_ENB_PARAM_DL_CENTER_FREQ,
LTE_FDD_ENB_PARAM_UL_CENTER_FREQ,
LTE_FDD_ENB_PARAM_N_RB_DL,
LTE_FDD_ENB_PARAM_N_RB_UL,
LTE_FDD_ENB_PARAM_DL_BW,
......@@ -220,6 +226,8 @@ static const char lte_fdd_enb_param_text[LTE_FDD_ENB_PARAM_N_ITEMS][100] = {"ban
"band",
"dl_earfcn",
"ul_earfcn",
"dl_center_freq",
"ul_center_freq",
"n_rb_dl",
"n_rb_ul",
"dl_bw",
......@@ -268,6 +276,7 @@ typedef struct{
int64 int64_u_bound;
bool special_bounds;
bool dynamic;
bool read_only;
}LTE_FDD_ENB_VAR_STRUCT;
/*******************************************************************************
......
......@@ -29,6 +29,7 @@
06/15/2014 Ben Wojtowicz Added RRC NAS message handler.
08/03/2014 Ben Wojtowicz Added message parsers, state machines, and
message senders.
09/03/2014 Ben Wojtowicz Added authentication and security support.
*******************************************************************************/
......@@ -98,15 +99,20 @@ private:
// Message Parsers
void parse_attach_request(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_authentication_failure(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_authentication_response(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_identity_response(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_security_mode_complete(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void parse_security_mode_reject(LIBLTE_BYTE_MSG_STRUCT *msg, LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
// State Machines
void attach_sm(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
// Message Senders
void send_attach_reject(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb, uint8 rej_cause);
void send_authentication_reject(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_authentication_request(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
void send_identity_request(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb, uint8 id_type);
void send_security_mode_command(LTE_fdd_enb_user *user, LTE_fdd_enb_rb *rb);
// Parameters
boost::mutex sys_info_mutex;
......
......@@ -30,6 +30,8 @@
08/03/2014 Ben Wojtowicz Added MME procedures/states, RRC NAS support,
RRC transaction id, PDCP sequence numbers,
and RLC transmit variables.
09/03/2014 Ben Wojtowicz Added more MME states and ability to store
the contention resolution identity.
*******************************************************************************/
......@@ -83,12 +85,18 @@ typedef enum{
LTE_FDD_ENB_MME_STATE_ID_REQUEST_IMSI,
LTE_FDD_ENB_MME_STATE_REJECT,
LTE_FDD_ENB_MME_STATE_AUTHENTICATE,
LTE_FDD_ENB_MME_STATE_AUTH_REJECTED,
LTE_FDD_ENB_MME_STATE_ENABLE_SECURITY,
LTE_FDD_ENB_MME_STATE_RELEASE,
LTE_FDD_ENB_MME_STATE_N_ITEMS,
}LTE_FDD_ENB_MME_STATE_ENUM;
static const char LTE_fdd_enb_mme_state_text[LTE_FDD_ENB_MME_STATE_N_ITEMS][100] = {"IDLE",
"ID REQUEST IMSI",
"REJECT",
"AUTHENTICATE"};
"AUTHENTICATE",
"AUTH REJECTED",
"ENABLE SECURITY",
"RELEASE"};
typedef enum{
LTE_FDD_ENB_RRC_PROC_IDLE = 0,
......@@ -235,6 +243,10 @@ public:
LTE_FDD_ENB_MAC_CONFIG_ENUM get_mac_config(void);
void start_ul_sched_timer(uint32 m_seconds);
void handle_ul_sched_timer_expiry(uint32 timer_id);
void set_con_res_id(uint64 con_res_id);
uint64 get_con_res_id(void);
void set_send_con_res_id(bool send_con_res_id);
bool get_send_con_res_id(void);
// Generic
void set_qos(LTE_FDD_ENB_QOS_ENUM _qos);
......@@ -292,9 +304,11 @@ private:
boost::mutex mac_sdu_queue_mutex;
std::list<LIBLTE_BIT_MSG_STRUCT *> mac_sdu_queue;
LTE_FDD_ENB_MAC_CONFIG_ENUM mac_config;
uint64 mac_con_res_id;
uint32 ul_sched_timer_m_seconds;
uint32 ul_sched_timer_id;
uint32 t_poll_retransmit_timer_id;
bool mac_send_con_res_id;
// Generic
void queue_msg(LIBLTE_BIT_MSG_STRUCT *msg, boost::mutex *mutex, std::list<LIBLTE_BIT_MSG_STRUCT *> *queue);
......
......@@ -28,6 +28,8 @@
05/04/2014 Ben Wojtowicz Added radio bearer support.
06/15/2014 Ben Wojtowicz Added initialize routine.
08/03/2014 Ben Wojtowicz Refactored user identities.
09/03/2014 Ben Wojtowicz Added ciphering and integrity algorithm
storing.
*******************************************************************************/
......@@ -63,6 +65,18 @@ typedef struct{
uint64 imei;
}LTE_FDD_ENB_USER_ID_STRUCT;
typedef struct{
uint32 nas_count_ul;
uint32 nas_count_dl;
uint8 rand[16];
uint8 res[8];
uint8 ck[16];
uint8 ik[16];
uint8 autn[16];
uint8 k_nas_enc[32];
uint8 k_nas_int[32];
}LTE_FDD_ENB_AUTHENTICATION_VECTOR_STRUCT;
/*******************************************************************************
CLASS DECLARATIONS
*******************************************************************************/
......@@ -90,6 +104,26 @@ public:
void set_c_rnti(uint16 _c_rnti);
uint16 get_c_rnti(void);
bool is_c_rnti_set(void);
void set_auth_vec(LTE_FDD_ENB_AUTHENTICATION_VECTOR_STRUCT *av);
LTE_FDD_ENB_AUTHENTICATION_VECTOR_STRUCT* get_auth_vec(void);
void increment_nas_count_dl(void);
void increment_nas_count_ul(void);
bool is_auth_vec_set(void);
// Capabilities
void set_eea_support(uint8 eea, bool support);
bool get_eea_support(uint8 eea);
void set_eia_support(uint8 eia, bool support);
bool get_eia_support(uint8 eia);
void set_uea_support(uint8 uea, bool support);
bool get_uea_support(uint8 uea);
bool is_uea_set(void);
void set_uia_support(uint8 uia, bool support);
bool get_uia_support(uint8 uia);
bool is_uia_set(void);
void set_gea_support(uint8 gea, bool support);
bool get_gea_support(uint8 gea);
bool is_gea_set(void);
// Radio Bearers
void get_srb0(LTE_fdd_enb_rb **rb);
......@@ -101,6 +135,10 @@ public:
LTE_FDD_ENB_ERROR_ENUM get_srb2(LTE_fdd_enb_rb **rb);
// MAC
bool get_dl_ndi(void);
void flip_dl_ndi(void);
bool get_ul_ndi(void);
void flip_ul_ndi(void);
LIBLTE_MAC_PDU_STRUCT pusch_mac_pdu;
// Generic
......@@ -109,11 +147,23 @@ public:
private:
// Identity
LTE_FDD_ENB_USER_ID_STRUCT id;
uint64 temp_id;
uint32 c_rnti;
bool id_set;
bool c_rnti_set;
LTE_FDD_ENB_USER_ID_STRUCT id;
LTE_FDD_ENB_AUTHENTICATION_VECTOR_STRUCT auth_vec;
uint64 temp_id;
uint32 c_rnti;
bool id_set;
bool c_rnti_set;
bool auth_vec_set;
// Capabilities
bool eea_support[8];
bool eia_support[8];
bool uea_support[8];
bool uea_set;
bool uia_support[8];
bool uia_set;
bool gea_support[8];
bool gea_set;
// Radio Bearers
LTE_fdd_enb_rb *srb0;
......@@ -121,6 +171,10 @@ private:
LTE_fdd_enb_rb *srb2;
LTE_fdd_enb_rb *drb[8];
// MAC
bool dl_ndi;
bool ul_ndi;
// Generic
bool delete_at_idle;
};
......
......@@ -33,6 +33,8 @@
05/04/2014 Ben Wojtowicz Added PCAP support.
06/15/2014 Ben Wojtowicz Omitting path from __FILE__.
08/03/2014 Ben Wojtowicz Added support for limiting PCAP output.
09/03/2014 Ben Wojtowicz Added better MCC/MNC support and UL EARFCN,
and DL and UL center frequencies.
*******************************************************************************/
......@@ -109,6 +111,8 @@ LTE_fdd_enb_cnfg_db::LTE_fdd_enb_cnfg_db()
var_map_int64[LTE_FDD_ENB_PARAM_FREQ_BAND] = 0;
var_map_int64[LTE_FDD_ENB_PARAM_DL_EARFCN] = liblte_interface_first_dl_earfcn[0];
var_map_int64[LTE_FDD_ENB_PARAM_UL_EARFCN] = liblte_interface_get_corresponding_ul_earfcn(liblte_interface_first_dl_earfcn[0]);
var_map_int64[LTE_FDD_ENB_PARAM_DL_CENTER_FREQ] = liblte_interface_dl_earfcn_to_frequency(liblte_interface_first_dl_earfcn[0]);
var_map_int64[LTE_FDD_ENB_PARAM_UL_CENTER_FREQ] = liblte_interface_ul_earfcn_to_frequency(liblte_interface_get_corresponding_ul_earfcn(liblte_interface_first_dl_earfcn[0]));
var_map_int64[LTE_FDD_ENB_PARAM_N_RB_DL] = LIBLTE_PHY_N_RB_DL_10MHZ;
var_map_int64[LTE_FDD_ENB_PARAM_N_RB_UL] = LIBLTE_PHY_N_RB_UL_10MHZ;
var_map_int64[LTE_FDD_ENB_PARAM_DL_BW] = LIBLTE_RRC_DL_BANDWIDTH_50;
......@@ -168,6 +172,8 @@ LTE_FDD_ENB_ERROR_ENUM LTE_fdd_enb_cnfg_db::set_param(LTE_FDD_ENB_PARAM_ENUM par
set_param(LTE_FDD_ENB_PARAM_N_ID_1, (value - (value % 3))/3);
}else if(LTE_FDD_ENB_PARAM_DL_EARFCN == param){
set_param(LTE_FDD_ENB_PARAM_UL_EARFCN, (int64)liblte_interface_get_corresponding_ul_earfcn(value));
set_param(LTE_FDD_ENB_PARAM_DL_CENTER_FREQ, (int64)liblte_interface_dl_earfcn_to_frequency(value));
set_param(LTE_FDD_ENB_PARAM_UL_CENTER_FREQ, (int64)liblte_interface_ul_earfcn_to_frequency(liblte_interface_get_corresponding_ul_earfcn(value)));
radio->set_earfcns(value, (int64)liblte_interface_get_corresponding_ul_earfcn(value));
}
}
......@@ -222,9 +228,10 @@ LTE_FDD_ENB_ERROR_ENUM LTE_fdd_enb_cnfg_db::set_param(LTE_FDD_ENB_PARAM_ENUM par
LTE_FDD_ENB_ERROR_ENUM LTE_fdd_enb_cnfg_db::set_param(LTE_FDD_ENB_PARAM_ENUM param,
std::string value)
{
std::map<LTE_FDD_ENB_PARAM_ENUM, uint32>::iterator iter = var_map_uint32.find(param);
LTE_FDD_ENB_ERROR_ENUM err = LTE_FDD_ENB_ERROR_INVALID_PARAM;
uint32 i;
std::map<LTE_FDD_ENB_PARAM_ENUM, uint32>::iterator iter = var_map_uint32.find(param);
LTE_FDD_ENB_ERROR_ENUM err = LTE_FDD_ENB_ERROR_INVALID_PARAM;
uint32 i;
const char *v_str = value.c_str();
if(var_map_uint32.end() != iter)
{
......@@ -232,7 +239,7 @@ LTE_FDD_ENB_ERROR_ENUM LTE_fdd_enb_cnfg_db::set_param(LTE_FDD_ENB_PARAM_ENUM par
for(i=0; i<value.length(); i++)
{
(*iter).second <<= 4;
(*iter).second |= (value[i] & 0x0F);
(*iter).second |= (v_str[i] & 0x0F);
}
err = LTE_FDD_ENB_ERROR_NONE;
}
......@@ -450,11 +457,32 @@ void LTE_fdd_enb_cnfg_db::construct_sys_info(void)
if(var_map_uint32.end() != uint32_iter)
{
sys_info.sib1.plmn_id[0].id.mcc = ((*uint32_iter).second) & 0xFFFF;
sys_info.mcc = 0;
for(i=0; i<3; i++)
{
sys_info.mcc *= 10;
sys_info.mcc |= (((*uint32_iter).second) >> (2-i)*4) & 0xF;
}
}
uint32_iter = var_map_uint32.find(LTE_FDD_ENB_PARAM_MNC);
if(var_map_uint32.end() != uint32_iter)
{
sys_info.sib1.plmn_id[0].id.mnc = ((*uint32_iter).second) & 0xFFFF;
sys_info.mnc = 0;
if(((((*uint32_iter).second) >> 8) & 0xF) == 0xF)
{
for(i=0; i<2; i++)
{
sys_info.mnc *= 10;
sys_info.mnc |= (((*uint32_iter).second) >> (1-i)*4) & 0xF;
}
}else{
for(i=0; i<3; i++)
{
sys_info.mnc *= 10;
sys_info.mnc |= (((*uint32_iter).second) >> (2-i)*4) & 0xF;
}
}
}
sys_info.sib1.plmn_id[0].resv_for_oper = LIBLTE_RRC_NOT_RESV_FOR_OPER;
sys_info.sib1.cell_barred = LIBLTE_RRC_CELL_NOT_BARRED;
......
......@@ -27,6 +27,8 @@
---------- ------------- --------------------------------------------
06/15/2014 Ben Wojtowicz Created file
08/03/2014 Ben Wojtowicz Added authentication vector support.
09/03/2014 Ben Wojtowicz Added sequence number resynch and key
generation.
*******************************************************************************/
......@@ -100,8 +102,7 @@ LTE_fdd_enb_hss::~LTE_fdd_enb_hss()
/****************************/
LTE_FDD_ENB_ERROR_ENUM LTE_fdd_enb_hss::add_user(std::string imsi,
std::string imei,
std::string k,
std::string amf)
std::string k)
{
std::list<LTE_FDD_ENB_HSS_USER_STRUCT *>::iterator iter;
LTE_FDD_ENB_HSS_USER_STRUCT *new_user = new LTE_FDD_ENB_HSS_USER_STRUCT;
......@@ -109,7 +110,6 @@ LTE_FDD_ENB_ERROR_ENUM LTE_fdd_enb_hss::add_user(std::string imsi,
const char *imsi_str = imsi.c_str();
const char *imei_str = imei.c_str();
const char *k_str = k.c_str();
const char *amf_str = amf.c_str();
uint32 i;
if(NULL != new_user &&
......@@ -152,27 +152,6 @@ LTE_FDD_ENB_ERROR_ENUM LTE_fdd_enb_hss::add_user(std::string imsi,
}
}
for(i=0; i<2; i++)
{
if(amf_str[i*2+0] >= '0' && amf_str[i*2+0] <= '9')
{
new_user->stored_data.amf[i] = (amf_str[i*2+0] - '0') << 4;
}else if(amf_str[i*2+0] >= 'A' && amf_str[i*2+0] <= 'F'){
new_user->stored_data.amf[i] = ((amf_str[i*2+0] - 'A') + 0xA) << 4;
}else{
new_user->stored_data.amf[i] = ((amf_str[i*2+0] - 'a') + 0xA) << 4;
}
if(amf_str[i*2+1] >= '0' && amf_str[i*2+1] <= '9')
{
new_user->stored_data.amf[i] |= amf_str[i*2+1] - '0';
}else if(amf_str[i*2+1] >= 'A' && amf_str[i*2+1] <= 'F'){
new_user->stored_data.amf[i] |= (amf_str[i*2+1] - 'A') + 0xA;
}else{
new_user->stored_data.amf[i] |= (amf_str[i*2+1] - 'a') + 0xA;
}
}
new_user->generated_data.sqn_he = 0;
new_user->generated_data.seq_he = 0;
new_user->generated_data.ind_he = 0;
......@@ -251,24 +230,6 @@ std::string LTE_fdd_enb_hss::print_all_users(void)
output += (char)((hex_val-0xA) + 'A');
}
}
output += " amf=";
for(i=0; i<2; i++)
{
hex_val = ((*iter)->stored_data.amf[i] >> 4) & 0xF;
if(hex_val < 0xA)
{
output += (char)(hex_val + '0');
}else{
output += (char)((hex_val-0xA) + 'A');
}
hex_val = (*iter)->stored_data.amf[i] & 0xF;
if(hex_val < 0xA)
{
output += (char)(hex_val + '0');
}else{
output += (char)((hex_val-0xA) + 'A');
}
}
}
return(output);
......@@ -348,6 +309,7 @@ void LTE_fdd_enb_hss::generate_security_data(LTE_FDD_ENB_USER_ID_STRUCT *id,
uint32 i;
uint32 rand_val;
uint8 sqn[6];
uint8 amf[2] = {0x80, 0x00}; // 3GPP 33.102 v10.0.0 Annex H
for(iter=user_list.begin(); iter!=user_list.end(); iter++)
{
......@@ -355,6 +317,7 @@ void LTE_fdd_enb_hss::generate_security_data(LTE_FDD_ENB_USER_ID_STRUCT *id,
id->imsi == (*iter)->id.imsi)
{
// Generate sqn
// From 33.102 v10.0.0 section C.3.2
(*iter)->generated_data.seq_he = ((*iter)->generated_data.seq_he + 1) % LTE_FDD_ENB_SEQ_HE_MAX_VALUE;
(*iter)->generated_data.ind_he = ((*iter)->generated_data.ind_he + 1) % LTE_FDD_ENB_IND_HE_MAX_VALUE;
(*iter)->generated_data.sqn_he = ((*iter)->generated_data.seq_he << LTE_FDD_ENB_IND_HE_N_BITS) | (*iter)->generated_data.ind_he;
......@@ -377,8 +340,9 @@ void LTE_fdd_enb_hss::generate_security_data(LTE_FDD_ENB_USER_ID_STRUCT *id,
liblte_security_milenage_f1((*iter)->stored_data.k,
(*iter)->generated_data.auth_vec.rand,
sqn,
(*iter)->stored_data.amf,
amf,
(*iter)->generated_data.mac);
liblte_security_milenage_f2345((*iter)->stored_data.k,
(*iter)->generated_data.auth_vec.rand,
(*iter)->generated_data.auth_vec.res,
......@@ -393,13 +357,18 @@ void LTE_fdd_enb_hss::generate_security_data(LTE_FDD_ENB_USER_ID_STRUCT *id,
}
for(i=0; i<2; i++)
{
(*iter)->generated_data.auth_vec.autn[6+i] = (*iter)->stored_data.amf[i];
(*iter)->generated_data.auth_vec.autn[6+i] = amf[i];
}
for(i=0; i<8; i++)
{
(*iter)->generated_data.auth_vec.autn[8+i] = (*iter)->generated_data.mac[i];
}
// Reset NAS counts
// 3GPP 33.401 v10.0.0 section 6.5
(*iter)->generated_data.auth_vec.nas_count_ul = 0;
(*iter)->generated_data.auth_vec.nas_count_dl = 0;
// Generate Kasme
liblte_security_generate_k_asme((*iter)->generated_data.auth_vec.ck,
(*iter)->generated_data.auth_vec.ik,
......@@ -410,10 +379,67 @@ void LTE_fdd_enb_hss::generate_security_data(LTE_FDD_ENB_USER_ID_STRUCT *id,
(*iter)->generated_data.k_asme);
// Generate K_nas_enc and K_nas_int
// FIXME
// FIXME: Dynamic picking of algorithms
liblte_security_generate_k_nas((*iter)->generated_data.k_asme,
LIBLTE_SECURITY_CIPHERING_ALGORITHM_ID_EEA0,
LIBLTE_SECURITY_INTEGRITY_ALGORITHM_ID_128_EIA2,
(*iter)->generated_data.auth_vec.k_nas_enc,
(*iter)->generated_data.auth_vec.k_nas_int);
// Generate K_enb
liblte_security_generate_k_enb((*iter)->generated_data.k_asme,
(*iter)->generated_data.auth_vec.nas_count_ul,
(*iter)->generated_data.k_enb);
// Generate K_rrc_enc and K_rrc_int
liblte_security_generate_k_rrc((*iter)->generated_data.k_enb,
LIBLTE_SECURITY_CIPHERING_ALGORITHM_ID_EEA0,
LIBLTE_SECURITY_INTEGRITY_ALGORITHM_ID_128_EIA2,
(*iter)->generated_data.k_rrc_enc,
(*iter)->generated_data.k_rrc_int);
// Generate K_up_enc and K_up_int
liblte_security_generate_k_up((*iter)->generated_data.k_enb,
LIBLTE_SECURITY_CIPHERING_ALGORITHM_ID_EEA0,
LIBLTE_SECURITY_INTEGRITY_ALGORITHM_ID_128_EIA2,
(*iter)->generated_data.k_up_enc,
(*iter)->generated_data.k_up_int);
// Generate K_enb, K_up_enc, K_rrc_int, and K_rrc_enc
// FIXME
break;
}
}
}
void LTE_fdd_enb_hss::security_resynch(LTE_FDD_ENB_USER_ID_STRUCT *id,
uint16 mcc,
uint16 mnc,
uint8 *auts)
{
boost::mutex::scoped_lock lock(user_mutex);
std::list<LTE_FDD_ENB_HSS_USER_STRUCT *>::iterator iter;
uint32 i;
uint8 sqn[6];
for(iter=user_list.begin(); iter!=user_list.end(); iter++)
{
if(id->imei == (*iter)->id.imei &&
id->imsi == (*iter)->id.imsi)
{
// Decode returned SQN and break into SEQ and IND
liblte_security_milenage_f5_star((*iter)->stored_data.k,
(*iter)->generated_data.auth_vec.rand,
(*iter)->generated_data.ak);
(*iter)->generated_data.sqn_he = 0;
for(i=0; i<6; i++)
{
sqn[i] = auts[i] ^ (*iter)->generated_data.ak[i];
(*iter)->generated_data.sqn_he |= (uint64)sqn[i] << (5-i)*8;
}
(*iter)->generated_data.seq_he = (*iter)->generated_data.sqn_he >> LTE_FDD_ENB_IND_HE_N_BITS;
(*iter)->generated_data.ind_he = (*iter)->generated_data.sqn_he & LTE_FDD_ENB_IND_HE_MASK;
if((*iter)->generated_data.ind_he > 0)
{
(*iter)->generated_data.ind_he--;
}
break;
}
......
This diff is collapsed.
......@@ -37,6 +37,8 @@
06/15/2014 Ben Wojtowicz Added uplink scheduling and changed fn_combo
to current_tti.
08/03/2014 Ben Wojtowicz Removed debug message.
09/03/2014 Ben Wojtowicz Combined the contention resolution ID and
the first downlink RLC message.
*******************************************************************************/
......@@ -510,10 +512,20 @@ void LTE_fdd_enb_mac::handle_sdu_ready(LTE_FDD_ENB_MAC_SDU_READY_MSG_STRUCT *sdu
alloc.ndi = false;
// Pack the SDU
mac_pdu.chan_type = LIBLTE_MAC_CHAN_TYPE_DLSCH;
mac_pdu.N_subheaders = 1;
mac_pdu.subheader[0].lcid = sdu_ready->rb->get_rb_id();
memcpy(&mac_pdu.subheader[0].payload.sdu, sdu, sizeof(LIBLTE_BIT_MSG_STRUCT));
mac_pdu.chan_type = LIBLTE_MAC_CHAN_TYPE_DLSCH;
if(sdu_ready->rb->get_send_con_res_id())
{
mac_pdu.N_subheaders = 2;
mac_pdu.subheader[0].lcid = LIBLTE_MAC_DLSCH_UE_CONTENTION_RESOLUTION_ID_LCID;
mac_pdu.subheader[0].payload.ue_con_res_id.id = sdu_ready->rb->get_con_res_id();
mac_pdu.subheader[1].lcid = sdu_ready->rb->get_rb_id();
memcpy(&mac_pdu.subheader[1].payload.sdu, sdu, sizeof(LIBLTE_BIT_MSG_STRUCT));
sdu_ready->rb->set_send_con_res_id(false);
}else{
mac_pdu.N_subheaders = 1;
mac_pdu.subheader[0].lcid = sdu_ready->rb->get_rb_id();
memcpy(&mac_pdu.subheader[0].payload.sdu, sdu, sizeof(LIBLTE_BIT_MSG_STRUCT));
}
// Determine the current_tti
current_tti = (sched_dl_subfr[sched_cur_dl_subfn].current_tti + 4) % (LTE_FDD_ENB_CURRENT_TTI_MAX + 1);
......@@ -559,9 +571,7 @@ void LTE_fdd_enb_mac::handle_ulsch_ccch_sdu(LTE_fdd_enb_user *user,
{
LTE_fdd_enb_rb *rb = NULL;
LTE_FDD_ENB_RLC_PDU_READY_MSG_STRUCT rlc_pdu_ready;
LIBLTE_MAC_PDU_STRUCT mac_pdu;
LIBLTE_PHY_ALLOCATION_STRUCT alloc;
uint32 current_tti;
uint64 con_res_id;
uint32 i;
if(LIBLTE_MAC_ULSCH_CCCH_LCID == lcid)
......@@ -578,59 +588,15 @@ void LTE_fdd_enb_mac::handle_ulsch_ccch_sdu(LTE_fdd_enb_user *user,
// Get SRB0
user->get_srb0(&rb);
// Fill in the contention resolution allocation
alloc.pre_coder_type = LIBLTE_PHY_PRE_CODER_TYPE_TX_DIVERSITY;
alloc.mod_type = LIBLTE_PHY_MODULATION_TYPE_QPSK;
alloc.chan_type = LIBLTE_PHY_CHAN_TYPE_DLSCH;
alloc.rv_idx = 0;
alloc.N_codewords = 1;
sys_info_mutex.lock();
if(1 == sys_info.N_ant)
{
alloc.tx_mode = 1;
}else{
alloc.tx_mode = 2;
}
sys_info_mutex.unlock();
alloc.rnti = user->get_c_rnti();
alloc.mcs = 0;
alloc.tpc = LIBLTE_PHY_TPC_COMMAND_DCI_1_1A_1B_1D_2_3_DB_ZERO;
alloc.ndi = false;
// Pack the contention resolution PDU
mac_pdu.chan_type = LIBLTE_MAC_CHAN_TYPE_DLSCH;
mac_pdu.N_subheaders = 1;
mac_pdu.subheader[0].lcid = LIBLTE_MAC_DLSCH_UE_CONTENTION_RESOLUTION_ID_LCID;
mac_pdu.subheader[0].payload.ue_con_res_id.id = 0;
// Save the contention resolution ID
con_res_id = 0;
for(i=0; i<sdu->N_bits; i++)
{
mac_pdu.subheader[0].payload.ue_con_res_id.id <<= 1;
mac_pdu.subheader[0].payload.ue_con_res_id.id |= sdu->msg[i];
}
// Determine the contention resolution current_tti
current_tti = (sched_dl_subfr[sched_cur_dl_subfn].current_tti + 4) % (LTE_FDD_ENB_CURRENT_TTI_MAX + 1);
// Add the contention resolution PDU to the scheduling queue
if(LTE_FDD_ENB_ERROR_NONE != add_to_dl_sched_queue(current_tti,
&mac_pdu,
&alloc))
{
interface->send_debug_msg(LTE_FDD_ENB_DEBUG_TYPE_ERROR,
LTE_FDD_ENB_DEBUG_LEVEL_MAC,
__FILE__,
__LINE__,
"Can't schedule PDU");
}else{
interface->send_debug_msg(LTE_FDD_ENB_DEBUG_TYPE_INFO,
LTE_FDD_ENB_DEBUG_LEVEL_MAC,
__FILE__,
__LINE__,
&alloc.msg,
"PDU scheduled for RNTI=%u, DL_QUEUE_SIZE=%u",