1 /*
2   Copyright 2021 Northern.tech AS
3 
4   This file is part of CFEngine 3 - written and maintained by Northern.tech AS.
5 
6   This program is free software; you can redistribute it and/or modify it
7   under the terms of the GNU General Public License as published by the
8   Free Software Foundation; version 3.
9 
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14 
15   You should have received a copy of the GNU General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
18 
19   To the extent this program is licensed as part of the Enterprise
20   versions of CFEngine, the applicable Commercial Open Source License
21   (COSL) may apply to this file if you as a licensee so wish it. See
22   included file COSL.txt.
23 */
24 
25 /* Low Level networking routines. */
26 
27 #ifndef CFENGINE_NET_H
28 #define CFENGINE_NET_H
29 
30 
31 #include <cfnet.h>
32 
33 
34 extern uint32_t bwlimit_kbytes;
35 
36 
37 int SendTransaction(ConnectionInfo *conn_info, const char *buffer, int len, char status);
38 int ReceiveTransaction(ConnectionInfo *conn_info, char *buffer, int *more);
39 
40 int SetReceiveTimeout(int fd, unsigned long ms);
41 
42 int SocketConnect(const char *host, const char *port,
43                   unsigned int connect_timeout, bool force_ipv4,
44                   char *txtaddr, size_t txtaddr_size);
45 
46 /**
47  * @NOTE DO NOT USE THIS FUNCTION. The only reason it is non-static is because
48  *       of a separate implementation for windows in Enterprise.
49  */
50 bool TryConnect(int sd, unsigned long timeout_ms,
51                 const struct sockaddr *sa, socklen_t sa_len);
52 
53 
54 #endif
55