I use pcap_pmd in a DPDK application, and it does not set the packet_type
field automatically. How can I determine the correct packet type after the packet is received from the interface?
edit: The ethernet header structure:
/**
* Ethernet header: Contains the destination address, source address
* and frame type.
*/
struct ether_hdr {
struct ether_addr d_addr; /**< Destination address. */
struct ether_addr s_addr; /**< Source address. */
uint16_t ether_type; /**< Frame type. */
} __attribute__((__packed__));
does not give a clue on where to search for the L3 protocol identifier.
Digging just a bit deeper into the rte_ether.h
header gave the answer: ether_hdr::ether_type
is the desired next protocol id, it can have one of the following values:
/* Ethernet frame types */
#define ETHER_TYPE_IPv4 0x0800 /**< IPv4 Protocol. */
#define ETHER_TYPE_IPv6 0x86DD /**< IPv6 Protocol. */
#define ETHER_TYPE_ARP 0x0806 /**< Arp Protocol. */
#define ETHER_TYPE_RARP 0x8035 /**< Reverse Arp Protocol. */
#define ETHER_TYPE_VLAN 0x8100 /**< IEEE 802.1Q VLAN tagging. */
#define ETHER_TYPE_1588 0x88F7 /**< IEEE 802.1AS 1588 Precise Time Protocol. */
#define ETHER_TYPE_SLOW 0x8809 /**< Slow protocols (LACP and Marker). */
#define ETHER_TYPE_TEB 0x6558 /**< Transparent Ethernet Bridging. */