example/ipsec_api/odp_ipsec.c
static
pkt_disposition_e do_ipsec_in_classify(odp_packet_t *ppkt)
{
	odph_ipv4hdr_t *ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(*ppkt, NULL);
	odph_ahhdr_t *ah = NULL;
	odph_esphdr_t *esp = NULL;
	ipsec_cache_entry_t *entry;
	odp_ipsec_in_param_t in_param;
	int rc;

	/* Check IP header for IPSec protocols and look it up */
	locate_ipsec_headers(ip, &ah, &esp);
	if (!ah && !esp)
		return PKT_CONTINUE;
	entry = find_ipsec_cache_entry_in(odp_be_to_cpu_32(ip->src_addr),
					  odp_be_to_cpu_32(ip->dst_addr),
					  ah,
					  esp);
	if (!entry)
		return PKT_CONTINUE;

	memset(&in_param, 0, sizeof(in_param));
	if (global->appl.lookup) {
		in_param.num_sa = 0;
		in_param.sa = NULL;
	} else {
		in_param.num_sa = 1;
		in_param.sa = &entry->ipsec_sa;
	}

	/* Issue crypto request */
	if (global->appl.mode != ODP_IPSEC_OP_MODE_SYNC) {
		rc = odp_ipsec_in_enq(ppkt, 1, &in_param);
		if (rc <= 0)
			return PKT_DROP;

		return PKT_POSTED;
	} else {
		int out = 1;
		odp_ipsec_packet_result_t result;

		rc = odp_ipsec_in(ppkt, 1, ppkt, &out, &in_param);
		if (rc <= 0)
			return PKT_DROP;

		if (odp_ipsec_result(&result, *ppkt) < 0) {
			ODPH_DBG("odp_ipsec_result() failed\n");
			return PKT_DROP;
		}
		if (result.status.error.all != 0) {
			ODPH_DBG("Error in inbound IPsec processing\n");
			return PKT_DROP;
		}
		return PKT_CONTINUE;
	}
}
/**
 * Packet Processing - Input IPsec packet classification
 *
 * Verify the received packet has IPsec headers and a match
 * in the IPsec cache, if so issue crypto request else skip
 * input crypto.
 *
 * @param pkt   Packet to classify
 * @param ctx   Packet process context
 *
 * @return PKT_CONTINUE if done else PKT_POSTED
 */
Packet Processing - Input IPsec packet classification
Verify the received packet has IPsec headers and a match
in the IPsec cache, if so issue crypto request else skip
input crypto.

@param pkt   Packet to classify
@param ctx   Packet process context


Packet Processing - Input IPsec packet classification Verify the received packet has IPsec headers and a match in the IPsec cache if so issue crypto request else skip input crypto . @param pkt Packet to classify @param ctx Packet process context
static
pkt_disposition_e do_ipsec_in_classify(odp_packet_t *ppkt)
{
	odph_ipv4hdr_t *ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(*ppkt, NULL);
	odph_ahhdr_t *ah = NULL;
	odph_esphdr_t *esp = NULL;
	ipsec_cache_entry_t *entry;
	odp_ipsec_in_param_t in_param;
	int rc;
	locate_ipsec_headers(ip, &ah, &esp);
	if (!ah && !esp)
		return PKT_CONTINUE;
	entry = find_ipsec_cache_entry_in(odp_be_to_cpu_32(ip->src_addr),
					  odp_be_to_cpu_32(ip->dst_addr),
					  ah,
					  esp);
	if (!entry)
		return PKT_CONTINUE;
	memset(&in_param, 0, sizeof(in_param));
	if (global->appl.lookup) {
		in_param.num_sa = 0;
		in_param.sa = NULL;
	} else {
		in_param.num_sa = 1;
		in_param.sa = &entry->ipsec_sa;
	}
	if (global->appl.mode != ODP_IPSEC_OP_MODE_SYNC) {
		rc = odp_ipsec_in_enq(ppkt, 1, &in_param);
		if (rc <= 0)
			return PKT_DROP;
		return PKT_POSTED;
	} else {
		int out = 1;
		odp_ipsec_packet_result_t result;
		rc = odp_ipsec_in(ppkt, 1, ppkt, &out, &in_param);
		if (rc <= 0)
			return PKT_DROP;
		if (odp_ipsec_result(&result, *ppkt) < 0) {
			ODPH_DBG("odp_ipsec_result() failed\n");
			return PKT_DROP;
		}
		if (result.status.error.all != 0) {
			ODPH_DBG("Error in inbound IPsec processing\n");
			return PKT_DROP;
		}
		return PKT_CONTINUE;
	}
}
static pkt_disposition_e do_ipsec_in_classify ( odp_packet_t * ppkt ) { odph_ipv4hdr_t * ip = ( odph_ipv4hdr_t * ) odp_packet_l3_ptr ( * ppkt , NULL ) ; odph_ahhdr_t * ah = NULL ; odph_esphdr_t * esp = NULL ; ipsec_cache_entry_t * entry ; odp_ipsec_in_param_t in_param ; int rc ; locate_ipsec_headers ( ip , & ah , & esp ) ; if ( ! ah && ! esp ) return PKT_CONTINUE ; entry = find_ipsec_cache_entry_in ( odp_be_to_cpu_32 ( ip -> src_addr ) , odp_be_to_cpu_32 ( ip -> dst_addr ) , ah , esp ) ; if ( ! entry ) return PKT_CONTINUE ; memset ( & in_param , 0 , sizeof ( in_param ) ) ; if ( global -> appl . lookup ) { in_param . num_sa = 0 ; in_param . sa = NULL ; } else { in_param . num_sa = 1 ; in_param . sa = & entry -> ipsec_sa ; } if ( global -> appl . mode != ODP_IPSEC_OP_MODE_SYNC ) { rc = odp_ipsec_in_enq ( ppkt , 1 , & in_param ) ; if ( rc <= 0 ) return PKT_DROP ; return PKT_POSTED ; } else { int out = 1 ; odp_ipsec_packet_result_t result ; rc = odp_ipsec_in ( ppkt , 1 , ppkt , & out , & in_param ) ; if ( rc <= 0 ) return PKT_DROP ; if ( odp_ipsec_result ( & result , * ppkt ) < 0 ) { ODPH_DBG ( " \n " ) ; return PKT_DROP ; } if ( result . status . error . all != 0 ) { ODPH_DBG ( " \n " ) ; return PKT_DROP ; } return PKT_CONTINUE ; } }
Packet Processing - Input IPsec packet classification
 Verify the received packet has IPsec headers and a match
 in the IPsec cache, if so issue crypto request else skip
 input crypto.
Packet Processing - Input IPsec packet classification Verify the received packet has IPsec headers and a match in the IPsec cache if so issue crypto request else skip input crypto .
/* Check IP header for IPSec protocols and look it up */ /* Issue crypto request */