/* * Copyright (c) 2015 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __IPSEC_H__ #define __IPSEC_H__ #include #include #include #include #include #include #include #include #include #include typedef clib_error_t *(*add_del_sa_sess_cb_t) (u32 sa_index, u8 is_add); typedef clib_error_t *(*check_support_cb_t) (ipsec_sa_t * sa); typedef clib_error_t *(*enable_disable_cb_t) (int is_enable); typedef struct { u8 *name; /* add/del callback */ add_del_sa_sess_cb_t add_del_sa_sess_cb; /* check support function */ check_support_cb_t check_support_cb; u32 ah4_encrypt_node_index; u32 ah4_decrypt_node_index; u32 ah4_encrypt_next_index; u32 ah4_decrypt_next_index; u32 ah6_encrypt_node_index; u32 ah6_decrypt_node_index; u32 ah6_encrypt_next_index; u32 ah6_decrypt_next_index; } ipsec_ah_backend_t; typedef struct { u8 *name; /* add/del callback */ add_del_sa_sess_cb_t add_del_sa_sess_cb; /* check support function */ check_support_cb_t check_support_cb; /* enable or disable function */ enable_disable_cb_t enable_disable_cb; u32 esp4_encrypt_node_index; u32 esp4_decrypt_node_index; u32 esp4_encrypt_next_index; u32 esp4_decrypt_next_index; u32 esp6_encrypt_node_index; u32 esp6_decrypt_node_index; u32 esp6_encrypt_next_index; u32 esp6_decrypt_next_index; u32 esp4_decrypt_tun_node_index; u32 esp4_decrypt_tun_next_index; u32 esp4_encrypt_tun_node_index; u32 esp6_decrypt_tun_node_index; u32 esp6_decrypt_tun_next_index; u32 esp6_encrypt_tun_node_index; u32 esp_mpls_encrypt_tun_node_index; } ipsec_esp_backend_t; typedef struct { vnet_crypto_op_id_t enc_op_id; vnet_crypto_op_id_t dec_op_id; vnet_crypto_alg_t alg; u8 iv_size; u8 block_align; u8 icv_size; } ipsec_main_crypto_alg_t; typedef struct { vnet_crypto_op_id_t op_id; vnet_crypto_alg_t alg; u8 icv_size; } ipsec_main_integ_alg_t; typedef struct { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); vnet_crypto_op_t *crypto_ops; vnet_crypto_op_t *integ_ops; vnet_crypto_op_t *chained_crypto_ops; vnet_crypto_op_t *chained_integ_ops; vnet_crypto_op_chunk_t *chunks; vnet_crypto_async_frame_t **async_frames; } ipsec_per_thread_data_t; typedef struct { /* pool of tunnel instances */ ipsec_spd_t *spds; /* pool of policies */ ipsec_policy_t *policies; /* hash tables of UDP port registrations */ uword *udp_port_registrations; uword *tunnel_index_by_key; /* convenience */ vlib_main_t *vlib_main; vnet_main_t *vnet_main; /* hashes */ uword *spd_index_by_spd_id; uword *spd_index_by_sw_if_index; uword *sa_index_by_sa_id; uword *ipsec4_if_pool_index_by_key; uword *ipsec6_if_pool_index_by_key; uword *ipsec_if_real_dev_by_show_dev; uword *ipsec_if_by_sw_if_index; clib_bihash_8_16_t tun4_protect_by_key; clib_bihash_24_16_t tun6_p