[APR-6626]return IKE termination cause to service
authorDenis Vinogradov <denis.vinogradov@samsung.com>
Thu, 24 Dec 2020 01:06:24 +0000 (10:06 +0900)
committerI am Robot <robot_ap@samsung.com>
Sun, 27 Dec 2020 16:21:59 +0000 (01:21 +0900)
  [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 <denis.vinogradov@samsung.com>
src/libcharon/comm/alerts.c
src/libcharon/comm/charon_comm_interface.h
src/libcharon/comm/comm_msg.c
src/libcharon/comm/comm_msg.h

index 057ec94680a6b6027ba28071dd986dfe01f05102..81cdf045ca0b66e2de1f4673a024a44eac94579e 100755 (executable)
@@ -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);
index eae9e87a00a54e16c9160f76e5c1ae2bd760037d..106701d6634ff21218d5889f5fc572cd750ceec1 100755 (executable)
@@ -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);
 
index f620c0cc988a89a202a570fcb133e7461c13a072..06115c06355936a05f86f96533ce6c07ef36824a 100755 (executable)
@@ -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)
index deea8ab3e03bd42d1971b02b37f4fe9d34a2e30d..56592e21f3631941673d11b0a59dee5daf7c4d1e 100755 (executable)
@@ -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 {