1 | /*
|
---|
2 | * Public domain
|
---|
3 | *
|
---|
4 | * BSD socket emulation code for Winsock2
|
---|
5 | * Brent Cook <bcook@openbsd.org>
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * From
|
---|
10 | * https://raw.githubusercontent.com/libressl-portable/portable/master/include/compat/win32netcompat.h
|
---|
11 | * https://raw.githubusercontent.com/libressl-portable/portable/master/include/compat/arpa/inet.h
|
---|
12 | * https://raw.githubusercontent.com/libressl-portable/portable/master/include/compat/arpa/nameser.h
|
---|
13 | */
|
---|
14 |
|
---|
15 | #ifndef LIBCRYPTOCOMPAT_WIN32NETCOMPAT_H
|
---|
16 | #define LIBCRYPTOCOMPAT_WIN32NETCOMPAT_H
|
---|
17 |
|
---|
18 | #ifdef _WIN32
|
---|
19 |
|
---|
20 | #include <ws2tcpip.h>
|
---|
21 | #include <errno.h>
|
---|
22 | #include <unistd.h>
|
---|
23 |
|
---|
24 | #ifndef SHUT_RDWR
|
---|
25 | #define SHUT_RDWR SD_BOTH
|
---|
26 | #endif
|
---|
27 | #ifndef SHUT_RD
|
---|
28 | #define SHUT_RD SD_RECEIVE
|
---|
29 | #endif
|
---|
30 | #ifndef SHUT_WR
|
---|
31 | #define SHUT_WR SD_SEND
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | int posix_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
|
---|
35 |
|
---|
36 | int posix_close(int fd);
|
---|
37 | ssize_t posix_read(int fd, void *buf, size_t count);
|
---|
38 |
|
---|
39 | ssize_t posix_write(int fd, const void *buf, size_t count);
|
---|
40 |
|
---|
41 | int posix_getsockopt(int sockfd, int level, int optname,
|
---|
42 | void *optval, socklen_t *optlen);
|
---|
43 |
|
---|
44 | int posix_setsockopt(int sockfd, int level, int optname,
|
---|
45 | const void *optval, socklen_t optlen);
|
---|
46 |
|
---|
47 | #ifndef NO_REDEF_POSIX_FUNCTIONS
|
---|
48 | #define connect(sockfd, addr, addrlen) posix_connect(sockfd, addr, addrlen)
|
---|
49 | #define close(fd) posix_close(fd)
|
---|
50 | #define read(fd, buf, count) posix_read(fd, buf, count)
|
---|
51 | #define write(fd, buf, count) posix_write(fd, buf, count)
|
---|
52 | #define getsockopt(sockfd, level, optname, optval, optlen) \
|
---|
53 | posix_getsockopt(sockfd, level, optname, optval, optlen)
|
---|
54 | #define setsockopt(sockfd, level, optname, optval, optlen) \
|
---|
55 | posix_setsockopt(sockfd, level, optname, optval, optlen)
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | #ifndef AI_ADDRCONFIG
|
---|
59 | #define AI_ADDRCONFIG 0x00000400
|
---|
60 | #endif
|
---|
61 |
|
---|
62 | #ifndef INADDRSZ
|
---|
63 | #define INADDRSZ 4
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | #ifndef IN6ADDRSZ
|
---|
67 | #define IN6ADDRSZ 16
|
---|
68 | #endif
|
---|
69 |
|
---|
70 | #ifndef INT16SZ
|
---|
71 | #define INT16SZ 2
|
---|
72 | #endif
|
---|
73 |
|
---|
74 | int inet_pton(int af, const char * src, void * dst);
|
---|
75 |
|
---|
76 | #endif
|
---|
77 |
|
---|
78 | #endif
|
---|