Changing netapi_secGetChanCtxInfo API definition and implementation
authorTinku Mannan <tmannan@ti.com>
Tue, 23 Jul 2013 18:16:21 +0000 (14:16 -0400)
committerTinku Mannan <tmannan@ti.com>
Tue, 23 Jul 2013 18:16:21 +0000 (14:16 -0400)
ti/runtime/netapi/netapi_sec.h
ti/runtime/netapi/netcp_cfg.h
ti/runtime/netapi/src/netapi_sec.c

index 1b1de57ca2b24bb234b4d32f0b88a4857cce64fa..b731481241f23d3747da9f567b3a1a704a85ed30 100755 (executable)
@@ -245,25 +245,20 @@ void  netapi_getSaStats (NETAPI_T                   h,
 
 /**
  *  @ingroup cfg_security_functions
- *  @brief netapi_secGetChanCtxInfo API to retrieve SA and PA channel handles for security
- *   context if already configured
- *
- *  @details API to retrieve SA and PA channel handles for security
- *   context if already configured
- *  @param[in]  h       The NETAPI handle, @ref NETAPI_T
- *  @param[in] sa_app_id   Application id returned from call to @ref netapi_secAddSA
- *  @param[in] policy_app_id Application id returned from call to @ref netapi_secAddPolicy
- *  @param[out] pPaHandleOuterIP Pointer to PA LLD handle for outer IP
- *  @param[out] pPaHandleInnerIP Pointer to PA LLD handle for inner IP
- *  @param[out] pSaHandle Pointer to SA LLD
+ *  @brief  API to retrieve internal context information from channel resources
+ *          maintained by NWAL. Selective NetCP PA/SA channel handles are exposed
+ *          to handle the case of multiple owner use case for PA/SA LLD
+ *  @details API to retrieve internal context information from channel resources
+ *          maintained by NWAL. Selective NetCP PA/SA channel handles are exposed
+ *          to handle the case of multiple owner use case for PA/SA LLD
+ *  @param[in]   h      The NETAPI handle, @ref NETAPI_T
+ *  @param[in]   appId  Application Id returned from any config APIs
+ *  @param[out]  pInfo  NWAL Channel context information
  *  @retval     none
  *  @pre        @ref netapi_init, @ref netapi_secAddSA
-*/
+ */
 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);
 
 #endif
index f3c9c85fb588705912ca7aeba50f4a5955a83e74..87951ceaa2a422b2e2596cb86ccb3b3ce4c4810a 100755 (executable)
@@ -190,7 +190,11 @@ typedef NETCP_CFG_ROUTE_T* NETCP_CFG_ROUTE_HANDLE_T;
  */
 #define NETCP_CFG_ALL_EXCEPTIONS 0xff
 
-
+/**
+ * @ingroup cfg_constants
+ * @brief General APP_ID Type definition.
+ */
+typedef uint32_t NETCP_CFG_APP_ID_T;
 
 
 /**
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;
 }