"Fossies" - the Fresh Open Source Software Archive

Member "cfengine-3.15.4/libpromises/lastseen.h" (7 Jun 2021, 2243 Bytes) of package /linux/misc/cfengine-3.15.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code 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 {
   38     LAST_SEEN_ROLE_CONNECT,
   39     LAST_SEEN_ROLE_ACCEPT
   40 } LastSeenRole;
   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