64 return ( len_msb < 0x06 );
78 const void *ll_dest,
const void *ll_source,
102 const void **ll_dest,
const void **ll_source,
112 if (
iob_len ( iobuf ) < (
sizeof ( *
ethhdr ) +
sizeof ( *llc_proto ))){
113 DBG (
"Ethernet packet too short (%zd bytes)\n",
137 llc_proto = iobuf->
data;
138 *net_proto = *llc_proto;
177 const uint8_t *eth_addr = ll_addr;
179 sprintf ( buf,
"%02x:%02x:%02x:%02x:%02x:%02x",
180 eth_addr[0], eth_addr[1], eth_addr[2],
181 eth_addr[3], eth_addr[4], eth_addr[5] );
193 int eth_mc_hash (
unsigned int af,
const void *net_addr,
void *ll_addr ) {
194 const uint8_t *net_addr_bytes = net_addr;
195 uint8_t *ll_addr_bytes = ll_addr;
199 ll_addr_bytes[0] = 0x01;
200 ll_addr_bytes[1] = 0x00;
201 ll_addr_bytes[2] = 0x5e;
202 ll_addr_bytes[3] = net_addr_bytes[1] & 0x7f;
203 ll_addr_bytes[4] = net_addr_bytes[2];
204 ll_addr_bytes[5] = net_addr_bytes[3];
207 ll_addr_bytes[0] = 0x33;
208 ll_addr_bytes[1] = 0x33;
209 memcpy ( &ll_addr_bytes[2], &net_addr_bytes[12], 4 );
236 memcpy ( ( eui64 + 0 ), ( ll_addr + 0 ), 3 );
237 memcpy ( ( eui64 + 5 ), ( ll_addr + 3 ), 3 );
#define LL_MULTICAST
Packet is a multicast (including broadcast) packet.
uint16_t h_protocol
Protocol ID.
#define iob_pull(iobuf, len)
#define EINVAL
Invalid argument.
struct ll_protocol ethernet_protocol __ll_protocol
Ethernet protocol.
#define AF_INET6
IPv6 Internet addresses.
int eth_eth_addr(const void *ll_addr, void *eth_addr)
Generate Ethernet-compatible compressed link-layer address.
#define iob_push(iobuf, len)
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
size_t mtu
Maximum transmission unit length.
uint8_t eth_broadcast[ETH_ALEN]
Ethernet broadcast MAC address.
REQUIRING_SYMBOL(ethernet_protocol)
const uint8_t * ll_broadcast
Link-layer broadcast address.
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.
void eth_init_addr(const void *hw_addr, void *ll_addr)
Initialise Ethernet address.
Address Resolution Protocol constants and types.
int eth_eui64(const void *ll_addr, void *eui64)
Generate EUI-64 address.
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.
#define ENOTSUP
Operation not supported.
struct net_device * alloc_netdev(size_t priv_len)
Allocate network device.
const char * name
Protocol name.
uint8_t h_dest[ETH_ALEN]
Destination MAC address.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define __unused
Declare a variable or data structure as unused.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static struct net_device * netdev
static int eth_is_llc_packet(struct ethhdr *ethhdr)
Check if Ethernet packet has an 802.3 LLC header.
int eth_mc_hash(unsigned int af, const void *net_addr, void *ll_addr)
Hash multicast address.
static int is_multicast_ether_addr(const void *addr)
Check if Ethernet address is a multicast address.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
long int random(void)
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
uint8_t h_source[ETH_ALEN]
Source MAC address.
uint16_t net_proto
Network-layer protocol.
#define LL_BROADCAST
Packet is a broadcast packet.
Network device management.
void * data
Start of data.
static int is_broadcast_ether_addr(const void *addr)
Check if Ethernet address is the broadcast address.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
size_t max_pkt_len
Maximum packet length.
#define DBG(...)
Print a debugging message.
#define ARPHRD_ETHER
Ethernet 10Mbps.
An Ethernet link-layer header.
REQUIRE_OBJECT(config_ethernet)
#define AF_INET
IPv4 Internet addresses.
void eth_random_addr(void *hw_addr)
Generate random Ethernet address.
struct ll_protocol * ll_protocol
Link-layer protocol.