Imported Upstream version 2.7
[ossec-hids.git] / src / os_maild / maild.h
1 /* @(#) $Id: ./src/os_maild/maild.h, 2011/09/08 dcid Exp $
2  */
3
4 /* Copyright (C) 2009 Trend Micro Inc.
5  * All rights 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  * License details at the LICENSE file included with OSSEC or
13  * online at: http://www.ossec.net/en/licensing.html
14  */
15
16
17 #ifndef _MAILD_H
18 #define _MAILD_H
19
20 #define MAIL_LIST_SIZE      96   /* Max number of emails to be saved */
21 #define MAXCHILDPROCESS     6    /* Maximum simultaneos childs */
22
23 /* Each timeout is x * 5 */
24 #define NEXTMAIL_TIMEOUT    2    /* Time to check for next msg - 5 */
25 #define DEFAULT_TIMEOUT     18   /* socket read timeout - 18 (*5)*/
26 #define SUBJECT_SIZE        128  /* Maximum subject size */
27
28  /* Maximum body size */
29 #define BODY_SIZE           OS_MAXSTR + OS_SIZE_1024
30
31 #define SMS_SUBJECT         "OSSEC %d - %d - %s"
32 #define MAIL_SUBJECT        "OSSEC Notification - %s - Alert level %d"
33 #define MAIL_SUBJECT_FULL   "OSSEC Alert - %s - Level %d - %s"
34
35 /* Full subject without ossec in the name */
36 #ifdef CLEANFULL
37 #define MAIL_SUBJECT_FULL2   "%d - %s - %s"
38 #endif
39
40 #ifdef GEOIP
41 #define MAIL_BODY           "\r\nOSSEC HIDS Notification.\r\n" \
42                             "%s\r\n\r\n" \
43                             "Received From: %s\r\n" \
44                             "Rule: %d fired (level %d) -> \"%s\"\r\n" \
45                             "%s" \
46                             "%s" \
47                             "Portion of the log(s):\r\n\r\n%s\r\n" \
48                             "\r\n\r\n --END OF NOTIFICATION\r\n\r\n\r\n"
49 #else
50 #define MAIL_BODY           "\r\nOSSEC HIDS Notification.\r\n" \
51                             "%s\r\n\r\n" \
52                             "Received From: %s\r\n" \
53                             "Rule: %d fired (level %d) -> \"%s\"\r\n" \
54                             "Portion of the log(s):\r\n\r\n%s\r\n" \
55                             "\r\n\r\n --END OF NOTIFICATION\r\n\r\n\r\n"
56 #endif
57
58 /* Mail msg structure */
59 typedef struct _MailMsg
60 {
61         char *subject;
62         char *body;
63 }MailMsg;
64
65 #include "shared.h"
66 #include "config/mail-config.h"
67
68
69 /* Config function */
70 int MailConf(int test_config, char *cfgfile, MailConfig *Mail);
71
72
73 /* Receive the e-mail message */
74 MailMsg *OS_RecvMailQ(file_queue *fileq, struct tm *p, MailConfig *mail,
75                       MailMsg **msg_sms);
76
77 /* Sends an email */
78 int OS_Sendmail(MailConfig *mail, struct tm *p);
79 int OS_Sendsms(MailConfig *mail, struct tm *p, MailMsg *sms_msg);
80 int OS_SendCustomEmail(char **to, char *subject, char *smtpserver, char *from, FILE *fp, struct tm *p);
81
82
83 /* Mail timeout used by the file-queue */
84 int mail_timeout;
85
86
87 /* Global var for highest level on mail subjects */
88 int   _g_subject_level;
89 char _g_subject[SUBJECT_SIZE +2];
90
91
92 #endif