1 /*
2  *  Copyright (C) 2013-2022 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
3  *  Copyright (C) 2009-2013 Sourcefire, Inc.
4  *
5  *  Authors: aCaB <acab@clamav.net>
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  *  MA 02110-1301, USA.
20  */
21 
22 #ifndef __NET_H
23 #define __NET_H
24 
25 /* Don't include clamav-config.h, because that brings in platform.h
26    and platform.h will make these functions recursive ;-). */
27 #ifndef ssize_t
28 typedef int ssize_t;
29 #endif
30 
31 #define F_GETFL 1
32 #define F_SETFL 2
33 #define O_NONBLOCK 1
34 
35 int w32_socket(int domain, int type, int protocol);
36 int w32_getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen);
37 int w32_setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen);
38 int w32_bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
39 int w32_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
40 ssize_t w32_send(int sockfd, const void *buf, size_t len, int flags);
41 ssize_t w32_recv(int sockfd, void *buf, size_t len, int flags);
42 int w32_closesocket(int sockfd);
43 struct servent *w32_getservbyname(const char *name, const char *proto);
44 #define endservent()
45 int w32_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
46 void w32_freeaddrinfo(struct addrinfo *res);
47 const char *w32_inet_ntop(int af, const void *src, char *dst, socklen_t size);
48 int w32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
49 int poll_with_event(struct pollfd *fds, int nfds, int timeout, HANDLE event);
50 int w32_accept(SOCKET sockfd, const struct sockaddr *addr, socklen_t *addrlen);
51 int w32_listen(int sockfd, int backlog);
52 int w32_shutdown(int sockfd, int how);
53 int w32_getpeername(int sd, struct sockaddr *name, int *namelen);
54 char *w32_inet_ntoa(struct in_addr in);
55 int fcntl(int fd, int cmd, ...);
56 
57 #endif
58