new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / headers / read-agents.h
1 /* Copyright (C) 2009 Trend Micro Inc.
2  * All right reserved.
3  *
4  * This program is a free software; you can redistribute it
5  * and/or modify it under the terms of the GNU General Public
6  * License (version 2) as published by the FSF - Free Software
7  * Foundation
8  */
9
10 #ifndef __CRAGENT_H
11 #define __CRAGENT_H
12
13 #include <external/cJSON/cJSON.h>
14
15
16 /* Unique key for each agent */
17 typedef struct _agent_info {
18     char *last_keepalive;
19     char *syscheck_time;
20     char *syscheck_endtime;
21     char *rootcheck_time;
22     char *rootcheck_endtime;
23     char *os;
24     char *version;
25 } agent_info;
26
27 /* Print syscheck db (of modified files) */
28 int print_syscheck(const char *sk_name, const char *sk_ip, const char *fname, int print_registry,
29                    int all_files, int csv_output, cJSON *json_output, int update_counter);
30
31 /* Print rootcheck db */
32 int print_rootcheck(const char *sk_name, const char *sk_ip, const char *fname, int resolved,
33                     int csv_output, cJSON *json_output, int show_last);
34
35
36 /* Delete syscheck db */
37 int delete_syscheck(const char *sk_name, const char *sk_ip, int full_delete) __attribute__((nonnull));
38
39 /* Delete rootcheck db */
40 int delete_rootcheck(const char *sk_name, const char *sk_ip, int full_delete) __attribute__((nonnull));
41
42 /* Delete agent information */
43 int delete_agentinfo(const char *name) __attribute__((nonnull));
44
45 /* Get all available agents */
46 char **get_agents(int flag);
47
48 /* Get all available agents with specified timeout */
49 char **get_agents_with_timeout(int flag, int timeout);
50
51 /* Free the agent list */
52 void free_agents(char **agent_list);
53
54 /* Print the text representation of the agent status */
55 const char *print_agent_status(int status);
56
57 /* Gets the status of an agent, based on the name/IP address */
58 int get_agent_status(const char *agent_name, const char *agent_ip);
59
60 /* Get information from an agent */
61 agent_info *get_agent_info(const char *agent_name, const char *agent_ip) __attribute__((nonnull(2)));
62
63 /* Connect to remoted to be able to send messages to the agents
64  * Returns the socket on success or -1 on failure
65  */
66 int connect_to_remoted(void);
67
68 #ifndef WIN32
69 /* Return the unix permission string based on the syscheck db perm string
70  * agentless logs octal permissions, local syscheck decimal st_mode
71  * Returns a pointer to a local static array
72  */
73 const char *agent_file_perm(char *perm);
74 #endif
75
76 /* Sends a message to an agent
77  * Returns -1 on error
78  */
79 int send_msg_to_agent(int msocket, const char *msg, const char *agt_id, const char *exec) __attribute__((nonnull(2)));
80
81 #define GA_NOTACTIVE        2
82 #define GA_ACTIVE           3
83 #define GA_ALL              5
84 #define GA_ALL_WSTATUS      7
85
86 /* Status */
87 #define GA_STATUS_ACTIVE    12
88 #define GA_STATUS_NACTIVE   13
89 #define GA_STATUS_INV       14
90
91 #endif