26 #include <netinet/in.h>
102 if (icv_length != app_icv_len) {
103 DOCA_LOG_ERR(
"icv length in policy (%d) does not match application's icv length (%d)",
124 struct rte_hash **ip6_table)
150 ret = rte_hash_lookup(*ip6_table, (
void *)rule->
ip6.
src_ip);
152 ret = rte_hash_add_key(*ip6_table, rule->
ip6.
src_ip);
162 ret = rte_hash_lookup(*ip6_table, (
void *)rule->
ip6.
dst_ip);
164 ret = rte_hash_add_key(*ip6_table, rule->
ip6.
dst_ip);
259 DOCA_LOG_ERR(
"Failed to insert entries for encryption policy");
263 app_cfg->app_rules.nb_encrypt_rules++;
270 struct doca_flow_port *secured_port,
287 DOCA_LOG_ERR(
"Failed to insert entries for decryption policy");
291 app_cfg->app_rules.nb_decrypt_rules++;
319 (policy->
l4_protocol == IPPROTO_UDP) ?
"UDP" :
"TCP");
uint32_t get_icv_len_int(enum doca_flow_crypto_icv_len icv_len)
doca_error_t add_decrypt_entry(struct decrypt_rule *rule, int rule_id, struct doca_flow_port *port, struct ipsec_security_gw_config *app_cfg)
doca_error_t add_encrypt_entry(struct encrypt_rule *rule, int rule_id, struct ipsec_security_gw_ports_map **ports, struct ipsec_security_gw_config *app_cfg)
static doca_error_t parse_ipv6_str(const char *str_ip, doca_be32_t *ipv6_addr)
doca_error_t parse_ipv4_str(const char *str_ip, doca_be32_t *ipv4_addr)
static struct app_gpu_cfg app_cfg
DOCA_EXPERIMENTAL doca_error_t doca_argp_get_log_level(int *log_level)
Get the log level the user inserted it.
enum doca_error doca_error_t
DOCA API return codes.
@ DOCA_ERROR_NOT_SUPPORTED
doca_flow_crypto_icv_len
doca flow crypto ICV length
doca_flow_crypto_key_type
doca flow crypto key type
@ DOCA_FLOW_CRYPTO_ICV_LENGTH_16
@ DOCA_FLOW_CRYPTO_ICV_LENGTH_12
@ DOCA_FLOW_CRYPTO_ICV_LENGTH_8
@ DOCA_FLOW_CRYPTO_KEY_128
@ DOCA_FLOW_CRYPTO_KEY_256
doca_flow_l3_type
doca flow layer 3 packet type
@ DOCA_FLOW_L4_TYPE_EXT_TCP
@ DOCA_FLOW_L4_TYPE_EXT_UDP
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_DBG(format,...)
Generates a DEBUG application log message.
@ IPSEC_SECURITY_GW_TUNNEL
#define DYN_RESERVED_RULES
char * hex_dump(const void *data, size_t size)
static doca_error_t convert_to_doca_icv(uint8_t icv_length, enum doca_flow_crypto_icv_len *length)
static doca_error_t ipsec_security_gw_policy_encrypt_parse(struct ipsec_security_gw_ipsec_policy *policy, struct ipsec_security_gw_config *app_cfg, struct encrypt_rule *rule, struct rte_hash **ip6_table)
DOCA_LOG_REGISTER(IPSEC_SECURITY_GW::POLICY)
static enum doca_flow_crypto_key_type convert_to_doca_key_type(uint8_t key_type)
doca_error_t ipsec_security_gw_handle_decrypt_policy(struct ipsec_security_gw_config *app_cfg, struct doca_flow_port *secured_port, struct ipsec_security_gw_ipsec_policy *policy, struct decrypt_rule *rule)
void print_policy_attrs(struct ipsec_security_gw_ipsec_policy *policy)
static doca_error_t parse_sa_attrs(struct ipsec_security_gw_ipsec_policy *policy, enum doca_flow_crypto_icv_len app_icv_len, struct ipsec_security_gw_sa_attrs *sa_attrs)
doca_error_t ipsec_security_gw_handle_encrypt_policy(struct ipsec_security_gw_config *app_cfg, struct ipsec_security_gw_ports_map *ports[], struct ipsec_security_gw_ipsec_policy *policy, struct encrypt_rule *rule)
static doca_error_t ipsec_security_gw_policy_decrypt_parse(struct ipsec_security_gw_ipsec_policy *policy, struct ipsec_security_gw_config *app_cfg, struct decrypt_rule *rule)
#define POLICY_MODE_TUNNEL
#define POLICY_L4_TYPE_UDP
#define POLICY_L3_TYPE_IPV4
#define POLICY_KEY_TYPE_128
enum doca_flow_l3_type inner_l3_type
enum doca_flow_l3_type l3_type
struct ipsec_security_gw_sa_attrs sa_attrs
enum doca_flow_l4_type_ext protocol
struct ipsec_security_gw_sa_attrs sa_attrs
doca_be32_t encap_dst_ip4
struct ipsec_security_gw_ip6 ip6
enum doca_flow_l3_type encap_l3_type
doca_be32_t encap_dst_ip6[4]
struct ipsec_security_gw_ip4 ip4
enum doca_flow_l3_type l3_type
char dst_ip_addr[MAX_IP_ADDR_LEN+1]
uint8_t enc_key_data[MAX_KEY_LEN]
char outer_dst_ip[MAX_IP_ADDR_LEN+1]
uint8_t outer_l3_protocol
char outer_src_ip[MAX_IP_ADDR_LEN+1]
char src_ip_addr[MAX_IP_ADDR_LEN+1]
uint8_t enc_key_data[MAX_KEY_LEN]
enum doca_flow_crypto_key_type key_type
static struct doca_flow_port * ports[FLOW_SWITCH_PORTS_MAX]