Commit 7cb55cbd authored by gauthier's avatar gauthier

WIP PGW-C send CSResp MISSING or UNKNOWN APN

parent 61a95d7b
...@@ -104,6 +104,20 @@ public: ...@@ -104,6 +104,20 @@ public:
virtual ~gtpc_ie_exception() throw(){} virtual ~gtpc_ie_exception() throw(){}
}; };
struct gtpc_missing_ie_exception : public gtpc_exception {
public:
gtpc_missing_ie_exception(uint8_t gtpc_msg, uint8_t ie_type) throw() {
phrase = fmt::format("GTPV2-C msg {} missing IE {} Exception", gtpc_msg, ie_type);
}
gtpc_missing_ie_exception(const char* gtpc_msg, const char* ie_type) throw() {
phrase = fmt::format("GTPV2-C msg {} missing IE {} Exception", gtpc_msg, ie_type);
}
gtpc_missing_ie_exception(std::string& aphrase) throw() {
phrase = aphrase;
}
virtual ~gtpc_missing_ie_exception() throw(){}
};
struct gtpc_ie_unimplemented_exception : public gtpc_ie_exception { struct gtpc_ie_unimplemented_exception : public gtpc_ie_exception {
public: public:
gtpc_ie_unimplemented_exception(uint8_t ie_type) throw() : gtpc_ie_exception(ie_type) { gtpc_ie_unimplemented_exception(uint8_t ie_type) throw() : gtpc_ie_exception(ie_type) {
......
...@@ -520,7 +520,9 @@ gtpv2c_msg::gtpv2c_msg(const gtpv2c_create_session_response& gtp_ies) : gtpv2c_m ...@@ -520,7 +520,9 @@ gtpv2c_msg::gtpv2c_msg(const gtpv2c_create_session_response& gtp_ies) : gtpv2c_m
ies = {}; ies = {};
set_message_type(GTP_CREATE_SESSION_RESPONSE); set_message_type(GTP_CREATE_SESSION_RESPONSE);
if (gtp_ies.cause.first) {std::shared_ptr<gtpv2c_cause_ie> sie(new gtpv2c_cause_ie(gtp_ies.cause.second)); add_ie(sie);} if (gtp_ies.cause.first) {
std::shared_ptr<gtpv2c_cause_ie> sie(new gtpv2c_cause_ie(gtp_ies.cause.second)); add_ie(sie);
} else throw gtpc_missing_ie_exception("GTP_CREATE_SESSION_RESPONSE", "GTP_IE_CAUSE");
//if (gtp_ies.ie_presence_mask & GTPV2C_CREATE_SESSION_RESPONSE_PR_IE_CHANGE_REPORTING_ACTION) {std::shared_ptr<xxx> sie(new xxx(gtp_ies.xxx)); add_ie(sie);} //if (gtp_ies.ie_presence_mask & GTPV2C_CREATE_SESSION_RESPONSE_PR_IE_CHANGE_REPORTING_ACTION) {std::shared_ptr<xxx> sie(new xxx(gtp_ies.xxx)); add_ie(sie);}
//if (gtp_ies.ie_presence_mask & GTPV2C_CREATE_SESSION_RESPONSE_PR_IE_CSG_INFORMATION_REPORTING_ACTION) {std::shared_ptr<xxx> sie(new xxx(gtp_ies.xxx)); add_ie(sie);} //if (gtp_ies.ie_presence_mask & GTPV2C_CREATE_SESSION_RESPONSE_PR_IE_CSG_INFORMATION_REPORTING_ACTION) {std::shared_ptr<xxx> sie(new xxx(gtp_ies.xxx)); add_ie(sie);}
//if (gtp_ies.ie_presence_mask & GTPV2C_CREATE_SESSION_RESPONSE_PR_IE_HENB_INFORMATION_REPORTING) {std::shared_ptr<xxx> sie(new xxx(gtp_ies.xxx)); add_ie(sie);} //if (gtp_ies.ie_presence_mask & GTPV2C_CREATE_SESSION_RESPONSE_PR_IE_HENB_INFORMATION_REPORTING) {std::shared_ptr<xxx> sie(new xxx(gtp_ies.xxx)); add_ie(sie);}
......
...@@ -429,7 +429,7 @@ void pgw_app::handle_itti_msg (std::shared_ptr<itti_s5s8_create_session_request> ...@@ -429,7 +429,7 @@ void pgw_app::handle_itti_msg (std::shared_ptr<itti_s5s8_create_session_request>
if ((csreq->teid) && (not pgw_app_inst->is_s5s8c_teid_exist(csreq->teid))) { if ((csreq->teid) && (not pgw_app_inst->is_s5s8c_teid_exist(csreq->teid))) {
Logger::pgwc_app().warn("Received S5_S8 CREATE_SESSION_REQUEST with dest teid " TEID_FMT " unknown, ignore message", csreq->teid); Logger::pgwc_app().warn("Received S5_S8 CREATE_SESSION_REQUEST with dest teid " TEID_FMT " unknown, ignore message", csreq->teid);
cause_t cause = {.cause_value = CONTEXT_NOT_FOUND, .pce = 0, .bce = 0, .cs = 0}; cause_t cause = {.cause_value = CONTEXT_NOT_FOUND, .pce = 0, .bce = 0, .cs = 0};
send_create_session_response_cause (csreq->gtpc_tx_id, csreq->teid, csreq->r_endpoint, cause); send_create_session_response_cause (csreq->gtpc_tx_id, csreq->gtp_ies.sender_fteid_for_cp.teid_gre_key, csreq->r_endpoint, cause);
return; return;
} }
...@@ -438,7 +438,7 @@ void pgw_app::handle_itti_msg (std::shared_ptr<itti_s5s8_create_session_request> ...@@ -438,7 +438,7 @@ void pgw_app::handle_itti_msg (std::shared_ptr<itti_s5s8_create_session_request>
Logger::pgwc_app().warn("Received CREATE_SESSION_REQUEST unknown requested APN %s, ignore message", csreq->gtp_ies.apn.access_point_name.c_str()); Logger::pgwc_app().warn("Received CREATE_SESSION_REQUEST unknown requested APN %s, ignore message", csreq->gtp_ies.apn.access_point_name.c_str());
// TODO send reply // TODO send reply
cause_t cause = {.cause_value = MISSING_OR_UNKNOWN_APN, .pce = 0, .bce = 0, .cs = 0}; cause_t cause = {.cause_value = MISSING_OR_UNKNOWN_APN, .pce = 0, .bce = 0, .cs = 0};
send_create_session_response_cause (csreq->gtpc_tx_id, csreq->teid, csreq->r_endpoint, cause); send_create_session_response_cause (csreq->gtpc_tx_id, csreq->gtp_ies.sender_fteid_for_cp.teid_gre_key, csreq->r_endpoint, cause);
return; return;
} }
......
...@@ -467,20 +467,27 @@ void sgwc_app::handle_itti_msg (itti_s11_downlink_data_notification_acknowledge& ...@@ -467,20 +467,27 @@ void sgwc_app::handle_itti_msg (itti_s11_downlink_data_notification_acknowledge&
void sgwc_app::handle_itti_msg (itti_s5s8_create_session_response& m) void sgwc_app::handle_itti_msg (itti_s5s8_create_session_response& m)
{ {
Logger::sgwc_app().debug("Received S5S8 CREATE_SESSION_RESPONSE sender teid " TEID_FMT " gtpc_tx_id " PROC_ID_FMT " ", m.teid, m.gtpc_tx_id); Logger::sgwc_app().debug("Received S5S8 CREATE_SESSION_RESPONSE sender teid " TEID_FMT " gtpc_tx_id " PROC_ID_FMT " ", m.teid, m.gtpc_tx_id);
if (m.gtp_ies.s5_s8_pgw_fteid.second.interface_type != S5_S8_PGW_GTP_C) { if (m.gtp_ies.cause.second.cause_value < CONTEXT_NOT_FOUND) {
Logger::sgwc_app().warn("Received S5S8 CREATE_SESSION_RESPONSE with s5_s8_pgw_fteid.interface_type != S5_S8_PGW_GTP_C %d, ignore CSResp", m.gtp_ies.sender_fteid_for_cp.second.interface_type); if (m.gtp_ies.s5_s8_pgw_fteid.second.interface_type != S5_S8_PGW_GTP_C) {
return; Logger::sgwc_app().warn("Received S5S8 CREATE_SESSION_RESPONSE with s5_s8_pgw_fteid.interface_type != S5_S8_PGW_GTP_C %d, ignore CSResp", m.gtp_ies.sender_fteid_for_cp.second.interface_type);
} return;
if (m.gtp_ies.s5_s8_pgw_fteid.second.teid_gre_key == 0) { }
// MME sent request with teid = 0. This is not valid... if (m.gtp_ies.s5_s8_pgw_fteid.second.teid_gre_key == 0) {
Logger::sgwc_app().warn("Received S5S8 CREATE_SESSION_RESPONSE with s5_s8_pgw_fteid.teid = 0, ignore CSResp"); // MME sent request with teid = 0. This is not valid...
return; Logger::sgwc_app().warn("Received S5S8 CREATE_SESSION_RESPONSE with s5_s8_pgw_fteid.teid = 0, ignore CSResp");
return;
}
} }
if (is_s5s8sgw_teid_2_sgw_contexts(m.teid)) { if (is_s5s8sgw_teid_2_sgw_contexts(m.teid)) {
std::pair<std::shared_ptr<sgw_eps_bearer_context>, std::shared_ptr<sgw_pdn_connection>> p = s5s8sgw_teid_2_sgw_contexts(m.teid); std::pair<std::shared_ptr<sgw_eps_bearer_context>, std::shared_ptr<sgw_pdn_connection>> p = s5s8sgw_teid_2_sgw_contexts(m.teid);
if ((p.first.get()) && (p.second.get())) { if ((p.first.get()) && (p.second.get())) {
p.first->handle_itti_msg(m, p.second); p.first->handle_itti_msg(m, p.second);
Logger::sgwc_app().debug("sgw_eps_bearer_context: %s!", p.first->toString().c_str()); // cleanup
if (0 == p.first->get_num_pdn_connections()) {
delete_sgw_eps_bearer_context(p.first);
} else {
Logger::sgwc_app().debug("sgw_eps_bearer_context: %s!", p.first->toString().c_str());
}
} else { } else {
Logger::sgwc_app().debug("Received S5S8 CREATE_SESSION_RESPONSE with dest teid " TEID_FMT ", SGW contexts not found, ignore CSResp", m.teid); Logger::sgwc_app().debug("Received S5S8 CREATE_SESSION_RESPONSE with dest teid " TEID_FMT ", SGW contexts not found, ignore CSResp", m.teid);
} }
......
...@@ -144,6 +144,7 @@ public: ...@@ -144,6 +144,7 @@ public:
void remove_eps_bearer(const ebi_t& ebi); void remove_eps_bearer(const ebi_t& ebi);
void remove_eps_bearer(std::shared_ptr<sgw_eps_bearer> bearer); void remove_eps_bearer(std::shared_ptr<sgw_eps_bearer> bearer);
void delete_bearers(); void delete_bearers();
int get_num_bearers() {return sgw_eps_bearers.size();};
bool is_released() const {return is_dl_up_tunnels_released;} bool is_released() const {return is_dl_up_tunnels_released;}
//fteid_t generate_s5s8_up_fteid(const struct in_addr ipv4_address, const bearer_qos_t& bearer_qos); //fteid_t generate_s5s8_up_fteid(const struct in_addr ipv4_address, const bearer_qos_t& bearer_qos);
......
...@@ -258,6 +258,10 @@ void create_session_request_procedure::handle_itti_msg (itti_s5s8_create_session ...@@ -258,6 +258,10 @@ void create_session_request_procedure::handle_itti_msg (itti_s5s8_create_session
} }
} }
} }
} else if (csresp.gtp_ies.cause.second.cause_value >= CONTEXT_NOT_FOUND) {
if (pdn->get_num_bearers()) {
ebc->delete_pdn_connection(pdn);
}
} }
......
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