Added logging to MME GTP-C. Fixed weird comment bug.

master
Pedro Alvarez 7 years ago
parent 425f5d22b5
commit 13595ccb2d

@ -402,8 +402,8 @@ enum gtpc_interface_type
struct gtpc_f_teid_ie
{
bool v4_present;
bool v6_present;
bool ipv4_present;
bool ipv6_present;
enum gtpc_interface_type interface_type;
uint32_t teid;
in_addr_t ipv4;

@ -248,6 +248,7 @@ struct gtpc_create_session_response
bool sender_f_teid_present;
struct gtpc_f_teid_ie sender_f_teid; //C
//PGW S5/S8/S2b F-TEID //C
bool paa_present;
struct gtpc_pdn_address_allocation_ie paa; //C
//apn_restriction
//apn_ambr

@ -22,8 +22,8 @@ phy_cell_id = 1
tac = 0x0007
mcc = 001
mnc = 01
mme_addr = 127.0.1.100
gtp_bind_addr = 127.0.1.1
mme_addr = 127.0.0.1
gtp_bind_addr = 127.0.0.1
n_prb = 25
#####################################################################

@ -66,7 +66,7 @@ class mme:
public:
static mme* get_instance(void);
static void cleanup(void);
int init(mme_args_t* args, srslte::log_filter *s1ap_log);
int init(mme_args_t* args, srslte::log_filter *s1ap_log, srslte::log_filter *mme_gtpc_log);
void stop();
int get_s1_mme();
void run_thread();
@ -84,7 +84,7 @@ private:
/*Logs*/
srslte::log_filter *m_s1ap_log;
srslte::log_filter *m_mme_gtpc_log;
};
} // namespace srsepc

@ -26,6 +26,8 @@
#ifndef MME_GTPC_H
#define MME_GTPC_H
#include "srslte/common/log.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/buffer_pool.h"
#include <boost/thread/mutex.hpp>
#include "srslte/asn1/gtpc.h"
@ -43,9 +45,9 @@ public:
static mme_gtpc* get_instance(void);
static void cleanup(void);
bool init();
bool init(srslte::log_filter *mme_gtpc_log);
uint64_t get_new_ctrl_teid();
uint32_t get_new_ctrl_teid();
void send_create_session_request(uint64_t imsi, uint32_t mme_s1ap_id);
void handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu);
@ -55,14 +57,15 @@ private:
virtual ~mme_gtpc();
static mme_gtpc *m_instance;
srslte::log_filter *m_mme_gtpc_log;
srslte::byte_buffer_pool *m_pool;
s1ap* m_s1ap;
spgw* m_spgw;
in_addr_t m_mme_gtpc_ip;
uint64_t m_next_ctrl_teid;
std::map<uint64_t,uint32_t> m_teid_to_mme_s1ap_id;
uint32_t m_next_ctrl_teid;
std::map<uint32_t,uint32_t> m_teid_to_mme_s1ap_id;
};

@ -201,6 +201,11 @@ main (int argc,char * argv[] )
s1ap_log.set_level(srslte::LOG_LEVEL_DEBUG);
s1ap_log.set_hex_limit(32);
srslte::log_filter mme_gtpc_log;
mme_gtpc_log.init("GTPC",logger);
mme_gtpc_log.set_level(srslte::LOG_LEVEL_DEBUG);
mme_gtpc_log.set_hex_limit(32);
srslte::log_filter hss_log;
hss_log.init("HSS ",logger);
hss_log.set_level(srslte::LOG_LEVEL_DEBUG);
@ -212,7 +217,7 @@ main (int argc,char * argv[] )
spgw_log.set_hex_limit(32);
mme *mme = mme::get_instance();
if (mme->init(&args.mme_args, &s1ap_log)) {
if (mme->init(&args.mme_args, &s1ap_log, &mme_gtpc_log)) {
cout << "Error initializing MME" << endl;
exit(1);
}

@ -70,12 +70,12 @@ mme::cleanup(void)
}
int
mme::init(mme_args_t* args, srslte::log_filter *s1ap_log)
mme::init(mme_args_t* args, srslte::log_filter *s1ap_log, srslte::log_filter *mme_gtpc_log)
{
/*Init logger*/
m_s1ap_log = s1ap_log;
m_mme_gtpc_log = mme_gtpc_log;
/*Init S1AP*/
m_s1ap = s1ap::get_instance();
if(m_s1ap->init(args->s1ap_args, s1ap_log)){
@ -85,7 +85,7 @@ mme::init(mme_args_t* args, srslte::log_filter *s1ap_log)
/*Init GTP-C*/
m_mme_gtpc = mme_gtpc::get_instance();
if(!m_mme_gtpc->init())
if(!m_mme_gtpc->init(m_mme_gtpc_log))
{
m_s1ap_log->console("Error initializing GTP-C\n");
exit(-1);

@ -36,7 +36,6 @@ mme_gtpc* mme_gtpc::m_instance = NULL;
boost::mutex mme_gtpc_instance_mutex;
mme_gtpc::mme_gtpc()
:m_next_ctrl_teid(1)
{
}
@ -66,16 +65,24 @@ mme_gtpc::cleanup(void)
bool
mme_gtpc::init()
mme_gtpc::init(srslte::log_filter *mme_gtpc_log)
{
/*Init log*/
m_mme_gtpc_log = mme_gtpc_log;
m_next_ctrl_teid = 1;
m_s1ap = s1ap::get_instance();
m_mme_gtpc_ip = inet_addr("127.0.0.1");//FIXME At the moment, the GTP-C messages are not sent over the wire. So this parameter is not used.
m_spgw = spgw::get_instance();
m_mme_gtpc_log->info("MME GTP-C Initialized\n");
m_mme_gtpc_log->console("MME GTP-C Initialized\n");
return true;
}
uint64_t
uint32_t
mme_gtpc::get_new_ctrl_teid()
{
return m_next_ctrl_teid++; //FIXME Use a Id pool?
@ -83,6 +90,8 @@ mme_gtpc::get_new_ctrl_teid()
void
mme_gtpc::send_create_session_request(uint64_t imsi, uint32_t mme_ue_s1ap_id)
{
m_mme_gtpc_log->info("Preparing Create Session Request. IMSI %lu\n", imsi);
m_mme_gtpc_log->console("Preparing Create Session Request. IMSI %lu\n", imsi);
struct srslte::gtpc_pdu cs_req_pdu;
struct srslte::gtpc_create_session_request *cs_req = &cs_req_pdu.choice.create_session_request;
@ -99,19 +108,22 @@ mme_gtpc::send_create_session_request(uint64_t imsi, uint32_t mme_ue_s1ap_id)
cs_req_pdu.header.type = srslte::GTPC_MSG_TYPE_CREATE_SESSION_REQUEST;
//Setup GTP-C Create Session Request IEs
// Control TEID allocated \\
// Control TEID allocated
cs_req->sender_f_teid.teid = get_new_ctrl_teid();
cs_req->sender_f_teid.ipv4 = m_mme_gtpc_ip;
// APN \\
m_mme_gtpc_log->info("Next control TEID: %lu \n", m_next_ctrl_teid);
m_mme_gtpc_log->info("Allocated control TEID: %lu \n", cs_req->sender_f_teid.teid);
m_mme_gtpc_log->console("Allocated control TEID: %lu \n", cs_req->sender_f_teid.teid);
// APN
memcpy(cs_req->apn, "internet", sizeof("internet"));
// RAT Type \\
cs_req->rat_type = GTPC_RAT_TYPE::EUTRAN;
// RAT Type
//cs_req->rat_type = srslte::GTPC_RAT_TYPE::EUTRAN;
//Save RX Control TEID
m_teid_to_mme_s1ap_id.insert(std::pair<uint64_t,uint32_t>(cs_req->sender_f_teid.teid, mme_ue_s1ap_id));
m_teid_to_mme_s1ap_id.insert(std::pair<uint32_t,uint32_t>(cs_req->sender_f_teid.teid, mme_ue_s1ap_id));
m_spgw->handle_create_session_request(cs_req, &cs_resp_pdu);
handle_create_session_response(&cs_resp_pdu);
}
@ -119,24 +131,25 @@ void
mme_gtpc::handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu)
{
struct srslte::gtpc_create_session_response *cs_resp = & cs_resp_pdu->choice.create_session_response;
m_mme_gtpc_log->info("Received Create Session Response\n");
if (cs_resp_pdu->header.type != srslte::GTPC_MSG_TYPE_CREATE_SESSION_RESPONSE)
{
//m_mme_gtpc_log->warning("Could not create GTPC session.\n");
m_mme_gtpc_log->warning("Could not create GTPC session. Not a create session response\n");
//TODO Handle err
return;
}
if (cs_resp->cause.cause_value != srslte::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED){
//m_mme_gtpc_log->warning("Could not create GTPC session.\n");
m_mme_gtpc_log->warning("Could not create GTPC session. Create Session Request not accepted\n");
//TODO Handle error
return;
}
//Get MME_UE_S1AP_ID from the Ctrl TEID
std::map<uint64_t,uint32_t>::iterator id_it = m_teid_to_mme_s1ap_id.find(cs_resp_pdu->header.teid);
std::map<uint32_t,uint32_t>::iterator id_it = m_teid_to_mme_s1ap_id.find(cs_resp_pdu->header.teid);
if(id_it == m_teid_to_mme_s1ap_id.end())
{
//Could not find MME UE S1AP TEID
m_mme_gtpc_log->warning("Could not find MME UE S1AP TEID.\n");
return;
}
uint32_t mme_s1ap_id = id_it->second;

@ -428,7 +428,7 @@ s1ap::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRANSPORT_STRUCT
m_s1ap_log->warning("Could not find UE. MME-UE S1AP id: %lu\n",mme_ue_s1ap_id);
return false;
}
m_s1ap_log->debug("Found UE. MME-UE S1AP id: %lu",mme_ue_s1ap_id);
m_s1ap_log->debug("Found UE. MME-UE S1AP id: %lu\n",mme_ue_s1ap_id);
//Get NAS message type
uint8_t pd, msg_type;
@ -564,6 +564,8 @@ s1ap::send_initial_context_setup_request(uint32_t mme_ue_s1ap_id, struct srslte:
LIBLTE_S1AP_E_RABTOBESETUPITEMCTXTSUREQ_STRUCT *erab_ctxt = &in_ctxt_req->E_RABToBeSetupListCtxtSUReq.buffer[0]; //FIXME support more than one erab
srslte::byte_buffer_t *reply_buffer = m_pool->allocate();
m_s1ap_log->info("Preparing to send Initial Context Setup request\n");
//Find UE Context
std::map<uint32_t, ue_ctx_t*>::iterator ue_ctx_it = m_active_ues.find(mme_ue_s1ap_id);
if(ue_ctx_it == m_active_ues.end())
@ -622,7 +624,8 @@ s1ap::send_initial_context_setup_request(uint32_t mme_ue_s1ap_id, struct srslte:
m_s1ap_log->error("Failed to send Initial Context Setup Request\n");
return false;
}
m_s1ap_log->info("Sent Intial Context Setup Request\n");
m_s1ap_log->console("Sent Intial Context Setup Request\n");
m_pool->deallocate(reply_buffer);
return true;

@ -313,13 +313,14 @@ spgw::handle_create_session_request(struct srslte::gtpc_create_session_request *
srslte::gtpc_header *header = &cs_resp_pdu->header;
srslte::gtpc_create_session_response *cs_resp = &cs_resp_pdu->choice.create_session_response;
m_spgw_log->info("Received Create Session Request\n");
//Setup GTP-C header
header->piggyback = false;
header->teid_present = true;
header->teid = cs_req->sender_f_teid.teid; //Send create session requesponse to the CS Request TEID
header->type = srslte::GTPC_MSG_TYPE_CREATE_SESSION_RESPONSE;
//Setup uplink control TEID
uint64_t spgw_uplink_ctrl_teid = get_new_ctrl_teid();
//Setup uplink user TEID
@ -327,28 +328,28 @@ spgw::handle_create_session_request(struct srslte::gtpc_create_session_request *
//Allocate UE IP
in_addr_t ue_ip = get_new_ue_ipv4();
//Save the UE IMSI to Ctrl TEID map //TODO!!!
//Save the UE IP to User TEID map //TODO!!!
//Create session response message
//Initialize to zero\\
bzero(cs_resp,sizeof(struct srslte::gtpc_create_session_response));
//Setup Cause\\
//Setup Cause
cs_resp->cause.cause_value = srslte::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED;
//Setup sender F-TEID (ctrl)\\
cs_resp->sender_f_teid.teid_present = true;
//Setup sender F-TEID (ctrl)
cs_resp->sender_f_teid.ipv4_present = true;
cs_resp->sender_f_teid.teid = spgw_uplink_ctrl_teid;
cs_resp->sender_f_teid.ipv4 = 0;//FIXME This is not relevant, as the GTP-C is not transmitted over sockets yet.
//Bearer context created\\
//Bearer context created
cs_resp->eps_bearer_context_created.ebi = 5;
cs_resp->eps_bearer_context_created.cause.cause_value = srslte::GTPC_CAUSE_VALUE_REQUEST_ACCEPTED;
cs_resp->eps_bearer_context_created.s1_u_sgw_f_teid_present=true;
cs_resp->eps_bearer_context_created.s1_u_sgw_f_teid.teid = spgw_uplink_user_teid;
//Fill in the PDA\\
//Fill in the PDA
cs_resp->paa_present = true;
cs_resp->paa.pdn_type = srslte::GTPC_PDN_TYPE_IPV4;
cs_resp->paa.ipv4_present = true;
cs_resp->paa.ipv4 = ue_ip;
m_spgw_log->info("Sending Create Session Response\n");
m_mme_gtpc->handle_create_session_response(cs_resp_pdu);
return;
}

Loading…
Cancel
Save