From: Denis Vinogradov Date: Thu, 24 Dec 2020 01:06:24 +0000 (+0900) Subject: [APR-6626]return IKE termination cause to service X-Git-Tag: MMI-RSA31.Q1-48-36-11~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=773887efc43185e498b9eb5a8988b36340b71557;p=GitHub%2FMotorolaMobilityLLC%2Fexternal-strongswan.git [APR-6626]return IKE termination cause to service [JIRA]: SOC-126438 [Problem]: After DPD timeout connection is deleted but framework retries to create connection on WiFi. [Issue]: Service does not know termination cause and could not make proper decision [Solution]: Provide termination cause for IKE SA Change-Id: Ie0e43055a489aba0456d6ef66136d4d5adfce15f Signed-off-by: Denis Vinogradov --- diff --git a/src/libcharon/comm/alerts.c b/src/libcharon/comm/alerts.c index 057ec94..81cdf04 100755 --- a/src/libcharon/comm/alerts.c +++ b/src/libcharon/comm/alerts.c @@ -232,9 +232,11 @@ static void send_alert_event(ike_sa_t *ike_sa, alert_t alert) */ case ALERT_LOCAL_AUTH_FAILED: /* re-authentication failed */ + charon_send_terminated_indication(name); + break; case ALERT_RETRANSMIT_SEND_TIMEOUT: /* re-transmit failed */ - charon_send_terminated_indication(name); + charon_send_terminated_indication_with_cause(name, CAUSE_TIMEOUT); break; default: DBG1(DBG_CFG,"Alert %d ignored. Do not send notification to service", alert); diff --git a/src/libcharon/comm/charon_comm_interface.h b/src/libcharon/comm/charon_comm_interface.h index eae9e87..106701d 100755 --- a/src/libcharon/comm/charon_comm_interface.h +++ b/src/libcharon/comm/charon_comm_interface.h @@ -13,6 +13,7 @@ void charon_send_terminate_response(charon_error_code_t error, stroke_msg_t *msg void charon_send_initate_failure(stroke_msg_t *msg, int index); void charon_send_initiate_success(stroke_msg_t *msg, int index); void charon_send_terminated_indication(char* name); +void charon_send_terminated_indication_with_cause(char* name, int cause); status_t charon_process_sim_auth(char* name, char *rand, char *autn, char *ck, char *ik, char *res, int *res_len, sim_auth_resp_code_t *status); diff --git a/src/libcharon/comm/comm_msg.c b/src/libcharon/comm/comm_msg.c index f620c0c..06115c0 100755 --- a/src/libcharon/comm/comm_msg.c +++ b/src/libcharon/comm/comm_msg.c @@ -392,6 +392,21 @@ void charon_send_terminated_indication(char* name) { charon_response_t *ind = create_response_msg(IND_TERMINATED); push_string(&ind, ind_terminated.name, name); + ind->ind_terminated.cause = CAUSE_NORMAL; + + int sock = send_message(ind, ind->length); + if (sock > 0) + { + close(sock); + } + free(ind); +} + +void charon_send_terminated_indication_with_cause(char* name, int cause) +{ + charon_response_t *ind = create_response_msg(IND_TERMINATED); + push_string(&ind, ind_terminated.name, name); + ind->ind_terminated.cause = cause; int sock = send_message(ind, ind->length); if (sock > 0) diff --git a/src/libcharon/comm/comm_msg.h b/src/libcharon/comm/comm_msg.h index deea8ab..56592e2 100755 --- a/src/libcharon/comm/comm_msg.h +++ b/src/libcharon/comm/comm_msg.h @@ -65,6 +65,11 @@ typedef enum { AUTH_SYNC_FAIL, } sim_auth_resp_code_t; +typedef enum { + CAUSE_NORMAL, + CAUSE_TIMEOUT +} charon_termination_cause_t; + typedef struct { unsigned short length; @@ -94,6 +99,7 @@ typedef struct struct { char *name; + charon_termination_cause_t cause; } ind_terminated; struct {