• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2022 Huawei Technologies Co., Ltd. All rights reserved.
3  *
4  * UniProton is licensed under Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *          http://license.coscl.org.cn/MulanPSL2
8  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11  * See the Mulan PSL v2 for more details.
12  * Create: 2022-09-21
13  * Description: 网络
14  */
15 
16 #ifndef LWIP_PORTING_SOCKETS_H
17 #define LWIP_PORTING_SOCKETS_H
18 
19 #include "lwip/arch.h"
20 #include <sys/socket.h>
21 #include <poll.h>
22 #include <netinet/tcp.h>
23 #include <netinet/in.h>
24 #include <sys/ioctl.h>
25 #include <sys/select.h>
26 #include <limits.h>
27 #include <fcntl.h>
28 #include_next <lwip/sockets.h>
29 
30 #if FD_SETSIZE < (LWIP_SOCKET_OFFSET + MEMP_NUM_NETCONN)
31 #error "external FD_SETSIZE too small for number of sockets"
32 #else
33 #define LWIP_SELECT_MAXNFDS FD_SETSIZE
34 #endif
35 
36 #if IOV_MAX > 0xFFFF
37 #error "IOV_MAX larger than supported by LwIP"
38 #endif
39 
40 #if LWIP_UDP && LWIP_UDPLITE
41 #define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */
42 #define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
43 #endif
44 
45 // For BSD 4.4 socket sa_len compatibility
46 #define DF_NADDR(addr)  ip_addr_t naddr = (addr)
47 #define SA_LEN(addr, _)  (IP_IS_V4_VAL(addr) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6))
48 #define sa_len sa_data[0] * 0 + SA_LEN(naddr, _)
49 #define sin_len sin_zero[0]
50 #define sin6_len sin6_addr.s6_addr[0]
51 
52 // for sockets.c, TCP_KEEPALIVE is not supported currently
53 #define TCP_KEEPALIVE   0xFF
54 #define SIN_ZERO_LEN    8
55 
56 int closesocket(int sockfd);
57 int ioctlsocket(int s, long cmd, void *argp);
58 
59 #endif /* LWIP_PORTING_SOCKETS_H */
60