example/ipsec_api/odp_ipsec.c
static
pkt_disposition_e do_ipsec_out_classify(odp_packet_t *ppkt, pkt_ctx_t *ctx)
{
	odph_ipv4hdr_t *ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(*ppkt, NULL);
	ipsec_cache_entry_t *entry;
	odp_ipsec_out_param_t out_param;
	int rc;

	/* Find record */
	entry = find_ipsec_cache_entry_out(odp_be_to_cpu_32(ip->src_addr),
					   odp_be_to_cpu_32(ip->dst_addr),
					   ip->proto);
	if (!entry)
		return PKT_CONTINUE;

	memset(&out_param, 0, sizeof(out_param));
	out_param.num_sa = 1;
	out_param.num_opt = 0;
	out_param.sa = &entry->ipsec_sa;
	out_param.opt = NULL;

	/* Issue crypto request */
	if (global->appl.mode == ODP_IPSEC_OP_MODE_INLINE) {
		odp_ipsec_out_inline_param_t inline_param;

		inline_param.pktio = ctx->pktio;
		inline_param.outer_hdr.ptr = (void *)&ctx->eth;
		inline_param.outer_hdr.len = ODPH_ETHHDR_LEN;
		rc = odp_ipsec_out_inline(ppkt, 1, &out_param, &inline_param);
		if (rc <= 0)
			return PKT_DROP;

		return PKT_DONE;
	} else if (global->appl.mode != ODP_IPSEC_OP_MODE_SYNC) {
		rc = odp_ipsec_out_enq(ppkt, 1, &out_param);
		if (rc <= 0)
			return PKT_DROP;

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

		rc = odp_ipsec_out(ppkt, 1, ppkt, &out, &out_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 outbound IPsec processing\n");
			return PKT_DROP;
		}
		return PKT_CONTINUE;
	}
}
/**
 * Packet Processing - Output IPsec packet classification
 *
 * Verify the outbound packet has a match in the IPsec cache,
 * if so issue prepend IPsec headers and prepare parameters
 * for crypto API call.  Post the packet to ATOMIC queue so
 * that sequence numbers can be applied in packet order as
 * the next processing step.
 *
 * @param pkt   Packet to classify
 * @param ctx   Packet process context
 *
 * @return PKT_CONTINUE if done else PKT_POSTED
 */
Packet Processing - Output IPsec packet classification
Verify the outbound packet has a match in the IPsec cache,
if so issue prepend IPsec headers and prepare parameters
for crypto API call.  Post the packet to ATOMIC queue so
that sequence numbers can be applied in packet order as
the next processing step.

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


Packet Processing - Output IPsec packet classification Verify the outbound packet has a match in the IPsec cache if so issue prepend IPsec headers and prepare parameters for crypto API call . Post the packet to ATOMIC queue so that sequence numbers can be applied in packet order as the next processing step . @param pkt Packet to classify @param ctx Packet process context
static
pkt_disposition_e do_ipsec_out_classify(odp_packet_t *ppkt, pkt_ctx_t *ctx)
{
	odph_ipv4hdr_t *ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(*ppkt, NULL);
	ipsec_cache_entry_t *entry;
	odp_ipsec_out_param_t out_param;
	int rc;
	entry = find_ipsec_cache_entry_out(odp_be_to_cpu_32(ip->src_addr),
					   odp_be_to_cpu_32(ip->dst_addr),
					   ip->proto);
	if (!entry)
		return PKT_CONTINUE;
	memset(&out_param, 0, sizeof(out_param));
	out_param.num_sa = 1;
	out_param.num_opt = 0;
	out_param.sa = &entry->ipsec_sa;
	out_param.opt = NULL;
	if (global->appl.mode == ODP_IPSEC_OP_MODE_INLINE) {
		odp_ipsec_out_inline_param_t inline_param;
		inline_param.pktio = ctx->pktio;
		inline_param.outer_hdr.ptr = (void *)&ctx->eth;
		inline_param.outer_hdr.len = ODPH_ETHHDR_LEN;
		rc = odp_ipsec_out_inline(ppkt, 1, &out_param, &inline_param);
		if (rc <= 0)
			return PKT_DROP;
		return PKT_DONE;
	} else if (global->appl.mode != ODP_IPSEC_OP_MODE_SYNC) {
		rc = odp_ipsec_out_enq(ppkt, 1, &out_param);
		if (rc <= 0)
			return PKT_DROP;
		return PKT_POSTED;
	} else {
		int out = 1;
		odp_ipsec_packet_result_t result;
		rc = odp_ipsec_out(ppkt, 1, ppkt, &out, &out_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 outbound IPsec processing\n");
			return PKT_DROP;
		}
		return PKT_CONTINUE;
	}
}
static pkt_disposition_e do_ipsec_out_classify ( odp_packet_t * ppkt , pkt_ctx_t * ctx ) { odph_ipv4hdr_t * ip = ( odph_ipv4hdr_t * ) odp_packet_l3_ptr ( * ppkt , NULL ) ; ipsec_cache_entry_t * entry ; odp_ipsec_out_param_t out_param ; int rc ; entry = find_ipsec_cache_entry_out ( odp_be_to_cpu_32 ( ip -> src_addr ) , odp_be_to_cpu_32 ( ip -> dst_addr ) , ip -> proto ) ; if ( ! entry ) return PKT_CONTINUE ; memset ( & out_param , 0 , sizeof ( out_param ) ) ; out_param . num_sa = 1 ; out_param . num_opt = 0 ; out_param . sa = & entry -> ipsec_sa ; out_param . opt = NULL ; if ( global -> appl . mode == ODP_IPSEC_OP_MODE_INLINE ) { odp_ipsec_out_inline_param_t inline_param ; inline_param . pktio = ctx -> pktio ; inline_param . outer_hdr . ptr = ( void * ) & ctx -> eth ; inline_param . outer_hdr . len = ODPH_ETHHDR_LEN ; rc = odp_ipsec_out_inline ( ppkt , 1 , & out_param , & inline_param ) ; if ( rc <= 0 ) return PKT_DROP ; return PKT_DONE ; } else if ( global -> appl . mode != ODP_IPSEC_OP_MODE_SYNC ) { rc = odp_ipsec_out_enq ( ppkt , 1 , & out_param ) ; if ( rc <= 0 ) return PKT_DROP ; return PKT_POSTED ; } else { int out = 1 ; odp_ipsec_packet_result_t result ; rc = odp_ipsec_out ( ppkt , 1 , ppkt , & out , & out_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 - Output IPsec packet classification
 Verify the outbound packet has a match in the IPsec cache,
 if so issue prepend IPsec headers and prepare parameters
 for crypto API call.
Packet Processing - Output IPsec packet classification Verify the outbound packet has a match in the IPsec cache if so issue prepend IPsec headers and prepare parameters for crypto API call .
/* Find record */ /* Issue crypto request */