Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / bin / tests / system / rpzrecurse / testgen.pl
blob6d774a0ae640ad9bcd5cf593c29b599256ded171
1 #!/usr/bin/env perl
3 # Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 # PERFORMANCE OF THIS SOFTWARE.
17 use strict;
18 use warnings;
20 my $boilerplate_header = <<'EOB';
21 # common configuration
22 include "named.conf.header";
24 view "recursive" {
25 zone "." {
26 type hint;
27 file "root.hint";
30 # policy configuration to be tested
31 response-policy {
32 EOB
34 my $no_option = <<'EOB';
37 # policy zones to be tested
38 EOB
40 my $qname_wait_recurse = <<'EOB';
41 } qname-wait-recurse no;
43 # policy zones to be tested
44 EOB
46 my $boilerplate_end = <<'EOB';
48 EOB
50 my $policy_option = $qname_wait_recurse;
52 my $serialnum = "1";
53 my $policy_zone_header = <<'EOH';
54 $TTL 60
55 @ IN SOA root.ns ns SERIAL 3600 1800 86400 60
56 NS ns
57 ns A 127.0.0.1
58 EOH
60 sub policy_client_ip {
61 return "32.1.0.0.127.rpz-client-ip CNAME .\n";
64 sub policy_qname {
65 my $query_nbr = shift;
66 return sprintf "q%02d.l2.l1.l0 CNAME .\n", $query_nbr;
69 sub policy_ip {
70 return "32.255.255.255.255.rpz-ip CNAME .\n";
73 sub policy_nsdname {
74 return "ns.example.org.rpz-nsdname CNAME .\n";
77 sub policy_nsip {
78 return "32.255.255.255.255.rpz-ip CNAME .\n";
81 my %static_triggers = (
82 'client-ip' => \&policy_client_ip,
83 'ip' => \&policy_ip,
84 'nsdname' => \&policy_nsdname,
85 'nsip' => \&policy_nsip,
88 sub mkconf {
89 my $case_id = shift;
90 my $n_queries = shift;
92 { # generate the query list
93 my $query_list_filename = "ns2/$case_id.queries";
94 my $query_list_fh;
96 open $query_list_fh, ">$query_list_filename" or die;
98 for( my $i = 1; $i <= $n_queries; $i++ ) {
99 print $query_list_fh sprintf "q%02d.l2.l1.l0\n", $i;
103 my @zones;
105 { # generate the conf file
106 my $conf_filename = "ns2/named.$case_id.conf";
108 my $conf_fh;
110 open $conf_fh, ">$conf_filename" or die;
112 print $conf_fh $boilerplate_header;
114 my $zone_seq = 0;
116 @zones = map {
118 sprintf( "$case_id.%02d.policy.local", $zone_seq++ ),
121 } @_;
123 print $conf_fh map { qq{ zone "$_->[0]";\n} } @zones;
125 print $conf_fh $policy_option;
127 print $conf_fh map { qq{ zone "$_->[0]" { type master; file "db.$_->[0]"; };\n} } @zones;
129 print $conf_fh $boilerplate_end;
132 # generate the policy zone contents
133 foreach my $policy_zone_info( @zones ) {
134 my $policy_zone_name = $policy_zone_info->[0];
135 my $policy_zone_contents = $policy_zone_info->[1];
137 my $policy_zone_filename = "ns2/db.$policy_zone_name";
138 my $policy_zone_fh;
140 open $policy_zone_fh, ">$policy_zone_filename" or die;
142 my $header = $policy_zone_header;
143 $header =~ s/SERIAL/$serialnum/;
144 print $policy_zone_fh $header;
146 foreach my $trigger( @$policy_zone_contents ) {
147 if( exists $static_triggers{$trigger} ) {
148 # matches a trigger type with a static value
149 print $policy_zone_fh $static_triggers{$trigger}->();
151 else {
152 # a qname trigger, where what was specified is the query number it should match
153 print $policy_zone_fh policy_qname( $trigger );
159 mkconf(
160 '1a',
162 [ 'client-ip' ],
165 mkconf(
166 '1b',
168 [ 1 ],
171 mkconf(
172 '1c',
174 [ 'client-ip', 2 ],
177 mkconf(
178 '2a',
180 map { [ $_ ]; } 1 .. 32
183 mkconf(
184 '3a',
186 [ 'ip' ],
189 mkconf(
190 '3b',
192 [ 'nsdname' ],
195 mkconf(
196 '3c',
198 [ 'nsip' ],
201 mkconf(
202 '3d',
204 [ 'ip', 1 ]
207 mkconf(
208 '3e',
210 [ 'nsdname', 1 ]
213 mkconf(
214 '3f',
216 [ 'nsip', 1 ]
220 my $seq_code = 'aa';
221 my $seq_nbr = 0;
223 while( $seq_nbr < 32 ) {
225 mkconf(
226 "4$seq_code",
228 ( map { [ $_ ]; } 1 .. $seq_nbr ),
229 [ 'ip', $seq_nbr + 2 ],
230 ( map { [ $_ + 2 ]; } ($seq_nbr + 1) .. 31 ),
233 $seq_code++;
234 $seq_nbr++;
238 mkconf(
239 '5a',
241 [ 1 ],
242 [ 2, 'ip' ],
243 [ 4 ],
244 [ 5, 'ip' ],
245 [ 6 ],
248 $policy_option = $no_option;
250 mkconf(
251 '6a',
253 [ ],
256 $serialnum = "2";
257 mkconf(
258 '6b',
260 [ 'nsdname' ],
263 $serialnum = "3";
264 mkconf(
265 '6c',
267 [ ],
270 __END__
272 0x01 - has client-ip
273 32.1.0.0.127.rpz-client-ip CNAME .
274 0x02 - has qname
275 qX.l2.l1.l0 CNAME .
276 0x10 - has ip
277 32.255.255.255.255.rpz-ip CNAME .
278 0x20 - has nsdname
279 ns.example.org.rpz-nsdname CNAME .
280 0x40 - has nsip
281 32.255.255.255.255.rpz-nsip CNAME .
283 $case.$seq.policy.local
285 case 1a = 0x01
286 .q01 = (00,0x01)=-r
287 case 1b = 0x02
288 .q01 = (00,0x02)=-r
289 .q02 = (--,----)=+r
290 case 1c = 0x03
291 .q01 = (00,0x01)=-r
293 case 2a = 0x03{32}
294 .q01 = (00,0x02)=-r
295 .q02 = (01,0x02)=-r
297 .q31 = (30,0x02)=-r
298 .q32 = (31,0x02)=-r
299 .q33 = (--,----)=+r
301 case 3a = 0x10
302 .q01 = (00,0x10)=+r
303 case 3b = 0x20
304 .q01 = (00,0x20)=+r
305 case 3c = 0x40
306 .q01 = (00,0x40)=+r
307 case 3d = 0x12
308 .q01 = (00,0x10)=+r
309 .q02 = (00,0x02)=-r
310 case 3e = 0x22
311 .q01 = (00,0x20)=+r
312 .q02 = (00,0x02)=-r
313 case 3f = 0x42
314 .q01 = (00,0x40)=+r
315 .q02 = (00,0x02)=-r
317 case 4aa = 0x12,0x02{31}
318 .q01 = (00,0x10)=+r
319 .q02 = (00,0x02)=-r
320 .q03 = (01,0x02)=+r
322 .q32 = (30,0x02)=+r
323 .q33 = (31,0x02)=+r
324 case 4__ = 0x02{n(1->30)},0x12,0x02{31-n}
325 .q01 = (00,0x02)=-r
327 .q(n+1) = (n,0x10)=+r
328 .q(n+2) = (n,0x02)=-r
330 .q33 = (31,0x02)=+r
331 case 4bf = 0x02{31},0x12
332 .q01 = (00,0x02)=-r
333 .q02 = (01,0x02)=-r
335 .q31 = (30,0x02)=-r
336 .q32 = (31,0x10)=+r
337 .q33 = (31,0x02)=-r
339 case 5a = 0x02,0x12,0x02,0x12,0x02
340 .q01 = (00,0x02)=-r
341 .q02 = (01,0x02)=-r
342 .q03 = (01,0x10)=+r
343 .q04 = (02,0x02)=+r
344 .q05 = (03,0x02)=+r
345 .q06 = (04,0x02)=+r