cfengine  3.15.4
About: CFEngine is a configuration management system for configuring and maintaining Unix-like computers (using an own high level policy language). Community version.
  Fossies Dox: cfengine-3.15.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

lastseen.h
Go to the documentation of this file.
1 /*
2  Copyright 2019 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_LASTSEEN_H
26 #define CFENGINE_LASTSEEN_H
27 
28 #include <statistics.h>
29 
30 typedef struct
31 {
32  time_t lastseen;
33  QPoint Q; // Average time between connections (rolling weighted average)
34 } KeyHostSeen;
35 
36 typedef enum
37 {
41 
42 
43 bool Address2Hostkey(char *dst, size_t dst_size, const char *address);
44 
45 void LastSaw1(const char *ipaddress, const char *hashstr, LastSeenRole role);
46 void LastSaw(const char *ipaddress, const char *digest, LastSeenRole role);
47 
48 bool DeleteIpFromLastSeen(const char *ip, char *digest, size_t digest_size);
49 bool DeleteDigestFromLastSeen(const char *key, char *ip, size_t ip_size, bool a_entry_required);
50 
51 /*
52  * Return false in order to stop iteration
53  */
54 typedef bool (*LastSeenQualityCallback)(const char *hostkey, const char *address,
55  bool incoming, const KeyHostSeen *quality,
56  void *ctx);
57 
58 bool ScanLastSeenQuality(LastSeenQualityCallback callback, void *ctx);
59 int LastSeenHostKeyCount(void);
60 bool IsLastSeenCoherent(void);
61 int RemoveKeysFromLastSeen(const char *input, bool must_be_coherent,
62  char *equivalent, size_t equivalent_size);
63 
64 #endif
static int input(void)
Definition: cf3lex.c:2154
LastSeenRole
Definition: lastseen.h:37
@ LAST_SEEN_ROLE_CONNECT
Definition: lastseen.h:38
@ LAST_SEEN_ROLE_ACCEPT
Definition: lastseen.h:39
bool DeleteIpFromLastSeen(const char *ip, char *digest, size_t digest_size)
removes all traces of host 'ip' from lastseen DB
Definition: lastseen.c:447
int RemoveKeysFromLastSeen(const char *input, bool must_be_coherent, char *equivalent, size_t equivalent_size)
removes all traces of entry 'input' from lastseen DB
Definition: lastseen.c:694
int LastSeenHostKeyCount(void)
Definition: lastseen.c:645
void LastSaw(const char *ipaddress, const char *digest, LastSeenRole role)
Definition: lastseen.c:90
bool DeleteDigestFromLastSeen(const char *key, char *ip, size_t ip_size, bool a_entry_required)
removes all traces of key digest 'key' from lastseen DB
Definition: lastseen.c:517
bool IsLastSeenCoherent(void)
check whether the lastseen DB is coherent or not.
Definition: lastseen.c:304
bool ScanLastSeenQuality(LastSeenQualityCallback callback, void *ctx)
Definition: lastseen.c:576
bool(* LastSeenQualityCallback)(const char *hostkey, const char *address, bool incoming, const KeyHostSeen *quality, void *ctx)
Definition: lastseen.h:54
void LastSaw1(const char *ipaddress, const char *hashstr, LastSeenRole role)
Same as LastSaw() but the digest parameter is the hash as a "SHA=..." string, to avoid converting twi...
Definition: lastseen.c:83
bool Address2Hostkey(char *dst, size_t dst_size, const char *address)
Definition: lastseen.c:196