1#ifndef __VSF_LINUX_ETHERDEVICE_H__
2#define __VSF_LINUX_ETHERDEVICE_H__
8static inline void eth_broadcast_addr(
u8 *addr)
13static inline bool is_local_ether_addr(
const u8 *addr)
15 return 0x02 & addr[0];
18#if __IS_COMPILER_GCC__
19# pragma GCC diagnostic push
20# pragma GCC diagnostic ignored "-Wcast-align"
21#elif __IS_COMPILER_LLVM__ || __IS_COMPILER_ARM_COMPILER_6__
22# pragma clang diagnostic push
23# pragma clang diagnostic ignored "-Wcast-align"
26static inline bool is_broadcast_ether_addr(
const u8 *addr)
28 return (*(
const u16 *)(addr + 0) &
29 *(
const u16 *)(addr + 2) &
30 *(
const u16 *)(addr + 4)) == 0xffff;
33static inline bool is_zero_ether_addr(
const u8 *addr)
35 return (*(
const u16 *)(addr + 0) |
36 *(
const u16 *)(addr + 2) |
37 *(
const u16 *)(addr + 4)) == 0;
40static inline bool is_multicast_ether_addr(
const u8 *addr)
42 u16 a = *(
const u16 *)addr;
43#if __BYTE_ORDER == __BIG_ENDIAN
44 return 0x01 & (a >> ((
sizeof(a) * 8) - 8));
50#if __IS_COMPILER_GCC__
51# pragma GCC diagnostic pop
52#elif __IS_COMPILER_LLVM__ || __IS_COMPILER_ARM_COMPILER_6__
53# pragma clang diagnostic pop
56static inline bool is_unicast_ether_addr(
const u8 *addr)
58 return !is_multicast_ether_addr(addr);
61static inline bool is_valid_ether_addr(
const u8 *addr)
63 return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr);
#define ETH_ALEN
Definition if_ether.h:12
unsigned short u16
Definition lvgl.h:41
unsigned char u8
Definition lvgl.h:40
void * memset(void *s, int ch, size_t n)