[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 5191500a58acf3b09c73fa58d1ae6ef4af750b49..9cacf500e7251b93f7f9a0eb35dfa1d227783d96 100755 (executable)
extern ipsecMgrMcb_t globalDB;
extern NETAPI_T netapi_handle;
-extern ipsecMgrIfConfigEntry_T ipConfigList[];
-
-
-int compareIPAddr(unsigned char* ip1, unsigned char* ip2, int ip_type)
-{
- int found = 1;
- int i;
- for (i = 0; i<4; i++)
- {
- if (ip1[i] != ip2[i])
- {
- found = 0;
- break;
- }
-
- }
- return found;
-}
/**************************************************************************
* FUNCTION PURPOSE: Internal function to find a free slot to store APPID
* in list
NETCP_CFG_FLOW_T flow;
NETCP_CFG_SA_HANDLE_T pSaHandle;
char* pTok = NULL;
- int iface;
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));
-
-
/* 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;
- /* need to check which interface this SA will be attached to */
- for (i=0;i<16;i++)
- {
- /* get interface for destination ip address */
- if (compareIPAddr(&ipConfigList[i].ip[0],
- &saInfo.dst.ipv4[0],
- saInfo.ipType))
- {
- printf("netapiplib_ifAddSA: match found, interface: %s\n",
- ipConfigList[i].name);
-
- pTok = strtok(ipConfigList[i].name, ":.");
- /* now we have the interface name, is this eth0 or eth1 */
- if (pTok)
- printf("netapiplib_ifAddSA: match found,after strtok interface: %s\n",
- pTok);
- /* now we have eth0 or eth1, now find the i/f number */
- sscanf(pTok,"eth%d", &iface);
-
- globalDB.rx_sa[slot].iface = iface;
- flow.dma_engine= 1;
- flow.flowid = globalDB.flowId[iface];
- route.p_flow = &flow;
- route.p_dest_q = globalDB.pktio_channel[iface];
- break;
-
- }
- }
-
+
+ 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;
-#if 0
- netapi_secGetChanCtxInfo(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");
flow.dma_engine= 1;
- flow.flowid = globalDB.flowId[globalDB.rx_sa[slot].iface];
+ flow.flowid = globalDB.flowId;
route.p_flow = &flow;
- route.p_dest_q = globalDB.pktio_channel[globalDB.rx_sa[slot].iface];
+ route.p_dest_q = globalDB.pktio_channel;
/* Get the IP protocol version. */
{
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_secGetChanCtxInfo(netapi_handle,
- (NETCP_CFG_SA_T)sa_handle,
- globalDB.rx_sa[slot].spAppId,
- &pPaHandleOuterIP,
- &pPaHandleInnerIP,
- &pSaHandle);
-#endif
#endif
return 0;
}