- node = vlib_get_node_by_name (vlib_get_main (),
- (sa->is_tunnel_ip6 ?
- (u8 *) "ah6-encrypt" :
- (u8 *) "ah4-encrypt"));
- dpo_stack_from_node (node->index, &sa->dpo[IPSEC_PROTOCOL_AH], &tmp);
-
- node = vlib_get_node_by_name (vlib_get_main (),
- (sa->is_tunnel_ip6 ?
- (u8 *) "esp6-encrypt" :
- (u8 *) "esp4-encrypt"));
- dpo_stack_from_node (node->index, &sa->dpo[IPSEC_PROTOCOL_ESP], &tmp);
+ dpo_stack_from_node ((ipsec_sa_is_set_IS_TUNNEL_V6 (sa) ?
+ im->ah6_encrypt_node_index :
+ im->ah4_encrypt_node_index),
+ &sa->dpo[IPSEC_PROTOCOL_AH], &tmp);
+ dpo_stack_from_node ((ipsec_sa_is_set_IS_TUNNEL_V6 (sa) ?
+ im->esp6_encrypt_node_index :
+ im->esp4_encrypt_node_index),
+ &sa->dpo[IPSEC_PROTOCOL_ESP], &tmp);
+ dpo_reset (&tmp);
+}
+
+void
+ipsec_sa_set_crypto_alg (ipsec_sa_t * sa, ipsec_crypto_alg_t crypto_alg)
+{
+ ipsec_main_t *im = &ipsec_main;
+ sa->crypto_alg = crypto_alg;
+ sa->crypto_iv_size = im->crypto_algs[crypto_alg].iv_size;
+ sa->crypto_block_size = im->crypto_algs[crypto_alg].block_size;
+ sa->crypto_enc_op_id = im->crypto_algs[crypto_alg].enc_op_id;
+ sa->crypto_dec_op_id = im->crypto_algs[crypto_alg].dec_op_id;
+ sa->crypto_calg = im->crypto_algs[crypto_alg].alg;
+ ASSERT (sa->crypto_iv_size <= ESP_MAX_IV_SIZE);
+ ASSERT (sa->crypto_block_size <= ESP_MAX_BLOCK_SIZE);
+ if (IPSEC_CRYPTO_ALG_IS_GCM (crypto_alg))
+ {
+ sa->integ_icv_size = im->crypto_algs[crypto_alg].icv_size;
+ ipsec_sa_set_IS_AEAD (sa);
+ }
+}
+
+void
+ipsec_sa_set_integ_alg (ipsec_sa_t * sa, ipsec_integ_alg_t integ_alg)
+{
+ ipsec_main_t *im = &ipsec_main;
+ sa->integ_alg = integ_alg;
+ sa->integ_icv_size = im->integ_algs[integ_alg].icv_size;
+ sa->integ_op_id = im->integ_algs[integ_alg].op_id;
+ sa->integ_calg = im->integ_algs[integ_alg].alg;
+ ASSERT (sa->integ_icv_size <= ESP_MAX_ICV_SIZE);