diff options
Diffstat (limited to 'bin/tests/system/formerr')
-rw-r--r-- | bin/tests/system/formerr/clean.sh | 16 | ||||
-rw-r--r-- | bin/tests/system/formerr/formerr.pl | 95 | ||||
-rw-r--r-- | bin/tests/system/formerr/nametoolong | 19 | ||||
-rw-r--r-- | bin/tests/system/formerr/noquestions | 1 | ||||
-rw-r--r-- | bin/tests/system/formerr/ns1/named.conf.in | 26 | ||||
-rw-r--r-- | bin/tests/system/formerr/ns1/root.db | 19 | ||||
-rw-r--r-- | bin/tests/system/formerr/setup.sh | 16 | ||||
-rw-r--r-- | bin/tests/system/formerr/tests.sh | 45 | ||||
-rw-r--r-- | bin/tests/system/formerr/twoquestions | 7 |
9 files changed, 244 insertions, 0 deletions
diff --git a/bin/tests/system/formerr/clean.sh b/bin/tests/system/formerr/clean.sh new file mode 100644 index 0000000..0bb0e3d --- /dev/null +++ b/bin/tests/system/formerr/clean.sh @@ -0,0 +1,16 @@ +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +rm -f nametoolong.out +rm -f twoquestions.out +rm -f noquestions.out +rm -f ns*/named.conf +rm -f ns*/named.lock +rm -f ns*/named.run +rm -f ns*/named.memstats diff --git a/bin/tests/system/formerr/formerr.pl b/bin/tests/system/formerr/formerr.pl new file mode 100644 index 0000000..f0937e2 --- /dev/null +++ b/bin/tests/system/formerr/formerr.pl @@ -0,0 +1,95 @@ +#!/usr/bin/perl +# +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +# This is a tool for sending an arbitrary packet via UDP or TCP to an +# arbitrary address and port. The packet is specified in a file or on +# the standard input, in the form of a series of bytes in hexidecimal. +# Whitespace is ignored, as is anything following a '#' symbol. +# +# For example, the following input would generate normal query for +# isc.org/NS/IN": +# +# # QID: +# 0c d8 +# # header: +# 01 00 00 01 00 00 00 00 00 00 +# # qname isc.org: +# 03 69 73 63 03 6f 72 67 00 +# # qtype NS: +# 00 02 +# # qclass IN: +# 00 01 +# +# Note that we do not wait for a response for the server. This is simply +# a way of injecting arbitrary packets to test server resposnes. +# +# Usage: packet.pl [-a <address>] [-p <port>] [-t (udp|tcp)] [filename] +# +# If not specified, address defaults to 127.0.0.1, port to 53, protocol +# to udp, and file to stdin. +# +# XXX: Doesn't support IPv6 yet + +require 5.006_001; + +use strict; +use Getopt::Std; +use IO::File; +use IO::Socket; + +sub usage { + print ("Usage: packet.pl [-a address] [-p port] [file]\n"); + exit 1; +} + +my %options={}; +getopts("a:p:", \%options); + +my $addr = "127.0.0.1"; +$addr = $options{a} if defined $options{a}; + +my $port = 53; +$port = $options{p} if defined $options{p}; + +my $file = "STDIN"; +if (@ARGV >= 1) { + my $filename = shift @ARGV; + open FH, "<$filename" or die "$filename: $!"; + $file = "FH"; +} + +my $input = ""; +while (defined(my $line = <$file>) ) { + chomp $line; + $line =~ s/#.*$//; + $input .= $line; +} + +$input =~ s/\s+//g; +my $data = pack("H*", $input); +my $len = length $data; + +my $output = unpack("H*", $data); +print ("sending: $output\n"); + +my $sock = IO::Socket::INET->new(PeerAddr => $addr, PeerPort => $port, + Proto => "tcp") or die "$!"; + +my $bytes; +$bytes = $sock->syswrite(pack("n", $len), 2); +$bytes = $sock->syswrite($data, $len); +$bytes = $sock->sysread($data, 2); +$len = unpack("n", $data); +$bytes = $sock->sysread($data, $len); +print "got: ", unpack("H*", $data). "\n"; + +$sock->close; +close $file; diff --git a/bin/tests/system/formerr/nametoolong b/bin/tests/system/formerr/nametoolong new file mode 100644 index 0000000..b81545f --- /dev/null +++ b/bin/tests/system/formerr/nametoolong @@ -0,0 +1,19 @@ +00 00 00 00 00 01 00 00 00 00 00 00 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0f 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 +0e 41 41 41 41 41 41 41 41 41 41 41 41 41 41 00 +00 01 +00 01 diff --git a/bin/tests/system/formerr/noquestions b/bin/tests/system/formerr/noquestions new file mode 100644 index 0000000..f087bcd --- /dev/null +++ b/bin/tests/system/formerr/noquestions @@ -0,0 +1 @@ +00 00 00 00 00 00 00 00 00 00 00 00 diff --git a/bin/tests/system/formerr/ns1/named.conf.in b/bin/tests/system/formerr/ns1/named.conf.in new file mode 100644 index 0000000..b24ceaa --- /dev/null +++ b/bin/tests/system/formerr/ns1/named.conf.in @@ -0,0 +1,26 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +options { + query-source address 10.53.0.1; + notify-source 10.53.0.1; + transfer-source 10.53.0.1; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.1; }; + listen-on-v6 { none; }; + recursion no; +}; + +zone "." { + type master; + file "root.db"; +}; diff --git a/bin/tests/system/formerr/ns1/root.db b/bin/tests/system/formerr/ns1/root.db new file mode 100644 index 0000000..9515924 --- /dev/null +++ b/bin/tests/system/formerr/ns1/root.db @@ -0,0 +1,19 @@ +; Copyright (C) Internet Systems Consortium, Inc. ("ISC") +; +; This Source Code Form is subject to the terms of the Mozilla Public +; License, v. 2.0. If a copy of the MPL was not distributed with this +; file, You can obtain one at http://mozilla.org/MPL/2.0/. +; +; See the COPYRIGHT file distributed with this work for additional +; information regarding copyright ownership. + +$TTL 300 +. IN SOA marka.isc.org. a.root.servers.nil. ( + 2010 ; serial + 600 ; refresh + 600 ; retry + 1200 ; expire + 600 ; minimum + ) +. NS a.root-servers.nil. +a.root-servers.nil. A 10.53.0.4 diff --git a/bin/tests/system/formerr/setup.sh b/bin/tests/system/formerr/setup.sh new file mode 100644 index 0000000..7e60631 --- /dev/null +++ b/bin/tests/system/formerr/setup.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +SYSTEMTESTTOP=.. +. $SYSTEMTESTTOP/conf.sh + +$SHELL clean.sh +copy_setports ns1/named.conf.in ns1/named.conf diff --git a/bin/tests/system/formerr/tests.sh b/bin/tests/system/formerr/tests.sh new file mode 100644 index 0000000..d8b91e8 --- /dev/null +++ b/bin/tests/system/formerr/tests.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +SYSTEMTESTTOP=.. +. $SYSTEMTESTTOP/conf.sh + +status=0 + +echo_i "test name too long" +$PERL formerr.pl -a 10.53.0.1 -p ${PORT} nametoolong > nametoolong.out +ans=`grep got: nametoolong.out` +if [ "${ans}" != "got: 000080010000000000000000" ]; +then + echo_i "failed"; status=`expr $status + 1`; +fi + +echo_i "two questions" +$PERL formerr.pl -a 10.53.0.1 -p ${PORT} twoquestions > twoquestions.out +ans=`grep got: twoquestions.out` +if [ "${ans}" != "got: 000080010000000000000000" ]; +then + echo_i "failed"; status=`expr $status + 1`; +fi + +# this would be NOERROR if it included a COOKIE option, +# but is a FORMERR without one. +echo_i "empty question section (and no COOKIE option)" +$PERL formerr.pl -a 10.53.0.1 -p ${PORT} noquestions > noquestions.out +ans=`grep got: noquestions.out` +if [ "${ans}" != "got: 000080010000000000000000" ]; +then + echo_i "failed"; status=`expr $status + 1`; +fi + +echo_i "exit status: $status" + +[ $status -eq 0 ] || exit 1 diff --git a/bin/tests/system/formerr/twoquestions b/bin/tests/system/formerr/twoquestions new file mode 100644 index 0000000..2192e3d --- /dev/null +++ b/bin/tests/system/formerr/twoquestions @@ -0,0 +1,7 @@ +00 00 00 00 00 02 00 00 00 00 00 00 +0e 41 41 41 41 41 41 41 41 41 41 41 41 41 41 00 +00 01 +00 02 +0e 41 41 41 41 41 41 41 41 41 41 41 41 41 41 00 +00 01 +00 01 |