Imported Upstream version 2.3
[ossec-hids.git] / src / analysisd / eventinfo.h
1 /* @(#) $Id: eventinfo.h,v 1.37 2009/07/24 18:34:11 dcid Exp $ */
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 3) 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[9];
71     char mon[4];
72 }Eventinfo;
73
74
75 /* Events List structure */
76 typedef struct _EventNode
77 {
78     Eventinfo *event;
79     struct _EventNode *next;
80     struct _EventNode *prev;
81 }EventNode;
82
83
84
85 /** Types of events (from decoders) **/
86 #define UNKNOWN         0   /* Unkown */
87 #define SYSLOG          1   /* syslog messages */
88 #define IDS             2   /* IDS alerts */
89 #define FIREWALL    3   /* Firewall events */
90 #define WEBLOG      7   /* Apache logs */
91 #define SQUID       8   /* Squid logs */
92 #define WINDOWS     9   /* Windows logs */
93 #define HOST_INFO   10  /* Host information logs (from nmap or similar) */
94 #define OSSEC_RL    11  /* Ossec rules */
95 #define OSSEC_ALERT 12  /* Ossec Alerts */
96
97
98 /* FTS allowed values */
99 #define FTS_NAME        001000
100 #define FTS_SRCUSER     002000
101 #define FTS_DSTUSER     004000
102 #define FTS_SRCIP       000100
103 #define FTS_DSTIP       000200
104 #define FTS_LOCATION    000400
105 #define FTS_ID          000010
106 #define FTS_DATA        000020
107 #define FTS_SYSTEMNAME  000040
108 #define FTS_DONE        010000
109
110
111 /** Functions for events **/
112
113 /* Search for matches in the last events */
114 Eventinfo *Search_LastEvents(Eventinfo *lf, RuleInfo *currently_rule);
115 Eventinfo *Search_LastSids(Eventinfo *my_lf, RuleInfo *currently_rule);
116 Eventinfo *Search_LastGroups(Eventinfo *my_lf, RuleInfo *currently_rule);
117
118 /* Zero the eventinfo structure */
119 void Zero_Eventinfo(Eventinfo *lf);
120
121 /* Free the eventinfo structure */
122 void Free_Eventinfo(Eventinfo *lf);
123
124 /* Add and event to the list of previous events */
125 void OS_AddEvent(Eventinfo *lf);
126
127 /* Return the last event from the Event list */
128 EventNode *OS_GetLastEvent();
129
130 /* Create the event list. Maxsize must be specified */
131 void OS_CreateEventList(int maxsize);
132
133
134 /* Pointers to the event decoders */
135 void *SrcUser_FP(Eventinfo *lf, char *field);
136 void *DstUser_FP(Eventinfo *lf, char *field);
137 void *SrcIP_FP(Eventinfo *lf, char *field);
138 void *DstIP_FP(Eventinfo *lf, char *field);
139 void *SrcPort_FP(Eventinfo *lf, char *field);
140 void *DstPort_FP(Eventinfo *lf, char *field);
141 void *Protocol_FP(Eventinfo *lf, char *field);
142 void *Action_FP(Eventinfo *lf, char *field);
143 void *ID_FP(Eventinfo *lf, char *field);
144 void *Url_FP(Eventinfo *lf, char *field);
145 void *Data_FP(Eventinfo *lf, char *field);
146 void *Status_FP(Eventinfo *lf, char *field);
147 void *SystemName_FP(Eventinfo *lf, char *field);
148 void *None_FP(Eventinfo *lf, char *field);
149
150
151
152 #endif /* _EVTINFO__H */