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