1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef USB_NET_NET_H 17 #define USB_NET_NET_H 18 19 #include "hdf_base.h" 20 #include "hdf_device_desc.h" 21 22 #define DEFAULT_MTU 1500 23 #define DEFAULT_NET_HEAD_LEN 14 24 #define INDEX_ZERO 0 25 #define INDEX_ONE 1 26 #define INDEX_TWO 2 27 /** 28 * ether_addr_copy - Copy an Ethernet address 29 * @dst: Pointer to a six-byte array Ethernet address destination 30 * @src: Pointer to a six-byte array Ethernet address source 31 * 32 * Please note: dst & src must both be aligned to uint16_t. 33 */ 34 #if defined(__i386) || defined(__x86_64) || defined(__s390x__) || defined(__aarch64__) 35 #define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 1 36 #endif 37 etherAddrCopy(uint8_t * dst,const uint8_t * src)38static inline void etherAddrCopy(uint8_t *dst, const uint8_t *src) 39 { 40 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) 41 *(uint32_t *)dst = *(const uint32_t *)src; 42 *(uint16_t *)(dst + 4) = *(const uint16_t *)(src + 4); 43 #else 44 uint16_t *a = (uint16_t *)dst; 45 const uint16_t *b = (const uint16_t *)src; 46 47 a[INDEX_ZERO] = b[INDEX_ZERO]; 48 a[INDEX_ONE] = b[INDEX_ONE]; 49 a[INDEX_TWO] = b[INDEX_TWO]; 50 #endif 51 } 52 53 void UsbnetWriteLog(char *buff, int size, int tag); 54 55 #endif