1 /******************************************************************************
2 * FILE PURPOSE: local defines for net_test application.
3 ******************************************************************************
4 * FILE NAME: net_test.h
5 *
6 * DESCRIPTION: NET TEST definitions and defines
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2010-2011
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 */
41 /* ============================================================= */
44 #define MAX_SEC_INDEX 7
46 //IPSEC MODE(only choose one rx and one tx)
47 #define IPSEC_MODE_RX_INFLOW 1
48 #define IPSEC_MODE_TX_INFLOW 2
49 #define IPSEC_MODE_RX_SIDEBAND 3
50 #define IPSEC_MODE_TX_SIDEBAND 4
53 #define netTest_MAC_HEADER_LEN 14
54 #define netTest_IP_HEADER_LEN 20
55 #define netTest_UDP_HEADER_LEN 8
56 #define netTest_ESP_HEADER_LEN 8
57 #define netTest_AES_CBC_IV_LEN 16
58 #define netTest_AES_CTR_IV_LEN 8
59 #define netTest_3DES_CBC_IV_LEN 8
60 #define netTest_AES_GCM_IV_LEN 8
61 #define netTest_AES_CCM_IV_LEN 8
62 #define netTest_AES_GMAC_IV_LEN 8
63 #define netTest_NULL_IV_LEN 0
64 #define netTest_ICV_LEN 12
65 #define netTest_AES_GCM_CCM_ICV_LEN 16
66 #define netTest_AES_GMAC_ICV_LEN 16
69 /* The input strings for the input config file is given below */
70 #define INIT_CONFIG_MAC0 "mac0"
71 #define INIT_CONFIG_MAC1 "mac1"
72 #define INIT_CONFIG_IP0 "ip0"
73 #define INIT_CONFIG_IP1 "ip1"
74 #define INIT_CONFIG_IP2 "ip2"
75 #define INIT_CONFIG_LOCAL_IPSEC_IP "local_ipsec_ip"
76 #define INIT_CONFIG_REMOTE_IPSEC_IP "remote_ipsec_ip"
77 #define INIT_CONFIG_IPSEC_MODE_RX "ipsec_mode_rx"
78 #define INIT_CONFIG_IPSEC_MODE_TX "ipsec_mode_tx"
79 #define INIT_CONFIG_IPSEC_IF_NO "ipsec_if"
82 #define CONFIG_STRING_LEN 25
86 #define MAX_ROUTES 16
87 /* tmannan - begin */
89 typedef struct {
90 nwalDmTxPayloadInfo_t tx_payload_info;
91 uint8_t inner_ip_offset;
92 NETCP_CFG_SA_T rx_tunnel;
93 void * rx_data_mode_handle;
94 void * rx_inflow_mode_handle;
95 NETCP_CFG_SA_T tx_tunnel;
96 void * tx_data_mode_handle;
97 void * tx_inflow_mode_handle;
98 uint8_t enc_key_length;
99 uint8_t auth_tag_size;
100 nwalTxPktInfo_t tx_pkt_info;
101 nwal_saEALG cipherMode;
102 nwal_saAALG authMode;
103 /*stuff for routing use case */
104 unsigned int src; //BE
105 unsigned int dst; //BE
106 unsigned int spi; //BE
107 unsigned int seq; //BE
108 int iv_len; //iv len (size of iv in pkt)
109 int bl; //block len (for padding calc)
110 #ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
111 /* Save NETCP CMD details during create time */
112 nwalTxDmPSCmdInfo_t rx_dmPSCmdInfo;
113 nwalTxDmPSCmdInfo_t tx_dmPSCmdInfo;
114 #endif
115 } netTestSA_t;
119 typedef struct{
120 char mac0[CONFIG_STRING_LEN];
121 char mac1[CONFIG_STRING_LEN];
122 char ip0[CONFIG_STRING_LEN];
123 char ip1[CONFIG_STRING_LEN];
124 char ip2[CONFIG_STRING_LEN];
125 char local_ipsec_ip[CONFIG_STRING_LEN];
126 char remote_ipsec_ip[CONFIG_STRING_LEN];
127 char ipsec_mode_rx[CONFIG_STRING_LEN];
128 char ipsec_mode_tx[CONFIG_STRING_LEN];
129 char routes[MAX_ROUTES][CONFIG_STRING_LEN];
130 char ports[MAX_ROUTES][CONFIG_STRING_LEN];
131 char dst_ips[MAX_ROUTES][CONFIG_STRING_LEN];
132 char paths[MAX_ROUTES][CONFIG_STRING_LEN];
133 char ipsec_if_no[CONFIG_STRING_LEN];
134 } netTestConfigFile_t;
139 typedef struct {
140 unsigned char mac0[6];
141 unsigned char mac1[6];
142 nwalIpAddr_t ip0;
143 nwalIpAddr_t ip1;
144 nwalIpAddr_t ip2;
145 nwalIpAddr_t local_ipsec_ip;
146 nwalIpAddr_t remote_ipsec_ip;
147 uint8_t ipsec_mode_rx;
148 uint8_t ipsec_mode_tx;
149 int ipsec_if_no; /* 0 if mac0, 1 if mac 1 */
151 } netTestConfig_t;
154 typedef struct {
155 unsigned char mac0[2][6];
156 unsigned char mac1[2][6];
157 nwalIpAddr_t ip0[2];
158 nwalIpAddr_t ip1[2];
159 nwalIpAddr_t ip2[2];
160 nwalIpAddr_t local_ipsec_ip;
161 nwalIpAddr_t remote_ipsec_ip;
162 uint8_t ipsec_mode_rx;
163 uint8_t ipsec_mode_tx;
164 int ipsec_if_no; /* 0 if mac0, 1 if mac 1 */
166 } netTestConfigMax_t;
168 typedef struct stats_t
169 {
170 long itx; //initially generated
171 long itx2;
172 long rx;
173 long tx;
174 long n_bad;
175 long n_new;
176 long n_class0_rx; //count of pkts classified
177 long n_class1_rx; //count of pkts classified
178 long n_class2_rx; //count of pkts classified
179 long n_t1;
180 long n_t2;
181 long n_t3;
182 long sec_tx;
183 long sec_rx;
184 long sb_tx;
185 long sb_rx;
186 long secp_rx;
187 long n_auth_ok;
188 unsigned long long app_cycles;
189 unsigned long long send_cycles;
190 unsigned long long tx_cache_cycles;
191 unsigned long long total_decrypt_time;
192 unsigned long long total_encrypt_time;
193 long rx_min;
194 long tx_min;
195 long if_rx[TUNE_NETAPI_MAX_NUM_MAC];
196 long core_rx;
197 long n_stats_cb;
198 long ip;
199 } STATS_T;
201 typedef struct head_t
202 {
203 long ip[5];
204 long udp[2];
205 } HEAD_T;
207 typedef struct key_t
208 {
209 long src_ip;
210 long dst_ip;
211 short src_port;
212 short dst_port;
213 } KEY_T;