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 /* ============================================================= */
43 //IPSEC MODE(only choose one rx and one tx)
45 #define IPSEC_MODE_RX_INFLOW 1
46 #define IPSEC_MODE_TX_INFLOW 2
47 #define IPSEC_MODE_RX_SIDEBAND 3
48 #define IPSEC_MODE_TX_SIDEBAND 4
50 #define MAX_SEC_INDEX 4
51 #define netTest_MAC_HEADER_LEN 14
52 #define netTest_IP_HEADER_LEN 20
53 #define netTest_UDP_HEADER_LEN 8
54 #define netTest_ESP_HEADER_LEN 8
55 #define netTest_AES_CBC_IV_LEN 16
56 #define netTest_AES_CTR_IV_CONTEXT_LEN 16
57 #define netTest_AES_CTR_IV_PACKET_LEN 8
58 #define netTest_3DES_CBC_IV_LEN 8
59 #define netTest_NULL_IV_LEN 0
60 #define netTest_ICV_LEN 12
64 /* The input strings for the input config file is given below */
65 #define INIT_CONFIG_MAC0 "mac0"
66 #define INIT_CONFIG_MAC1 "mac1"
67 #define INIT_CONFIG_IP0 "ip0"
68 #define INIT_CONFIG_IP1 "ip1"
69 #define INIT_CONFIG_IP2 "ip2"
70 #define INIT_CONFIG_LOCAL_IPSEC_IP "local_ipsec_ip"
71 #define INIT_CONFIG_REMOTE_IPSEC_IP "remote_ipsec_ip"
72 #define INIT_CONFIG_IPSEC_MODE_RX "ipsec_mode_rx"
73 #define INIT_CONFIG_IPSEC_MODE_TX "ipsec_mode_tx"
74 #define INIT_CONFIG_IPSEC_IF_NO "ipsec_if"
77 #define CONFIG_STRING_LEN 25
81 #define MAX_ROUTES 16
82 /* tmannan - begin */
84 typedef struct {
85 nwalDmTxPayloadInfo_t tx_payload_info;
86 uint8_t inner_ip_offset;
87 NETCP_CFG_SA_T rx_tunnel;
88 void * rx_data_mode_handle;
89 void * rx_inflow_mode_handle;
90 NETCP_CFG_SA_T tx_tunnel;
91 void * tx_data_mode_handle;
92 void * tx_inflow_mode_handle;
93 uint8_t enc_key_length;
94 uint8_t auth_tag_size;
95 nwalTxPktInfo_t tx_pkt_info;
96 nwal_saEALG cipherMode;
97 /*stuff for routing use case */
98 unsigned int src; //BE
99 unsigned int dst; //BE
100 unsigned int spi; //BE
101 unsigned int seq; //BE
102 int iv_len; //iv len (size of iv in pkt)
103 int bl; //block len (for padding calc)
104 #ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
105 /* Save NETCP CMD details during create time */
106 nwalTxDmPSCmdInfo_t rx_dmPSCmdInfo;
107 nwalTxDmPSCmdInfo_t tx_dmPSCmdInfo;
108 #endif
109 } netTestSA_t;
113 typedef struct{
114 char mac0[CONFIG_STRING_LEN];
115 char mac1[CONFIG_STRING_LEN];
116 char ip0[CONFIG_STRING_LEN];
117 char ip1[CONFIG_STRING_LEN];
118 char ip2[CONFIG_STRING_LEN];
119 char local_ipsec_ip[CONFIG_STRING_LEN];
120 char remote_ipsec_ip[CONFIG_STRING_LEN];
121 char ipsec_mode_rx[CONFIG_STRING_LEN];
122 char ipsec_mode_tx[CONFIG_STRING_LEN];
123 char routes[MAX_ROUTES][CONFIG_STRING_LEN];
124 char ports[MAX_ROUTES][CONFIG_STRING_LEN];
125 char dst_ips[MAX_ROUTES][CONFIG_STRING_LEN];
126 char paths[MAX_ROUTES][CONFIG_STRING_LEN];
127 char ipsec_if_no[CONFIG_STRING_LEN];
128 } netTestConfigFile_t;
133 typedef struct {
134 unsigned char mac0[6];
135 unsigned char mac1[6];
136 nwalIpAddr_t ip0;
137 nwalIpAddr_t ip1;
138 nwalIpAddr_t ip2;
139 nwalIpAddr_t local_ipsec_ip;
140 nwalIpAddr_t remote_ipsec_ip;
141 uint8_t ipsec_mode_rx;
142 uint8_t ipsec_mode_tx;
143 int ipsec_if_no; /* 0 if mac0, 1 if mac 1 */
145 } netTestConfig_t;
147 typedef struct stats_t
148 {
149 long itx; //initially generated
150 long itx2;
151 long rx;
152 long tx;
153 long n_bad;
154 long n_new;
155 long n_class0_rx; //count of pkts classified
156 long n_class1_rx; //count of pkts classified
157 long n_class2_rx; //count of pkts classified
158 long n_t1;
159 long n_t2;
160 long n_t3;
161 long sec_tx;
162 long sec_rx;
163 long sb_tx;
164 long sb_rx;
165 long secp_rx;
166 long n_auth_ok;
167 unsigned long long app_cycles;
168 unsigned long long send_cycles;
169 unsigned long long tx_cache_cycles;
170 unsigned long long total_decrypt_time;
171 unsigned long long total_encrypt_time;
172 long rx_min;
173 long tx_min;
174 } STATS_T;
176 typedef struct head_t
177 {
178 long ip[5];
179 long udp[2];
180 } HEAD_T;
182 typedef struct key_t
183 {
184 long src_ip;
185 long dst_ip;
186 short src_port;
187 short dst_port;
188 } KEY_T;