diff --git a/srsepc/epc.conf.example b/srsepc/epc.conf.example index fe8a48735..7dd211a0c 100644 --- a/srsepc/epc.conf.example +++ b/srsepc/epc.conf.example @@ -41,4 +41,4 @@ db_file = user_db.csv [spgw] gtpu_bind_addr=127.0.1.100 -sgi_if_addr=172.0.0.1 +sgi_if_addr=172.16.0.1 diff --git a/srsepc/hdr/spgw/spgw.h b/srsepc/hdr/spgw/spgw.h index 00d2ebd12..047a5db9a 100644 --- a/srsepc/hdr/spgw/spgw.h +++ b/srsepc/hdr/spgw/spgw.h @@ -87,6 +87,8 @@ private: srslte::error_t init_sgi_if(spgw_args_t *args); srslte::error_t init_s1u(spgw_args_t *args); + srslte::error_t init_ue_ip(spgw_args_t *args); + uint64_t get_new_ctrl_teid(); uint64_t get_new_user_teid(); in_addr_t get_new_ue_ipv4(); @@ -112,6 +114,8 @@ private: std::map m_teid_to_tunnel_ctx; //Map control TEID to tunnel ctx. Usefull to get reply ctrl TEID, UE IP, etc. std::map m_ip_to_teid; //Map IP to User-plane TEID for downlink traffic + uint32_t m_h_next_ue_ip; + /*Logs*/ srslte::log_filter *m_spgw_log; diff --git a/srsepc/src/spgw/spgw.cc b/srsepc/src/spgw/spgw.cc index a69ff04d5..afd7efef4 100644 --- a/srsepc/src/spgw/spgw.cc +++ b/srsepc/src/spgw/spgw.cc @@ -104,6 +104,13 @@ spgw::init(spgw_args_t* args, srslte::log_filter *spgw_log) m_spgw_log->console("Could not initialize the S1-U interface.\n"); return -1; } + //Initialize UE ip pool + err = init_ue_ip(args); + if (err != srslte::ERROR_NONE) + { + m_spgw_log->console("Could not initialize the S1-U interface.\n"); + return -1; + } //Init mutex pthread_mutex_init(&m_mutex,NULL); @@ -237,6 +244,13 @@ spgw::init_s1u(spgw_args_t *args) return srslte::ERROR_NONE; } +srslte::error_t +spgw::init_ue_ip(spgw_args_t *args) +{ + m_h_next_ue_ip = ntohl(inet_addr(args->sgi_if_addr.c_str())); + return srslte::ERROR_NONE; +} + void spgw::run_thread() { @@ -395,7 +409,8 @@ spgw::get_new_user_teid() in_addr_t spgw::get_new_ue_ipv4() { - return inet_addr("172.0.0.2");//FIXME Tmp hack + m_h_next_ue_ip++; + return ntohl(m_h_next_ue_ip);//FIXME Tmp hack } void