izmjene licence
[ossec-hids.git] / src / analysisd / eventinfo.h
1 /* @(#) $Id: ./src/analysisd/eventinfo.h, 2011/09/08 dcid Exp $
2  */
3
4 /* Copyright (C) 2009 Trend Micro Inc.
5  * All right reserved.
6  *
7  * This program is a free software; you can redistribute it
8  * and/or modify it under the terms of the GNU General Public
9  * License (version 2) as published by the FSF - Free Software
10  * Foundation
11  */
12
13
14
15 #ifndef _EVTINFO__H
16
17 #define _EVTINFO__H
18
19 #include "rules.h"
20 #include "decoders/decoder.h"
21
22
23 /* Event Information structure */
24 typedef struct _Eventinfo
25 {
26     /* Extracted from the event */
27     char *log;
28     char *full_log;
29     char *location;
30     char *hostname;
31     char *program_name;
32
33
34     /* Extracted from the decoders */
35     char *srcip;
36     char *dstip;
37     char *srcport;
38     char *dstport;
39     char *protocol;
40     char *action;
41     char *srcuser;
42     char *dstuser;
43     char *id;
44     char *status;
45     char *command;
46     char *url;
47     char *data;
48     char *systemname;
49
50
51     /* Pointer to the rule that generated it */
52     RuleInfo *generated_rule;
53
54     /* Pointer to the decoder that matched */
55     OSDecoderInfo *decoder_info;
56
57     /* Sid node to delete */
58     OSListNode *sid_node_to_delete;
59
60     /* Extract when the event fires a rule */
61     int size;
62     int p_name_size;
63
64
65     /* Other internal variables */
66     short int matched;
67
68     int time;
69     int day;
70     int year;
71     char hour[10];
72     char mon[4];
73
74     /* SYSCHECK Results variables */
75     char *filename;
76     int perm_before;
77     int perm_after;
78     char *md5_before;
79     char *md5_after;
80     char *sha1_before;
81     char *sha1_after;
82     char *size_before;
83     char *size_after;
84     char *owner_before;
85     char *owner_after;
86     char *gowner_before;
87     char *gowner_after;
88 }Eventinfo;
89
90
91 /* Events List structure */
92 typedef struct _EventNode
93 {
94     Eventinfo *event;
95     struct _EventNode *next;
96     struct _EventNode *prev;
97 }EventNode;
98
99
100
101 /* For test rule only. */
102 #ifdef TESTRULE
103 int full_output;
104 int alert_only;
105 #endif
106
107
108 /** Types of events (from decoders) **/
109 #define UNKNOWN         0   /* Unkown */
110 #define SYSLOG          1   /* syslog messages */
111 #define IDS             2   /* IDS alerts */
112 #define FIREWALL    3   /* Firewall events */
113 #define WEBLOG      7   /* Apache logs */
114 #define SQUID       8   /* Squid logs */
115 #define DECODER_WINDOWS     9   /* Windows logs */
116 #define HOST_INFO   10  /* Host information logs (from nmap or similar) */
117 #define OSSEC_RL    11  /* Ossec rules */
118 #define OSSEC_ALERT 12  /* Ossec Alerts */
119
120
121 /* FTS allowed values */
122 #define FTS_NAME        001000
123 #define FTS_SRCUSER     002000
124 #define FTS_DSTUSER     004000
125 #define FTS_SRCIP       000100
126 #define FTS_DSTIP       000200
127 #define FTS_LOCATION    000400
128 #define FTS_ID          000010
129 #define FTS_DATA        000020
130 #define FTS_SYSTEMNAME  000040
131 #define FTS_DONE        010000
132
133
134 /** Functions for events **/
135
136 /* Search for matches in the last events */
137 Eventinfo *Search_LastEvents(Eventinfo *lf, RuleInfo *currently_rule);
138 Eventinfo *Search_LastSids(Eventinfo *my_lf, RuleInfo *currently_rule);
139 Eventinfo *Search_LastGroups(Eventinfo *my_lf, RuleInfo *currently_rule);
140
141 /* Zero the eventinfo structure */
142 void Zero_Eventinfo(Eventinfo *lf);
143
144 /* Free the eventinfo structure */
145 void Free_Eventinfo(Eventinfo *lf);
146
147 /* Add and event to the list of previous events */
148 void OS_AddEvent(Eventinfo *lf);
149
150 /* Return the last event from the Event list */
151 EventNode *OS_GetLastEvent();
152
153 /* Create the event list. Maxsize must be specified */
154 void OS_CreateEventList(int maxsize);
155
156
157 /* Pointers to the event decoders */
158 void *SrcUser_FP(Eventinfo *lf, char *field);
159 void *DstUser_FP(Eventinfo *lf, char *field);
160 void *SrcIP_FP(Eventinfo *lf, char *field);
161 void *DstIP_FP(Eventinfo *lf, char *field);
162 void *SrcPort_FP(Eventinfo *lf, char *field);
163 void *DstPort_FP(Eventinfo *lf, char *field);
164 void *Protocol_FP(Eventinfo *lf, char *field);
165 void *Action_FP(Eventinfo *lf, char *field);
166 void *ID_FP(Eventinfo *lf, char *field);
167 void *Url_FP(Eventinfo *lf, char *field);
168 void *Data_FP(Eventinfo *lf, char *field);
169 void *Status_FP(Eventinfo *lf, char *field);
170 void *SystemName_FP(Eventinfo *lf, char *field);
171 void *None_FP(Eventinfo *lf, char *field);
172
173
174
175 #endif /* _EVTINFO__H */