Changing netapi_secGetChanCtxInfo API definition and implementation
[keystone-rtos/netapi.git] / ti / runtime / netapi / src / netapi_sec.c
index f80b94e006be501e599e042a809b983c55e57dbb..d9ee3193a163d8e38ff715ff9b8f1a77ea535625 100755 (executable)
@@ -693,81 +693,65 @@ void  netapi_getSaStats (NETAPI_T               h,
 
 
 /**********************************************************************************
- * FUNCTION PURPOSE:  API to  retrieve SA and PA channel handles for security context 
- *                  if already configured
+ * FUNCTION PURPOSE:  API to  API to retrieve local channel context information
  **********************************************************************************
- * DESCRIPTION:  API to retrieve SA and PA channel handles for security context if already
- *              configured
+ * DESCRIPTION:  API to retrieve API to retrieve local channel context information
  *********************************************************************************/
 void netapi_secGetChanCtxInfo(NETAPI_T h,
-                           NETCP_CFG_SA_T sa_app_id,
-                           NETCP_CFG_IPSEC_POLICY_T policy_app_id,
-                           NETCP_CFG_PA_HANDLE_T* pPaHandleOuterIP,
-                           NETCP_CFG_PA_HANDLE_T* pPaHandleInnerIP,
-                           NETCP_CFG_SA_HANDLE_T* pSaHandle)
+                           NETCP_CFG_APP_ID_T appId,
+                           nwalChanCxtInfo_t* pInfo)
 {
+
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     void * handle_inflow;
     void * handle_sideband = NULL;
     void * handle_policy=NULL;
     nwalChanCxtInfo_t info;
+    uint32_t stage = 0;
+    int policyId;
+    int tunnelId;
 
-    memset(&info, 0, sizeof(nwalChanCxtInfo_t));
+    if(!pInfo)
+        return;
+    memset(pInfo, 0, sizeof(nwalChanCxtInfo_t));
 
-    int tunnelId = netapi_cfgGetMatchId(sa_app_id);
-    int policyId = netapi_cfgGetMatchId(policy_app_id);
+    stage = netapi_cfgGetMatchStage(appId);
+    netapi_Log("netapi_secGetChanCtxInfo: app id: 0x%x, stage: 0x%x\n", appId, stage);
 
-    handle_inflow = netapip_netcpCfgGetSaHandles(&netapi_get_global()->nwal_context,
-                                          tunnelId, &handle_sideband);
 
-    if(handle_inflow)
+    switch (stage)
     {
-        handle_policy = netapip_netcpCfgGetPolicy(&netapi_get_global()->nwal_context,policyId);
-        nwal_getChanCxtInfo(&netapi_get_global()->nwal_context,
-                            handle_policy,
-                            &info);
-
-       if (pPaHandleInnerIP)
-            *pPaHandleInnerIP = info.paInnerIpHandle;
-
-        nwal_getChanCxtInfo(&netapi_get_global()->nwal_context,
-                            handle_policy,
-                            &info);
-
-       if (pPaHandleInnerIP)
-            *pPaHandleInnerIP = info.paInnerIpHandle;
-
-        nwal_getChanCxtInfo(&netapi_get_global()->nwal_context,
+        case 1:
+            /* this is for SA, need SA and OUTER IP handle */
+            tunnelId = netapi_cfgGetMatchId(appId);
+            handle_inflow = netapip_netcpCfgGetSaHandles(&netapi_get_global()->nwal_context,
+                                          tunnelId, &handle_sideband);
+            if(handle_inflow)
+            {
+                nwal_getChanCxtInfo(&netapi_get_global()->nwal_context,
                             handle_inflow,
-                            &info);
-
-        if (pPaHandleOuterIP)
-            *pPaHandleOuterIP = info.paOuterIpHandle;
-
-        if(pSaHandle)
-            *pSaHandle = info.saChanHandle;
-
-        if (pPaHandleOuterIP)
-            netapi_Log("netapi_secGetChanCtxInfo: *pa_handle outer IP: 0x%x\n",
-            (paHandleL2L3_t)*pPaHandleOuterIP);
-
-        if (pPaHandleInnerIP)
-            netapi_Log("netapi_secGetChanCtxInfo: *pa_handle inner IP: 0x%x\n",
-            (paHandleL2L3_t)*pPaHandleInnerIP);
-
-        if (pSaHandle)
-            netapi_Log("netapi_secGetChanCtxInfo: *sa_handle: 0x%x\n",
-            (Sa_ChanHandle)*pSaHandle);
-
-    }
-    else
-    {
-        if (pPaHandleOuterIP)
-            *pPaHandleOuterIP = NULL;
-        if (pPaHandleInnerIP)
-            *pPaHandleInnerIP = NULL;
-        if (pSaHandle)
-            *pSaHandle = NULL;
+                            pInfo);
+                netapi_Log("netapi_secGetChanCtxInfo: outerIP: 0x%x, SA chan handle: 0x%x, bitmap: 0x%x\n",
+                    pInfo->paOuterIpHandle, pInfo->saChanHandle, pInfo->validBitMap);
+            }
+            break;
+        case 2:
+            /* this is for policy, need SA inner IP */
+            policyId = netapi_cfgGetMatchId(appId);
+            handle_policy = netapip_netcpCfgGetPolicy(&netapi_get_global()->nwal_context,
+                                                          policyId);
+            if (handle_policy)
+            {
+                nwal_getChanCxtInfo(&netapi_get_global()->nwal_context,
+                            handle_policy,
+                            pInfo);
+                netapi_Log("netapi_secGetChanCtxInfo: innerIP: 0x%x, bitmap: 0x%x\n",
+                    pInfo->paInnerIpHandle, pInfo->validBitMap);
+            }
+            break;
+        default:
+            netapi_Log("netapi_secGetChanCtxInfo:Invalid APPID provided\n");
+            break;
     }
     return;
 }