example/ipsec_crypto/odp_ipsec_misc.h
static inline
int locate_ipsec_headers(odph_ipv4hdr_t *ip,
			 odph_ahhdr_t **ah_p,
			 odph_esphdr_t **esp_p)
{
	uint8_t *in = ipv4_data_p(ip);
	odph_ahhdr_t *ah = NULL;
	odph_esphdr_t *esp = NULL;

	if (ODPH_IPPROTO_AH == ip->proto) {
		ah = (odph_ahhdr_t *)in;
		in += ((ah)->ah_len + 2) * 4;
		if (ODPH_IPPROTO_ESP == ah->next_header) {
			esp = (odph_esphdr_t *)in;
			in += sizeof(odph_esphdr_t);
		}
	} else if (ODPH_IPPROTO_ESP == ip->proto) {
		esp = (odph_esphdr_t *)in;
		in += sizeof(odph_esphdr_t);
	}

	*ah_p = ah;
	*esp_p = esp;
	return in - (ipv4_data_p(ip));
}
/**
 * Locate IPsec headers (AH and/or ESP) in packet
 *
 * @param ip     Pointer to packets IPv4 header
 * @param ah_p   Pointer to location to return AH header pointer
 * @param esp_p  Pointer to location to return ESP header pointer
 *
 * @return length of IPsec headers found
 */
Locate IPsec headers (AH and/or ESP) in packet
@param ip     Pointer to packets IPv4 header
@param ah_p   Pointer to location to return AH header pointer
@param esp_p  Pointer to location to return ESP header pointer

@return length of IPsec headers found
Locate IPsec headers ( AH and / or ESP ) in packet @param ip Pointer to packets IPv4 header @param ah_p Pointer to location to return AH header pointer @param esp_p Pointer to location to return ESP header pointer @return length of IPsec headers found
static inline
int locate_ipsec_headers(odph_ipv4hdr_t *ip,
			 odph_ahhdr_t **ah_p,
			 odph_esphdr_t **esp_p)
{
	uint8_t *in = ipv4_data_p(ip);
	odph_ahhdr_t *ah = NULL;
	odph_esphdr_t *esp = NULL;
	if (ODPH_IPPROTO_AH == ip->proto) {
		ah = (odph_ahhdr_t *)in;
		in += ((ah)->ah_len + 2) * 4;
		if (ODPH_IPPROTO_ESP == ah->next_header) {
			esp = (odph_esphdr_t *)in;
			in += sizeof(odph_esphdr_t);
		}
	} else if (ODPH_IPPROTO_ESP == ip->proto) {
		esp = (odph_esphdr_t *)in;
		in += sizeof(odph_esphdr_t);
	}
	*ah_p = ah;
	*esp_p = esp;
	return in - (ipv4_data_p(ip));
}
static inline int locate_ipsec_headers ( odph_ipv4hdr_t * ip , odph_ahhdr_t * * ah_p , odph_esphdr_t * * esp_p ) { uint8_t * in = ipv4_data_p ( ip ) ; odph_ahhdr_t * ah = NULL ; odph_esphdr_t * esp = NULL ; if ( ODPH_IPPROTO_AH == ip -> proto ) { ah = ( odph_ahhdr_t * ) in ; in += ( ( ah ) -> ah_len + 2 ) * 4 ; if ( ODPH_IPPROTO_ESP == ah -> next_header ) { esp = ( odph_esphdr_t * ) in ; in += sizeof ( odph_esphdr_t ) ; } } else if ( ODPH_IPPROTO_ESP == ip -> proto ) { esp = ( odph_esphdr_t * ) in ; in += sizeof ( odph_esphdr_t ) ; } * ah_p = ah ; * esp_p = esp ; return in - ( ipv4_data_p ( ip ) ) ; }
Locate IPsec headers (AH and/or ESP) in packet
 @param ip     Pointer to packets IPv4 header
 @param ah_p   Pointer to location to return AH header pointer
 @param esp_p  Pointer to location to return ESP header pointer
Locate IPsec headers ( AH and / or ESP ) in packet @param ip Pointer to packets IPv4 header @param ah_p Pointer to location to return AH header pointer @param esp_p Pointer to location to return ESP header pointer