2 * Copyright (c) 2003 Proofpoint, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
9 * Contributed by Jose Marcio Martins da Cruz - Ecole des Mines de Paris
10 * Jose-Marcio.Martins@ensmp.fr
13 /* a part of this code is based on inetd.c for which this copyright applies: */
15 * Copyright (c) 1983, 1991, 1993, 1994
16 * The Regents of the University of California. All rights reserved.
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 * 3. All advertising materials mentioning features or use of this software
27 * must display the following acknowledgement:
28 * This product includes software developed by the University of
29 * California, Berkeley and its contributors.
30 * 4. Neither the name of the University nor the names of its contributors
31 * may be used to endorse or promote products derived from this software
32 * without specific prior written permission.
34 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
35 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
38 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
43 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 ** stuff included - given some warnings (inet_ntoa)
54 ** - surely not everything is needed
57 #if NETINET || NETINET6
58 # include <arpa/inet.h>
68 # define RATECTL_DEBUG 0
71 /* this should be a power of 2, otherwise CPMHMASK doesn't work well */
73 # define CPMHSIZE 1024
76 #define CPMHMASK (CPMHSIZE-1)
79 /* Number of connections for a certain "tick" */
82 unsigned long ct_Ticks;
89 #if NETINET6 && NETINET
92 struct in_addr c4_Addr;
93 struct in6_addr c6_Addr;
95 # define ch_Addr4 cu_Addr.c4_Addr
96 # define ch_Addr6 cu_Addr.c6_Addr
97 #else /* NETINET6 && NETINET */
99 struct in6_addr ch_Addr;
100 # define ch_Addr6 ch_Addr
101 # else /* NETINET6 */
102 struct in_addr ch_Addr;
103 # define ch_Addr4 ch_Addr
104 # endif /* NETINET6 */
105 #endif /* NETINET6 && NETINET */
109 unsigned long ch_colls;
111 /* 6 buckets for ticks: 60s */
112 CTime_T ch_Times[CHTSIZE];
114 int ch_oc; /* open connections */
119 #define SM_CLFL_NONE 0x00
120 #define SM_CLFL_UPDATE 0x01
121 #define SM_CLFL_EXC 0x02 /* check if limit is exceeded */
123 extern void connection_rate_check __P((SOCKADDR *, ENVELOPE *));
124 extern int conn_limits __P((ENVELOPE *, time_t, SOCKADDR *, int, CHash_T *, int, int));
125 extern bool occ_exceeded __P((ENVELOPE *, MCI *, const char *, SOCKADDR *));
126 extern bool occ_close __P((ENVELOPE *, MCI *, const char *, SOCKADDR *));
127 extern void dump_ch __P((SM_FILE_T *));
128 #endif /* ! RATECTRL_H */