Unverified Commit f64e6938 authored by lionelgo's avatar lionelgo Committed by GitHub

Merge pull request #2 from OPENAIRINTERFACE/develop

Develop
parents 87fac28e 86881999
......@@ -45,8 +45,22 @@ sgwc_app *sgwc_app_inst = nullptr;
pgw_config pgw_cfg;
sgwc_config sgwc_cfg;
void send_heartbeat_to_tasks(const uint32_t sequence);
//------------------------------------------------------------------------------
void my_app_signal_handler(int s){
void send_heartbeat_to_tasks(const uint32_t sequence)
{
itti_msg_ping *itti_msg = new itti_msg_ping(TASK_SGWC_APP, TASK_ALL, sequence);
std::shared_ptr<itti_msg_ping> i = std::shared_ptr<itti_msg_ping>(itti_msg);
int ret = itti_inst->send_broadcast_msg(i);
if (RETURNok != ret) {
Logger::sgwc_app().error( "Could not send ITTI message %s to task TASK_ALL", i->get_msg_name());
}
}
//------------------------------------------------------------------------------
void my_app_signal_handler(int s)
{
std::cout << "Caught signal " << s << std::endl;
Logger::system().startup( "exiting" );
itti_inst->send_terminate_msg(TASK_SGWC_APP);
......
......@@ -296,12 +296,6 @@ void pfcp_session::cleanup()
std::string pfcp_session::to_string() const
{
std::string s = {};
s.append("\n+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n");
s.append("| PFCP switch Packet Detection Rule list ordered by established sessions: |\n");
s.append("+----------------+----+--------+--------+------------+---------------------------------------+----------------------+----------------+-------------------------------------------------------------+\n" ) ;
s.append("| SEID |pdr | far |predence| action | create outer hdr tun id| rmv outer hdr tun id| UE IPv4 | |\n");
s.append("+----------------+----+--------+--------+------------+---------------------------------------+----------------------+----------------+---------------------------------------------------------------------+\n");
//for (auto it_pdr : pdrs) {
for (std::vector<std::shared_ptr<pfcp::pfcp_pdr>>::const_iterator it_pdr = pdrs.begin(); it_pdr!=pdrs.end(); ++it_pdr) {
s.append(fmt::format("|{:016x}", seid)); // TODO continue this line
std::shared_ptr<pfcp::pfcp_pdr> pdr = *it_pdr;
......
......@@ -443,6 +443,12 @@ void pfcp_switch::add_pfcp_ul_pdr_by_up_teid(const teid_t teid, std::shared_ptr<
}
}
}
//------------------------------------------------------------------------------
void pfcp_switch::remove_pfcp_ul_pdrs_by_up_teid(const teid_t teid)
{
ul_s1u_teid2pfcp_pdr.erase(teid);
}
//------------------------------------------------------------------------------
void pfcp_switch::add_pfcp_dl_pdr_by_ue_ip(const uint32_t ue_ip, std::shared_ptr<pfcp::pfcp_pdr>& pdr)
{
......@@ -466,6 +472,11 @@ void pfcp_switch::add_pfcp_dl_pdr_by_ue_ip(const uint32_t ue_ip, std::shared_ptr
}
}
//------------------------------------------------------------------------------
void pfcp_switch::remove_pfcp_dl_pdrs_by_ue_ip(const uint32_t ue_ip)
{
ue_ipv4_hbo2pfcp_pdr.erase(ue_ip);
}
//------------------------------------------------------------------------------
std::string pfcp_switch::to_string() const
{
std::string s = {};
......@@ -581,8 +592,17 @@ void pfcp_switch::handle_pfcp_session_establishment_request(std::shared_ptr<itti
|| (cause.cause_value == CAUSE_VALUE_CONDITIONAL_IE_MISSING)){
resp->pfcp_ies.set(offending_ie);
}
// TODO warn may be huge, do a vector of string
Logger::pfcp_switch().info(to_string());
#if DEBUG_IS_ON
std::cout << "\n+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+" << std::endl;
std::cout << "| PFCP switch Packet Detection Rule list ordered by established sessions: |" << std::endl;
std::cout << "+----------------+----+--------+--------+------------+---------------------------------------+----------------------+----------------+-------------------------------------------------------------+" << std::endl;
std::cout << "| SEID |pdr | far |predence| action | create outer hdr tun id| rmv outer hdr tun id| UE IPv4 | |" << std::endl;
std::cout << "+----------------+----+--------+--------+------------+---------------------------------------+----------------------+----------------+-------------------------------------------------------------+" << std::endl;
for (const auto& it : up_seid2pfcp_sessions) {
std::cout << it.second->to_string() << std::endl;
}
#endif
}
//------------------------------------------------------------------------------
void pfcp_switch::handle_pfcp_session_modification_request(std::shared_ptr<itti_sxab_session_modification_request> sreq, itti_sxab_session_modification_response* resp)
......@@ -707,7 +727,17 @@ void pfcp_switch::handle_pfcp_session_modification_request(std::shared_ptr<itti_
|| (cause.cause_value == CAUSE_VALUE_CONDITIONAL_IE_MISSING)){
resp->pfcp_ies.set(offending_ie);
}
Logger::pfcp_switch().info(to_string());
#if DEBUG_IS_ON
std::cout << "\n+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+" << std::endl;
std::cout << "| PFCP switch Packet Detection Rule list ordered by established sessions: |" << std::endl;
std::cout << "+----------------+----+--------+--------+------------+---------------------------------------+----------------------+----------------+-------------------------------------------------------------+" << std::endl;
std::cout << "| SEID |pdr | far |predence| action | create outer hdr tun id| rmv outer hdr tun id| UE IPv4 | |" << std::endl;
std::cout << "+----------------+----+--------+--------+------------+---------------------------------------+----------------------+----------------+-------------------------------------------------------------+" << std::endl;
for (const auto& it : up_seid2pfcp_sessions) {
std::cout << it.second->to_string() << std::endl;
}
#endif
}
//------------------------------------------------------------------------------
void pfcp_switch::handle_pfcp_session_deletion_request(std::shared_ptr<itti_sxab_session_deletion_request> sreq, itti_sxab_session_deletion_response* resp)
......@@ -728,7 +758,17 @@ void pfcp_switch::handle_pfcp_session_deletion_request(std::shared_ptr<itti_sxab
}
pfcp_associations::get_instance().notify_del_session(fseid);
resp->pfcp_ies.set(cause);
Logger::pfcp_switch().info(to_string());
#if DEBUG_IS_ON
std::cout << "\n+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+" << std::endl;
std::cout << "| PFCP switch Packet Detection Rule list ordered by established sessions: |" << std::endl;
std::cout << "+----------------+----+--------+--------+------------+---------------------------------------+----------------------+----------------+-------------------------------------------------------------+" << std::endl;
std::cout << "| SEID |pdr | far |predence| action | create outer hdr tun id| rmv outer hdr tun id| UE IPv4 | |" << std::endl;
std::cout << "+----------------+----+--------+--------+------------+---------------------------------------+----------------------+----------------+-------------------------------------------------------------+" << std::endl;
for (const auto& it : up_seid2pfcp_sessions) {
std::cout << it.second->to_string() << std::endl;
}
#endif
}
//------------------------------------------------------------------------------
void pfcp_switch::pfcp_session_look_up_pack_in_access(struct iphdr* const iph, const std::size_t num_bytes, const endpoint& r_endpoint, const uint32_t tunnel_id)
......@@ -789,16 +829,24 @@ void pfcp_switch::pfcp_session_look_up_pack_in_core(const char *buffer, const st
pfcp::far_id_t far_id = {};
if ((*it)->get(far_id)) {
std::shared_ptr<pfcp::pfcp_far> sfar = {};
//Logger::pfcp_switch().trace( "pfcp_session_look_up_pack_in_core %d bytes, far id %08X", num_bytes, far_id);
#if TRACE_IS_ON
Logger::pfcp_switch().trace( "pfcp_session_look_up_pack_in_core %d bytes, far id %08X", num_bytes, far_id);
#endif
if (ssession->get(far_id.far_id, sfar)) {
//Logger::pfcp_switch().trace( "pfcp_session_look_up_pack_in_core %d bytes, got far, far id %08X", num_bytes, far_id);
#if TRACE_IS_ON
Logger::pfcp_switch().trace( "pfcp_session_look_up_pack_in_core %d bytes, got far, far id %08X", num_bytes, far_id);
#endif
sfar->apply_forwarding_rules(iph, num_bytes, nocp, buff);
if (buff) {
//Logger::pfcp_switch().trace( "Buffering %d bytes, far id %08X", num_bytes, far_id);
#if TRACE_IS_ON
Logger::pfcp_switch().trace( "Buffering %d bytes, far id %08X", num_bytes, far_id);
#endif
(*it)->buffering_requested(buffer, num_bytes);
}
if (nocp) {
//Logger::pfcp_switch().trace( "Notify CP %d bytes, far id %08X", num_bytes, far_id);
#if TRACE_IS_ON
Logger::pfcp_switch().trace( "Notify CP %d bytes, far id %08X", num_bytes, far_id);
#endif
(*it)->notify_cp_requested(ssession);
}
}
......
......@@ -102,7 +102,7 @@ private:
//switching_data_per_cpu_socket switching_data[];
struct iovec msg_iov_; /* scatter/gather array */
std::unordered_map<pfcp::fseid_t, std::shared_ptr<pfcp::pfcp_session>> cp_fseid2pfcp_sessions;
std::unordered_map<pfcp::fseid_t, std::shared_ptr<pfcp::pfcp_session>> cp_fseid2pfcp_sessions;
folly::AtomicHashMap<uint64_t, std::shared_ptr<pfcp::pfcp_session>> up_seid2pfcp_sessions;
folly::AtomicHashMap<teid_t, std::shared_ptr<std::vector<std::shared_ptr<pfcp::pfcp_pdr>>>> ul_s1u_teid2pfcp_pdr;
folly::AtomicHashMap<uint32_t, std::shared_ptr<std::vector<std::shared_ptr<pfcp::pfcp_pdr>>>> ue_ipv4_hbo2pfcp_pdr;
......@@ -170,8 +170,8 @@ public:
void time_out_max_commit_interval(const uint32_t timer_id);
void remove_pfcp_session(const pfcp::fseid_t& cp_fseid);
void remove_pfcp_ul_pdrs_by_up_teid(const teid_t) {};
void remove_pfcp_dl_pdrs_by_ue_ip(const uint32_t) {};
void remove_pfcp_ul_pdrs_by_up_teid(const teid_t);
void remove_pfcp_dl_pdrs_by_ue_ip(const uint32_t);
std::string to_string() const;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment