ethernet.h File Reference

Ethernet protocol. More...

#include <stdint.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
void eth_init_addr (const void *hw_addr, void *ll_addr)
 Initialise Ethernet address.
const char * eth_ntoa (const void *ll_addr)
 Transcribe Ethernet address.
int eth_mc_hash (unsigned int af, const void *net_addr, void *ll_addr)
 Hash multicast address.
int eth_eth_addr (const void *ll_addr, void *eth_addr)
 Generate Ethernet-compatible compressed link-layer address.
struct net_devicealloc_etherdev (size_t priv_size)
 Allocate Ethernet device.


Detailed Description

Ethernet protocol.

Definition in file ethernet.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

void eth_init_addr ( const void *  hw_addr,
void *  ll_addr 
)

Initialise Ethernet address.

Parameters:
hw_addr Hardware address
ll_addr Link-layer address

Definition at line 105 of file ethernet.c.

References ETH_ALEN, and memcpy.

00105                                                           {
00106         memcpy ( ll_addr, hw_addr, ETH_ALEN );
00107 }

const char* eth_ntoa ( const void *  ll_addr  ) 

Transcribe Ethernet address.

Parameters:
ll_addr Link-layer address
Return values:
string Link-layer address in human-readable format

Definition at line 115 of file ethernet.c.

References sprintf.

Referenced by amd8111e_get_mac_address(), aoe_rx_cfg(), b44_probe(), bnx2_probe(), corkscrew_probe1(), cs89x0_probe(), davicom_probe(), dmfe_probe(), eepro_probe(), epic100_probe(), eth_probe(), forcedeth_probe(), ibft_fill_nic(), iwlist(), mtd_probe(), ne_probe(), net80211_probe_step(), net80211_step_associate(), pcnet32_probe(), phantom_add_macaddr(), phantom_del_macaddr(), phantom_get_macaddr(), prism2_probe(), rhine_probe1(), rtl8169_probe(), smc9000_probe(), t595_probe(), t5x9_probe(), tg3_probe(), tlan_probe(), tulip_probe(), undinet_probe(), velocity_probe(), vxge_probe(), w89c840_probe(), and wpa_derive_ptk().

00115                                               {
00116         static char buf[18]; /* "00:00:00:00:00:00" */
00117         const uint8_t *eth_addr = ll_addr;
00118 
00119         sprintf ( buf, "%02x:%02x:%02x:%02x:%02x:%02x",
00120                   eth_addr[0], eth_addr[1], eth_addr[2],
00121                   eth_addr[3], eth_addr[4], eth_addr[5] );
00122         return buf;
00123 }

int eth_mc_hash ( unsigned int  af,
const void *  net_addr,
void *  ll_addr 
)

Hash multicast address.

Parameters:
af Address family
net_addr Network-layer address
ll_addr Link-layer address to fill in
Return values:
rc Return status code

Definition at line 133 of file ethernet.c.

References AF_INET, and ENOTSUP.

00133                                                                          {
00134         const uint8_t *net_addr_bytes = net_addr;
00135         uint8_t *ll_addr_bytes = ll_addr;
00136 
00137         switch ( af ) {
00138         case AF_INET:
00139                 ll_addr_bytes[0] = 0x01;
00140                 ll_addr_bytes[1] = 0x00;
00141                 ll_addr_bytes[2] = 0x5e;
00142                 ll_addr_bytes[3] = net_addr_bytes[1] & 0x7f;
00143                 ll_addr_bytes[4] = net_addr_bytes[2];
00144                 ll_addr_bytes[5] = net_addr_bytes[3];
00145                 return 0;
00146         default:
00147                 return -ENOTSUP;
00148         }
00149 }

int eth_eth_addr ( const void *  ll_addr,
void *  eth_addr 
)

Generate Ethernet-compatible compressed link-layer address.

Parameters:
ll_addr Link-layer address
eth_addr Ethernet-compatible address to fill in

Definition at line 157 of file ethernet.c.

References ETH_ALEN, and memcpy.

00157                                                          {
00158         memcpy ( eth_addr, ll_addr, ETH_ALEN );
00159         return 0;
00160 }

struct net_device* alloc_etherdev ( size_t  priv_size  )  [read]

Allocate Ethernet device.

Parameters:
priv_size Size of driver private data
Return values:
netdev Network device, or NULL

Definition at line 183 of file ethernet.c.

References alloc_netdev(), eth_broadcast, ETH_FRAME_LEN, net_device::ll_broadcast, net_device::ll_protocol, net_device::max_pkt_len, and netdev.

Referenced by a3c90x_probe(), atl1e_probe(), b44_probe(), e1000_probe(), e1000e_probe(), efab_probe(), ifec_pci_probe(), igb_probe(), legacy_probe(), mtnic_probe(), myri10ge_pci_probe(), natsemi_probe(), phantom_probe(), pnic_probe(), rtl8169_probe(), rtl_probe(), sis190_init_board(), skge_devinit(), sky2_init_netdev(), undinet_probe(), and vxge_device_register().

00183                                                         {
00184         struct net_device *netdev;
00185 
00186         netdev = alloc_netdev ( priv_size );
00187         if ( netdev ) {
00188                 netdev->ll_protocol = &ethernet_protocol;
00189                 netdev->ll_broadcast = eth_broadcast;
00190                 netdev->max_pkt_len = ETH_FRAME_LEN;
00191         }
00192         return netdev;
00193 }


Generated on Tue Apr 6 20:01:50 2010 for gPXE by  doxygen 1.5.7.1