example/generator/odp_generator.c
static void process_pkts(int thr, thread_args_t *thr_args,
			 odp_packet_t pkt_tbl[], unsigned len)
{
	odp_packet_t pkt;
	uint32_t left, offset, i;
	odph_ipv4hdr_t *ip;

	for (i = 0; i < len; ++i) {
		pkt = pkt_tbl[i];

		/* Drop packets with errors */
		if (odp_unlikely(odp_packet_has_error(pkt)))
			continue;

		offset = odp_packet_l3_offset(pkt);
		left = odp_packet_len(pkt) - offset;

		if (left < sizeof(odph_ipv4hdr_t))
			continue;

		ip = (odph_ipv4hdr_t *)((uint8_t *)odp_packet_data(pkt) +
					offset);

		/* only ip pkts */
		if (ODPH_IPV4HDR_VER(ip->ver_ihl) != ODPH_IPV4)
			continue;

		thr_args->counters.ctr_pkt_rcv++;

		/* udp */
		if (ip->proto == ODPH_IPPROTO_UDP) {
			thr_args->counters.ctr_udp_rcv++;
		} else if (ip->proto == ODPH_IPPROTO_ICMPV4) {
			uint32_t l3_size = ODPH_IPV4HDR_IHL(ip->ver_ihl) * 4;

			offset += l3_size;
			left -=  l3_size;

			if (left < sizeof(odph_icmphdr_t))
				continue;

			process_icmp_pkt(thr, thr_args,
					 (uint8_t *)odp_packet_data(pkt) +
					 offset);
		}
	}
}
/**
 * Process odp packets
 *
 * @param  thr worker id
 * @param  thr_args worker argument
 * @param  pkt_tbl packets to be print
 * @param  len packet number
 */
Process odp packets
@param  thr worker id
@param  thr_args worker argument
@param  pkt_tbl packets to be print
@param  len packet number
Process odp packets @param thr worker id @param thr_args worker argument @param pkt_tbl packets to be print @param len packet number
static void process_pkts(int thr, thread_args_t *thr_args,
			 odp_packet_t pkt_tbl[], unsigned len)
{
	odp_packet_t pkt;
	uint32_t left, offset, i;
	odph_ipv4hdr_t *ip;
	for (i = 0; i < len; ++i) {
		pkt = pkt_tbl[i];
		if (odp_unlikely(odp_packet_has_error(pkt)))
			continue;
		offset = odp_packet_l3_offset(pkt);
		left = odp_packet_len(pkt) - offset;
		if (left < sizeof(odph_ipv4hdr_t))
			continue;
		ip = (odph_ipv4hdr_t *)((uint8_t *)odp_packet_data(pkt) +
					offset);
		if (ODPH_IPV4HDR_VER(ip->ver_ihl) != ODPH_IPV4)
			continue;
		thr_args->counters.ctr_pkt_rcv++;
		if (ip->proto == ODPH_IPPROTO_UDP) {
			thr_args->counters.ctr_udp_rcv++;
		} else if (ip->proto == ODPH_IPPROTO_ICMPV4) {
			uint32_t l3_size = ODPH_IPV4HDR_IHL(ip->ver_ihl) * 4;
			offset += l3_size;
			left -=  l3_size;
			if (left < sizeof(odph_icmphdr_t))
				continue;
			process_icmp_pkt(thr, thr_args,
					 (uint8_t *)odp_packet_data(pkt) +
					 offset);
		}
	}
}
static void process_pkts ( int thr , thread_args_t * thr_args , odp_packet_t pkt_tbl [ ] , unsigned len ) { odp_packet_t pkt ; uint32_t left , offset , i ; odph_ipv4hdr_t * ip ; for ( i = 0 ; i < len ; ++ i ) { pkt = pkt_tbl [ i ] ; if ( odp_unlikely ( odp_packet_has_error ( pkt ) ) ) continue ; offset = odp_packet_l3_offset ( pkt ) ; left = odp_packet_len ( pkt ) - offset ; if ( left < sizeof ( odph_ipv4hdr_t ) ) continue ; ip = ( odph_ipv4hdr_t * ) ( ( uint8_t * ) odp_packet_data ( pkt ) + offset ) ; if ( ODPH_IPV4HDR_VER ( ip -> ver_ihl ) != ODPH_IPV4 ) continue ; thr_args -> counters . ctr_pkt_rcv ++ ; if ( ip -> proto == ODPH_IPPROTO_UDP ) { thr_args -> counters . ctr_udp_rcv ++ ; } else if ( ip -> proto == ODPH_IPPROTO_ICMPV4 ) { uint32_t l3_size = ODPH_IPV4HDR_IHL ( ip -> ver_ihl ) * 4 ; offset += l3_size ; left -= l3_size ; if ( left < sizeof ( odph_icmphdr_t ) ) continue ; process_icmp_pkt ( thr , thr_args , ( uint8_t * ) odp_packet_data ( pkt ) + offset ) ; } } }
Process odp packets
 @param  thr worker id
 @param  thr_args worker argument
 @param  pkt_tbl packets to be print
 @param  len packet number
Process odp packets @param thr worker id @param thr_args worker argument @param pkt_tbl packets to be print @param len packet number
/* Drop packets with errors */ /* only ip pkts */ /* udp */