[keystone-rtos/netapi.git] / ti / runtime / netapi / applications / ipsec_offload / ipsecmgr / src / netapilib_interface.c
diff --git a/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapilib_interface.c b/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapilib_interface.c
index 7ade54d30d36512b94e6c8a0ecdc322e91116da4..9cacf500e7251b93f7f9a0eb35dfa1d227783d96 100755 (executable)
extern ipsecMgrMcb_t globalDB;
extern NETAPI_T netapi_handle;
-
/**************************************************************************
* FUNCTION PURPOSE: Internal function to find a free slot to store APPID
* in list
ipsecmgr_fp_handle_t *sa_handle
)
{
+ int i;
uint8_t auth_key[36];
uint8_t encr_key[36];
int error, index,slot;
NETCP_CFG_ROUTE_T route;
NETCP_CFG_FLOW_T flow;
NETCP_CFG_SA_HANDLE_T pSaHandle;
-
-
+ char* pTok = NULL;
ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
"netapilib_ifAddSA:, DEBUG: Translating SA\n");
memset((void *)&route, 0, sizeof (NETCP_CFG_ROUTE_T));
memset((void *)&flow, 0, sizeof (NETCP_CFG_FLOW_T));
- flow.dma_engine= 1;
- flow.flowid = globalDB.flowId;
- route.p_flow = &flow;
- route.p_dest_q = globalDB.pktio_channel;
-
-
/* Initialize the SA Config structure. */
/* Get the IP protocol version. */
if (af == IPSECMGR_AF_IPV4)
{
saInfo.ipType = nwal_IPV4;
/* Populate the source and destination IP addresses. */
- for (index = 0; index < 4; index++)
+ for (index = 0; index < NWAL_IPV4_ADDR_SIZE; index++)
{
saInfo.dst.ipv4[index] = sa_id->daddr.ipv4[index];
saInfo.src.ipv4[index] = sa_info->saddr.ipv4[index];
saInfo.ipType = nwal_IPV6;
/* Populate the source and destination IP addresses. */
- for (index = 0; index < 16; index++)
+ for (index = 0; index < NWAL_IPV6_ADDR_SIZE; index++)
{
saInfo.dst.ipv6[index] = sa_id->daddr.ipv6[index];
saInfo.src.ipv6[index] = sa_info->saddr.ipv6[index];
return -1;
}
saInfo.dir = NWAL_SA_DIR_INBOUND;
+
+ flow.dma_engine= 1;
+ flow.flowid = globalDB.flowId;
+ printf("add_sa:flowid: %d\n",flow.flowid);
+
+ route.p_flow = &flow;
+ route.p_dest_q = globalDB.pktio_channel;
+
+ printf("add_sa: p_dest_q: 0x%x, flowId: 0x%x\n",
+ route.p_dest_q,
+ route.p_flow->flowid);
+ route.valid_params |= NETCP_CFG_VALID_PARAM_ROUTE_TYPE;
+ route.routeType = NWAL_ROUTE_RX_INTF_W_FLOW;
}
else if (sa_info->dir == DIR_OUTBOUND)
{
saInfo.authMode = NWAL_SA_AALG_HMAC_SHA1;
else if (sa_info->auth.algo == SA_AALG_HMAC_MD5)
saInfo.authMode = NWAL_SA_AALG_HMAC_MD5;
+ else if (sa_info->auth.algo == SA_AALG_AES_XCBC)
+ saInfo.authMode = NWAL_SA_AALG_AES_XCBC;
else if (sa_info->auth.algo == SA_AALG_NONE || sa_info->auth.algo == SA_AALG_NULL)
saInfo.authMode = NWAL_SA_AALG_NULL;
else
if (error == NETAPI_ERR_OK)
{
*sa_handle = globalDB.tx_sa[slot].saAppId;
- printf("netapilib_ifAddSA: using slot: %d\n", slot);
-#if 0
- netapi_secGetChanHandles(netapi_handle,
- saAppIdOut,
- NULL,
- &pSaHandle);
-#endif
}
else
{
/* SA was created successfully. */
return 0;
}
+
/**************************************************************************
* FUNCTION PURPOSE: The function is used to translate the SA configuration
* parameters received from the IPSec Snopper and call the NETAPI function
int netapilib_ifDeleteSA (ipsecmgr_fp_handle_t sa_handle)
{
int error, slot;
-
+ cpu_set_t cpu_set;
+
slot = findAppIdSlot(&globalDB.rx_sa[0],sa_handle, 1);
/* Determine if rx_sa or tx_sa is being deleted */
)
{
#ifdef ENABLE_ADD_POLICY
+#warning "ENABLE_ADD_POLICY"
NETCP_CFG_IPSEC_POLICY_T spAppIdIn;
int error, index, slot;
nwal_IpType ipType;
NETCP_CFG_PA_HANDLE_T pPaHandleOuterIP;
NETCP_CFG_PA_HANDLE_T pPaHandleInnerIP;
NETCP_CFG_SA_HANDLE_T pSaHandle;
+
+ cpu_set_t cpu_set;
+ /* assign main net_test thread to run on core 0 */
+ CPU_ZERO( &cpu_set);
+ CPU_SET( 0, &cpu_set);
+ hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,"netapilib_ifAddSP: called\n");
if (slot == -1)
{
ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
- "netapilib_ifAddSA:, Too many OUTBOUND SAs already offloaded\n");
+ "netapilib_ifAddSA:, SA app_id not found\n");
return -1;
}
-
+
+
flow.dma_engine= 1;
flow.flowid = globalDB.flowId;
route.p_flow = &flow;
route.p_dest_q = globalDB.pktio_channel;
+
/* Get the IP protocol version. */
if (af == IPSECMGR_AF_IPV4)
{
ipType = nwal_IPV4;
/* Populate the source and destination IP addresses. */
- for (index = 0; index < 4; index++)
+ for (index = 0; index < NWAL_IPV4_ADDR_SIZE; index++)
{
dst_ip_addr.ipv4[index] = sel->daddr.ipv4[index];
src_ip_addr.ipv4[index] = sel->saddr.ipv4[index];
{
ipType = nwal_IPV6;
/* Populate the source and destination IP addresses. */
- for (index = 0; index < 16; index++)
+ for (index = 0; index < NWAL_IPV6_ADDR_SIZE; index++)
{
dst_ip_addr.ipv6[index] = sel->daddr.ipv6[index];
src_ip_addr.ipv6[index] = sel->saddr.ipv6[index];
ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
"netapilib_ifAddSA: Translation of SP successful, app_id: 0x%x\n", *sp_handle);
-#if 0
- netapi_secGetChanHandles(netapi_handle,
- (NETCP_CFG_SA_T)sa_handle,
- globalDB.rx_sa[slot].spAppId,
- &pPaHandleOuterIP,
- &pPaHandleInnerIP,
- &pSaHandle);
-#endif
#endif
return 0;
}
hw_ctx->flow_id = info.rxSaPaFlowId;
ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
- "netapilib_ifGetSACtx: rxPaSaFlowId: 0x%x, rxSaPaFlowId: 0x%x\n",
+ "netapilib_ifGetSACtx: rxPaSaflowId: 0x%x, rxSaPaflowId: 0x%x\n",
info.rxPaSaFlowId,
info.rxSaPaFlowId);
ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,