| 
    CNDP
    22.08.0
    
   | 
 
#include <errno.h>#include <stdio.h>#include <stdint.h>#include <stdlib.h>#include <net/ethernet.h>#include <linux/if_ether.h>#include <stdbool.h>#include <string.h>#include <cne_common.h>Go to the source code of this file.
Data Structures | |
| struct | ether_addr | 
| struct | cne_ether_hdr | 
| struct | cne_vlan_hdr | 
Ethernet Helpers in CNE
Definition in file cne_ether.h.
| #define CNE_ETHER_MAX_VLAN_FRAME_LEN (ETHER_MAX_LEN + 4) | 
Maximum VLAN frame length, including CRC.
Definition at line 30 of file cne_ether.h.
| #define CNE_ETHER_MAX_JUMBO_FRAME_LEN 0x3F00 | 
Maximum Jumbo frame length, including CRC.
Definition at line 32 of file cne_ether.h.
| #define CNE_ETHER_MAX_VLAN_ID 4095 | 
Maximum VLAN ID.
Definition at line 34 of file cne_ether.h.
| #define CNE_ETHER_MIN_MTU 68 | 
Minimum MTU for IPv4 packets, see RFC 791.
Definition at line 36 of file cne_ether.h.
| #define ETHER_LOCAL_ADMIN_ADDR 0x02 | 
Locally assigned Eth. address.
Definition at line 57 of file cne_ether.h.
| #define ETHER_GROUP_ADDR 0x01 | 
Multicast or broadcast Eth. address.
Definition at line 58 of file cne_ether.h.
| #define CNE_ETHER_TYPE_IPV4 0x0800 | 
IPv4 Protocol.
Definition at line 81 of file cne_ether.h.
| #define CNE_ETHER_TYPE_IPV6 0x86DD | 
IPv6 Protocol.
Definition at line 82 of file cne_ether.h.
| #define CNE_ETHER_TYPE_ARP 0x0806 | 
Arp Protocol.
Definition at line 83 of file cne_ether.h.
| #define CNE_ETHER_TYPE_RARP 0x8035 | 
Reverse Arp Protocol.
Definition at line 84 of file cne_ether.h.
| #define CNE_ETHER_TYPE_VLAN 0x8100 | 
IEEE 802.1Q VLAN tagging.
Definition at line 85 of file cne_ether.h.
| #define CNE_ETHER_TYPE_QINQ 0x88A8 | 
IEEE 802.1ad QinQ tagging.
Definition at line 86 of file cne_ether.h.
| #define CNE_ETHER_TYPE_PPPOE_DISCOVERY 0x8863 | 
PPPoE Discovery Stage.
Definition at line 87 of file cne_ether.h.
| #define CNE_ETHER_TYPE_PPPOE_SESSION 0x8864 | 
PPPoE Session Stage.
Definition at line 88 of file cne_ether.h.
| #define CNE_ETHER_TYPE_ETAG 0x893F | 
IEEE 802.1BR E-Tag.
Definition at line 89 of file cne_ether.h.
| #define CNE_ETHER_TYPE_1588 0x88F7 | 
IEEE 802.1AS 1588 Precise Time Protocol.
Definition at line 91 of file cne_ether.h.
| #define CNE_ETHER_TYPE_SLOW 0x8809 | 
Slow protocols (LACP and Marker).
Definition at line 92 of file cne_ether.h.
| #define CNE_ETHER_TYPE_TEB 0x6558 | 
Transparent Ethernet Bridging.
Definition at line 93 of file cne_ether.h.
| #define CNE_ETHER_TYPE_LLDP 0x88CC | 
LLDP Protocol.
Definition at line 94 of file cne_ether.h.
| #define CNE_ETHER_TYPE_MPLS 0x8847 | 
MPLS ethertype.
Definition at line 95 of file cne_ether.h.
| #define CNE_ETHER_TYPE_MPLSM 0x8848 | 
MPLS multicast ethertype.
Definition at line 96 of file cne_ether.h.
| #define __ETHER_TYPE_IPV4 0x0008 | 
IPv4 Protocol.
Definition at line 99 of file cne_ether.h.
| #define __ETHER_TYPE_IPV6 0xDD86 | 
IPv6 Protocol.
Definition at line 100 of file cne_ether.h.
| #define __ETHER_TYPE_ARP 0x0608 | 
Arp Protocol.
Definition at line 101 of file cne_ether.h.
| #define __ETHER_TYPE_RARP 0x3580 | 
Reverse Arp Protocol.
Definition at line 102 of file cne_ether.h.
| #define __ETHER_TYPE_VLAN 0x0081 | 
IEEE 802.1Q VLAN tagging.
Definition at line 103 of file cne_ether.h.
| #define __ETHER_TYPE_QINQ 0xA888 | 
IEEE 802.1ad QinQ tagging.
Definition at line 104 of file cne_ether.h.
| #define __ETHER_TYPE_PPPOE_DISCOVERY 0x6388 | 
PPPoE Discovery Stage.
Definition at line 105 of file cne_ether.h.
| #define __ETHER_TYPE_PPPOE_SESSION 0x6488 | 
PPPoE Session Stage.
Definition at line 106 of file cne_ether.h.
| #define __ETHER_TYPE_ETAG 0x3F89 | 
IEEE 802.1BR E-Tag.
Definition at line 107 of file cne_ether.h.
| #define __ETHER_TYPE_1588 0xF788 | 
IEEE 802.1AS 1588 Precise Time Protocol.
Definition at line 109 of file cne_ether.h.
| #define __ETHER_TYPE_SLOW 0x0988 | 
Slow protocols (LACP and Marker).
Definition at line 110 of file cne_ether.h.
| #define __ETHER_TYPE_TEB 0x5865 | 
Transparent Ethernet Bridging.
Definition at line 111 of file cne_ether.h.
| #define __ETHER_TYPE_LLDP 0xCC88 | 
LLDP Protocol.
Definition at line 112 of file cne_ether.h.
| #define __ETHER_TYPE_MPLS 0x4788 | 
MPLS ethertype.
Definition at line 113 of file cne_ether.h.
| #define __ETHER_TYPE_MPLSM 0x4888 | 
MPLS multicast ethertype.
Definition at line 114 of file cne_ether.h.
| CNDP_API __cne_always_inline int ether_addr_is_same | ( | const struct ether_addr * | ea1, | 
| const struct ether_addr * | ea2 | ||
| ) | 
Check if two Ethernet addresses are the same.
| ea1 | A pointer to the first ether_addr structure containing the ethernet address. | 
| ea2 | A pointer to the second ether_addr structure containing the ethernet address. | 
Definition at line 131 of file cne_ether.h.
| CNDP_API __cne_always_inline int ether_addr_is_zero | ( | const struct ether_addr * | ea | ) | 
Check if an Ethernet address is filled with zeros.
| ea | A pointer to a ether_addr structure containing the ethernet address to check. | 
Definition at line 150 of file cne_ether.h.
| CNDP_API __cne_always_inline int ether_addr_is_unicast | ( | const struct ether_addr * | ea | ) | 
Check if an Ethernet address is a unicast address.
| ea | A pointer to a ether_addr structure containing the ethernet address to check. | 
Definition at line 168 of file cne_ether.h.
| CNDP_API __cne_always_inline int ether_addr_is_multicast | ( | const struct ether_addr * | ea | ) | 
Check if an Ethernet address is a multicast address.
| ea | A pointer to a ether_addr structure containing the ethernet address to check. | 
Definition at line 184 of file cne_ether.h.
| CNDP_API __cne_always_inline int ether_addr_is_broadcast | ( | const struct ether_addr * | ea | ) | 
Check if an Ethernet address is a broadcast address.
| ea | A pointer to a ether_addr structure containing the ethernet address to check. | 
Definition at line 200 of file cne_ether.h.
| CNDP_API __cne_always_inline int ether_addr_is_universal | ( | const struct ether_addr * | ea | ) | 
Check if an Ethernet address is a universally assigned address.
| ea | A pointer to a ether_addr structure containing the ethernet address to check. | 
Definition at line 218 of file cne_ether.h.
| CNDP_API __cne_always_inline int ether_addr_is_local_admin | ( | const struct ether_addr * | ea | ) | 
Check if an Ethernet address is a locally assigned address.
| ea | A pointer to a ether_addr structure containing the ethernet address to check. | 
Definition at line 234 of file cne_ether.h.
| CNDP_API __cne_always_inline int ether_addr_is_valid_assigned | ( | const struct ether_addr * | ea | ) | 
Check if an Ethernet address is a valid address. Checks that the address is a unicast address and is not filled with zeros.
| ea | A pointer to a ether_addr structure containing the ethernet address to check. | 
Definition at line 251 of file cne_ether.h.
| CNDP_API __cne_always_inline void ether_random_addr | ( | uint8_t * | addr | ) | 
Generate a random Ethernet address that is locally administered and not multicast.
| addr | A pointer to Ethernet address. | 
Definition at line 263 of file cne_ether.h.
| CNDP_API __cne_always_inline void ether_addr_copy | ( | const struct ether_addr * | ea_from, | 
| struct ether_addr * | ea_to | ||
| ) | 
Fast copy an Ethernet address.
| ea_from | A pointer to a ether_addr structure holding the Ethernet address to copy. | 
| ea_to | A pointer to a ether_addr structure where to copy the Ethernet address. | 
Definition at line 282 of file cne_ether.h.
| CNDP_API __cne_always_inline void ether_format_addr | ( | char * | buf, | 
| uint16_t | size, | ||
| const struct ether_addr * | eth_addr | ||
| ) | 
Format 48bits Ethernet address in pattern xx:xx:xx:xx:xx:xx.
| buf | A pointer to buffer contains the formatted MAC address. | 
| size | The format buffer size. | 
| eth_addr | A pointer to a ether_addr structure. | 
Definition at line 334 of file cne_ether.h.
| CNDP_API __cne_always_inline int ether_unformat_addr | ( | const char * | s, | 
| struct ether_addr * | ea | ||
| ) | 
Convert string with Ethernet address to an ether_addr.
| s | A pointer to buffer contains the formatted MAC address. The supported formats are: XX:XX:XX:XX:XX:XX or XXXX:XXXX:XXXX where XX is a hex digit: 0-9, a-f, or A-F. | 
| ea | A pointer to a ether_addr structure. | 
Definition at line 426 of file cne_ether.h.
| CNDP_API __cne_always_inline struct ether_addr* cne_ether_aton | ( | const char * | a, | 
| struct ether_addr * | e | ||
| ) | 
Convert a string Ethernet MAC address to the binary form
| a | String containing the MAC address in two forms XX:XX:XX:XX:XX:XX or XXXX:XXXX:XXX | 
| e | pointer to a struct ether_addr to place the return value. | 
Definition at line 449 of file cne_ether.h.