1 | /* $Id: daemon.h,v 1.30 2011/06/28 00:13:48 sbajic Exp $ */ |
---|
2 | |
---|
3 | /* |
---|
4 | DSPAM |
---|
5 | COPYRIGHT (C) 2002-2012 DSPAM PROJECT |
---|
6 | |
---|
7 | This program is free software: you can redistribute it and/or modify |
---|
8 | it under the terms of the GNU Affero General Public License as |
---|
9 | published by the Free Software Foundation, either version 3 of the |
---|
10 | License, or (at your option) any later version. |
---|
11 | |
---|
12 | This program is distributed in the hope that it will be useful, |
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | GNU Affero General Public License for more details. |
---|
16 | |
---|
17 | You should have received a copy of the GNU Affero General Public License |
---|
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef _DAEMON_H |
---|
23 | # define _DAEMON_H |
---|
24 | |
---|
25 | #include <sys/types.h> |
---|
26 | #ifndef _WIN32 |
---|
27 | #include <pwd.h> |
---|
28 | #endif |
---|
29 | |
---|
30 | #ifdef HAVE_CONFIG_H |
---|
31 | #include <auto-config.h> |
---|
32 | #endif |
---|
33 | |
---|
34 | #include <pthread.h> |
---|
35 | #include <netinet/in.h> |
---|
36 | #include <netinet/tcp.h> |
---|
37 | #include <arpa/inet.h> |
---|
38 | |
---|
39 | #include "buffer.h" |
---|
40 | #include "dspam.h" |
---|
41 | #include "libdspam.h" |
---|
42 | |
---|
43 | #ifdef DAEMON |
---|
44 | |
---|
45 | int __daemon_run; /* should we keep running? */ |
---|
46 | int __num_threads; /* number of live threads */ |
---|
47 | int __hup; /* should we reload? */ |
---|
48 | pthread_mutex_t __lock; /* global var lock */ |
---|
49 | |
---|
50 | typedef struct { |
---|
51 | int sockfd; |
---|
52 | char authenticated; |
---|
53 | pthread_t thread; |
---|
54 | struct sockaddr_in remote_addr; |
---|
55 | buffer *packet_buffer; |
---|
56 | DRIVER_CTX *DTX; |
---|
57 | } THREAD_CTX; |
---|
58 | |
---|
59 | int daemon_listen(DRIVER_CTX *DTX); |
---|
60 | int daemon_reply(THREAD_CTX *TTX, int reply, const char *ecode, |
---|
61 | const char *text); |
---|
62 | int daemon_extension(THREAD_CTX *TTX, const char *extension); |
---|
63 | void * process_connection(void *ptr); |
---|
64 | char * daemon_expect(THREAD_CTX *TTX, const char *command); |
---|
65 | char * daemon_getline(THREAD_CTX *TTX, int timeout); |
---|
66 | void process_signal(int sig); |
---|
67 | void increment_thread_count(void); |
---|
68 | void decrement_thread_count(void); |
---|
69 | buffer *read_sock(THREAD_CTX *TTX, AGENT_CTX *ATX); |
---|
70 | |
---|
71 | #define LMTP_GREETING 220 |
---|
72 | #define LMTP_QUIT 221 |
---|
73 | #define LMTP_OK 250 |
---|
74 | #define LMTP_DATA 354 |
---|
75 | #define LMTP_ERROR_PROCESS 500 |
---|
76 | #define LMTP_FAILURE 530 |
---|
77 | #define LMTP_AUTH_ERROR 503 |
---|
78 | #define LMTP_BAD_CMD 503 |
---|
79 | #define LMTP_NO_RCPT 554 |
---|
80 | #define LMTP_TEMP_FAIL 421 |
---|
81 | |
---|
82 | #define SSM_DSPAM 0x00 |
---|
83 | #define SSM_STANDARD 0x01 |
---|
84 | #define SSM_AUTO 0x02 |
---|
85 | |
---|
86 | #endif |
---|
87 | #endif /* _DAEMON_H */ |
---|