Qsmtp  0.30dev
qsmtpd.h
Go to the documentation of this file.
1 
4 #ifndef QSMTPD_H
5 #define QSMTPD_H
6 
7 #include <qdns.h>
8 #include <sstring.h>
9 
10 #include <netinet/in.h>
11 #include <sys/queue.h>
12 #include <sys/types.h>
13 
17 struct smtpcomm {
18  char *name;
19  int len;
20  long mask;
21  int (*func)(void);
22  long state;
23  unsigned int flags;
26 };
27 
32 struct xmitstat {
33  unsigned int esmtp:1;
34  unsigned int ipv4conn:1;
35  unsigned int check2822:2;
36  unsigned int helostatus:3;
37  unsigned int datatype:1;
38  unsigned int spf:4;
39  int fromdomain:3;
40  unsigned int spacebug:1;
41  size_t thisbytes;
42  string mailfrom;
43  string authname;
44  char *tlsclient;
45  string remotehost;
46  char remoteip[INET6_ADDRSTRLEN];
47  const char *remoteinfo;
48  const char *remoteport;
49  string helostr;
51  struct in6_addr sremoteip;
52  char localip[INET6_ADDRSTRLEN];
53  struct in6_addr slocalip;
54  struct ips *frommx;
55  char *spfexp;
56  const char *spfmechanism;
57 };
58 
59 extern struct smtpcomm *current_command;
61 extern struct xmitstat xmitstat;
62 extern string heloname;
63 extern string msgidhost;
64 extern string liphost;
65 extern unsigned int goodrcpt;
66 extern int badbounce;
67 extern unsigned long sslauth;
68 extern unsigned long databytes;
69 extern int relayclient;
70 extern unsigned long comstate;
71 extern int authhide;
72 extern int submission_mode;
74 extern int err_control(const char *);
75 extern int err_control2(const char *, const char *);
76 extern void freedata(void);
77 extern pid_t fork_clean();
78 extern int pipe_move(int p[2], int target);
79 void __attribute__ ((noreturn)) conn_cleanup(const int rc);
80 
81 #define EBOGUS 1002
82 #define EDONE 1003
83 
84 TAILQ_HEAD(, recip) head;
85 
95 struct recip {
96  TAILQ_ENTRY(recip) entries;
97  string to;
98  int ok;
99 };
100 
101 extern struct recip *thisrecip;
102 
103 #define HELOSTR (xmitstat.helostr.len ? xmitstat.helostr.s : xmitstat.remotehost.s)
104 #define HELOLEN (xmitstat.helostr.len ? xmitstat.helostr.len : xmitstat.remotehost.len)
105 
106 #define MAILFROM (xmitstat.mailfrom.len ? xmitstat.mailfrom.s : "")
107 
108 static inline int
109 connection_is_ipv4(void)
110 {
111 #ifdef IPV4ONLY
112  return 1;
113 #else /* IPV4ONLY */
114  return xmitstat.ipv4conn;
115 #endif /* IPV4ONLY */
116 }
117 
118 static inline int
119 is_authenticated_client(void)
120 {
121  return (xmitstat.authname.len != 0) || (xmitstat.tlsclient != NULL);
122 }
123 
124 #endif
unsigned int spacebug
Definition: qsmtpd.h:40
list of IP addresses for a given host
Definition: qdns.h:28
string to
Definition: qsmtpd.h:97
struct smtpcomm * current_command
Definition: qsmtpd.c:47
list of recipients given for this transaction
Definition: qsmtpd.h:95
unsigned int esmtp
Definition: qsmtpd.h:33
char * tlsclient
Definition: qsmtpd.h:44
size_t len
Definition: sstring.h:17
int err_control(const char *)
write and log error message if opening config file leads to an error
Definition: qsmtpd.c:96
int badbounce
Definition: qsmtpd.c:76
int err_control2(const char *, const char *)
write and log error message if opening config file leads to an error
Definition: qsmtpd.c:112
long mask
Definition: qsmtpd.h:20
char localip[INET6_ADDRSTRLEN]
Definition: qsmtpd.h:52
int(* func)(void)
Definition: qsmtpd.h:21
int submission_mode
Definition: qsmtpd.c:85
int relayclient
Definition: qsmtpd.c:70
unsigned int spf
Definition: qsmtpd.h:38
unsigned int check2822
Definition: qsmtpd.h:35
string liphost
Definition: qsmtpd.c:81
const char * remoteport
Definition: qsmtpd.h:48
unsigned int datatype
Definition: qsmtpd.h:37
int len
Definition: qsmtpd.h:19
string helostr
Definition: qsmtpd.h:49
Definition: qsmtpd.h:17
unsigned int flags
Definition: qsmtpd.h:23
string authname
Definition: qsmtpd.h:43
headers of functions for DNS lookups
long state
Definition: qsmtpd.h:22
const char * spfmechanism
Definition: qsmtpd.h:56
string msgidhost
Definition: qsmtpd.c:80
struct in6_addr sremoteip
Definition: qsmtpd.h:51
unsigned int goodrcpt
Definition: qsmtpd.c:75
string remotehost
Definition: qsmtpd.h:45
unsigned int helostatus
Definition: qsmtpd.h:36
int authhide
Definition: qsmtpd.c:84
void freedata(void)
free all ressources allocated for mail transaction
Definition: qsmtpd.c:381
struct ips * frommx
Definition: qsmtpd.h:54
const char * remoteinfo
Definition: qsmtpd.h:47
pid_t fork_clean()
fork() but clean up internal structures
Definition: qsmtpd.c:409
definition of string record and headers of corresponding helper functions
char * spfexp
Definition: qsmtpd.h:55
string heloname
Definition: common_setup.c:16
struct in6_addr slocalip
Definition: qsmtpd.h:53
string mailfrom
Definition: qsmtpd.h:42
int pipe_move(int p[2], int target)
move the read end of the pipe to the target descriptor
Definition: child.c:22
unsigned long comstate
Definition: qsmtpd.c:83
int ok
Definition: qsmtpd.h:98
unsigned long databytes
Definition: qsmtpd.c:74
char * name
Definition: qsmtpd.h:18
size_t thisbytes
Definition: qsmtpd.h:41
unsigned long sslauth
Definition: qsmtpd.c:73
unsigned int ipv4conn
Definition: qsmtpd.h:34
char remoteip[INET6_ADDRSTRLEN]
Definition: qsmtpd.h:46
Definition: qsmtpd.h:32
int fromdomain
Definition: qsmtpd.h:39
void conn_cleanup(const int rc)
clean up the allocated data and exit the process
Definition: qsmtpd.c:447