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 #ifndef CFENGINE_CLIENT_CODE_H
26 #define CFENGINE_CLIENT_CODE_H
27 
28 
29 #include <platform.h>
30 #include <item_lib.h>
31 
32 #include <communication.h>
33 
34 
35 bool cfnet_init(const char *tls_min_version, const char *ciphers);
36 void cfnet_shut(void);
37 bool cfnet_IsInitialized(void);
38 void DetermineCfenginePort(void);
39 bool SetCfenginePort(const char *port_str);
40 
41 /**
42   @param err Set to 0 on success, -1 no server response, -2 authentication failure.
43   */
44 AgentConnection *ServerConnection(const char *server, const char *port,
45                                   unsigned int connect_timeout,
46                                   ConnectionFlags flags, int *err);
47 void DisconnectServer(AgentConnection *conn);
48 
49 bool CompareHashNet(const char *file1, const char *file2, bool encrypt, AgentConnection *conn);
50 bool CopyRegularFileNet(const char *source, const char *dest, off_t size,
51                         bool encrypt, AgentConnection *conn);
52 Item *RemoteDirList(const char *dirname, bool encrypt, AgentConnection *conn);
53 
54 int TLSConnectCallCollect(ConnectionInfo *conn_info, const char *username);
55 
56 
57 #endif
58