1 /* 2 * Copyright (c) 2024 Archermind Technology (Nanjing) Co. Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef USB_NET_NET_H 10 #define USB_NET_NET_H 11 12 #include "hdf_base.h" 13 #include "hdf_device_desc.h" 14 15 #define DEFAULT_MTU 1500 16 #define DEFAULT_NET_HEAD_LEN 14 17 #define INDEX_ZERO 0 18 #define INDEX_ONE 1 19 #define INDEX_TWO 2 20 /** 21 * ether_addr_copy - Copy an Ethernet address 22 * @dst: Pointer to a six-byte array Ethernet address destination 23 * @src: Pointer to a six-byte array Ethernet address source 24 * 25 * Please note: dst & src must both be aligned to uint16_t. 26 */ 27 #if defined(__i386) || defined(__x86_64) || defined(__s390x__) || defined(__aarch64__) 28 #define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 1 29 #endif 30 etherAddrCopy(uint8_t *dst, const uint8_t *src)31static inline void etherAddrCopy(uint8_t *dst, const uint8_t *src) 32 { 33 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) 34 *(uint32_t *)dst = *(const uint32_t *)src; 35 *(uint16_t *)(dst + 4) = *(const uint16_t *)(src + 4); 36 #else 37 uint16_t *a = (uint16_t *)dst; 38 const uint16_t *b = (const uint16_t *)src; 39 40 a[INDEX_ZERO] = b[INDEX_ZERO]; 41 a[INDEX_ONE] = b[INDEX_ONE]; 42 a[INDEX_TWO] = b[INDEX_TWO]; 43 #endif 44 } 45 46 void UsbnetWriteLog(char *buff, int size, int tag); 47 48 #endif