1 /*
2  * include/haproxy/mailer-t.h
3  * This file defines everything related to mailer.
4  *
5  * Copyright 2015 Horms Solutions Ltd., Simon Horman <horms@verge.net.au>
6  *
7  * Based on include/haproxy/peers-t.h
8  *
9  * Copyright 2010 EXCELIANCE, Emeric Brun <ebrun@exceliance.fr>
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation, version 2.1
14  * exclusively.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
24  */
25 
26 #ifndef _HAPROXY_MAILERS_T_H
27 #define _HAPROXY_MAILERS_T_H
28 
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <netinet/in.h>
32 #include <arpa/inet.h>
33 
34 #include <haproxy/check-t.h>
35 #include <haproxy/tcpcheck-t.h>
36 #include <haproxy/thread-t.h>
37 
38 struct mailer {
39 	char *id;
40 	struct mailers *mailers;
41 	struct {
42 		const char *file;	/* file where the section appears */
43 		int line;		/* line where the section appears */
44 	} conf;				/* config information */
45 	struct sockaddr_storage addr;	/* SMTP server address */
46 	struct protocol *proto;		/* SMTP server address's protocol */
47 	struct xprt_ops *xprt;		/* SMTP server socket operations at transport layer */
48 	void *sock_init_arg;		/* socket operations's opaque init argument if needed */
49 	struct mailer *next;		/* next mailer in the list */
50 };
51 
52 struct mailers {
53 	char *id;			/* mailers section name */
54 	struct mailer *mailer_list;	/* mailers in this mailers section */
55 	struct {
56 		const char *file;	/* file where the section appears */
57 		int line;		/* line where the section appears */
58 	} conf;				/* config information */
59 	struct mailers *next;	        /* next mailers section */
60 	int count;			/* total number of mailers in this mailers section */
61 	int users;			/* number of users of this mailers section */
62 	struct {			/* time to: */
63 		int mail;		/*   try connecting to mailserver and sending a email */
64 	} timeout;
65 };
66 
67 struct email_alert {
68 	struct list list;
69 	struct tcpcheck_rules rules;
70 	struct server *srv;
71 };
72 
73 struct email_alertq {
74 	struct list email_alerts;
75 	struct check check;		/* Email alerts are implemented using existing check
76 					 * code even though they are not checks. This structure
77 					 * is as a parameter to the check code.
78 					 * Each check corresponds to a mailer */
79 	__decl_thread(HA_SPINLOCK_T lock);
80 };
81 
82 #endif /* _HAPROXY_MAILERS_T_H */
83 
84