MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fill_ipsec_param

Function fill_ipsec_param

dpdk/app/test/test_ipsec_perf.c:158–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158static int
159fill_ipsec_param(struct ipsec_sa *sa)
160{
161 struct rte_ipsec_sa_prm *prm = &sa->sa_prm;
162
163 memset(prm, 0, sizeof(*prm));
164
165 prm->flags = sa->sa_flags;
166
167 /* setup ipsec xform */
168 prm->ipsec_xform = sa->ipsec_xform;
169 prm->ipsec_xform.salt = (uint32_t)rte_rand();
170 prm->ipsec_xform.replay_win_sz = sa->replay_win_sz;
171
172 /* setup tunnel related fields */
173 prm->tun.hdr_len = sizeof(ipv4_outer);
174 prm->tun.next_proto = IPPROTO_IPIP;
175 prm->tun.hdr = &ipv4_outer;
176
177 if (sa->type == RTE_CRYPTO_SYM_XFORM_AEAD) {
178 sa->aead_xform.type = sa->type;
179 sa->aead_xform.aead.algo = aead_algo->algo;
180 sa->aead_xform.next = NULL;
181 sa->aead_xform.aead.digest_length = aead_algo->digest_len;
182 sa->aead_xform.aead.iv.offset = IV_OFFSET;
183 sa->aead_xform.aead.iv.length = 12;
184
185 if (sa->ipsec_xform.direction ==
186 RTE_SECURITY_IPSEC_SA_DIR_INGRESS) {
187 sa->aead_xform.aead.op = RTE_CRYPTO_AEAD_OP_DECRYPT;
188 } else {
189 sa->aead_xform.aead.op = RTE_CRYPTO_AEAD_OP_ENCRYPT;
190 }
191
192 sa->crypto_xforms = &sa->aead_xform;
193 } else {
194 sa->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
195 sa->cipher_xform.cipher.algo = cipher_algo->algo;
196 sa->cipher_xform.cipher.iv.offset = IV_OFFSET;
197 sa->cipher_xform.cipher.iv.length = 12;
198 sa->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
199 sa->auth_xform.auth.algo = auth_algo->algo;
200 sa->auth_xform.auth.digest_length = auth_algo->digest_len;
201
202
203 if (sa->ipsec_xform.direction ==
204 RTE_SECURITY_IPSEC_SA_DIR_INGRESS) {
205 sa->cipher_xform.cipher.op =
206 RTE_CRYPTO_CIPHER_OP_DECRYPT;
207 sa->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
208 sa->cipher_xform.next = NULL;
209 sa->auth_xform.next = &sa->cipher_xform;
210 sa->crypto_xforms = &sa->auth_xform;
211 } else {
212 sa->cipher_xform.cipher.op =
213 RTE_CRYPTO_CIPHER_OP_ENCRYPT;
214 sa->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
215 sa->auth_xform.next = NULL;

Callers 1

create_saFunction · 0.70

Calls 2

memsetFunction · 0.85
rte_randFunction · 0.85

Tested by

no test coverage detected