example/ipsec_api/odp_ipsec.c
static
void ipsec_init_post(odp_ipsec_op_mode_t api_mode)
{
	sp_db_entry_t *entry;
	odp_ipsec_config_t ipsec_config;
	odp_ipsec_capability_t ipsec_cap;

	if (odp_ipsec_capability(&ipsec_cap) != ODP_IPSEC_OK) {
		ODPH_ERR("Error: failure getting IPSec caps\n");
		exit(EXIT_FAILURE);
	}

	odp_ipsec_config_init(&ipsec_config);
	ipsec_config.inbound.parse_level = ODP_PROTO_LAYER_ALL;
	ipsec_config.inbound_mode = api_mode;
	ipsec_config.outbound_mode = api_mode;
	ipsec_config.inbound.default_queue = global->completionq;
	if (odp_ipsec_config(&ipsec_config) != ODP_IPSEC_OK) {
		ODPH_ERR("Error: failure setting IPSec config\n");
		exit(EXIT_FAILURE);
	}

	/* Attempt to find appropriate SA for each SP */
	for (entry = sp_db->list; NULL != entry; entry = entry->next) {
		sa_db_entry_t *cipher_sa = NULL;
		sa_db_entry_t *auth_sa = NULL;
		tun_db_entry_t *tun = NULL;

		if (entry->esp) {
			cipher_sa = find_sa_db_entry(&entry->src_subnet,
						     &entry->dst_subnet,
						     1);
			tun = find_tun_db_entry(cipher_sa->src_ip,
						cipher_sa->dst_ip);
		}
		if (entry->ah) {
			auth_sa = find_sa_db_entry(&entry->src_subnet,
						   &entry->dst_subnet,
						   0);
			tun = find_tun_db_entry(auth_sa->src_ip,
						auth_sa->dst_ip);
		}

		if (cipher_sa || auth_sa) {
			if (create_ipsec_cache_entry(cipher_sa,
						     auth_sa,
						     tun,
						     entry->input,
						     global->completionq)) {
				ODPH_ERR("Error: IPSec cache entry failed.\n"
						);
				exit(EXIT_FAILURE);
			}
		} else {
			printf(" WARNING: SA not found for SP\n");
			dump_sp_db_entry(entry);
		}
	}
}
/**
 * IPsec post argument processing initialization
 *
 * Resolve SP DB with SA DB and create corresponding IPsec cache entries
 *
 * @param api_mode  Mode to use for IPsec operation
 */
IPsec post argument processing initialization
Resolve SP DB with SA DB and create corresponding IPsec cache entries

@param api_mode  Mode to use for IPsec operation
IPsec post argument processing initialization Resolve SP DB with SA DB and create corresponding IPsec cache entries @param api_mode Mode to use for IPsec operation
static
void ipsec_init_post(odp_ipsec_op_mode_t api_mode)
{
	sp_db_entry_t *entry;
	odp_ipsec_config_t ipsec_config;
	odp_ipsec_capability_t ipsec_cap;
	if (odp_ipsec_capability(&ipsec_cap) != ODP_IPSEC_OK) {
		ODPH_ERR("Error: failure getting IPSec caps\n");
		exit(EXIT_FAILURE);
	}
	odp_ipsec_config_init(&ipsec_config);
	ipsec_config.inbound.parse_level = ODP_PROTO_LAYER_ALL;
	ipsec_config.inbound_mode = api_mode;
	ipsec_config.outbound_mode = api_mode;
	ipsec_config.inbound.default_queue = global->completionq;
	if (odp_ipsec_config(&ipsec_config) != ODP_IPSEC_OK) {
		ODPH_ERR("Error: failure setting IPSec config\n");
		exit(EXIT_FAILURE);
	}
	for (entry = sp_db->list; NULL != entry; entry = entry->next) {
		sa_db_entry_t *cipher_sa = NULL;
		sa_db_entry_t *auth_sa = NULL;
		tun_db_entry_t *tun = NULL;
		if (entry->esp) {
			cipher_sa = find_sa_db_entry(&entry->src_subnet,
						     &entry->dst_subnet,
						     1);
			tun = find_tun_db_entry(cipher_sa->src_ip,
						cipher_sa->dst_ip);
		}
		if (entry->ah) {
			auth_sa = find_sa_db_entry(&entry->src_subnet,
						   &entry->dst_subnet,
						   0);
			tun = find_tun_db_entry(auth_sa->src_ip,
						auth_sa->dst_ip);
		}
		if (cipher_sa || auth_sa) {
			if (create_ipsec_cache_entry(cipher_sa,
						     auth_sa,
						     tun,
						     entry->input,
						     global->completionq)) {
				ODPH_ERR("Error: IPSec cache entry failed.\n"
						);
				exit(EXIT_FAILURE);
			}
		} else {
			printf(" WARNING: SA not found for SP\n");
			dump_sp_db_entry(entry);
		}
	}
}
static void ipsec_init_post ( odp_ipsec_op_mode_t api_mode ) { sp_db_entry_t * entry ; odp_ipsec_config_t ipsec_config ; odp_ipsec_capability_t ipsec_cap ; if ( odp_ipsec_capability ( & ipsec_cap ) != ODP_IPSEC_OK ) { ODPH_ERR ( " \n " ) ; exit ( EXIT_FAILURE ) ; } odp_ipsec_config_init ( & ipsec_config ) ; ipsec_config . inbound . parse_level = ODP_PROTO_LAYER_ALL ; ipsec_config . inbound_mode = api_mode ; ipsec_config . outbound_mode = api_mode ; ipsec_config . inbound . default_queue = global -> completionq ; if ( odp_ipsec_config ( & ipsec_config ) != ODP_IPSEC_OK ) { ODPH_ERR ( " \n " ) ; exit ( EXIT_FAILURE ) ; } for ( entry = sp_db -> list ; NULL != entry ; entry = entry -> next ) { sa_db_entry_t * cipher_sa = NULL ; sa_db_entry_t * auth_sa = NULL ; tun_db_entry_t * tun = NULL ; if ( entry -> esp ) { cipher_sa = find_sa_db_entry ( & entry -> src_subnet , & entry -> dst_subnet , 1 ) ; tun = find_tun_db_entry ( cipher_sa -> src_ip , cipher_sa -> dst_ip ) ; } if ( entry -> ah ) { auth_sa = find_sa_db_entry ( & entry -> src_subnet , & entry -> dst_subnet , 0 ) ; tun = find_tun_db_entry ( auth_sa -> src_ip , auth_sa -> dst_ip ) ; } if ( cipher_sa || auth_sa ) { if ( create_ipsec_cache_entry ( cipher_sa , auth_sa , tun , entry -> input , global -> completionq ) ) { ODPH_ERR ( " \n " ) ; exit ( EXIT_FAILURE ) ; } } else { printf ( " \n " ) ; dump_sp_db_entry ( entry ) ; } } }
IPsec post argument processing initialization
 Resolve SP DB with SA DB and create corresponding IPsec cache entries
IPsec post argument processing initialization Resolve SP DB with SA DB and create corresponding IPsec cache entries
/* Attempt to find appropriate SA for each SP */