154568cb3Sopenharmony_ci/* 254568cb3Sopenharmony_ci * Copyright (c) 2022-2022 Huawei Technologies Co., Ltd. All rights reserved. 354568cb3Sopenharmony_ci * 454568cb3Sopenharmony_ci * UniProton is licensed under Mulan PSL v2. 554568cb3Sopenharmony_ci * You can use this software according to the terms and conditions of the Mulan PSL v2. 654568cb3Sopenharmony_ci * You may obtain a copy of Mulan PSL v2 at: 754568cb3Sopenharmony_ci * http://license.coscl.org.cn/MulanPSL2 854568cb3Sopenharmony_ci * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 954568cb3Sopenharmony_ci * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 1054568cb3Sopenharmony_ci * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 1154568cb3Sopenharmony_ci * See the Mulan PSL v2 for more details. 1254568cb3Sopenharmony_ci * Create: 2022-09-21 1354568cb3Sopenharmony_ci * Description: 网络 1454568cb3Sopenharmony_ci */ 1554568cb3Sopenharmony_ci 1654568cb3Sopenharmony_ci#ifndef LWIP_PORTING_SOCKETS_H 1754568cb3Sopenharmony_ci#define LWIP_PORTING_SOCKETS_H 1854568cb3Sopenharmony_ci 1954568cb3Sopenharmony_ci#include "lwip/arch.h" 2054568cb3Sopenharmony_ci#include <sys/socket.h> 2154568cb3Sopenharmony_ci#include <poll.h> 2254568cb3Sopenharmony_ci#include <netinet/tcp.h> 2354568cb3Sopenharmony_ci#include <netinet/in.h> 2454568cb3Sopenharmony_ci#include <sys/ioctl.h> 2554568cb3Sopenharmony_ci#include <sys/select.h> 2654568cb3Sopenharmony_ci#include <limits.h> 2754568cb3Sopenharmony_ci#include <fcntl.h> 2854568cb3Sopenharmony_ci#include_next <lwip/sockets.h> 2954568cb3Sopenharmony_ci 3054568cb3Sopenharmony_ci#if FD_SETSIZE < (LWIP_SOCKET_OFFSET + MEMP_NUM_NETCONN) 3154568cb3Sopenharmony_ci#error "external FD_SETSIZE too small for number of sockets" 3254568cb3Sopenharmony_ci#else 3354568cb3Sopenharmony_ci#define LWIP_SELECT_MAXNFDS FD_SETSIZE 3454568cb3Sopenharmony_ci#endif 3554568cb3Sopenharmony_ci 3654568cb3Sopenharmony_ci#if IOV_MAX > 0xFFFF 3754568cb3Sopenharmony_ci#error "IOV_MAX larger than supported by LwIP" 3854568cb3Sopenharmony_ci#endif 3954568cb3Sopenharmony_ci 4054568cb3Sopenharmony_ci#if LWIP_UDP && LWIP_UDPLITE 4154568cb3Sopenharmony_ci#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */ 4254568cb3Sopenharmony_ci#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */ 4354568cb3Sopenharmony_ci#endif 4454568cb3Sopenharmony_ci 4554568cb3Sopenharmony_ci// For BSD 4.4 socket sa_len compatibility 4654568cb3Sopenharmony_ci#define DF_NADDR(addr) ip_addr_t naddr = (addr) 4754568cb3Sopenharmony_ci#define SA_LEN(addr, _) (IP_IS_V4_VAL(addr) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6)) 4854568cb3Sopenharmony_ci#define sa_len sa_data[0] * 0 + SA_LEN(naddr, _) 4954568cb3Sopenharmony_ci#define sin_len sin_zero[0] 5054568cb3Sopenharmony_ci#define sin6_len sin6_addr.s6_addr[0] 5154568cb3Sopenharmony_ci 5254568cb3Sopenharmony_ci// for sockets.c, TCP_KEEPALIVE is not supported currently 5354568cb3Sopenharmony_ci#define TCP_KEEPALIVE 0xFF 5454568cb3Sopenharmony_ci#define SIN_ZERO_LEN 8 5554568cb3Sopenharmony_ci 5654568cb3Sopenharmony_ciint closesocket(int sockfd); 5754568cb3Sopenharmony_ciint ioctlsocket(int s, long cmd, void *argp); 5854568cb3Sopenharmony_ci 5954568cb3Sopenharmony_ci#endif /* LWIP_PORTING_SOCKETS_H */ 60