iPXE
|
Ethernet protocol. More...
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <byteswap.h>
#include <errno.h>
#include <assert.h>
#include <ipxe/if_arp.h>
#include <ipxe/if_ether.h>
#include <ipxe/in.h>
#include <ipxe/netdevice.h>
#include <ipxe/iobuf.h>
#include <ipxe/ethernet.h>
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static int | eth_is_llc_packet (struct ethhdr *ethhdr) |
Check if Ethernet packet has an 802.3 LLC header. More... | |
int | eth_push (struct net_device *netdev __unused, struct io_buffer *iobuf, const void *ll_dest, const void *ll_source, uint16_t net_proto) |
Add Ethernet link-layer header. More... | |
int | eth_pull (struct net_device *netdev __unused, struct io_buffer *iobuf, const void **ll_dest, const void **ll_source, uint16_t *net_proto, unsigned int *flags) |
Remove Ethernet link-layer header. More... | |
void | eth_init_addr (const void *hw_addr, void *ll_addr) |
Initialise Ethernet address. More... | |
void | eth_random_addr (void *hw_addr) |
Generate random Ethernet address. More... | |
const char * | eth_ntoa (const void *ll_addr) |
Transcribe Ethernet address. More... | |
int | eth_mc_hash (unsigned int af, const void *net_addr, void *ll_addr) |
Hash multicast address. More... | |
int | eth_eth_addr (const void *ll_addr, void *eth_addr) |
Generate Ethernet-compatible compressed link-layer address. More... | |
int | eth_eui64 (const void *ll_addr, void *eui64) |
Generate EUI-64 address. More... | |
struct net_device * | alloc_etherdev (size_t priv_size) |
Allocate Ethernet device. More... | |
REQUIRING_SYMBOL (ethernet_protocol) | |
REQUIRE_OBJECT (config_ethernet) | |
Variables | |
uint8_t | eth_broadcast [ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } |
Ethernet broadcast MAC address. More... | |
struct ll_protocol ethernet_protocol | __ll_protocol |
Ethernet protocol. More... | |
Ethernet protocol.
Definition in file ethernet.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
inlinestatic |
Check if Ethernet packet has an 802.3 LLC header.
ethhdr | Ethernet header |
is_llc | Packet has 802.3 LLC header |
Definition at line 55 of file ethernet.c.
References ethhdr::h_protocol.
Referenced by eth_pull().
int eth_push | ( | struct net_device *netdev | __unused, |
struct io_buffer * | iobuf, | ||
const void * | ll_dest, | ||
const void * | ll_source, | ||
uint16_t | net_proto | ||
) |
Add Ethernet link-layer header.
netdev | Network device |
iobuf | I/O buffer |
ll_dest | Link-layer destination address |
ll_source | Source link-layer address |
net_proto | Network-layer protocol, in network-byte order |
rc | Return status code |
Definition at line 77 of file ethernet.c.
References ETH_ALEN, ethhdr::h_dest, ethhdr::h_protocol, ethhdr::h_source, iob_push, and memcpy().
int eth_pull | ( | struct net_device *netdev | __unused, |
struct io_buffer * | iobuf, | ||
const void ** | ll_dest, | ||
const void ** | ll_source, | ||
uint16_t * | net_proto, | ||
unsigned int * | flags | ||
) |
Remove Ethernet link-layer header.
netdev | Network device |
iobuf | I/O buffer |
ll_dest | Link-layer destination address |
ll_source | Source link-layer address |
net_proto | Network-layer protocol, in network-byte order |
flags | Packet flags |
rc | Return status code |
Definition at line 101 of file ethernet.c.
References io_buffer::data, DBG, EINVAL, eth_is_llc_packet(), flags, ethhdr::h_dest, ethhdr::h_protocol, ethhdr::h_source, iob_len(), iob_pull, is_broadcast_ether_addr(), is_multicast_ether_addr(), LL_BROADCAST, and LL_MULTICAST.
Referenced by undinet_transmit().
void eth_init_addr | ( | const void * | hw_addr, |
void * | ll_addr | ||
) |
Initialise Ethernet address.
hw_addr | Hardware address |
ll_addr | Link-layer address |
Definition at line 150 of file ethernet.c.
void eth_random_addr | ( | void * | hw_addr | ) |
Generate random Ethernet address.
hw_addr | Generated hardware address |
Definition at line 159 of file ethernet.c.
References addr, ETH_ALEN, and random().
Referenced by igbvf_probe(), intelvf_mbox_reset(), lan78xx_fetch_mac(), smsc95xx_fetch_mac(), and txnic_bgx_mac().
const char* eth_ntoa | ( | const void * | ll_addr | ) |
Transcribe Ethernet address.
ll_addr | Link-layer address |
string | Link-layer address in human-readable format |
Definition at line 175 of file ethernet.c.
References sprintf.
Referenced by acpimac_extract(), amd8111e_get_mac_address(), b44_probe(), bnx2_probe(), bofm_en(), bofm_test(), corkscrew_probe1(), cs89x0_probe(), davicom_probe(), dmfe_probe(), ecm_fetch_mac(), eepro_probe(), ena_get_device_attributes(), eoib_create(), eoib_rx_av(), eoib_tx_av(), epic100_probe(), eth_probe(), eth_slow_lacp_dump(), eth_slow_marker_dump(), exanic_probe(), fcoe_expired(), fcoe_fip_rx(), fcoe_fip_rx_advertisement(), fcoe_fip_rx_els_response(), fcoe_fip_rx_vlan(), fcoe_rx(), gve_describe(), hermon_bofm_harvest(), hermon_bofm_update(), ibft_fill_nic(), ice_admin_mac_read(), intel_fetch_mac(), intel_fetch_mac_eeprom(), intelvf_mbox_reset(), intelx_try_fetch_mac(), intelxl_admin_mac_read(), ipoib_find_remac(), ipoib_translate_tx_arp(), ipoib_transmit(), iwlist(), lan78xx_fetch_mac(), ne_probe(), net80211_probe_step(), net80211_step_associate(), nv_setup_mac_addr(), pcnet32_probe(), phantom_add_macaddr(), phantom_del_macaddr(), phantom_get_macaddr(), prism2_probe(), smc9000_probe(), smsc95xx_fetch_mac(), smsc95xx_vm3_fetch_mac(), smscusb_eeprom_fetch_mac(), smscusb_fdt_fetch_mac(), smscusb_otp_fetch_mac(), stp_rx(), t595_probe(), t5x9_probe(), tlan_probe(), tulip_probe(), txnic_lmac_probe(), undinet_probe(), virtnet_probe_legacy(), virtnet_probe_modern(), vxge_probe(), w89c840_probe(), wpa_derive_ptk(), xsmp_rx_xve_install(), and xve_create().
int eth_mc_hash | ( | unsigned int | af, |
const void * | net_addr, | ||
void * | ll_addr | ||
) |
Hash multicast address.
af | Address family |
net_addr | Network-layer address |
ll_addr | Link-layer address to fill in |
rc | Return status code |
Definition at line 193 of file ethernet.c.
int eth_eth_addr | ( | const void * | ll_addr, |
void * | eth_addr | ||
) |
Generate Ethernet-compatible compressed link-layer address.
ll_addr | Link-layer address |
eth_addr | Ethernet-compatible address to fill in |
Definition at line 222 of file ethernet.c.
int eth_eui64 | ( | const void * | ll_addr, |
void * | eui64 | ||
) |
Generate EUI-64 address.
ll_addr | Link-layer address |
eui64 | EUI-64 address to fill in |
rc | Return status code |
Definition at line 234 of file ethernet.c.
struct net_device* alloc_etherdev | ( | size_t | priv_size | ) |
Allocate Ethernet device.
priv_size | Size of driver private data |
netdev | Network device, or NULL |
Definition at line 264 of file ethernet.c.
References alloc_netdev(), eth_broadcast, ETH_FRAME_LEN, ETH_MAX_MTU, net_device::ll_broadcast, net_device::ll_protocol, net_device::max_pkt_len, net_device::mtu, and netdev.
Referenced by a3c90x_probe(), alloc_rndis(), atl1e_probe(), atl_probe(), axge_probe(), b44_probe(), bnxt_init_one(), dm96xx_probe(), ecm_probe(), efab_probe(), ena_probe(), eoib_create(), exanic_probe_port(), flexboot_nodnic_register_netdev(), forcedeth_probe(), gve_probe(), hermon_probe(), hunt_probe(), ice_probe(), icplus_probe(), ifec_pci_probe(), igbvf_probe(), intel_probe(), intelx_probe(), intelxl_probe(), intelxlvf_probe(), intelxvf_probe(), iphone_probe(), jme_probe(), lan78xx_probe(), legacy_probe(), mnpnet_start(), myri10ge_pci_probe(), myson_probe(), natsemi_probe(), ncm_probe(), netfront_probe(), pcnet32_probe(), phantom_probe(), pnic_probe(), rdc_probe(), realtek_probe(), rhine_probe(), sis190_init_board(), skeleton_probe(), skge_devinit(), sky2_init_netdev(), smsc75xx_probe(), smsc95xx_probe(), snpnet_start(), tg3_init_one(), txnic_alloc(), undinet_probe(), velocity_probe(), virtnet_probe_legacy(), virtnet_probe_modern(), vlan_create(), vmxnet3_probe(), and vxge_device_register().
REQUIRING_SYMBOL | ( | ethernet_protocol | ) |
REQUIRE_OBJECT | ( | config_ethernet | ) |
Ethernet broadcast MAC address.
Definition at line 47 of file ethernet.c.
Referenced by alloc_etherdev(), alloc_ipoibdev(), ath9k_init_misc(), ice_probe(), ipoib_complete_recv(), net80211_alloc(), and net80211_probe_step().
struct ll_protocol ethernet_protocol __ll_protocol |
Ethernet protocol.
Definition at line 243 of file ethernet.c.