some minor changes to test code:
[keystone-rtos/netapi.git] / ti / runtime / netapi / test / net_test_sa_utils.c
index 1d8d6b92abe58107b6b5f202bdbcdfaf7a05a845..1e28ea9bc844c186d81642c9d506940508245e97 100755 (executable)
@@ -138,6 +138,68 @@ void  netTest_utilBuildSADB(int i)
            trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
         }
     }
+    else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_NULL) &&
+             (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_CTR))
+    {
+        /* static configuration, will not change */
+        sa_info[i].tx_payload_info.aadSize = 0;
+        sa_info[i].tx_payload_info.pAad = NULL;
+        sa_info[i].tx_payload_info.pAuthIV = NULL;
+        sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN +
+                                                netTest_IP_HEADER_LEN;
+
+        sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
+                                               netTest_IP_HEADER_LEN +
+                                               netTest_ESP_HEADER_LEN +
+                                               netTest_AES_CTR_IV_LEN;
+        /* dynamic configuration, will  be calculated on the fly */
+        sa_info[i].tx_payload_info.authSize = 0;
+        sa_info[i].tx_payload_info.encSize = 0;
+        sa_info[i].tx_payload_info.pEncIV = 0;
+
+        sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
+        sa_info[i].authMode = netTestCfg.sa[i].authMode;
+        sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].auth_tag_size = 0;
+        sa_info[i].iv_len=8;
+        sa_info[i].bl=8;
+
+        sa_info[i].tx_pkt_info.enetPort = 0;
+        sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.startOffset = 0;
+        sa_info[i].tx_pkt_info.lpbackPass = 0;
+        sa_info[i].tx_pkt_info.ploadLen = 0;
+        sa_info[i].tx_pkt_info.pPkt = NULL;
+        sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.startOffset = 0;
+        sa_info[i].tx_pkt_info.lpbackPass = 0;
+        sa_info[i].tx_pkt_info.ploadLen = 0;
+        sa_info[i].tx_pkt_info.pPkt = NULL;
+        sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.saPayloadLen = 0;
+        sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+
+        sa_info[i].key_params = &netTestCfg.key_params[i];
+
+        sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
+        sa_info[i].dir =netTestCfg.sa[i].dir;
+        tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
+        tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
+        sa_info[i].spi =tmp_spi;
+        sa_info[i].tunnel_id = tmp_tunnel;
+        sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
+        sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
+        if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
+        {
+           trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
+        }
+        else
+        {
+           trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
+        }
+    }
     else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_HMAC_SHA2_256) &&
              (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_CTR))
     {
@@ -373,6 +435,64 @@ void  netTest_utilBuildSADB(int i)
            trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
         }
     }
+    else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_NULL) &&
+             (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_NULL))
+    {
+        /* static configuration, will not change */
+        sa_info[i].tx_payload_info.aadSize = 0;
+        sa_info[i].tx_payload_info.pAad = NULL;
+        sa_info[i].tx_payload_info.pAuthIV = NULL;
+        sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN +
+                                                netTest_IP_HEADER_LEN;
+         sa_info[i].tx_payload_info.encOffset =         netTest_MAC_HEADER_LEN +
+                                                       netTest_IP_HEADER_LEN +
+                                                       netTest_ESP_HEADER_LEN;
+
+        sa_info[i].iv_len=0;
+        sa_info[i].bl=0;
+
+        /* dynamic configuration, will  be calculated on the fly */
+        sa_info[i].tx_payload_info.authSize = 0;
+        sa_info[i].tx_payload_info.encSize = 0;
+        sa_info[i].tx_payload_info.pEncIV = 0;
+
+        sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
+        sa_info[i].authMode = netTestCfg.sa[i].authMode;
+        sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].auth_tag_size = 0;
+
+        sa_info[i].tx_pkt_info.enetPort = 0;
+        sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
+        sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.startOffset = 0;
+        sa_info[i].tx_pkt_info.lpbackPass = 0;
+        sa_info[i].tx_pkt_info.ploadLen = 0;
+        sa_info[i].tx_pkt_info.pPkt = NULL;
+        sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN;
+        sa_info[i].tx_pkt_info.saPayloadLen = 0;
+        sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
+        sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO |
+                                         NWAL_TX_FLAG1_DO_UDP_CHKSUM |
+                                         NWAL_TX_FLAG1_META_DATA_VALID;
+
+        sa_info[i].dir =netTestCfg.sa[i].dir;
+        tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
+        tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
+        sa_info[i].spi =tmp_spi;
+        sa_info[i].tunnel_id = tmp_tunnel;
+        sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
+        sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
+        if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
+        {
+           trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
+        }
+        else
+        {
+           trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
+        }
+
+    }
     else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_NULL) &&
              (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_CCM))
     {