0
|
1 /* Distributed Checksum Clearinghouse |
|
2 * |
|
3 * DNS blacklist and external filter definitions |
|
4 * |
|
5 * Copyright (c) 2008 by Rhyolite Software, LLC |
|
6 * |
|
7 * This agreement is not applicable to any entity which sells anti-spam |
|
8 * solutions to others or provides an anti-spam solution as part of a |
|
9 * security solution sold to other entities, or to a private network |
|
10 * which employs the DCC or uses data provided by operation of the DCC |
|
11 * but does not provide corresponding data to other users. |
|
12 * |
|
13 * Permission to use, copy, modify, and distribute this software without |
|
14 * changes for any purpose with or without fee is hereby granted, provided |
|
15 * that the above copyright notice and this permission notice appear in all |
|
16 * copies and any distributed versions or copies are either unchanged |
|
17 * or not called anything similar to "DCC" or "Distributed Checksum |
|
18 * Clearinghouse". |
|
19 * |
|
20 * Parties not eligible to receive a license under this agreement can |
|
21 * obtain a commercial license to use DCC by contacting Rhyolite Software |
|
22 * at sales@rhyolite.com. |
|
23 * |
|
24 * A commercial license would be for Distributed Checksum and Reputation |
|
25 * Clearinghouse software. That software includes additional features. This |
|
26 * free license for Distributed ChecksumClearinghouse Software does not in any |
|
27 * way grant permision to use Distributed Checksum and Reputation Clearinghouse |
|
28 * software |
|
29 * |
|
30 * THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL |
|
31 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES |
|
32 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC |
|
33 * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES |
|
34 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, |
|
35 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
|
36 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
|
37 * SOFTWARE. |
|
38 * |
|
39 * Rhyolite Software DCC 1.3.103-1.33 $Revision$ |
|
40 */ |
|
41 |
|
42 #ifndef HELPER_H |
|
43 #define HELPER_H |
|
44 |
|
45 #include "dcc_ck.h" |
|
46 |
|
47 #define HELPER_IDLE_STOP_SECS (10*60) /* helpers die of this much boredom */ |
|
48 #define HELPER_IDLE_RESTART (HELPER_IDLE_STOP_SECS - 30) |
|
49 #define HELPER_AUTO_REAP (HELPER_IDLE_STOP_SECS / 20) |
|
50 |
|
51 #define HELPER_PAT "helper=%d,%d,%d" |
|
52 |
|
53 |
|
54 typedef struct { |
|
55 u_int sn; /* serial # of parent */ |
|
56 u_int gen; /* generation of children */ |
|
57 u_int failures; /* failures in this generation */ |
|
58 int pipe_write; |
|
59 int pipe_read; |
|
60 /* save the socket and its port number obtained for the first child |
|
61 * to give to later children */ |
|
62 SOCKET soc; |
|
63 DCC_SOCKU su; |
|
64 int req_len; |
|
65 int argc; |
|
66 int free_args; |
|
67 char const **argv; |
|
68 pid_t *pids; |
|
69 int total_helpers; |
|
70 int max_helpers; |
|
71 int idle_helpers; |
|
72 int slow_helpers; /* hung or at least slow helpers */ |
|
73 int debug; |
|
74 time_t idle_restart; /* restart helpers after then */ |
|
75 u_char is_child; |
|
76 } HELPER; |
|
77 |
|
78 extern HELPER helper; |
|
79 |
|
80 |
|
81 typedef struct { |
|
82 u_int version; |
|
83 u_int magic; |
|
84 u_int sn; |
|
85 struct timeval start; /* when job started */ |
|
86 time_t avail_us; /* microseconds available for job */ |
|
87 char id[DCC_MSG_ID_LEN+1]; |
|
88 } HELPER_REQ_HDR; |
|
89 |
|
90 typedef struct { |
|
91 u_int version; |
|
92 u_int magic; |
|
93 u_int sn; |
|
94 } HELPER_RESP_HDR; |
|
95 |
|
96 #define HELPER_VERSION 0x10 |
|
97 #define HELPER_MAGIC_REQ 0xbeefdead |
|
98 #define HELPER_MAGIC_RESP 0xdeadbeef |
|
99 |
|
100 typedef struct { |
|
101 HELPER_REQ_HDR hdr; |
|
102 DNSBL_FGS fg; /* what to look for */ |
|
103 DNSBL_UNHIT unhit; /* groups of DNSBLs not still yet hit */ |
|
104 DNSBL_FGS fgs[MAX_DNSBL_GROUPS]; |
|
105 DNSBL_TGT tgt; |
|
106 } DNSBL_REQ; |
|
107 |
|
108 typedef struct { |
|
109 DNSBL_FGS fgs; /* what was found */ |
|
110 int bl_num; /* # of DNSBL hit */ |
|
111 char result[DCC_SU2STR_SIZE]; /* IP address found in DNSBL */ |
|
112 DNSBL_DOM tgt; /* name or address sought in DNSBL */ |
|
113 DNSBL_DOM probe; /* what was actually looked up */ |
|
114 } DNSBL_RESP_GROUP; |
|
115 typedef struct { |
|
116 HELPER_RESP_HDR hdr; |
|
117 DNSBL_UNHIT unhit; /* groups of DNSBLs not yet hit */ |
|
118 DNSBL_RESP_GROUP groups[MAX_DNSBL_GROUPS]; |
|
119 } DNSBL_RESP; |
|
120 |
|
121 |
|
122 extern void NRATTRIB helper_child(SOCKET, int, int); |
|
123 extern void reap_helpers(u_char); |
|
124 extern u_char ask_helper(DCC_CLNT_CTXT *, void *, time_t, |
|
125 HELPER_REQ_HDR *, int, HELPER_RESP_HDR *, int); |
|
126 |
|
127 extern u_char dnsbl_work(const DNSBL_REQ *, DNSBL_RESP *); |
|
128 |
|
129 #endif /* HELPER_H */ |