Cleaning up logging and printing.

master
Pedro Alvarez 7 years ago
parent 0e1058c8d2
commit cbc1e24e7e

@ -375,7 +375,6 @@ hss::get_k_amf_op(uint64_t imsi, uint8_t *k, uint8_t *amf, uint8_t *op )
} }
hss_ue_ctx_t *ue_ctx = ue_ctx_it->second; hss_ue_ctx_t *ue_ctx = ue_ctx_it->second;
m_hss_log->info("Found User %015lu\n",imsi); m_hss_log->info("Found User %015lu\n",imsi);
m_hss_log->console("Found User %015lu\n",imsi);
memcpy(k,ue_ctx->key,16); memcpy(k,ue_ctx->key,16);
memcpy(amf,ue_ctx->amf,2); memcpy(amf,ue_ctx->amf,2);
memcpy(op,ue_ctx->op,16); memcpy(op,ue_ctx->op,16);

@ -123,11 +123,7 @@ s1ap_nas_transport::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA
return false; return false;
} }
m_pool->deallocate(nas_msg); m_pool->deallocate(nas_msg);
/*
typedef struct{
LIBLTE_MME_KSI_AND_SEQUENCE_NUMBER_STRUCT ksi_and_seq_num;
uint16 short_mac;
}LIBLTE_MME_SERVICE_REQUEST_MSG_STRUCT;*/
//Create basic UE Ctx //Create basic UE Ctx
ue_ctx_t *ue_ctx_ptr = &ue_ctx; ue_ctx_t *ue_ctx_ptr = &ue_ctx;
ue_ctx.imsi = 0; ue_ctx.imsi = 0;
@ -143,7 +139,7 @@ s1ap_nas_transport::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA
ue_ctx.procedure_transaction_id = pdn_con_req.proc_transaction_id; ue_ctx.procedure_transaction_id = pdn_con_req.proc_transaction_id;
//Save whether ESM information transfer is necessary //Save whether ESM information transfer is necessary
ue_ctx.eit = pdn_con_req.esm_info_transfer_flag_present; ue_ctx.eit = pdn_con_req.esm_info_transfer_flag_present;
m_s1ap_log->console("EPS Bearer id: %d\n", eps_bearer_id); //m_s1ap_log->console("EPS Bearer id: %d\n", eps_bearer_id);
//Initialize NAS count //Initialize NAS count
ue_ctx.security_ctxt.ul_nas_count = 0; ue_ctx.security_ctxt.ul_nas_count = 0;
ue_ctx.security_ctxt.dl_nas_count = 0; ue_ctx.security_ctxt.dl_nas_count = 0;
@ -155,8 +151,6 @@ s1ap_nas_transport::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA
ue_ctx.erabs_ctx[i].state = ERAB_DEACTIVATED; ue_ctx.erabs_ctx[i].state = ERAB_DEACTIVATED;
ue_ctx.erabs_ctx[i].erab_id = i; ue_ctx.erabs_ctx[i].erab_id = i;
} }
//Get UE Identity //Get UE Identity
if(attach_req.eps_mobile_id.type_of_id == LIBLTE_MME_EPS_MOBILE_ID_TYPE_IMSI) if(attach_req.eps_mobile_id.type_of_id == LIBLTE_MME_EPS_MOBILE_ID_TYPE_IMSI)
{ {
@ -176,8 +170,8 @@ s1ap_nas_transport::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA
if(it == m_s1ap->m_tmsi_to_s1ap_id.end()) if(it == m_s1ap->m_tmsi_to_s1ap_id.end())
{ {
//Could not find IMSI from M-TMSI, send Id request //Could not find IMSI from M-TMSI, send Id request
m_s1ap_log->console("Attach Request -- Could not find M-TMSI. Sending ID request\n"); m_s1ap_log->console("Attach Request -- Could not find M-TMSI=0x%x. Sending ID request\n",m_tmsi);
m_s1ap_log->info("attach Request -- Could not find M-TMSI. Sending Id Request\n"); m_s1ap_log->info("Attach Request -- Could not find M-TMSI=0x%d. Sending Id Request\n", m_tmsi);
ue_ctx.mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id(); ue_ctx.mme_ue_s1ap_id = m_s1ap->get_next_mme_ue_s1ap_id();
m_s1ap->add_new_ue_ctx(ue_ctx); m_s1ap->add_new_ue_ctx(ue_ctx);
pack_identity_request(reply_buffer, ue_ctx.enb_ue_s1ap_id, ue_ctx.mme_ue_s1ap_id); pack_identity_request(reply_buffer, ue_ctx.enb_ue_s1ap_id, ue_ctx.mme_ue_s1ap_id);
@ -200,9 +194,31 @@ s1ap_nas_transport::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA
return false; return false;
} }
} }
m_s1ap_log->console("Attach request from IMSI: %015lu\n", imsi); m_s1ap_log->console("Attach request -- IMSI: %015lu\n", imsi);
m_s1ap_log->info("Attach request from IMSI: %015lu\n", imsi); m_s1ap_log->info("Attach request -- IMSI: %015lu\n", imsi);
m_s1ap_log->console("Attach request -- eNB-UE S1AP Id: %d, MME-UE S1AP Id: %d\n", ue_ctx_ptr->enb_ue_s1ap_id, ue_ctx_ptr->mme_ue_s1ap_id);
m_s1ap_log->console("Attach Request -- UE Network Capabilities EEA: %d%d%d%d%d%d%d%d\n",
attach_req.ue_network_cap.eea[0],
attach_req.ue_network_cap.eea[1],
attach_req.ue_network_cap.eea[2],
attach_req.ue_network_cap.eea[3],
attach_req.ue_network_cap.eea[4],
attach_req.ue_network_cap.eea[5],
attach_req.ue_network_cap.eea[6],
attach_req.ue_network_cap.eea[7]);
m_s1ap_log->console("Attach Request -- UE Network Capabilities EIA: %d%d%d%d%d%d%d%d\n",
attach_req.ue_network_cap.eia[0],
attach_req.ue_network_cap.eia[1],
attach_req.ue_network_cap.eia[2],
attach_req.ue_network_cap.eia[3],
attach_req.ue_network_cap.eia[4],
attach_req.ue_network_cap.eia[5],
attach_req.ue_network_cap.eia[6],
attach_req.ue_network_cap.eia[7]);
m_s1ap_log->console("Attach Request -- MS Network Capabilities Present: %s\n", attach_req.ms_network_cap_present ? "true" : "false");
m_s1ap_log->console("PDN Connectivity Request -- EPS Bearer Identity requested: %d\n", pdn_con_req.eps_bearer_id);
m_s1ap_log->console("PDN Connectivity Request -- Procedure Transaction Id: %d\n", pdn_con_req.proc_transaction_id);
m_s1ap_log->console("PDN Connectivity Request -- ESM Information Transfer requested: %s\n", pdn_con_req.esm_info_transfer_flag_present ? "true" : "false");
//Get Authentication Vectors from HSS //Get Authentication Vectors from HSS
if(!m_hss->gen_auth_info_answer(imsi, ue_ctx_ptr->security_ctxt.k_asme, autn, rand, ue_ctx_ptr->security_ctxt.xres)) if(!m_hss->gen_auth_info_answer(imsi, ue_ctx_ptr->security_ctxt.k_asme, autn, rand, ue_ctx_ptr->security_ctxt.xres))
@ -263,27 +279,30 @@ s1ap_nas_transport::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRA
switch (msg_type) { switch (msg_type) {
case LIBLTE_MME_MSG_TYPE_AUTHENTICATION_RESPONSE: case LIBLTE_MME_MSG_TYPE_AUTHENTICATION_RESPONSE:
m_s1ap_log->info("Uplink NAS: Received Authentication Response\n");
m_s1ap_log->console("Uplink NAS: Received Authentication Response\n");
handle_nas_authentication_response(nas_msg, ue_ctx, reply_buffer, reply_flag); handle_nas_authentication_response(nas_msg, ue_ctx, reply_buffer, reply_flag);
m_s1ap_log->info("UL NAS: Received Authentication Response\n");
break; break;
case LIBLTE_MME_MSG_TYPE_SECURITY_MODE_COMPLETE: case LIBLTE_MME_MSG_TYPE_SECURITY_MODE_COMPLETE:
m_s1ap_log->info("UL NAS: Received Security Mode Complete\n"); m_s1ap_log->info("Uplink NAS: Received Security Mode Complete\n");
m_s1ap_log->console("Uplink NAS: Received Security Mode Complete\n");
handle_nas_security_mode_complete(nas_msg, ue_ctx, reply_buffer, reply_flag); handle_nas_security_mode_complete(nas_msg, ue_ctx, reply_buffer, reply_flag);
return true; //no need for reply. FIXME this should be better structured...
break; break;
case LIBLTE_MME_MSG_TYPE_ATTACH_COMPLETE: case LIBLTE_MME_MSG_TYPE_ATTACH_COMPLETE:
m_s1ap_log->info("UL NAS: Received Attach Complete\n"); m_s1ap_log->info("Uplink NAS: Received Attach Complete\n");
m_s1ap_log->console("Uplink NAS: Received Attach Complete\n");
handle_nas_attach_complete(nas_msg, ue_ctx, reply_buffer, reply_flag); handle_nas_attach_complete(nas_msg, ue_ctx, reply_buffer, reply_flag);
ue_ctx->security_ctxt.ul_nas_count++; ue_ctx->security_ctxt.ul_nas_count++;
return true; //no need for reply. FIXME this should be better structured...
break; break;
case LIBLTE_MME_MSG_TYPE_ESM_INFORMATION_RESPONSE: case LIBLTE_MME_MSG_TYPE_ESM_INFORMATION_RESPONSE:
m_s1ap_log->info("UL NAS: Received ESM Information Response\n"); m_s1ap_log->info("Uplink NAS: Received ESM Information Response\n");
m_s1ap_log->console("Uplink NAS: Received ESM Information Response\n");
handle_esm_information_response(nas_msg, ue_ctx, reply_buffer, reply_flag); handle_esm_information_response(nas_msg, ue_ctx, reply_buffer, reply_flag);
ue_ctx->security_ctxt.ul_nas_count++; ue_ctx->security_ctxt.ul_nas_count++;
break; break;
case LIBLTE_MME_MSG_TYPE_IDENTITY_RESPONSE: case LIBLTE_MME_MSG_TYPE_IDENTITY_RESPONSE:
m_s1ap_log->info("UL NAS: Received ID Response\n"); m_s1ap_log->info("Uplink NAS: Received Identity Response\n");
m_s1ap_log->info("Uplink NAS: Received Identity Response\n");
handle_identity_response(nas_msg, ue_ctx, reply_buffer, reply_flag); handle_identity_response(nas_msg, ue_ctx, reply_buffer, reply_flag);
//ue_ctx->security_ctxt.ul_nas_count++; //ue_ctx->security_ctxt.ul_nas_count++;
break; break;

@ -301,31 +301,11 @@ spgw::run_thread()
} }
if (FD_ISSET(m_sgi_if, &set)) if (FD_ISSET(m_sgi_if, &set))
{ {
msg->msg[0] = 0x0;
msg->N_bytes = read(sgi, msg->msg, SRSLTE_MAX_BUFFER_SIZE_BYTES); msg->N_bytes = read(sgi, msg->msg, SRSLTE_MAX_BUFFER_SIZE_BYTES);
m_spgw_log->console("Received PDU from SGi. Bytes %d\n", msg->N_bytes); //m_spgw_log->console("Received PDU from SGi. Bytes %d\n", msg->N_bytes);
//m_spgw_log->debug("Received PDU from SGi. Bytes %d\n", msg->N_bytes); //m_spgw_log->debug("Received PDU from SGi. Bytes %d\n", msg->N_bytes);
if (msg->msg[0] != 0x60) {
//pdu->N_bytes = idx + N_bytes;
ip_pkt = (struct iphdr*)msg->msg;
//log_h->debug_hex(pdu->msg, pdu->N_bytes,
// "Read %d bytes from TUN/TAP\n",
// N_bytes);
// Check if entire packet was received
if(ntohs(ip_pkt->tot_len) == msg->N_bytes)
{
//Handle SGi PDU
msg->set_timestamp();
handle_sgi_pdu(msg); handle_sgi_pdu(msg);
} }
else
{
m_spgw_log->console("Did not read all bytes!!!");
}
}
}
} }
else else
{ {
@ -375,7 +355,7 @@ spgw::handle_sgi_pdu(srslte::byte_buffer_t *msg)
enb_addr.sin_family = AF_INET; enb_addr.sin_family = AF_INET;
enb_addr.sin_port = htons(GTPU_RX_PORT); enb_addr.sin_port = htons(GTPU_RX_PORT);
enb_addr.sin_addr.s_addr = enb_fteid.ipv4; enb_addr.sin_addr.s_addr = enb_fteid.ipv4;
m_spgw_log->console("UE F-TEID found, TEID 0x%x, eNB IP %s\n", enb_fteid.teid, inet_ntoa(enb_addr.sin_addr)); //m_spgw_log->console("UE F-TEID found, TEID 0x%x, eNB IP %s\n", enb_fteid.teid, inet_ntoa(enb_addr.sin_addr));
//Setup GTP-U header //Setup GTP-U header
srslte::gtpu_header_t header; srslte::gtpu_header_t header;
@ -398,7 +378,7 @@ spgw::handle_sgi_pdu(srslte::byte_buffer_t *msg)
m_spgw_log->error("Error sending packet to eNB\n"); m_spgw_log->error("Error sending packet to eNB\n");
return; return;
} }
m_spgw_log->console("Sent packet to %s:%d. Bytes=%d/%d\n",inet_ntoa(enb_addr.sin_addr), GTPU_RX_PORT,n,msg->N_bytes); //m_spgw_log->console("Sent packet to %s:%d. Bytes=%d/%d\n",inet_ntoa(enb_addr.sin_addr), GTPU_RX_PORT,n,msg->N_bytes);
return; return;
} }
@ -419,7 +399,7 @@ spgw::handle_s1u_pdu(srslte::byte_buffer_t *msg)
} }
else else
{ {
m_spgw_log->console("Forwarded packet to TUN interface. Bytes= %d/%d\n", n, msg->N_bytes); //m_spgw_log->console("Forwarded packet to TUN interface. Bytes= %d/%d\n", n, msg->N_bytes);
} }
return; return;
} }

Loading…
Cancel
Save