Compare commits
145 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3d0d44b14 | ||
|
|
dfcc6d0ae8 | ||
|
|
ddf1be3ff0 | ||
|
|
5939589262 | ||
|
|
b7094f374a | ||
|
|
1aac646480 | ||
|
|
dc14e9192d | ||
|
|
158eb6d7ab | ||
|
|
19f9698617 | ||
|
|
75778f05fc | ||
|
|
8ea2c27256 | ||
|
|
76b29b90c5 | ||
|
|
2d4608f817 | ||
|
|
45b14c489d | ||
|
|
5930d8ab30 | ||
|
|
31b349d025 | ||
|
|
470a973e50 | ||
|
|
566167f935 | ||
|
|
f88d50dc84 | ||
|
|
08fb898c6f | ||
|
|
da7f1a0520 | ||
|
|
376b4b944d | ||
|
|
9002d70655 | ||
|
|
1a3518cca3 | ||
|
|
3e4ebe51ad | ||
|
|
3fec0be47f | ||
|
|
93095c4d53 | ||
|
|
b86ea45de3 | ||
|
|
ef6958e0a5 | ||
|
|
b590f9eff8 | ||
|
|
107d933e97 | ||
|
|
e45ea32b07 | ||
|
|
23a78da970 | ||
|
|
dd010363a5 | ||
|
|
6089276fdd | ||
|
|
3e91b30dea | ||
|
|
62d883a72f | ||
|
|
e10e40b9c9 | ||
|
|
e7ad36a62d | ||
|
|
74c207a5ab | ||
|
|
cc1bf03eb5 | ||
|
|
11320638f6 | ||
|
|
299f44d3b2 | ||
|
|
44e2022878 | ||
|
|
abea1e6db8 | ||
|
|
876ab5140e | ||
|
|
f4ad59d79c | ||
|
|
d1880ec922 | ||
|
|
8179cd022d | ||
|
|
3b786c01f5 | ||
|
|
a09ff28a99 | ||
|
|
b6e1646ae9 | ||
|
|
33c7e6ef6e | ||
|
|
6b52e24008 | ||
|
|
6369575861 | ||
|
|
8ecad4ee2e | ||
|
|
8cee20f743 | ||
|
|
64251bf2ed | ||
|
|
27a94b364e | ||
|
|
1162114456 | ||
|
|
2fcb761366 | ||
|
|
03d5137280 | ||
|
|
210c2d020f | ||
|
|
41ce653860 | ||
|
|
a87239f9de | ||
|
|
1153367782 | ||
|
|
4a31eb33ca | ||
|
|
dec7e52a8b | ||
|
|
fb4d841853 | ||
|
|
50a61b62b3 | ||
|
|
4f1dc76ae1 | ||
|
|
570750713e | ||
|
|
268c38992c | ||
|
|
02fe70191c | ||
|
|
767919f75d | ||
|
|
52469521f0 | ||
|
|
4904a3a12d | ||
|
|
10ca4ff351 | ||
|
|
43eb82666d | ||
|
|
eaedbce579 | ||
|
|
06d37959ab | ||
|
|
311c8d03fa | ||
|
|
188cc74edf | ||
|
|
9fc9a94a2f | ||
|
|
02f19fbd8e | ||
|
|
04ca63661a | ||
|
|
966d673d66 | ||
|
|
3f1b1020d9 | ||
|
|
4f6b82d5aa | ||
|
|
dea7c1ecd4 | ||
|
|
5a57443c63 | ||
|
|
c7632b2f48 | ||
|
|
f17554deb0 | ||
|
|
7ae8d0386f | ||
|
|
562f662a03 | ||
|
|
62d7143b97 | ||
|
|
0bff1e596a | ||
|
|
2d70d20dc4 | ||
|
|
eff5a7ccfd | ||
|
|
ec72e372b8 | ||
|
|
9328be2f94 | ||
|
|
d2f60654d7 | ||
|
|
bd67af7e3d | ||
|
|
09ed371c7c | ||
|
|
e10f6d07f6 | ||
|
|
b79bf0872a | ||
|
|
56b970d184 | ||
|
|
0804543b37 | ||
|
|
36dee741fb | ||
|
|
907b305fd0 | ||
|
|
3ae6834c9a | ||
|
|
13b5f3d464 | ||
|
|
4a3d1a99d7 | ||
|
|
65ae6ac390 | ||
|
|
56ceb9db8e | ||
|
|
831acf3232 | ||
|
|
49da32935f | ||
|
|
f03aa2d025 | ||
|
|
0918a266f0 | ||
|
|
48b7b8fb19 | ||
|
|
bce7c42fd2 | ||
|
|
938a977a42 | ||
|
|
262564cb76 | ||
|
|
f682d506e4 | ||
|
|
289b5961b3 | ||
|
|
f6938dad17 | ||
|
|
9a60f89086 | ||
|
|
169c2f4094 | ||
|
|
e149301460 | ||
|
|
f13db7a635 | ||
|
|
3aba6023de | ||
|
|
dbe83aa9d7 | ||
|
|
55115bffc3 | ||
|
|
f2383e8327 | ||
|
|
ed9e25e312 | ||
|
|
db55ad5320 | ||
|
|
19902e415f | ||
|
|
b761459e7b | ||
|
|
3d28abda8b | ||
|
|
e82fe0b699 | ||
|
|
743ab113b4 | ||
|
|
1ce3c31379 | ||
|
|
0073346086 | ||
|
|
6491263704 | ||
|
|
65bfedf5a0 |
171
CHANGES
171
CHANGES
@@ -1,91 +1,71 @@
|
||||
714. [bug] Preserve interval timers across reloads unless changed.
|
||||
[RT# 729]
|
||||
|
||||
713. [func] named-checkconf takes '-t directory' similar to named.
|
||||
[RT #726]
|
||||
--- 9.1.1rc2 released ---
|
||||
|
||||
712. [bug] Sending a large signed update message caused an
|
||||
assertion failure. [RT #718]
|
||||
733. [bug] Reference counts of dns_acl_t objects need to be
|
||||
locked but were not. [RT #801]
|
||||
|
||||
708. [bug] When building with --with-openssl, the openssl headers
|
||||
included with BIND 9 should not be used. [RT #702]
|
||||
|
||||
--- 9.1.1rc1 released ---
|
||||
|
||||
729. [port] pthread_setconcurrency() needs to be called on Solaris.
|
||||
|
||||
727. [port] Work around OS bug where accept() succeeds but
|
||||
fails to fill in the peer address of the accepted
|
||||
connection, by treating it as an error rather than
|
||||
an assertion failure. [RT #809]
|
||||
|
||||
723. [bug] Referrals whose NS RRs had a 0 TTL caused the resolver
|
||||
to return DNS_R_SERVFAIL. [RT #783]
|
||||
|
||||
720. [bug] Server could enter infinite loop in
|
||||
dispatch.c:do_cancel(). [RT #733]
|
||||
|
||||
719. [bug] Rapid reloads could trigger an assertion failure.
|
||||
[RT #743, #763]
|
||||
|
||||
717. [bug] Certain TKEY processing failure modes could
|
||||
reference an uninitialized variable, causing the
|
||||
server to crash. [RT #750]
|
||||
|
||||
716. [bug] The first line of a $INCLUDE master file was lost if
|
||||
an origin was specified. [RT #744]
|
||||
|
||||
715. [bug] Resolving some A6 chains could cause an assertion
|
||||
failure in adb.c. [RT #738]
|
||||
|
||||
711. [bug] The libisc and liblwres implementations of
|
||||
inet_ntop contained an off by one error.
|
||||
|
||||
710. [func] The forwarders statement now takes an optional
|
||||
port. [RT #418]
|
||||
|
||||
709. [bug] ANY or SIG queries for data with a TTL of 0
|
||||
would return SERVFAIL. [RT #620]
|
||||
|
||||
708. [bug] When building with --with-openssl, the openssl headers
|
||||
included should not be used. [RT #702]
|
||||
|
||||
707. [func] The "filename" argument to named-checkzone is no
|
||||
longer optional, to reduce confusion. [RT #612]
|
||||
|
||||
706. [bug] Zones with an explicit "allow-update { none; };"
|
||||
were considered dynamic and therefore not reloaded
|
||||
on SIGHUP or "rndc reload".
|
||||
|
||||
705. [port] Work out resource limit type for use where rlim_t is
|
||||
not available. [RT #695]
|
||||
|
||||
704. [port] RLIMIT_NOFILE is not available on all platforms.
|
||||
[RT #695]
|
||||
|
||||
703. [port] sys/select.h is needed on older platforms. [RT #695]
|
||||
|
||||
702. [func] If the address 0.0.0.0 is seen in resolv.conf,
|
||||
use 127.0.0.1 instead. [RT #693]
|
||||
|
||||
701. [func] Root hints are now fully optional. Class IN
|
||||
views use compiled-in hints by default, as
|
||||
before. Non-IN views with no root hints now
|
||||
provide authoritative service but not recursion.
|
||||
A warning is logged if a view has neither root
|
||||
hints nor authoritative data for the root. [RT #696]
|
||||
|
||||
700. [bug] $GENERATE range check was wrong. [RT #688]
|
||||
|
||||
699. [bug] The lexer mishandled empty quoted strings. [RT #694]
|
||||
|
||||
698. [bug] Aborting nsupdate with ^C would lead to several
|
||||
race conditions.
|
||||
|
||||
697. [bug] nsupdate was not compatible with the undocumented
|
||||
BIND 8 behavior of ignoring TTLs in "update delete"
|
||||
commands. [RT #693]
|
||||
|
||||
696. [bug] lwresd would die with an assertion failure when passed
|
||||
a zero-length name. [RT #692]
|
||||
|
||||
695. [bug] If the resolver attempted to query a blackholed or
|
||||
bogus server, the resolution would fail immediately.
|
||||
699. [bug] The lexer mishandled empty quoted strings. [RT #694]
|
||||
|
||||
694. [bug] $GENERATE did not produce the last entry.
|
||||
[RT #682, #683]
|
||||
|
||||
693. [bug] An empty lwres statement in named.conf caused
|
||||
the server to crash while loading.
|
||||
693. [bug] An empty lwres statement in named.conf caused
|
||||
the server to crash while loading.
|
||||
|
||||
692. [bug] Deal with systems that have getaddrinfo() but not
|
||||
gai_strerror(). [RT #679]
|
||||
|
||||
691. [bug] Configuring per-view forwarders caused an assertion
|
||||
failure. [RT #675]
|
||||
failure. [RT #675, #734]
|
||||
|
||||
690. [func] $GENERATE now supports DNAME. [RT #654]
|
||||
|
||||
689. [doc] man pages are now installed. [RT #210]
|
||||
|
||||
688. [func] "make tags" now works on systems with the
|
||||
"Exuberant Ctags" etags.
|
||||
--- 9.1.0 released ---
|
||||
|
||||
687. [bug] Only say we have IPv6, with sufficent functionality,
|
||||
if it has actually been tested. [RT #586]
|
||||
|
||||
686. [bug] dig and nslookup can now be properly aborted during
|
||||
blocking operations. [RT #568]
|
||||
|
||||
685. [bug] nslookup should use the search list/domain options
|
||||
from resolv.conf by default. [RT #405, #630]
|
||||
|
||||
@@ -100,6 +80,14 @@
|
||||
680. [bug] dns_rdata_fromstruct() mishandled options bigger
|
||||
than 255 octets.
|
||||
|
||||
652. [bug] zone_saveunique() did not report the new name.
|
||||
[RT #668]
|
||||
|
||||
650. [bug] SIG(0) records were being generated and verified
|
||||
incorrectly. [RT #606]
|
||||
|
||||
--- 9.1.0rc1 released ---
|
||||
|
||||
679. [bug] $INCLUDE could leak memory and file descriptors on
|
||||
reload. [RT #639]
|
||||
|
||||
@@ -116,85 +104,43 @@
|
||||
675. [bug] TKEY queries could cause the server to leak
|
||||
memory.
|
||||
|
||||
674. [func] Allow messages to be TSIG signed / verified using
|
||||
a offset from the current time.
|
||||
|
||||
673. [func] The server can now convert RFC1886-style recursive
|
||||
lookup requests into RFC2874-style lookups, when
|
||||
enabled using the new option "allow-v6-synthesis".
|
||||
|
||||
672. [bug] The wrong time was in the "time signed" field when
|
||||
replying with BADTIME error.
|
||||
|
||||
671. [bug] The message code was failing to parse a message with
|
||||
no question section and a TSIG record. [RT #628]
|
||||
|
||||
670. [bug] The lwres replacements for getaddrinfo and
|
||||
getipnodebyname didn't properly check for the
|
||||
existence of the sockaddr sa_len field.
|
||||
|
||||
669. [func] dnssec-keygen now makes the public key file
|
||||
non-world-readable for symmetric keys. [RT #403]
|
||||
|
||||
668. [func] named-checkzone now reports multiple errors in master
|
||||
files.
|
||||
|
||||
667. [bug] On Linux, running named with the -u option and a
|
||||
non-world-readable configuration file didn't work.
|
||||
[RT #626]
|
||||
|
||||
--- 9.1.0b3 released ---
|
||||
|
||||
666. [bug] If a request sent by dig is longer than 512 bytes,
|
||||
use TCP.
|
||||
|
||||
665. [bug] Signed responses were not sent when the size of the
|
||||
TSIG + question exceeded the maximum message size.
|
||||
[RT #628]
|
||||
|
||||
664. [bug] The t_tasks and t_timers module tests are now skipped
|
||||
when building without threads, since they require
|
||||
threads.
|
||||
|
||||
663. [func] Accept a size_spec, not just an integer, in the
|
||||
(unimplemented and ignored) max-ixfr-log-size option
|
||||
for compatibility with recent versions of BIND 8.
|
||||
[RT #613]
|
||||
|
||||
662. [bug] dns_rdata_fromtext() failed to log certain errors.
|
||||
|
||||
661. [bug] Certain UDP IXFR requests caused an assertion failure
|
||||
(mpctx->allocated == 0). [RT #355, #394, #623]
|
||||
|
||||
660. [port] Detect multiple CPUs on HP-UX and IRIX.
|
||||
|
||||
659. [performance] Rewrite the name compression code to be much faster.
|
||||
|
||||
658. [cleanup] Remove all vestiges of 16 bit global compression.
|
||||
|
||||
657. [bug] When a listen-on statement in an lwres block does not
|
||||
specifiy a port, use 921, not 53. Also update the
|
||||
specify a port, use 921, not 53. Also update the
|
||||
listen-on documentation. [RT #616]
|
||||
|
||||
656. [func] Treat an unescaped newline in a quoted string as
|
||||
an error. This means that TXT records with missing
|
||||
close quotes should have meaningful errors printed.
|
||||
|
||||
655. [bug] Improve error reporting on unexpected eof when loading
|
||||
zones. [RT #611]
|
||||
|
||||
654. [bug] Origin was being forgotten in TCP retries in dig.
|
||||
[RT #574]
|
||||
|
||||
653. [bug] +defname option in dig was reversed in sense.
|
||||
653. [bug] +defname option in dig was reversed in sense.
|
||||
[RT #549]
|
||||
|
||||
652. [bug] zone_saveunique() did not report the new name.
|
||||
|
||||
651. [func] The AD bit in responses now has the meaning
|
||||
specified in <draft-ietf-dnsext-ad-is-secure>.
|
||||
|
||||
650. [bug] SIG(0) records were being generated and verified
|
||||
incorrectly. [RT #606]
|
||||
|
||||
649. [bug] It was possible to join to an already running fctx
|
||||
after it had "cloned" its events, but before it sent
|
||||
them. In this case, the event of the newly joined
|
||||
@@ -204,8 +150,6 @@
|
||||
caused the fetch to fail with a SERVFAIL result.
|
||||
[RT #588, #597, #605, #607]
|
||||
|
||||
648. [port] Add support for pre-RFC2133 IPv6 implementations.
|
||||
|
||||
647. [bug] Resolver queries sent after following multiple
|
||||
referrals had excessively long retransmission
|
||||
timeouts due to incorrectly counting the referrals
|
||||
@@ -214,12 +158,9 @@
|
||||
646. [bug] The UnixWare ISC_PLATFORM_FIXIN6INADDR fix in isc/net.h
|
||||
didn't _cleanly_ fix the problem it was trying to fix.
|
||||
|
||||
645. [port] BSD/OS 3.0 needs pthread_init(). [RT #603]
|
||||
|
||||
644. [bug] #622 needed more work. [RT #562]
|
||||
|
||||
643. [bug] xfrin error messages made more verbose, added class
|
||||
of the zone. [RT# 599]
|
||||
645. [port] BSD/OS 3.0 needs pthread_init(). [RT #603]
|
||||
|
||||
642. [bug] Break the exit_check() race in the zone module.
|
||||
[RT #598]
|
||||
@@ -235,9 +176,9 @@
|
||||
639. [bug] Reading entropy from the keyboard would sometimes fail.
|
||||
[RT #591]
|
||||
|
||||
638. [port] lib/isc/random.c needed to explicitly include time.h
|
||||
to get a prototype for time() when pthreads was not
|
||||
being used. [RT #592]
|
||||
638. [port] lib/isc/random.c needed to explicitly include
|
||||
time.h explicitly to get a prototype for time() when
|
||||
pthreads was not being used. [RT #592]
|
||||
|
||||
637. [port] Use isc_u?int64_t instead of (unsigned) long long in
|
||||
lib/isc/print.c. Also allow lib/isc/print.c to
|
||||
@@ -270,7 +211,7 @@
|
||||
628. [bug] If the root hints contained only AAAA addresses,
|
||||
named would be unable to perform resolution.
|
||||
|
||||
627. [bug] The EDNS0 blackhole detection code of change 324
|
||||
627. [bug] The EDNS0 blackhole detection code of changed 324
|
||||
waited for three retransmissions to each server,
|
||||
which takes much too long when a domain has many
|
||||
name servers and all of them drop EDNS0 queries.
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.37 2001/01/09 21:39:00 bwelling Exp $
|
||||
# $Id: Makefile.in,v 1.36.2.1 2001/01/09 22:31:05 bwelling Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
80
README
80
README
@@ -45,41 +45,61 @@ BIND 9
|
||||
|
||||
|
||||
|
||||
BIND 9.2
|
||||
BIND 9.1.1rc2
|
||||
|
||||
This is a snapshot of the development source tree that
|
||||
will become BIND 9.2. Bind 9.2 will have a number of
|
||||
new features over 9.1, including:
|
||||
BIND 9.1.1rc2 is a release candidate for BIND 9.1.1.
|
||||
It contains fixes for a small number of bugs in
|
||||
BIND 9.1.1rc1 but no new features.
|
||||
|
||||
- The ability to automatically convert RFC1886-style
|
||||
recursive lookup requests into RFC2874-style lookups,
|
||||
enabled using the new option "allow-v6-synthesis".
|
||||
This allows stub resolvers that support AAAA records
|
||||
but not A6 record chains or binary labels to perform
|
||||
lookups in domains that make use of these IPv6 DNS
|
||||
features.
|
||||
Features introduced in 9.1.0 included:
|
||||
|
||||
An IPv6 capable stub resolver based on the BIND 8 resolver
|
||||
code base and fully backwards compatible with existing BIND 8
|
||||
based resolvers is being developed and will be integrated into
|
||||
the BIND 9 distribution when completed.
|
||||
- Many BIND 8 features previously unimplemented in BIND 9,
|
||||
including domain-specific forwarding, the $GENERATE
|
||||
master file directive, and the "blackhole", "dialup",
|
||||
and "sortlist" options
|
||||
|
||||
This distribution already includes a new lightweight stub
|
||||
resolver library and associated resolver daemon that fully
|
||||
support forward and reverse lookups of both IPv4 and IPv6
|
||||
addresses. This library is still considered experimental and
|
||||
is not a complete replacement for the BIND 8 resolver library.
|
||||
Applications that use the BIND 8 res_* functions to perform
|
||||
DNS lookups or dynamic updates still need to be linked against
|
||||
the BIND 8 libraries. For DNS lookups, they can also use the
|
||||
new "getrrsetbyname()" API.
|
||||
- Forwarding of dynamic update requests; this is enabled
|
||||
by the "allow-update-forwarding" option
|
||||
|
||||
BIND 9.2 is capable of acting as an authoritative server
|
||||
- A new, simplified database interface and a number of
|
||||
sample drivers based on it; see doc/misc/sdb for details
|
||||
|
||||
- Support for building single-threaded servers for
|
||||
environments that do not supply POSIX threads
|
||||
|
||||
- New configuration options: "min-refresh-time",
|
||||
"max-refresh-time", "min-retry-time", "max-retry-time",
|
||||
"additional-from-auth", "additional-from-cache",
|
||||
"notify explicit"
|
||||
|
||||
- Faster lookups, particularly in large zones.
|
||||
|
||||
BIND 9.1 also includes experimental implementations of a
|
||||
number of DNS protocols extensions still under development
|
||||
in the IETF. These include transparent processing of
|
||||
unknown RR types and use of the EDNS "DNSSEC OK" bit to
|
||||
explicitly enable DNSSEC processing in responses.
|
||||
|
||||
Cryptographic operations are now based on the OpenSSL
|
||||
library instead of DNSsafe.
|
||||
|
||||
BIND 9.1 is primarily a name server software distribution.
|
||||
In addition to the name server, it also includes a new
|
||||
lightweight stub resolver library and associated resolver
|
||||
daemon that fully support forward and reverse lookups of both
|
||||
IPv4 and IPv6 addresses. This library is still considered
|
||||
experimental and is not a complete replacement for the BIND 8
|
||||
resolver library. Applications that use the BIND 8 res_*
|
||||
functions to perform DNS lookups or dynamic updates still need
|
||||
to be linked against the BIND 8 libraries. For DNS lookups,
|
||||
they can also use the new "getrrsetbyname()" API.
|
||||
|
||||
BIND 9.1 is capable of acting as an authoritative server
|
||||
for DNSSEC secured zones. This functionality is believed to
|
||||
be stable and complete except for lacking support for wildcard
|
||||
records in secure zones.
|
||||
|
||||
When acting as a caching server, BIND 9.2 can be configured
|
||||
When acting as a caching server, BIND 9.1 can be configured
|
||||
to perform DNSSEC secure resolution on behalf of its clients.
|
||||
This part of the DNSSEC implementation is still considered
|
||||
experimental. For detailed information about the state of the
|
||||
@@ -96,7 +116,9 @@ BIND 9.2
|
||||
in the named.conf options statement.
|
||||
|
||||
There are known problems with thread signal handling
|
||||
under Solaris 2.6.
|
||||
under Solaris 2.6 and BSD/OS. We recommend disabling
|
||||
threads with "configure --disable-threads" on these
|
||||
platforms.
|
||||
|
||||
FreeBSD prior to 4.2 and OpenBSD prior to 2.8 log
|
||||
messages like "fcntl(8, F_SETFL, 4): Inappropriate
|
||||
@@ -106,6 +128,7 @@ BIND 9.2
|
||||
|
||||
--with-libtool does not work on AIX.
|
||||
|
||||
|
||||
For a detailed list of user-visible changes from
|
||||
previous releases, see the CHANGES file.
|
||||
|
||||
@@ -134,12 +157,15 @@ Building
|
||||
Slackware Linux 7.0.1 with glibc 2.1.3
|
||||
OpenBSD 2.6, 2.8, -current
|
||||
UnixWare 7.1.1
|
||||
HP-UX 10.20
|
||||
|
||||
To build, just
|
||||
|
||||
./configure
|
||||
make
|
||||
|
||||
Do not use a parallel "make".
|
||||
|
||||
Several environment variables that can be set before running
|
||||
configure will affect compilation:
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: acconfig.h,v 1.33 2001/01/18 22:21:22 bwelling Exp $ */
|
||||
/* $Id: acconfig.h,v 1.31.2.2 2001/02/07 19:26:16 gson Exp $ */
|
||||
|
||||
/***
|
||||
*** This file is not to be included by any public header files, because
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.22 2001/01/09 21:39:05 bwelling Exp $
|
||||
# $Id: Makefile.in,v 1.21.2.1 2001/01/09 22:31:11 bwelling Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.7 2001/01/18 01:33:46 bwelling Exp $
|
||||
# $Id: Makefile.in,v 1.5.2.1 2001/01/09 22:31:13 bwelling Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
@@ -42,8 +42,6 @@ TARGETS = named-checkconf named-checkzone
|
||||
# Alphabetically
|
||||
SRCS = named-checkconf.c named-checkzone.c check-tool.c
|
||||
|
||||
MANPAGES = named-checkconf.8 named-checkzone.8
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
named-checkconf: named-checkconf.@O@ check-tool.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
|
||||
@@ -59,9 +57,7 @@ clean distclean::
|
||||
|
||||
installdirs:
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${sbindir}
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man8
|
||||
|
||||
install:: named-checkconf named-checkzone installdirs
|
||||
install:: named-checkconf named-checkzone
|
||||
${LIBTOOL} ${INSTALL_PROGRAM} named-checkconf ${DESTDIR}${sbindir}
|
||||
${LIBTOOL} ${INSTALL_PROGRAM} named-checkzone ${DESTDIR}${sbindir}
|
||||
for m in ${MANPAGES}; do ${INSTALL_PROGRAM} $$m ${DESTDIR}${mandir}/man8; done
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: check-tool.c,v 1.3 2001/01/09 21:39:07 bwelling Exp $ */
|
||||
/* $Id: check-tool.c,v 1.2.2.1 2001/01/09 22:31:14 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: check-tool.h,v 1.2 2001/01/09 21:39:09 bwelling Exp $ */
|
||||
/* $Id: check-tool.h,v 1.1.2.1 2001/01/09 22:31:15 bwelling Exp $ */
|
||||
|
||||
#ifndef CHECK_TOOL_H
|
||||
#define CHECK_TOOL_H
|
||||
|
||||
@@ -15,18 +15,14 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: named-checkconf.c,v 1.4 2001/01/29 03:23:11 marka Exp $ */
|
||||
/* $Id: named-checkconf.c,v 1.2.2.1 2001/01/09 22:31:16 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/dir.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
@@ -35,12 +31,6 @@
|
||||
|
||||
#include "check-tool.h"
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
fprintf(stderr, "usage: named-checkconf [-t directory] [named.conf]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
zonecbk(dns_c_ctx_t *ctx, dns_c_zone_t *zone, dns_c_view_t *view, void *uap) {
|
||||
|
||||
@@ -62,43 +52,19 @@ optscbk(dns_c_ctx_t *ctx, void *uap) {
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
int c;
|
||||
dns_c_ctx_t *configctx = NULL;
|
||||
const char *conffile = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
dns_c_cbks_t callbacks;
|
||||
isc_log_t *log = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
callbacks.zonecbk = zonecbk;
|
||||
callbacks.optscbk = optscbk;
|
||||
callbacks.zonecbkuap = NULL;
|
||||
callbacks.optscbkuap = NULL;
|
||||
|
||||
while ((c = isc_commandline_parse(argc, argv, "t:")) != EOF) {
|
||||
switch (c) {
|
||||
case 't':
|
||||
result = isc_dir_chroot(isc_commandline_argument);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "isc_dir_chroot: %s\n",
|
||||
isc_result_totext(result));
|
||||
exit(1);
|
||||
}
|
||||
result = isc_dir_chdir("/");
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "isc_dir_chdir: %s\n",
|
||||
isc_result_totext(result));
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (argv[isc_commandline_index] != NULL)
|
||||
conffile = argv[isc_commandline_index];
|
||||
if (argc > 1)
|
||||
conffile = argv[1];
|
||||
if (conffile == NULL || conffile[0] == '\0')
|
||||
conffile = "/etc/named.conf";
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: named-checkzone.c,v 1.11 2001/01/24 00:56:55 gson Exp $ */
|
||||
/* $Id: named-checkzone.c,v 1.6.2.2 2001/01/11 18:30:28 gson Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -61,7 +61,7 @@ static const char *dbtype[] = { "rbt" };
|
||||
static void
|
||||
usage(void) {
|
||||
fprintf(stderr,
|
||||
"usage: named-checkzone [-dq] [-c class] zonename filename\n");
|
||||
"usage: named-checkzone [-dq] [-c class] zone [filename]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,6 @@ setup(char *zonename, char *filename, char *classname) {
|
||||
ERRRET(result, "dns_rdataclass_fromtext");
|
||||
|
||||
dns_zone_setclass(zone, rdclass);
|
||||
dns_zone_setoption(zone, DNS_ZONEOPT_MANYERRORS, ISC_TRUE);
|
||||
|
||||
result = dns_zone_load(zone);
|
||||
|
||||
@@ -123,10 +122,12 @@ main(int argc, char **argv) {
|
||||
int c;
|
||||
char *origin = NULL;
|
||||
char *filename = NULL;
|
||||
char *classname;
|
||||
isc_log_t *lctx = NULL;
|
||||
isc_result_t result;
|
||||
char classname_in[] = "IN";
|
||||
char *classname = classname_in;
|
||||
|
||||
classname = classname_in;
|
||||
|
||||
while ((c = isc_commandline_parse(argc, argv, "c:dqs")) != EOF) {
|
||||
switch (c) {
|
||||
@@ -144,16 +145,20 @@ main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isc_commandline_index + 2 > argc)
|
||||
if (argv[isc_commandline_index] == NULL)
|
||||
usage();
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
if (!quiet)
|
||||
RUNTIME_CHECK(setup_logging(mctx, &lctx) == ISC_R_SUCCESS);
|
||||
|
||||
origin = argv[isc_commandline_index++];
|
||||
filename = argv[isc_commandline_index++];
|
||||
result = setup(origin, filename, classname);
|
||||
origin = argv[isc_commandline_index];
|
||||
isc_commandline_index++;
|
||||
if (argv[isc_commandline_index] != NULL)
|
||||
filename = argv[isc_commandline_index];
|
||||
else
|
||||
filename = origin;
|
||||
result = setup(origin, filename, (char *)classname);
|
||||
if (!quiet && result == ISC_R_SUCCESS)
|
||||
fprintf(stdout, "OK\n");
|
||||
destroy();
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.19 2001/01/18 01:33:48 bwelling Exp $
|
||||
# $Id: Makefile.in,v 1.17.4.1 2001/01/09 22:31:19 bwelling Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
@@ -48,8 +48,6 @@ UOBJS =
|
||||
|
||||
SRCS = dig.c dighost.c host.c nslookup.c
|
||||
|
||||
MANPAGES = dig.1 host.1
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
dig: dig.@O@ dighost.@O@ ${UOBJS} ${DEPLIBS}
|
||||
@@ -66,10 +64,8 @@ clean distclean::
|
||||
|
||||
installdirs:
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${bindir}
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man1
|
||||
|
||||
install:: dig host nslookup installdirs
|
||||
${LIBTOOL} ${INSTALL_PROGRAM} dig ${DESTDIR}${bindir}
|
||||
${LIBTOOL} ${INSTALL_PROGRAM} host ${DESTDIR}${bindir}
|
||||
${LIBTOOL} ${INSTALL_PROGRAM} nslookup ${DESTDIR}${bindir}
|
||||
for m in ${MANPAGES}; do ${INSTALL_PROGRAM} $$m ${DESTDIR}${mandir}/man1; done
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dig.c,v 1.135 2001/01/24 19:28:29 gson Exp $ */
|
||||
/* $Id: dig.c,v 1.131.2.1 2001/01/09 22:31:20 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
@@ -64,6 +64,7 @@ extern int sendcount;
|
||||
extern int ndots;
|
||||
extern int tries;
|
||||
extern int lookup_counter;
|
||||
extern char fixeddomain[MXNAME];
|
||||
extern int exitcode;
|
||||
extern isc_sockaddr_t bind_address;
|
||||
extern char keynametext[MXNAME];
|
||||
@@ -82,8 +83,6 @@ char *batchname = NULL;
|
||||
FILE *batchfp = NULL;
|
||||
char *argv0;
|
||||
|
||||
char domainopt[DNS_NAME_MAXTEXT];
|
||||
|
||||
isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE,
|
||||
nibble = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE;
|
||||
|
||||
@@ -157,7 +156,7 @@ show_usage(void) {
|
||||
" +domain=### (Set default domainname)\n"
|
||||
" +bufsize=### (Set EDNS0 Max UDP packet size)\n"
|
||||
" +[no]search (Set whether to use searchlist)\n"
|
||||
" +[no]defname (Ditto)\n"
|
||||
" +[no]defname (Set whether to use default domain)\n"
|
||||
" +[no]recursive (Recursive mode)\n"
|
||||
" +[no]ignore (Don't revert to TCP for TC responses.)"
|
||||
"\n"
|
||||
@@ -192,14 +191,11 @@ show_usage(void) {
|
||||
* Callback from dighost.c to print the received message.
|
||||
*/
|
||||
void
|
||||
received(int bytes, isc_sockaddr_t *from, dig_query_t *query) {
|
||||
received(int bytes, int frmsize, char *frm, dig_query_t *query) {
|
||||
isc_uint64_t diff;
|
||||
isc_time_t now;
|
||||
isc_result_t result;
|
||||
time_t tnow;
|
||||
char fromtext[ISC_SOCKADDR_FORMATSIZE];
|
||||
|
||||
isc_sockaddr_format(from, fromtext, sizeof(fromtext));
|
||||
|
||||
result = isc_time_now(&now);
|
||||
check_result(result, "isc_time_now");
|
||||
@@ -207,7 +203,8 @@ received(int bytes, isc_sockaddr_t *from, dig_query_t *query) {
|
||||
if (query->lookup->stats) {
|
||||
diff = isc_time_microdiff(&now, &query->time_sent);
|
||||
printf(";; Query time: %ld msec\n", (long int)diff/1000);
|
||||
printf(";; SERVER: %s(%s)\n", fromtext, query->servname);
|
||||
printf(";; SERVER: %.*s(%s)\n", frmsize, frm,
|
||||
query->servname);
|
||||
time(&tnow);
|
||||
printf(";; WHEN: %s", ctime(&tnow));
|
||||
if (query->lookup->doing_xfr) {
|
||||
@@ -228,8 +225,8 @@ received(int bytes, isc_sockaddr_t *from, dig_query_t *query) {
|
||||
puts("");
|
||||
} else if (query->lookup->identify && !short_form) {
|
||||
diff = isc_time_microdiff(&now, &query->time_sent);
|
||||
printf(";; Received %u bytes from %s(%s) in %d ms\n\n",
|
||||
bytes, fromtext, query->servname,
|
||||
printf(";; Received %u bytes from %.*s(%s) in %d ms\n\n",
|
||||
bytes, frmsize, frm, query->servname,
|
||||
(int)diff/1000);
|
||||
}
|
||||
}
|
||||
@@ -598,7 +595,7 @@ parse_int(char *arg, const char *desc, isc_uint32_t max) {
|
||||
/*
|
||||
* We're not using isc_commandline_parse() here since the command line
|
||||
* syntax of dig is quite a bit different from that which can be described
|
||||
* by that routine.
|
||||
* that routine.
|
||||
* XXX doc options
|
||||
*/
|
||||
|
||||
@@ -699,7 +696,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
|
||||
case 'd':
|
||||
switch (cmd[1]) {
|
||||
case 'e': /* defname */
|
||||
usesearch = state;
|
||||
lookup->defname = state;
|
||||
break;
|
||||
case 'n': /* dnssec */
|
||||
lookup->dnssec = state;
|
||||
@@ -709,8 +706,8 @@ plus_option(char *option, isc_boolean_t is_batchfile,
|
||||
goto need_value;
|
||||
if (!state)
|
||||
goto invalid_option;
|
||||
strncpy(domainopt, value, sizeof(domainopt));
|
||||
domainopt[sizeof(domainopt)-1] = '\0';
|
||||
strncpy(fixeddomain, value, sizeof(fixeddomain));
|
||||
fixeddomain[sizeof(fixeddomain)-1]=0;
|
||||
break;
|
||||
default:
|
||||
goto invalid_option;
|
||||
@@ -1372,10 +1369,6 @@ main(int argc, char **argv) {
|
||||
setup_libs();
|
||||
parse_args(ISC_FALSE, ISC_FALSE, argc, argv);
|
||||
setup_system();
|
||||
if (domainopt[0] != '\0') {
|
||||
set_search_domain(domainopt);
|
||||
usesearch = ISC_TRUE;
|
||||
}
|
||||
result = isc_app_onrun(mctx, global_task, onrun_callback, NULL);
|
||||
check_result(result, "isc_app_onrun");
|
||||
isc_app_run();
|
||||
@@ -1385,7 +1378,8 @@ main(int argc, char **argv) {
|
||||
s, default_lookup);
|
||||
s2 = s;
|
||||
s = ISC_LIST_NEXT(s, link);
|
||||
ISC_LIST_DEQUEUE(default_lookup->my_server_list, s2, link);
|
||||
ISC_LIST_DEQUEUE(default_lookup->my_server_list,
|
||||
(dig_server_t *)s2, link);
|
||||
isc_mem_free(mctx, s2);
|
||||
}
|
||||
isc_mem_free(mctx, default_lookup);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dighost.c,v 1.188 2001/01/24 19:28:30 gson Exp $ */
|
||||
/* $Id: dighost.c,v 1.174.2.5 2001/02/07 19:26:20 gson Exp $ */
|
||||
|
||||
/*
|
||||
* Notice to programmers: Do not use this code as an example of how to
|
||||
@@ -91,7 +91,10 @@ isc_boolean_t
|
||||
cancel_now = ISC_FALSE,
|
||||
usesearch = ISC_FALSE,
|
||||
qr = ISC_FALSE,
|
||||
is_dst_up = ISC_FALSE;
|
||||
is_dst_up = ISC_FALSE,
|
||||
have_domain = ISC_FALSE,
|
||||
is_blocking = ISC_FALSE;
|
||||
|
||||
in_port_t port = 53;
|
||||
unsigned int timeout = 0;
|
||||
isc_mem_t *mctx = NULL;
|
||||
@@ -108,7 +111,8 @@ int sockcount = 0;
|
||||
int ndots = -1;
|
||||
int tries = 2;
|
||||
int lookup_counter = 0;
|
||||
|
||||
char fixeddomain[MXNAME] = "";
|
||||
dig_searchlist_t *fixedsearch = NULL;
|
||||
/*
|
||||
* Exit Codes:
|
||||
* 0 Everything went well, including things like NXDOMAIN
|
||||
@@ -361,6 +365,7 @@ make_empty_lookup(void) {
|
||||
looknew->current_query = NULL;
|
||||
looknew->doing_xfr = ISC_FALSE;
|
||||
looknew->ixfr_serial = ISC_FALSE;
|
||||
looknew->defname = ISC_FALSE;
|
||||
looknew->trace = ISC_FALSE;
|
||||
looknew->trace_root = ISC_FALSE;
|
||||
looknew->identify = ISC_FALSE;
|
||||
@@ -415,13 +420,14 @@ clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
|
||||
looknew = make_empty_lookup();
|
||||
INSIST(looknew != NULL);
|
||||
strncpy(looknew->textname, lookold-> textname, MXNAME);
|
||||
looknew->textname[MXNAME-1] = 0;
|
||||
looknew->textname[MXNAME-1]=0;
|
||||
looknew->rdtype = lookold->rdtype;
|
||||
looknew->rdclass = lookold->rdclass;
|
||||
looknew->rdtypeset = lookold->rdtypeset;
|
||||
looknew->rdclassset = lookold->rdclassset;
|
||||
looknew->doing_xfr = lookold->doing_xfr;
|
||||
looknew->ixfr_serial = lookold->ixfr_serial;
|
||||
looknew->defname = lookold->defname;
|
||||
looknew->trace = lookold->trace;
|
||||
looknew->trace_root = lookold->trace_root;
|
||||
looknew->identify = lookold->identify;
|
||||
@@ -443,6 +449,7 @@ clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
|
||||
looknew->section_authority = lookold->section_authority;
|
||||
looknew->section_additional = lookold->section_additional;
|
||||
looknew->retries = lookold->retries;
|
||||
looknew->origin = lookold->origin;
|
||||
#ifdef DNS_OPT_NEWCODES_LIVE
|
||||
strncpy(looknew->viewname, lookold-> viewname, MXNAME);
|
||||
strncpy(looknew->zonename, lookold-> zonename, MXNAME);
|
||||
@@ -589,19 +596,6 @@ setup_file_key(void) {
|
||||
isc_mem_free(mctx, secretstore);
|
||||
}
|
||||
|
||||
static dig_searchlist_t *
|
||||
make_searchlist_entry(char *domain) {
|
||||
dig_searchlist_t *search;
|
||||
search = isc_mem_allocate(mctx, sizeof(*search));
|
||||
if (search == NULL)
|
||||
fatal("Memory allocation failure in %s:%d",
|
||||
__FILE__, __LINE__);
|
||||
strncpy(search->origin, domain, MXNAME);
|
||||
search->origin[MXNAME-1] = 0;
|
||||
ISC_LINK_INIT(search, link);
|
||||
return (search);
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup the system as a whole, reading key information and resolv.conf
|
||||
* settings.
|
||||
@@ -612,7 +606,7 @@ setup_system(void) {
|
||||
FILE *fp;
|
||||
char *ptr;
|
||||
dig_server_t *srv;
|
||||
dig_searchlist_t *search, *domain = NULL;
|
||||
dig_searchlist_t *search;
|
||||
isc_boolean_t get_servers;
|
||||
char *input;
|
||||
|
||||
@@ -622,61 +616,88 @@ setup_system(void) {
|
||||
get_servers = ISC_TF(server_list.head == NULL);
|
||||
fp = fopen(RESOLVCONF, "r");
|
||||
/* XXX Use lwres resolv.conf reader */
|
||||
if (fp == NULL)
|
||||
goto no_file;
|
||||
|
||||
while (fgets(rcinput, MXNAME, fp) != 0) {
|
||||
input = rcinput;
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr != NULL) {
|
||||
if (get_servers &&
|
||||
strcasecmp(ptr, "nameserver") == 0) {
|
||||
debug("got a nameserver line");
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr != NULL) {
|
||||
srv = make_server(ptr);
|
||||
ISC_LIST_APPEND(server_list, srv, link);
|
||||
}
|
||||
} else if (strcasecmp(ptr, "options") == 0) {
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr != NULL) {
|
||||
if((strncasecmp(ptr, "ndots:",
|
||||
6) == 0) &&
|
||||
(ndots == -1)) {
|
||||
ndots = atoi(
|
||||
&ptr[6]);
|
||||
debug("ndots is %d.",
|
||||
ndots);
|
||||
if (fp != NULL) {
|
||||
while (fgets(rcinput, MXNAME, fp) != 0) {
|
||||
input = rcinput;
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr != NULL) {
|
||||
if (get_servers &&
|
||||
strcasecmp(ptr, "nameserver") == 0) {
|
||||
debug("got a nameserver line");
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr != NULL) {
|
||||
srv = make_server(ptr);
|
||||
ISC_LIST_APPEND
|
||||
(server_list,
|
||||
srv, link);
|
||||
}
|
||||
} else if (strcasecmp(ptr, "options") == 0) {
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr != NULL) {
|
||||
if((strncasecmp(ptr, "ndots:",
|
||||
6) == 0) &&
|
||||
(ndots == -1)) {
|
||||
ndots = atoi(
|
||||
&ptr[6]);
|
||||
debug("ndots is "
|
||||
"%d.",
|
||||
ndots);
|
||||
}
|
||||
}
|
||||
} else if (strcasecmp(ptr, "search") == 0){
|
||||
while ((ptr = next_token(&input, " \t\r\n"))
|
||||
!= NULL) {
|
||||
debug("adding search %s",
|
||||
ptr);
|
||||
search = isc_mem_allocate(
|
||||
mctx, sizeof(struct
|
||||
dig_server));
|
||||
if (search == NULL)
|
||||
fatal("Memory "
|
||||
"allocation "
|
||||
"failure in %s:"
|
||||
"%d", __FILE__,
|
||||
__LINE__);
|
||||
strncpy(search->
|
||||
origin,
|
||||
ptr,
|
||||
MXNAME);
|
||||
search->origin[MXNAME-1]=0;
|
||||
ISC_LIST_INITANDAPPEND
|
||||
(search_list,
|
||||
search,
|
||||
link);
|
||||
}
|
||||
} else if ((strcasecmp(ptr, "domain") == 0) &&
|
||||
(fixeddomain[0] == 0 )){
|
||||
have_domain = ISC_TRUE;
|
||||
while ((ptr = next_token(&input, " \t\r\n"))
|
||||
!= NULL) {
|
||||
search = isc_mem_allocate(
|
||||
mctx, sizeof(struct
|
||||
dig_server));
|
||||
if (search == NULL)
|
||||
fatal("Memory "
|
||||
"allocation "
|
||||
"failure in %s:"
|
||||
"%d", __FILE__,
|
||||
__LINE__);
|
||||
strncpy(search->
|
||||
origin,
|
||||
ptr,
|
||||
MXNAME - 1);
|
||||
search->origin[MXNAME-1]=0;
|
||||
ISC_LIST_INITANDPREPEND
|
||||
(search_list,
|
||||
search,
|
||||
link);
|
||||
}
|
||||
}
|
||||
} else if (strcasecmp(ptr, "search") == 0){
|
||||
while ((ptr = next_token(&input, " \t\r\n"))
|
||||
!= NULL) {
|
||||
debug("adding search %s", ptr);
|
||||
search = make_searchlist_entry(ptr);
|
||||
ISC_LIST_INITANDAPPEND(search_list,
|
||||
search, link);
|
||||
}
|
||||
} else if (strcasecmp(ptr, "domain") == 0) {
|
||||
while ((ptr = next_token(&input, " \t\r\n"))
|
||||
!= NULL) {
|
||||
if (domain != NULL)
|
||||
isc_mem_free(mctx, domain);
|
||||
domain = make_searchlist_entry(ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
fclose(fp);
|
||||
no_file:
|
||||
|
||||
if (ISC_LIST_EMPTY(search_list) && domain != NULL) {
|
||||
ISC_LIST_INITANDAPPEND(search_list, domain, link);
|
||||
domain = NULL;
|
||||
}
|
||||
if (domain != NULL)
|
||||
isc_mem_free(mctx, domain);
|
||||
|
||||
if (ndots == -1)
|
||||
ndots = 1;
|
||||
|
||||
@@ -691,27 +712,6 @@ setup_system(void) {
|
||||
setup_text_key();
|
||||
}
|
||||
|
||||
static void
|
||||
clear_searchlist(void) {
|
||||
dig_searchlist_t *search;
|
||||
while ((search = ISC_LIST_HEAD(search_list)) != NULL) {
|
||||
ISC_LIST_UNLINK(search_list, search, link);
|
||||
isc_mem_free(mctx, search);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Override the search list derived from resolv.conf by 'domain'.
|
||||
*/
|
||||
void
|
||||
set_search_domain(char *domain) {
|
||||
dig_searchlist_t *search;
|
||||
|
||||
clear_searchlist();
|
||||
search = make_searchlist_entry(domain);
|
||||
ISC_LIST_APPEND(search_list, search, link);
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup the ISC and DNS libraries for use by the system.
|
||||
*/
|
||||
@@ -815,7 +815,7 @@ add_opt(dns_message_t *msg, isc_uint16_t udpsize, isc_boolean_t dnssec
|
||||
rdata->data = NULL;
|
||||
rdata->length = 0;
|
||||
#ifdef DNS_OPT_NEWCODES_LIVE
|
||||
for (i = 0; i < optlist.used; i++)
|
||||
for (i=0; i<optlist.used; i++)
|
||||
optsize += optlist.attrs[i].value.length + 4;
|
||||
result = isc_buffer_allocate(mctx, &rdatabuf, optsize);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
@@ -1093,6 +1093,7 @@ followup_lookup(dns_message_t *msg, dig_query_t *query,
|
||||
(query->lookup,
|
||||
ISC_FALSE);
|
||||
lookup->doing_xfr = ISC_FALSE;
|
||||
lookup->defname = ISC_FALSE;
|
||||
if (section ==
|
||||
DNS_SECTION_ANSWER) {
|
||||
lookup->trace =
|
||||
@@ -1133,10 +1134,8 @@ followup_lookup(dns_message_t *msg, dig_query_t *query,
|
||||
}
|
||||
|
||||
/*
|
||||
* Create and queue a new lookup using the next origin from the search
|
||||
* Create and queue a new lookup using the next origin from the origin
|
||||
* list, read in setup_system().
|
||||
*
|
||||
* Return ISC_TRUE iff there was another searchlist entry.
|
||||
*/
|
||||
static isc_boolean_t
|
||||
next_origin(dns_message_t *msg, dig_query_t *query) {
|
||||
@@ -1149,6 +1148,16 @@ next_origin(dns_message_t *msg, dig_query_t *query) {
|
||||
debug("next_origin()");
|
||||
debug("following up %s", query->lookup->textname);
|
||||
|
||||
if (fixedsearch == query->lookup->origin) {
|
||||
/*
|
||||
* This is a fixed domain search; there is no next entry.
|
||||
* While we're here, clear out the fixedsearch alloc.
|
||||
*/
|
||||
isc_mem_free(mctx, fixedsearch);
|
||||
fixedsearch = NULL;
|
||||
query->lookup->origin = NULL;
|
||||
return (ISC_FALSE);
|
||||
}
|
||||
if (!usesearch)
|
||||
/*
|
||||
* We're not using a search list, so don't even think
|
||||
@@ -1162,6 +1171,7 @@ next_origin(dns_message_t *msg, dig_query_t *query) {
|
||||
return (ISC_FALSE);
|
||||
cancel_lookup(query->lookup);
|
||||
lookup = requeue_lookup(query->lookup, ISC_TRUE);
|
||||
lookup->defname = ISC_FALSE;
|
||||
lookup->origin = ISC_LIST_NEXT(query->lookup->origin, link);
|
||||
return (ISC_TRUE);
|
||||
}
|
||||
@@ -1283,10 +1293,26 @@ setup_lookup(dig_lookup_t *lookup) {
|
||||
* is TRUE or we got a domain line in the resolv.conf file.
|
||||
*/
|
||||
/* XXX New search here? */
|
||||
if ((count_dots(lookup->textname) >= ndots) || !usesearch)
|
||||
if ((count_dots(lookup->textname) >= ndots) ||
|
||||
(!lookup->defname && !usesearch))
|
||||
lookup->origin = NULL; /* Force abs lookup */
|
||||
else if (lookup->origin == NULL && lookup->new_search && usesearch) {
|
||||
lookup->origin = ISC_LIST_HEAD(search_list);
|
||||
else if (lookup->origin == NULL && lookup->new_search &&
|
||||
(usesearch || have_domain)) {
|
||||
if (fixeddomain[0] != 0) {
|
||||
debug("using fixed domain %s", fixeddomain);
|
||||
if (fixedsearch != NULL)
|
||||
isc_mem_free(mctx, fixedsearch);
|
||||
fixedsearch = isc_mem_allocate(mctx,
|
||||
sizeof(struct dig_server));
|
||||
if (fixedsearch == NULL)
|
||||
fatal("Memory allocation failure in %s:%d",
|
||||
__FILE__, __LINE__);
|
||||
strncpy(fixedsearch->origin, fixeddomain,
|
||||
sizeof(fixedsearch->origin));
|
||||
fixedsearch->origin[sizeof(fixedsearch->origin)-1]=0;
|
||||
lookup->origin = fixedsearch;
|
||||
} else
|
||||
lookup->origin = ISC_LIST_HEAD(search_list);
|
||||
}
|
||||
if (lookup->origin != NULL) {
|
||||
debug("trying origin %s", lookup->origin->origin);
|
||||
@@ -1345,7 +1371,7 @@ setup_lookup(dig_lookup_t *lookup) {
|
||||
dns_message_puttempname(lookup->sendmsg,
|
||||
&lookup->name);
|
||||
isc_buffer_init(&b, store, MXNAME);
|
||||
fatal("'%s' is not a legal name "
|
||||
fatal("'%s' is not a legal name syntax "
|
||||
"(%s)", lookup->textname,
|
||||
dns_result_totext(result));
|
||||
}
|
||||
@@ -1437,7 +1463,7 @@ setup_lookup(dig_lookup_t *lookup) {
|
||||
if (lookup->udpsize > 0 || lookup->dnssec) {
|
||||
#else /* DNS_OPT_NEWCODES_LIVE */
|
||||
if (lookup->udpsize > 0 || || lookup->dnssec ||
|
||||
lookup->zonename[0] != 0 || lookup->viewname[0] != 0) {
|
||||
lookup->zonename[0] !=0 || lookup->viewname[0] != 0) {
|
||||
dns_fixedname_t fname;
|
||||
isc_buffer_t namebuf, *wirebuf = NULL;
|
||||
dns_compress_t cctx;
|
||||
@@ -2095,6 +2121,8 @@ check_for_more_data(dig_query_t *query, dns_message_t *msg,
|
||||
dns_rdata_soa_t soa;
|
||||
isc_result_t result;
|
||||
isc_buffer_t b;
|
||||
isc_region_t r;
|
||||
char abspace[MXNAME];
|
||||
isc_boolean_t atlimit=ISC_FALSE;
|
||||
|
||||
debug("check_for_more_data()");
|
||||
@@ -2238,7 +2266,13 @@ check_for_more_data(dig_query_t *query, dns_message_t *msg,
|
||||
} while (result == ISC_R_SUCCESS);
|
||||
if (atlimit) {
|
||||
doexit:
|
||||
received(b.used, &sevent->address, query);
|
||||
isc_buffer_init(&b, abspace, MXNAME);
|
||||
result = isc_sockaddr_totext(&sevent->address, &b);
|
||||
check_result(result,
|
||||
"isc_sockaddr_totext");
|
||||
isc_buffer_usedregion(&b, &r);
|
||||
received(b.used, r.length,
|
||||
(char *)r.base, query);
|
||||
if (atlimit)
|
||||
if (exitcode < 7)
|
||||
exitcode = 7;
|
||||
@@ -2259,6 +2293,9 @@ recv_done(isc_task_t *task, isc_event_t *event) {
|
||||
isc_buffer_t *b = NULL;
|
||||
dns_message_t *msg = NULL;
|
||||
isc_result_t result;
|
||||
isc_buffer_t ab;
|
||||
char abspace[MXNAME];
|
||||
isc_region_t r;
|
||||
dig_lookup_t *n, *l;
|
||||
isc_boolean_t docancel = ISC_FALSE;
|
||||
unsigned int local_timeout;
|
||||
@@ -2454,8 +2491,16 @@ recv_done(isc_task_t *task, isc_event_t *event) {
|
||||
if (!next_origin(msg, query)) {
|
||||
printmessage(query, msg,
|
||||
ISC_TRUE);
|
||||
received(b->used,
|
||||
&sevent->address,
|
||||
isc_buffer_init(&ab, abspace,
|
||||
MXNAME);
|
||||
result = isc_sockaddr_totext(
|
||||
&sevent->address,
|
||||
&ab);
|
||||
check_result(result,
|
||||
"isc_sockaddr_totext");
|
||||
isc_buffer_usedregion(&ab, &r);
|
||||
received(b->used, r.length,
|
||||
(char *)r.base,
|
||||
query);
|
||||
}
|
||||
} else {
|
||||
@@ -2471,8 +2516,15 @@ recv_done(isc_task_t *task, isc_event_t *event) {
|
||||
if (!next_origin(msg, query)) {
|
||||
printmessage(query, msg,
|
||||
ISC_TRUE);
|
||||
received(b->used,
|
||||
&sevent->address,
|
||||
isc_buffer_init(&ab, abspace, MXNAME);
|
||||
result = isc_sockaddr_totext(
|
||||
&sevent->address,
|
||||
&ab);
|
||||
check_result(result,
|
||||
"isc_sockaddr_totext");
|
||||
isc_buffer_usedregion(&ab, &r);
|
||||
received(b->used, r.length,
|
||||
(char *)r.base,
|
||||
query);
|
||||
}
|
||||
} else {
|
||||
@@ -2509,8 +2561,13 @@ recv_done(isc_task_t *task, isc_event_t *event) {
|
||||
else {
|
||||
if ((msg->rcode == 0) ||
|
||||
(l->origin == NULL)) {
|
||||
received(b->used,
|
||||
&sevent->address,
|
||||
isc_buffer_init(&ab, abspace, MXNAME);
|
||||
result = isc_sockaddr_totext(&sevent->address,
|
||||
&ab);
|
||||
check_result(result, "isc_sockaddr_totext");
|
||||
isc_buffer_usedregion(&ab, &r);
|
||||
received(b->used, r.length,
|
||||
(char *)r.base,
|
||||
query);
|
||||
}
|
||||
query->lookup->pending = ISC_FALSE;
|
||||
@@ -2584,9 +2641,9 @@ get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) {
|
||||
else {
|
||||
#ifdef USE_GETADDRINFO
|
||||
debug ("before getaddrinfo()");
|
||||
isc_app_block();
|
||||
is_blocking = ISC_TRUE;
|
||||
result = getaddrinfo(host, NULL, NULL, &res);
|
||||
isc_app_unblock();
|
||||
is_blocking = ISC_FALSE;
|
||||
if (result != 0) {
|
||||
fatal("Couldn't find server '%s': %s",
|
||||
host, gai_strerror(result));
|
||||
@@ -2597,9 +2654,9 @@ get_address(char *host, in_port_t port, isc_sockaddr_t *sockaddr) {
|
||||
freeaddrinfo(res);
|
||||
#else
|
||||
debug ("before gethostbyname()");
|
||||
isc_app_block();
|
||||
is_blocking = ISC_TRUE;
|
||||
he = gethostbyname(host);
|
||||
isc_app_unblock();
|
||||
is_blocking = ISC_FALSE;
|
||||
if (he == NULL)
|
||||
fatal("Couldn't find server '%s' (h_errno=%d)",
|
||||
host, h_errno);
|
||||
@@ -2651,6 +2708,17 @@ cancel_all(void) {
|
||||
|
||||
debug("cancel_all()");
|
||||
|
||||
if (is_blocking) {
|
||||
/*
|
||||
* If we get here while another thread is blocking, there's
|
||||
* really nothing we can do to make a clean shutdown
|
||||
* without waiting for the block to complete. The only
|
||||
* way to get the system down now is to just exit out,
|
||||
* and trust the OS to clean up for us.
|
||||
*/
|
||||
fputs("Abort.\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
LOCK_LOOKUP;
|
||||
if (free_now) {
|
||||
UNLOCK_LOOKUP;
|
||||
@@ -2692,8 +2760,20 @@ void
|
||||
destroy_libs(void) {
|
||||
void *ptr;
|
||||
dig_server_t *s;
|
||||
dig_searchlist_t *o;
|
||||
|
||||
debug("destroy_libs()");
|
||||
if (is_blocking) {
|
||||
/*
|
||||
* If we get here while another thread is blocking, there's
|
||||
* really nothing we can do to make a clean shutdown
|
||||
* without waiting for the block to complete. The only
|
||||
* way to get the system down now is to just exit out,
|
||||
* and trust the OS to clean up for us.
|
||||
*/
|
||||
fputs("Abort.\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
if (global_task != NULL) {
|
||||
debug("freeing task");
|
||||
isc_task_detach(&global_task);
|
||||
@@ -2717,6 +2797,11 @@ destroy_libs(void) {
|
||||
|
||||
free_now = ISC_TRUE;
|
||||
|
||||
if (fixedsearch != NULL) {
|
||||
debug("freeing fixed search");
|
||||
isc_mem_free(mctx, fixedsearch);
|
||||
fixedsearch = NULL;
|
||||
}
|
||||
s = ISC_LIST_HEAD(server_list);
|
||||
while (s != NULL) {
|
||||
debug("freeing global server %p", s);
|
||||
@@ -2724,7 +2809,13 @@ destroy_libs(void) {
|
||||
s = ISC_LIST_NEXT(s, link);
|
||||
isc_mem_free(mctx, ptr);
|
||||
}
|
||||
clear_searchlist();
|
||||
o = ISC_LIST_HEAD(search_list);
|
||||
while (o != NULL) {
|
||||
debug("freeing search %p", o);
|
||||
ptr = o;
|
||||
o = ISC_LIST_NEXT(o, link);
|
||||
isc_mem_free(mctx, ptr);
|
||||
}
|
||||
if (commctx != NULL) {
|
||||
debug("freeing commctx");
|
||||
isc_mempool_destroy(&commctx);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: host.c,v 1.63 2001/01/24 19:28:32 gson Exp $ */
|
||||
/* $Id: host.c,v 1.60.4.1 2001/01/09 22:31:24 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
@@ -45,12 +45,13 @@ extern ISC_LIST(dig_lookup_t) lookup_list;
|
||||
extern ISC_LIST(dig_server_t) server_list;
|
||||
extern ISC_LIST(dig_searchlist_t) search_list;
|
||||
|
||||
extern isc_boolean_t usesearch;
|
||||
extern isc_boolean_t debugging;
|
||||
extern unsigned int timeout;
|
||||
extern isc_mem_t *mctx;
|
||||
extern int ndots;
|
||||
extern int tries;
|
||||
extern isc_boolean_t usesearch;
|
||||
extern int lookup_counter;
|
||||
extern char *progname;
|
||||
extern isc_task_t *global_task;
|
||||
|
||||
@@ -229,20 +230,17 @@ dighost_shutdown(void) {
|
||||
}
|
||||
|
||||
void
|
||||
received(int bytes, isc_sockaddr_t *from, dig_query_t *query)
|
||||
{
|
||||
received(int bytes, int frmsize, char *frm, dig_query_t *query) {
|
||||
isc_time_t now;
|
||||
isc_result_t result;
|
||||
int diff;
|
||||
|
||||
if (!short_form) {
|
||||
char fromtext[ISC_SOCKADDR_FORMATSIZE];
|
||||
isc_sockaddr_format(from, fromtext, sizeof(fromtext));
|
||||
result = isc_time_now(&now);
|
||||
check_result(result, "isc_time_now");
|
||||
diff = isc_time_microdiff(&now, &query->time_sent);
|
||||
printf("Received %u bytes from %s in %d ms\n",
|
||||
bytes, fromtext, diff/1000);
|
||||
printf("Received %u bytes from %.*s in %d ms\n",
|
||||
bytes, frmsize, frm, diff/1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +249,7 @@ trying(int frmsize, char *frm, dig_lookup_t *lookup) {
|
||||
UNUSED(lookup);
|
||||
|
||||
if (!short_form)
|
||||
printf("Trying \"%.*s\"\n", frmsize, frm);
|
||||
printf ("Trying \"%.*s\"\n", frmsize, frm);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -272,12 +270,12 @@ say_message(dns_name_t *name, const char *msg, dns_rdata_t *rdata,
|
||||
result = dns_rdata_totext(rdata, NULL, b2);
|
||||
check_result(result, "dns_rdata_totext");
|
||||
isc_buffer_usedregion(b2, &r2);
|
||||
printf("%.*s %s %.*s", (int)r.length, (char *)r.base,
|
||||
msg, (int)r2.length, (char *)r2.base);
|
||||
printf ( "%.*s %s %.*s", (int)r.length, (char *)r.base,
|
||||
msg, (int)r2.length, (char *)r2.base);
|
||||
if (query->lookup->identify) {
|
||||
printf(" on server %s", query->servname);
|
||||
printf (" on server %s", query->servname);
|
||||
}
|
||||
printf("\n");
|
||||
printf ("\n");
|
||||
isc_buffer_free(&b);
|
||||
isc_buffer_free(&b2);
|
||||
}
|
||||
@@ -348,7 +346,7 @@ printsection(dns_message_t *msg, dns_section_t sectionid,
|
||||
while (loopresult == ISC_R_SUCCESS) {
|
||||
dns_rdataset_current(rdataset, &rdata);
|
||||
if (rdata.type <= 103)
|
||||
rtt = rtypetext[rdata.type];
|
||||
rtt=rtypetext[rdata.type];
|
||||
else if (rdata.type == 249)
|
||||
rtt = "key";
|
||||
else if (rdata.type == 250)
|
||||
@@ -578,8 +576,8 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
|
||||
(isc_textregion_t *)&tr);
|
||||
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fprintf(stderr,"Warning: invalid type: %s\n",
|
||||
isc_commandline_argument);
|
||||
fprintf (stderr,"Warning: invalid type: %s\n",
|
||||
isc_commandline_argument);
|
||||
else {
|
||||
lookup->rdtype = rdtype;
|
||||
lookup->rdtypeset = ISC_TRUE;
|
||||
@@ -592,8 +590,8 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
|
||||
(isc_textregion_t *)&tr);
|
||||
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fprintf(stderr,"Warning: invalid class: %s\n",
|
||||
isc_commandline_argument);
|
||||
fprintf (stderr,"Warning: invalid class: %s\n",
|
||||
isc_commandline_argument);
|
||||
else {
|
||||
lookup->rdclass = rdclass;
|
||||
lookup->rdclassset = ISC_TRUE;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dig.h,v 1.63 2001/01/24 19:28:34 gson Exp $ */
|
||||
/* $Id: dig.h,v 1.60.4.1 2001/01/09 22:31:26 bwelling Exp $ */
|
||||
|
||||
#ifndef DIG_H
|
||||
#define DIG_H
|
||||
@@ -91,6 +91,7 @@ struct dig_lookup {
|
||||
cdflag,
|
||||
trace,
|
||||
trace_root,
|
||||
defname,
|
||||
tcp_mode,
|
||||
nibble,
|
||||
comments,
|
||||
@@ -239,26 +240,14 @@ cancel_all(void);
|
||||
void
|
||||
destroy_libs(void);
|
||||
|
||||
void
|
||||
set_search_domain(char *domain);
|
||||
|
||||
/*
|
||||
* Routines to be defined in dig.c, host.c, and nslookup.c.
|
||||
* Routines needed in dig.c and host.c.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers);
|
||||
/*
|
||||
* Print the final result of the lookup.
|
||||
*/
|
||||
|
||||
void
|
||||
received(int bytes, isc_sockaddr_t *from, dig_query_t *query);
|
||||
/*
|
||||
* Print a message about where and when the response
|
||||
* was received from, like the final comment in the
|
||||
* output of "dig".
|
||||
*/
|
||||
received(int bytes, int frmsize, char *frm, dig_query_t *query);
|
||||
|
||||
void
|
||||
trying(int frmsize, char *frm, dig_lookup_t *lookup);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: nslookup.c,v 1.80 2001/01/24 19:28:33 gson Exp $ */
|
||||
/* $Id: nslookup.c,v 1.69.2.3 2001/01/17 19:37:37 gson Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -39,7 +39,6 @@ extern int h_errno;
|
||||
#include <dns/rdata.h>
|
||||
#include <dns/rdataclass.h>
|
||||
#include <dns/rdataset.h>
|
||||
#include <dns/rdatastruct.h>
|
||||
#include <dns/rdatatype.h>
|
||||
#include <dns/byaddr.h>
|
||||
|
||||
@@ -50,7 +49,7 @@ extern ISC_LIST(dig_server_t) server_list;
|
||||
extern ISC_LIST(dig_searchlist_t) search_list;
|
||||
|
||||
extern isc_boolean_t have_ipv6,
|
||||
usesearch, trace, qr, debugging;
|
||||
usesearch, trace, qr, debugging, is_blocking;
|
||||
extern in_port_t port;
|
||||
extern unsigned int timeout;
|
||||
extern isc_mem_t *mctx;
|
||||
@@ -61,6 +60,7 @@ extern int sendcount;
|
||||
extern int ndots;
|
||||
extern int tries;
|
||||
extern int lookup_counter;
|
||||
extern char fixeddomain[MXNAME];
|
||||
extern int exitcode;
|
||||
extern isc_taskmgr_t *taskmgr;
|
||||
extern isc_task_t *global_task;
|
||||
@@ -77,14 +77,12 @@ isc_boolean_t identify = ISC_FALSE,
|
||||
comments = ISC_TRUE, section_question = ISC_TRUE,
|
||||
section_answer = ISC_TRUE, section_authority = ISC_TRUE,
|
||||
section_additional = ISC_TRUE, recurse = ISC_TRUE,
|
||||
aaonly = ISC_FALSE;
|
||||
defname = ISC_TRUE, aaonly = ISC_FALSE;
|
||||
isc_boolean_t busy = ISC_FALSE, in_use = ISC_FALSE;
|
||||
char defclass[MXRD] = "IN";
|
||||
char deftype[MXRD] = "A";
|
||||
isc_event_t *global_event = NULL;
|
||||
|
||||
char domainopt[DNS_NAME_MAXTEXT];
|
||||
|
||||
static const char *rcodetext[] = {
|
||||
"NOERROR",
|
||||
"FORMERR",
|
||||
@@ -149,7 +147,6 @@ static const char *rtypetext[] = {
|
||||
"rtype_40 = ", /* 40 */
|
||||
"optional = "}; /* 41 */
|
||||
|
||||
#define N_KNOWN_RRTYPES (sizeof(rtypetext) / sizeof(rtypetext[0]))
|
||||
|
||||
static void flush_lookup_list(void);
|
||||
static void getinput(isc_task_t *task, isc_event_t *event);
|
||||
@@ -169,76 +166,32 @@ dighost_shutdown(void) {
|
||||
isc_task_send(global_task, &event);
|
||||
}
|
||||
|
||||
static void
|
||||
printsoa(dns_rdata_t *rdata) {
|
||||
dns_rdata_soa_t soa;
|
||||
isc_result_t result;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
|
||||
result = dns_rdata_tostruct(rdata, &soa, NULL);
|
||||
check_result(result, "dns_rdata_tostruct");
|
||||
|
||||
dns_name_format(&soa.origin, namebuf, sizeof(namebuf));
|
||||
printf("\torigin = %s\n", namebuf);
|
||||
dns_name_format(&soa.mname, namebuf, sizeof(namebuf));
|
||||
printf("\tmail addr = %s\n", namebuf);
|
||||
printf("\tserial = %u\n", soa.serial);
|
||||
printf("\trefresh = %u\n", soa.refresh);
|
||||
printf("\tretry = %u\n", soa.retry);
|
||||
printf("\texpire = %u\n", soa.expire);
|
||||
printf("\tminimum = %u\n", soa.minimum);
|
||||
dns_rdata_freestruct(&soa);
|
||||
void
|
||||
received(int bytes, int frmsize, char *frm, dig_query_t *query) {
|
||||
UNUSED(bytes);
|
||||
UNUSED(frmsize);
|
||||
UNUSED(frm);
|
||||
UNUSED(query);
|
||||
}
|
||||
|
||||
static void
|
||||
printa(dns_rdata_t *rdata) {
|
||||
isc_result_t result;
|
||||
char text[sizeof("255.255.255.255")];
|
||||
isc_buffer_t b;
|
||||
void
|
||||
trying(int frmsize, char *frm, dig_lookup_t *lookup) {
|
||||
UNUSED(frmsize);
|
||||
UNUSED(frm);
|
||||
UNUSED(lookup);
|
||||
|
||||
isc_buffer_init(&b, text, sizeof(text));
|
||||
result = dns_rdata_totext(rdata, NULL, &b);
|
||||
check_result(result, "dns_rdata_totext");
|
||||
printf("Address: %.*s\n", (int)isc_buffer_usedlength(&b),
|
||||
(char *)isc_buffer_base(&b));
|
||||
}
|
||||
|
||||
static void
|
||||
printrdata(dns_rdata_t *rdata) {
|
||||
isc_result_t result;
|
||||
isc_buffer_t *b = NULL;
|
||||
unsigned int size = 1024;
|
||||
isc_boolean_t done = ISC_FALSE;
|
||||
|
||||
if (rdata->type < N_KNOWN_RRTYPES)
|
||||
printf("%s", rtypetext[rdata->type]);
|
||||
else
|
||||
printf("rdata_%d = ", rdata->type);
|
||||
|
||||
while (!done) {
|
||||
result = isc_buffer_allocate(mctx, &b, size);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
result = dns_rdata_totext(rdata, NULL, b);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
printf("%.*s\n", (int)isc_buffer_usedlength(b),
|
||||
(char *)isc_buffer_base(b));
|
||||
done = ISC_TRUE;
|
||||
} else if (result != ISC_R_NOSPACE)
|
||||
check_result(result, "dns_rdata_totext");
|
||||
isc_buffer_free(&b);
|
||||
size *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
printsection(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers,
|
||||
dns_section_t section) {
|
||||
isc_result_t result, loopresult;
|
||||
isc_buffer_t *b = NULL;
|
||||
dns_name_t *name;
|
||||
dns_rdataset_t *rdataset = NULL;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
char *ptr;
|
||||
char *input;
|
||||
|
||||
UNUSED(query);
|
||||
UNUSED(headers);
|
||||
@@ -250,6 +203,8 @@ printsection(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers,
|
||||
return (ISC_R_SUCCESS);
|
||||
else if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
result = isc_buffer_allocate(mctx, &b, MXNAME);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
for (;;) {
|
||||
name = NULL;
|
||||
dns_message_currentname(msg, section,
|
||||
@@ -264,24 +219,105 @@ printsection(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers,
|
||||
case dns_rdatatype_a:
|
||||
if (section != DNS_SECTION_ANSWER)
|
||||
goto def_short_section;
|
||||
dns_name_format(name, namebuf,
|
||||
sizeof(namebuf));
|
||||
printf("Name:\t%s\n", namebuf);
|
||||
printa(&rdata);
|
||||
isc_buffer_clear(b);
|
||||
result = dns_name_totext(name,
|
||||
ISC_TRUE,
|
||||
b);
|
||||
check_result(result,
|
||||
"dns_name_totext");
|
||||
printf("Name:\t%.*s\n",
|
||||
(int)isc_buffer_usedlength(b),
|
||||
(char*)isc_buffer_base(b));
|
||||
isc_buffer_clear(b);
|
||||
result = dns_rdata_totext(&rdata,
|
||||
NULL,
|
||||
b);
|
||||
check_result(result,
|
||||
"dns_rdata_totext");
|
||||
printf("Address: %.*s\n",
|
||||
(int)isc_buffer_usedlength(b),
|
||||
(char*)isc_buffer_base(b));
|
||||
break;
|
||||
case dns_rdatatype_soa:
|
||||
dns_name_format(name, namebuf,
|
||||
sizeof(namebuf));
|
||||
printf("%s\n", namebuf);
|
||||
printsoa(&rdata);
|
||||
isc_buffer_clear(b);
|
||||
result = dns_name_totext(name,
|
||||
ISC_TRUE,
|
||||
b);
|
||||
check_result(result,
|
||||
"dns_name_totext");
|
||||
printf("%.*s\n",
|
||||
(int)isc_buffer_usedlength(b),
|
||||
(char*)isc_buffer_base(b));
|
||||
isc_buffer_clear(b);
|
||||
result = dns_rdata_totext(&rdata,
|
||||
NULL,
|
||||
b);
|
||||
check_result(result,
|
||||
"dns_rdata_totext");
|
||||
((char *)isc_buffer_used(b))[0]=0;
|
||||
input = isc_buffer_base(b);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\torigin = %s\n",
|
||||
ptr);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\tmail addr = %s\n",
|
||||
ptr);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\tserial = %s\n",
|
||||
ptr);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\trefresh = %s\n",
|
||||
ptr);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\tretry = %s\n",
|
||||
ptr);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\texpire = %s\n",
|
||||
ptr);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\tminimum = %s\n",
|
||||
ptr);
|
||||
break;
|
||||
default:
|
||||
def_short_section:
|
||||
dns_name_format(name, namebuf,
|
||||
sizeof(namebuf));
|
||||
printf("%s\t", namebuf);
|
||||
printrdata(&rdata);
|
||||
break;
|
||||
isc_buffer_clear(b);
|
||||
result = dns_name_totext(name,
|
||||
ISC_TRUE,
|
||||
b);
|
||||
check_result(result,
|
||||
"dns_name_totext");
|
||||
if (rdata.type <= 41)
|
||||
printf("%.*s\t%s",
|
||||
(int)isc_buffer_usedlength(b),
|
||||
(char*)isc_buffer_base(b),
|
||||
rtypetext[rdata.type]);
|
||||
else
|
||||
printf("%.*s\trdata_%d = ",
|
||||
(int)isc_buffer_usedlength(b),
|
||||
(char*)isc_buffer_base(b),
|
||||
rdata.type);
|
||||
isc_buffer_clear(b);
|
||||
result = dns_rdata_totext(&rdata,
|
||||
NULL, b);
|
||||
check_result(result,
|
||||
"dns_rdata_totext");
|
||||
printf("%.*s\n",
|
||||
(int)isc_buffer_usedlength(b),
|
||||
(char*)isc_buffer_base(b));
|
||||
}
|
||||
dns_rdata_reset(&rdata);
|
||||
loopresult = dns_rdataset_next(rdataset);
|
||||
@@ -291,9 +327,11 @@ printsection(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers,
|
||||
if (result == ISC_R_NOMORE)
|
||||
break;
|
||||
else if (result != ISC_R_SUCCESS) {
|
||||
isc_buffer_free (&b);
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
isc_buffer_free(&b);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -301,10 +339,13 @@ static isc_result_t
|
||||
detailsection(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers,
|
||||
dns_section_t section) {
|
||||
isc_result_t result, loopresult;
|
||||
isc_buffer_t *b = NULL;
|
||||
dns_name_t *name;
|
||||
dns_rdataset_t *rdataset = NULL;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
char namestore[DNS_NAME_MAXTEXT + 1]; /* Leave room for the NULL */
|
||||
char *ptr;
|
||||
char *input;
|
||||
|
||||
UNUSED(query);
|
||||
|
||||
@@ -332,6 +373,8 @@ detailsection(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers,
|
||||
return (ISC_R_SUCCESS);
|
||||
else if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
result = isc_buffer_allocate(mctx, &b, MXNAME);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
for (;;) {
|
||||
name = NULL;
|
||||
dns_message_currentname(msg, section,
|
||||
@@ -340,33 +383,92 @@ detailsection(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers,
|
||||
rdataset != NULL;
|
||||
rdataset = ISC_LIST_NEXT(rdataset, link)) {
|
||||
if (section == DNS_SECTION_QUESTION) {
|
||||
dns_name_format(name, namebuf,
|
||||
sizeof(namebuf));
|
||||
printf("\t%s, ", namebuf);
|
||||
dns_name_format(name, namestore,
|
||||
sizeof(namestore));
|
||||
printf("\t%s, ", namestore);
|
||||
dns_rdatatype_format(rdataset->type,
|
||||
namebuf,
|
||||
sizeof(namebuf));
|
||||
printf("type = %s, ", namebuf);
|
||||
namestore,
|
||||
sizeof(namestore));
|
||||
printf("type = %s, ", namestore);
|
||||
dns_rdataclass_format(rdataset->rdclass,
|
||||
namebuf,
|
||||
sizeof(namebuf));
|
||||
printf("class = %s\n", namebuf);
|
||||
namestore,
|
||||
sizeof(namestore));
|
||||
printf("class = %s\n", namestore);
|
||||
}
|
||||
loopresult = dns_rdataset_first(rdataset);
|
||||
while (loopresult == ISC_R_SUCCESS) {
|
||||
dns_rdataset_current(rdataset, &rdata);
|
||||
|
||||
dns_name_format(name, namebuf,
|
||||
sizeof(namebuf));
|
||||
printf(" -> %s\n", namebuf);
|
||||
|
||||
isc_buffer_clear(b);
|
||||
result = dns_name_totext(name,
|
||||
ISC_TRUE,
|
||||
b);
|
||||
check_result(result,
|
||||
"dns_name_totext");
|
||||
printf(" -> %.*s\n",
|
||||
(int)isc_buffer_usedlength(b),
|
||||
(char*)isc_buffer_base(b));
|
||||
switch (rdata.type) {
|
||||
case dns_rdatatype_soa:
|
||||
printsoa(&rdata);
|
||||
isc_buffer_clear(b);
|
||||
result = dns_rdata_totext(&rdata,
|
||||
NULL,
|
||||
b);
|
||||
check_result(result,
|
||||
"dns_rdata_totext");
|
||||
((char *)isc_buffer_used(b))[0]=0;
|
||||
input = isc_buffer_base(b);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\torigin = %s\n",
|
||||
ptr);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\tmail addr = %s\n",
|
||||
ptr);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\tserial = %s\n",
|
||||
ptr);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\trefresh = %s\n",
|
||||
ptr);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\tretry = %s\n",
|
||||
ptr);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\texpire = %s\n",
|
||||
ptr);
|
||||
ptr = next_token(&input, " \t\r\n");
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
printf("\tminimum = %s\n",
|
||||
ptr);
|
||||
break;
|
||||
default:
|
||||
printf("\t");
|
||||
printrdata(&rdata);
|
||||
isc_buffer_clear(b);
|
||||
if (rdata.type <= 41)
|
||||
printf("\t%s",
|
||||
rtypetext[rdata.type]);
|
||||
else
|
||||
printf("\trdata_%d = ",
|
||||
rdata.type);
|
||||
isc_buffer_clear(b);
|
||||
result = dns_rdata_totext(&rdata,
|
||||
NULL, b);
|
||||
check_result(result,
|
||||
"dns_rdata_totext");
|
||||
printf("%.*s\n",
|
||||
(int)isc_buffer_usedlength(b),
|
||||
(char*)isc_buffer_base(b));
|
||||
}
|
||||
dns_rdata_reset(&rdata);
|
||||
loopresult = dns_rdataset_next(rdataset);
|
||||
@@ -376,42 +478,47 @@ detailsection(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers,
|
||||
if (result == ISC_R_NOMORE)
|
||||
break;
|
||||
else if (result != ISC_R_SUCCESS) {
|
||||
isc_buffer_free (&b);
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
isc_buffer_free(&b);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
received(int bytes, isc_sockaddr_t *from, dig_query_t *query)
|
||||
{
|
||||
UNUSED(bytes);
|
||||
UNUSED(from);
|
||||
UNUSED(query);
|
||||
}
|
||||
|
||||
void
|
||||
trying(int frmsize, char *frm, dig_lookup_t *lookup) {
|
||||
UNUSED(frmsize);
|
||||
UNUSED(frm);
|
||||
UNUSED(lookup);
|
||||
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
|
||||
char servtext[ISC_SOCKADDR_FORMATSIZE];
|
||||
isc_buffer_t *b = NULL;
|
||||
isc_region_t r;
|
||||
isc_result_t result;
|
||||
|
||||
debug("printmessage()");
|
||||
|
||||
isc_sockaddr_format(&query->sockaddr, servtext, sizeof(servtext));
|
||||
debug("continuing on with rcode != 0");
|
||||
result = isc_buffer_allocate(mctx, &b, MXNAME);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
printf("Server:\t\t%s\n", query->servname);
|
||||
printf("Address:\t%s\n", servtext);
|
||||
|
||||
result = isc_sockaddr_totext(&query->sockaddr, b);
|
||||
check_result(result, "isc_sockaddr_totext");
|
||||
printf("Address:\t%.*s\n", (int)isc_buffer_usedlength(b),
|
||||
(char*)isc_buffer_base(b));
|
||||
isc_buffer_free(&b);
|
||||
puts("");
|
||||
|
||||
if (!short_form) {
|
||||
isc_boolean_t headers = ISC_TRUE;
|
||||
if (msg->rcode != 0) {
|
||||
result = isc_buffer_allocate(mctx, &b, MXNAME);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
result = dns_name_totext(query->lookup->name, ISC_FALSE,
|
||||
b);
|
||||
check_result(result, "dns_name_totext");
|
||||
isc_buffer_usedregion(b, &r);
|
||||
printf("** server can't find %.*s: %s\n",
|
||||
(int)r.length, (char*)r.base,
|
||||
rcodetext[msg->rcode]);
|
||||
isc_buffer_free(&b);
|
||||
debug("returning with rcode == 0");
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
if (!short_form){
|
||||
puts("------------");
|
||||
/* detailheader(query, msg);*/
|
||||
detailsection(query, msg, headers, DNS_SECTION_QUESTION);
|
||||
@@ -421,16 +528,6 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
|
||||
puts("------------");
|
||||
}
|
||||
|
||||
if (msg->rcode != 0) {
|
||||
char nametext[DNS_NAME_FORMATSIZE];
|
||||
dns_name_format(query->lookup->name,
|
||||
nametext, sizeof(nametext));
|
||||
printf("** server can't find %s: %s\n", nametext,
|
||||
rcodetext[msg->rcode]);
|
||||
debug("returning with rcode == 0");
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
if ((msg->flags & DNS_MESSAGEFLAG_AA) == 0)
|
||||
puts("Non-authoritative answer:");
|
||||
if (!ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ANSWER]))
|
||||
@@ -476,26 +573,25 @@ show_settings(isc_boolean_t full, isc_boolean_t serv_only) {
|
||||
}
|
||||
if (serv_only)
|
||||
return;
|
||||
printf("\nSet options:\n");
|
||||
printf(" %s\t\t\t%s\t\t%s\n",
|
||||
tcpmode ? "vc" : "novc",
|
||||
short_form ? "nodebug" : "debug",
|
||||
debugging ? "d2" : "nod2");
|
||||
printf(" %s\t\t%s\n",
|
||||
usesearch ? "search" : "nosearch",
|
||||
recurse ? "recurse" : "norecurse");
|
||||
printf(" timeout = %d\t\tretry = %d\tport = %d\n",
|
||||
timeout, tries, port);
|
||||
printf(" querytype = %-8s\tclass = %s\n", deftype, defclass);
|
||||
printf(" srchlist = ");
|
||||
for (listent = ISC_LIST_HEAD(search_list);
|
||||
listent != NULL;
|
||||
listent = ISC_LIST_NEXT(listent, link)) {
|
||||
printf("%s", listent->origin);
|
||||
if (ISC_LIST_NEXT(listent, link) != NULL)
|
||||
printf("/");
|
||||
}
|
||||
printf("\n");
|
||||
printf("\n\tSet options:\n");
|
||||
printf("\t %s\t\t\t%s\t\t%s\n",
|
||||
tcpmode?"vc":"novc", short_form?"nodebug":"debug",
|
||||
debugging?"d2":"nod2");
|
||||
printf("\t %s\t\t%s\t%s\n",
|
||||
defname?"defname":"nodefname",
|
||||
usesearch?"search ":"nosearch",
|
||||
recurse?"recurse":"norecurse");
|
||||
printf("\t timeout = %d\t\tretry = %d\tport = %d\n",
|
||||
timeout, tries, port);
|
||||
printf("\t querytype = %-8s\tclass = %s\n", deftype, defclass);
|
||||
if (fixeddomain[0] != 0)
|
||||
printf("\t domain = %s\n", fixeddomain);
|
||||
else if (!ISC_LIST_EMPTY(search_list)) {
|
||||
listent = ISC_LIST_HEAD(search_list);
|
||||
printf("\t domain = %s\n", listent->origin);
|
||||
} else
|
||||
printf("\t domain =\n");
|
||||
|
||||
}
|
||||
|
||||
static isc_boolean_t
|
||||
@@ -535,7 +631,7 @@ testclass(char *typetext) {
|
||||
static void
|
||||
safecpy(char *dest, char *src, int size) {
|
||||
strncpy(dest, src, size);
|
||||
dest[size-1] = 0;
|
||||
dest[size-1]=0;
|
||||
}
|
||||
|
||||
|
||||
@@ -545,32 +641,30 @@ setoption(char *opt) {
|
||||
show_settings(ISC_TRUE, ISC_FALSE);
|
||||
} else if (strncasecmp(opt, "class=", 6) == 0) {
|
||||
if (testclass(&opt[6]))
|
||||
safecpy(defclass, &opt[6], sizeof(defclass));
|
||||
safecpy(defclass, &opt[6], MXRD);
|
||||
} else if (strncasecmp(opt, "cl=", 3) == 0) {
|
||||
if (testclass(&opt[3]))
|
||||
safecpy(defclass, &opt[3], sizeof(defclass));
|
||||
safecpy(defclass, &opt[3], MXRD);
|
||||
} else if (strncasecmp(opt, "type=", 5) == 0) {
|
||||
if (testtype(&opt[5]))
|
||||
safecpy(deftype, &opt[5], sizeof(deftype));
|
||||
safecpy(deftype, &opt[5], MXRD);
|
||||
} else if (strncasecmp(opt, "ty=", 3) == 0) {
|
||||
if (testtype(&opt[3]))
|
||||
safecpy(deftype, &opt[3], sizeof(deftype));
|
||||
safecpy(deftype, &opt[3], MXRD);
|
||||
} else if (strncasecmp(opt, "querytype=", 10) == 0) {
|
||||
if (testtype(&opt[10]))
|
||||
safecpy(deftype, &opt[10], sizeof(deftype));
|
||||
safecpy(deftype, &opt[10], MXRD);
|
||||
} else if (strncasecmp(opt, "query=", 6) == 0) {
|
||||
if (testtype(&opt[6]))
|
||||
safecpy(deftype, &opt[6], sizeof(deftype));
|
||||
safecpy(deftype, &opt[6], MXRD);
|
||||
} else if (strncasecmp(opt, "qu=", 3) == 0) {
|
||||
if (testtype(&opt[3]))
|
||||
safecpy(deftype, &opt[3], sizeof(deftype));
|
||||
safecpy(deftype, &opt[3], MXRD);
|
||||
} else if (strncasecmp(opt, "domain=", 7) == 0) {
|
||||
safecpy(domainopt, &opt[7], sizeof(domainopt));
|
||||
set_search_domain(domainopt);
|
||||
safecpy(fixeddomain, &opt[7], MXNAME);
|
||||
usesearch = ISC_TRUE;
|
||||
} else if (strncasecmp(opt, "do=", 3) == 0) {
|
||||
safecpy(domainopt, &opt[3], sizeof(domainopt));
|
||||
set_search_domain(domainopt);
|
||||
safecpy(fixeddomain, &opt[3], MXNAME);
|
||||
usesearch = ISC_TRUE;
|
||||
} else if (strncasecmp(opt, "port=", 5) == 0) {
|
||||
port = atoi(&opt[5]);
|
||||
@@ -589,9 +683,9 @@ setoption(char *opt) {
|
||||
} else if (strncasecmp(opt, "ret=", 4) == 0) {
|
||||
tries = atoi(&opt[4]);
|
||||
} else if (strncasecmp(opt, "def", 3) == 0) {
|
||||
usesearch = ISC_TRUE;
|
||||
defname = ISC_TRUE;
|
||||
} else if (strncasecmp(opt, "nodef", 5) == 0) {
|
||||
usesearch = ISC_FALSE;
|
||||
defname = ISC_FALSE;
|
||||
} else if (strncasecmp(opt, "vc", 3) == 0) {
|
||||
tcpmode = ISC_TRUE;
|
||||
} else if (strncasecmp(opt, "novc", 5) == 0) {
|
||||
@@ -697,14 +791,14 @@ static void
|
||||
setsrv(char *opt) {
|
||||
dig_server_t *srv;
|
||||
|
||||
if (opt == NULL)
|
||||
if (opt == NULL) {
|
||||
return;
|
||||
|
||||
}
|
||||
flush_server_list();
|
||||
srv = isc_mem_allocate(mctx, sizeof(struct dig_server));
|
||||
srv=isc_mem_allocate(mctx, sizeof(struct dig_server));
|
||||
if (srv == NULL)
|
||||
fatal("memory allocation failure");
|
||||
safecpy(srv->servername, opt, sizeof(srv->servername));
|
||||
fatal("Memory allocation failure.");
|
||||
safecpy(srv->servername, opt, MXNAME-1);
|
||||
ISC_LIST_INITANDAPPEND(server_list, srv, link);
|
||||
}
|
||||
|
||||
@@ -716,11 +810,11 @@ get_next_command(void) {
|
||||
|
||||
buf = isc_mem_allocate(mctx, COMMSIZE);
|
||||
if (buf == NULL)
|
||||
fatal("memory allocation failure");
|
||||
fatal("Memory allocation failure.");
|
||||
fputs("> ", stderr);
|
||||
isc_app_block();
|
||||
is_blocking = ISC_TRUE;
|
||||
ptr = fgets(buf, COMMSIZE, stdin);
|
||||
isc_app_unblock();
|
||||
is_blocking = ISC_FALSE;
|
||||
if (ptr == NULL) {
|
||||
in_use = ISC_FALSE;
|
||||
goto cleanup;
|
||||
@@ -868,8 +962,7 @@ main(int argc, char **argv) {
|
||||
"the `-sil[ent]' option to prevent this message from appearing.\n", stderr);
|
||||
}
|
||||
setup_system();
|
||||
if (domainopt[0] != '\0')
|
||||
set_search_domain(domainopt);
|
||||
|
||||
if (in_use)
|
||||
result = isc_app_onrun(mctx, global_task, onrun_callback,
|
||||
NULL);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.15 2001/01/18 01:33:49 bwelling Exp $
|
||||
# $Id: Makefile.in,v 1.13.2.1 2001/01/09 22:31:28 bwelling Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
@@ -50,11 +50,6 @@ SRCS = dnssec-keygen.c dnssec-makekeyset.c \
|
||||
dnssec-signkey.c dnssec-signzone.c \
|
||||
dnssectool.c
|
||||
|
||||
MANPAGES = dnssec-keygen.8 \
|
||||
dnssec-makekeyset.8 \
|
||||
dnssec-signkey.8 \
|
||||
dnssec-signzone.8
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
dnssec-keygen: dnssec-keygen.@O@ ${OBJS} ${DEPLIBS}
|
||||
@@ -77,8 +72,6 @@ clean distclean::
|
||||
|
||||
installdirs:
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${sbindir}
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man8
|
||||
|
||||
install:: ${TARGETS} installdirs
|
||||
for t in ${TARGETS}; do ${LIBTOOL} ${INSTALL_PROGRAM} $$t ${DESTDIR}${sbindir}; done
|
||||
for m in ${MANPAGES}; do ${INSTALL_PROGRAM} $$m ${DESTDIR}${mandir}/man8; done
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dnssec-keygen.c,v 1.46 2001/01/09 21:39:22 bwelling Exp $ */
|
||||
/* $Id: dnssec-keygen.c,v 1.45.2.1 2001/01/09 22:31:29 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dnssec-makekeyset.c,v 1.46 2001/01/09 21:39:23 bwelling Exp $ */
|
||||
/* $Id: dnssec-makekeyset.c,v 1.45.4.1 2001/01/09 22:31:32 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dnssec-signkey.c,v 1.46 2001/01/09 21:39:24 bwelling Exp $ */
|
||||
/* $Id: dnssec-signkey.c,v 1.45.2.1 2001/01/09 22:31:33 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dnssec-signzone.c,v 1.129 2001/01/12 23:36:03 bwelling Exp $ */
|
||||
/* $Id: dnssec-signzone.c,v 1.126.2.2 2001/01/12 23:44:02 gson Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dnssectool.c,v 1.27 2001/01/09 21:39:27 bwelling Exp $ */
|
||||
/* $Id: dnssectool.c,v 1.26.2.1 2001/01/09 22:31:35 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dnssectool.h,v 1.13 2001/01/09 21:39:28 bwelling Exp $ */
|
||||
/* $Id: dnssectool.h,v 1.12.4.1 2001/01/09 22:31:36 bwelling Exp $ */
|
||||
|
||||
#ifndef DNSSECTOOL_H
|
||||
#define DNSSECTOOL_H 1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Makefile
|
||||
keycreate
|
||||
keydelete
|
||||
*.lo
|
||||
.libs
|
||||
*.la
|
||||
*.lo
|
||||
lwresd
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2001 Internet Software Consortium.
|
||||
# Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.2 2001/01/11 20:51:11 bwelling Exp $
|
||||
# $Id: Makefile.in,v 1.13.4.1 2001/01/09 22:31:38 bwelling Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
@@ -23,38 +23,35 @@ top_srcdir = @top_srcdir@
|
||||
|
||||
@BIND9_INCLUDES@
|
||||
|
||||
CINCLUDES = ${DNS_INCLUDES} ${ISC_INCLUDES}
|
||||
CINCLUDES = ${LWRES_INCLUDES} ${DNS_INCLUDES} ${ISC_INCLUDES}
|
||||
|
||||
CDEFINES =
|
||||
CWARNINGS =
|
||||
|
||||
DNSLIBS = ../../../../lib/dns/libdns.@A@ @DNS_OPENSSL_LIBS@ @DNS_GSSAPI_LIBS@
|
||||
ISCLIBS = ../../../../lib/isc/libisc.@A@
|
||||
DNSLIBS = ../../lib/dns/libdns.@A@ @DNS_OPENSSL_LIBS@ @DNS_GSSAPI_LIBS@
|
||||
ISCLIBS = ../../lib/isc/libisc.@A@
|
||||
LWRESLIBS = ../../lib/lwres/liblwres.@A@
|
||||
|
||||
DNSDEPLIBS = ../../../../lib/dns/libdns.@A@
|
||||
ISCDEPLIBS = ../../../../lib/isc/libisc.@A@
|
||||
DNSDEPLIBS = ../../lib/dns/libdns.@A@
|
||||
ISCDEPLIBS = ../../lib/isc/libisc.@A@
|
||||
LWRESDEPLIBS = ../../lib/lwres/liblwres.@A@
|
||||
|
||||
DEPLIBS = ${DNSDEPLIBS} ${ISCDEPLIBS}
|
||||
DEPLIBS = ${DNSDEPLIBS} ${ISCDEPLIBS} ${LWRESDEPLIBS}
|
||||
|
||||
LIBS = ${DNSLIBS} ${ISCLIBS} @LIBS@
|
||||
LIBS = ${DNSLIBS} ${ISCLIBS} ${LWRESLIBS} @LIBS@
|
||||
|
||||
TARGETS = keycreate keydelete
|
||||
TARGETS = lwresd
|
||||
|
||||
CREATEOBJS = keycreate.@O@
|
||||
DELETEOBJS = keydelete.@O@
|
||||
OBJS = main.@O@ client.@O@ err_pkt.@O@ \
|
||||
process_gabn.@O@ process_gnba.@O@ process_noop.@O@
|
||||
|
||||
SRCS = keycreate.c keydelete.c
|
||||
SRCS = main.c client.c err_pkt.c \
|
||||
process_gabn.c process_gnba.c process_noop.c
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
all: keycreate keydelete
|
||||
|
||||
keycreate: ${CREATEOBJS} ${DEPLIBS}
|
||||
${LIBTOOL} ${CC} ${CFLAGS} -o $@ ${CREATEOBJS} ${LIBS}
|
||||
|
||||
keydelete: ${DELETEOBJS} ${DEPLIBS}
|
||||
${LIBTOOL} ${CC} ${CFLAGS} -o $@ ${DELETEOBJS} ${LIBS}
|
||||
lwresd: ${OBJS} ${UOBJS} ${DEPLIBS}
|
||||
${LIBTOOL} ${CC} ${CFLAGS} -o $@ ${OBJS} ${UOBJS} ${LIBS}
|
||||
|
||||
clean distclean::
|
||||
rm -f ${TARGETS}
|
||||
|
||||
387
bin/lwresd/client.c
Normal file
387
bin/lwresd/client.c
Normal file
@@ -0,0 +1,387 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: client.c,v 1.30.4.1 2001/01/09 22:31:39 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <isc/socket.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/view.h>
|
||||
#include <dns/log.h>
|
||||
|
||||
#include "client.h"
|
||||
|
||||
void
|
||||
DP(int level, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
isc_log_vwrite(dns_lctx,
|
||||
DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_ADB,
|
||||
ISC_LOG_DEBUG(level), format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
hexdump(char *msg, void *base, size_t len) {
|
||||
unsigned char *p;
|
||||
unsigned int cnt;
|
||||
char buffer[180];
|
||||
char *n;
|
||||
|
||||
p = base;
|
||||
cnt = 0;
|
||||
n = buffer;
|
||||
*n = 0;
|
||||
|
||||
printf("*** %s (%u bytes @ %p)\n", msg, len, base);
|
||||
|
||||
while (cnt < len) {
|
||||
if (cnt % 16 == 0) {
|
||||
n = buffer;
|
||||
n += sprintf(buffer, "%p: ", p);
|
||||
} else if (cnt % 8 == 0) {
|
||||
*n++ = ' ';
|
||||
*n++ = '|';
|
||||
*n = 0;
|
||||
}
|
||||
n += sprintf(n, " %02x", *p++);
|
||||
cnt++;
|
||||
|
||||
if (cnt % 16 == 0) {
|
||||
DP(80, buffer);
|
||||
n = buffer;
|
||||
*n = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (n != buffer) {
|
||||
DP(80, buffer);
|
||||
n = buffer;
|
||||
*n = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clientmgr_can_die(clientmgr_t *cm) {
|
||||
if ((cm->flags & CLIENTMGR_FLAG_SHUTTINGDOWN) == 0)
|
||||
return;
|
||||
|
||||
if (ISC_LIST_HEAD(cm->running) != NULL)
|
||||
return;
|
||||
|
||||
lwres_context_destroy(&cm->lwctx);
|
||||
dns_view_detach(&cm->view);
|
||||
isc_task_detach(&cm->task);
|
||||
}
|
||||
|
||||
static void
|
||||
process_request(client_t *client) {
|
||||
lwres_buffer_t b;
|
||||
isc_result_t result;
|
||||
|
||||
lwres_buffer_init(&b, client->buffer, client->recvlength);
|
||||
lwres_buffer_add(&b, client->recvlength);
|
||||
|
||||
result = lwres_lwpacket_parseheader(&b, &client->pkt);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
DP(50, "invalid packet header received");
|
||||
goto restart;
|
||||
}
|
||||
|
||||
DP(50, "opcode %08x", client->pkt.opcode);
|
||||
|
||||
switch (client->pkt.opcode) {
|
||||
case LWRES_OPCODE_GETADDRSBYNAME:
|
||||
process_gabn(client, &b);
|
||||
return;
|
||||
case LWRES_OPCODE_GETNAMEBYADDR:
|
||||
process_gnba(client, &b);
|
||||
return;
|
||||
case LWRES_OPCODE_NOOP:
|
||||
process_noop(client, &b);
|
||||
return;
|
||||
default:
|
||||
DP(50, "unknown opcode %08x", client->pkt.opcode);
|
||||
goto restart;
|
||||
}
|
||||
|
||||
/*
|
||||
* Drop the packet.
|
||||
*/
|
||||
restart:
|
||||
DP(50, "restarting client %p...", client);
|
||||
client_state_idle(client);
|
||||
}
|
||||
|
||||
void
|
||||
client_recv(isc_task_t *task, isc_event_t *ev) {
|
||||
client_t *client = ev->ev_arg;
|
||||
clientmgr_t *cm = client->clientmgr;
|
||||
isc_socketevent_t *dev = (isc_socketevent_t *)ev;
|
||||
|
||||
INSIST(dev->region.base == client->buffer);
|
||||
INSIST(CLIENT_ISRECV(client));
|
||||
|
||||
CLIENT_SETRECVDONE(client);
|
||||
|
||||
INSIST((cm->flags & CLIENTMGR_FLAG_RECVPENDING) != 0);
|
||||
cm->flags &= ~CLIENTMGR_FLAG_RECVPENDING;
|
||||
|
||||
DP(50, "event received: task %p, length %u, result %u (%s)",
|
||||
task, dev->n, dev->result, isc_result_totext(dev->result));
|
||||
|
||||
if (dev->result != ISC_R_SUCCESS) {
|
||||
isc_event_free(&ev);
|
||||
dev = NULL;
|
||||
|
||||
/*
|
||||
* Go idle.
|
||||
*/
|
||||
client_state_idle(client);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXXMLG If we wanted to run on ipv6 as well, we'd need the pktinfo
|
||||
* bits. Right now we don't, so don't remember them.
|
||||
*/
|
||||
client->recvlength = dev->n;
|
||||
client->address = dev->address;
|
||||
isc_event_free(&ev);
|
||||
dev = NULL;
|
||||
|
||||
client_start_recv(cm);
|
||||
|
||||
process_request(client);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will start a new recv() on a socket for this client manager.
|
||||
*/
|
||||
isc_result_t
|
||||
client_start_recv(clientmgr_t *cm) {
|
||||
client_t *client;
|
||||
isc_result_t result;
|
||||
isc_region_t r;
|
||||
|
||||
if ((cm->flags & CLIENTMGR_FLAG_SHUTTINGDOWN) != 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
* If a recv is already running, don't bother.
|
||||
*/
|
||||
if ((cm->flags & CLIENTMGR_FLAG_RECVPENDING) != 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
* If we have no idle slots, just return success.
|
||||
*/
|
||||
client = ISC_LIST_HEAD(cm->idle);
|
||||
if (client == NULL)
|
||||
return (ISC_R_SUCCESS);
|
||||
INSIST(CLIENT_ISIDLE(client));
|
||||
|
||||
/*
|
||||
* Issue the recv. If it fails, return that it did.
|
||||
*/
|
||||
r.base = client->buffer;
|
||||
r.length = LWRES_RECVLENGTH;
|
||||
result = isc_socket_recv(cm->sock, &r, 0, cm->task, client_recv,
|
||||
client);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
/*
|
||||
* Set the flag to say we've issued a recv() call.
|
||||
*/
|
||||
cm->flags |= CLIENTMGR_FLAG_RECVPENDING;
|
||||
|
||||
/*
|
||||
* Remove the client from the idle list, and put it on the running
|
||||
* list.
|
||||
*/
|
||||
CLIENT_SETRECV(client);
|
||||
ISC_LIST_UNLINK(cm->idle, client, link);
|
||||
ISC_LIST_APPEND(cm->running, client, link);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
client_shutdown(isc_task_t *task, isc_event_t *ev) {
|
||||
clientmgr_t *cm = ev->ev_arg;
|
||||
|
||||
REQUIRE(task == cm->task);
|
||||
REQUIRE(ev->ev_type == LWRD_SHUTDOWN);
|
||||
REQUIRE((cm->flags & CLIENTMGR_FLAG_SHUTTINGDOWN) == 0);
|
||||
|
||||
DP(50, "got shutdown event, task %p", task);
|
||||
|
||||
/*
|
||||
* Cancel any pending I/O.
|
||||
*/
|
||||
if ((cm->flags & CLIENTMGR_FLAG_RECVPENDING) != 0)
|
||||
isc_socket_cancel(cm->sock, task, ISC_SOCKCANCEL_ALL);
|
||||
|
||||
/*
|
||||
* Run through the running client list and kill off any finds
|
||||
* in progress.
|
||||
*/
|
||||
/* XXXMLG */
|
||||
|
||||
cm->flags |= CLIENTMGR_FLAG_SHUTTINGDOWN;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do all the crap needed to move a client from the run queue to the idle
|
||||
* queue.
|
||||
*/
|
||||
void
|
||||
client_state_idle(client_t *client) {
|
||||
clientmgr_t *cm;
|
||||
|
||||
cm = client->clientmgr;
|
||||
|
||||
INSIST(client->sendbuf == NULL);
|
||||
INSIST(client->sendlength == 0);
|
||||
INSIST(client->arg == NULL);
|
||||
INSIST(client->v4find == NULL);
|
||||
INSIST(client->v6find == NULL);
|
||||
|
||||
ISC_LIST_UNLINK(cm->running, client, link);
|
||||
ISC_LIST_PREPEND(cm->idle, client, link);
|
||||
|
||||
CLIENT_SETIDLE(client);
|
||||
|
||||
clientmgr_can_die(cm);
|
||||
|
||||
client_start_recv(cm);
|
||||
}
|
||||
|
||||
void
|
||||
client_send(isc_task_t *task, isc_event_t *ev) {
|
||||
client_t *client = ev->ev_arg;
|
||||
clientmgr_t *cm = client->clientmgr;
|
||||
isc_socketevent_t *dev = (isc_socketevent_t *)ev;
|
||||
|
||||
UNUSED(task);
|
||||
UNUSED(dev);
|
||||
|
||||
INSIST(CLIENT_ISSEND(client));
|
||||
INSIST(client->sendbuf == dev->region.base);
|
||||
|
||||
DP(50, "task %p for client %p got send-done event", task, client);
|
||||
|
||||
if (client->sendbuf != client->buffer)
|
||||
lwres_context_freemem(cm->lwctx, client->sendbuf,
|
||||
client->sendlength);
|
||||
client->sendbuf = NULL;
|
||||
client->sendlength = 0;
|
||||
|
||||
client_state_idle(client);
|
||||
|
||||
isc_event_free(&ev);
|
||||
}
|
||||
|
||||
void
|
||||
client_initialize(client_t *client, clientmgr_t *cmgr) {
|
||||
client->clientmgr = cmgr;
|
||||
ISC_LINK_INIT(client, link);
|
||||
CLIENT_SETIDLE(client);
|
||||
client->arg = NULL;
|
||||
|
||||
client->recvlength = 0;
|
||||
|
||||
client->sendbuf = NULL;
|
||||
client->sendlength = 0;
|
||||
|
||||
client->find = NULL;
|
||||
client->v4find = NULL;
|
||||
client->v6find = NULL;
|
||||
client->find_wanted = 0;
|
||||
|
||||
client->options = 0;
|
||||
client->byaddr = NULL;
|
||||
client->addrinfo = NULL;
|
||||
|
||||
ISC_LIST_APPEND(cmgr->idle, client, link);
|
||||
}
|
||||
|
||||
void
|
||||
client_init_aliases(client_t *client) {
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < LWRES_MAX_ALIASES ; i++) {
|
||||
client->aliases[i] = NULL;
|
||||
client->aliaslen[i] = 0;
|
||||
}
|
||||
for (i = 0 ; i < LWRES_MAX_ADDRS ; i++) {
|
||||
client->addrs[i].family = 0;
|
||||
client->addrs[i].length = 0;
|
||||
memset(client->addrs[i].address, 0, LWRES_ADDR_MAXLEN);
|
||||
LWRES_LINK_INIT(&client->addrs[i], link);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
client_init_gabn(client_t *client) {
|
||||
/*
|
||||
* Initialize the real name and alias arrays in the reply we're
|
||||
* going to build up.
|
||||
*/
|
||||
client_init_aliases(client);
|
||||
client->gabn.naliases = 0;
|
||||
client->gabn.naddrs = 0;
|
||||
client->gabn.realname = NULL;
|
||||
client->gabn.aliases = client->aliases;
|
||||
client->gabn.realnamelen = 0;
|
||||
client->gabn.aliaslen = client->aliaslen;
|
||||
LWRES_LIST_INIT(client->gabn.addrs);
|
||||
client->gabn.base = NULL;
|
||||
client->gabn.baselen = 0;
|
||||
|
||||
/*
|
||||
* Set up the internal buffer to point to the receive region.
|
||||
*/
|
||||
isc_buffer_init(&client->recv_buffer, client->buffer,
|
||||
LWRES_RECVLENGTH);
|
||||
}
|
||||
|
||||
void
|
||||
client_init_gnba(client_t *client) {
|
||||
/*
|
||||
* Initialize the real name and alias arrays in the reply we're
|
||||
* going to build up.
|
||||
*/
|
||||
client_init_aliases(client);
|
||||
client->gnba.naliases = 0;
|
||||
client->gnba.realname = NULL;
|
||||
client->gnba.aliases = client->aliases;
|
||||
client->gnba.realnamelen = 0;
|
||||
client->gnba.aliaslen = client->aliaslen;
|
||||
client->gnba.base = NULL;
|
||||
client->gnba.baselen = 0;
|
||||
|
||||
isc_buffer_init(&client->recv_buffer, client->buffer,
|
||||
LWRES_RECVLENGTH);
|
||||
}
|
||||
194
bin/lwresd/client.h
Normal file
194
bin/lwresd/client.h
Normal file
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: client.h,v 1.18.4.1 2001/01/09 22:31:40 bwelling Exp $ */
|
||||
|
||||
#ifndef LWD_CLIENT_H
|
||||
#define LWD_CLIENT_H 1
|
||||
|
||||
#include <isc/event.h>
|
||||
#include <isc/eventclass.h>
|
||||
#include <isc/netaddr.h>
|
||||
#include <isc/sockaddr.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/types.h>
|
||||
|
||||
#include <lwres/lwres.h>
|
||||
|
||||
#define LWRD_EVENTCLASS ISC_EVENTCLASS(4242)
|
||||
|
||||
#define LWRD_SHUTDOWN (LWRD_EVENTCLASS + 0x0001)
|
||||
|
||||
typedef struct client_s client_t;
|
||||
typedef struct clientmgr_s clientmgr_t;
|
||||
|
||||
struct client_s {
|
||||
isc_sockaddr_t address; /* where to reply */
|
||||
clientmgr_t *clientmgr; /* our parent */
|
||||
ISC_LINK(client_t) link;
|
||||
unsigned int state;
|
||||
void *arg; /* packet processing state */
|
||||
|
||||
/*
|
||||
* Received data info.
|
||||
*/
|
||||
unsigned char buffer[LWRES_RECVLENGTH]; /* receive buffer */
|
||||
isc_uint32_t recvlength; /* length recv'd */
|
||||
lwres_lwpacket_t pkt;
|
||||
|
||||
/*
|
||||
* Send data state. If sendbuf != buffer (that is, the send buffer
|
||||
* isn't our receive buffer) it will be freed to the lwres_context_t.
|
||||
*/
|
||||
unsigned char *sendbuf;
|
||||
isc_uint32_t sendlength;
|
||||
isc_buffer_t recv_buffer;
|
||||
|
||||
/*
|
||||
* gabn (get address by name) state info.
|
||||
*/
|
||||
dns_adbfind_t *find;
|
||||
dns_adbfind_t *v4find;
|
||||
dns_adbfind_t *v6find;
|
||||
unsigned int find_wanted; /* Addresses we want */
|
||||
dns_fixedname_t target_name;
|
||||
lwres_gabnresponse_t gabn;
|
||||
|
||||
/*
|
||||
* gnba (get name by address) state info.
|
||||
*/
|
||||
lwres_gnbaresponse_t gnba;
|
||||
dns_byaddr_t *byaddr;
|
||||
unsigned int options;
|
||||
isc_netaddr_t na;
|
||||
dns_adbaddrinfo_t *addrinfo;
|
||||
|
||||
/*
|
||||
* Alias and address info. This is copied up to the gabn/gnba
|
||||
* structures eventually.
|
||||
*
|
||||
* XXXMLG We can keep all of this in a client since we only service
|
||||
* three packet types right now. If we started handling more,
|
||||
* we'd need to use "arg" above and allocate/destroy things.
|
||||
*/
|
||||
char *aliases[LWRES_MAX_ALIASES];
|
||||
isc_uint16_t aliaslen[LWRES_MAX_ALIASES];
|
||||
lwres_addr_t addrs[LWRES_MAX_ADDRS];
|
||||
};
|
||||
|
||||
/*
|
||||
* Client states.
|
||||
*
|
||||
* _IDLE The client is not doing anything at all.
|
||||
*
|
||||
* _RECV The client is waiting for data after issuing a socket recv().
|
||||
*
|
||||
* _RECVDONE Data has been received, and is being processed.
|
||||
*
|
||||
* _FINDWAIT An adb (or other) request was made that cannot be satisfied
|
||||
* immediately. An event will wake the client up.
|
||||
*
|
||||
* _SEND All data for a response has completed, and a reply was
|
||||
* sent via a socket send() call.
|
||||
*
|
||||
* Badly formatted state table:
|
||||
*
|
||||
* IDLE -> RECV when client has a recv() queued.
|
||||
*
|
||||
* RECV -> RECVDONE when recvdone event received.
|
||||
*
|
||||
* RECVDONE -> SEND if the data for a reply is at hand.
|
||||
* RECVDONE -> FINDWAIT if more searching is needed, and events will
|
||||
* eventually wake us up again.
|
||||
*
|
||||
* FINDWAIT -> SEND when enough data was received to reply.
|
||||
*
|
||||
* SEND -> IDLE when a senddone event was received.
|
||||
*
|
||||
* At any time -> IDLE on error. Sometimes this will be -> SEND
|
||||
* instead, if enough data is on hand to reply with a meaningful
|
||||
* error.
|
||||
*
|
||||
* Packets which are badly formatted may or may not get error returns.
|
||||
*/
|
||||
#define CLIENT_STATE_IDLE 1
|
||||
#define CLIENT_STATE_RECV 2
|
||||
#define CLIENT_STATE_RECVDONE 3
|
||||
#define CLIENT_STATE_FINDWAIT 4
|
||||
#define CLIENT_STATE_SEND 5
|
||||
#define CLIENT_STATE_SENDDONE 6
|
||||
|
||||
#define CLIENT_ISIDLE(c) ((c)->state == CLIENT_STATE_IDLE)
|
||||
#define CLIENT_ISRECV(c) ((c)->state == CLIENT_STATE_RECV)
|
||||
#define CLIENT_ISRECVDONE(c) ((c)->state == CLIENT_STATE_RECVDONE)
|
||||
#define CLIENT_ISFINDWAIT(c) ((c)->state == CLIENT_STATE_FINDWAIT)
|
||||
#define CLIENT_ISSEND(c) ((c)->state == CLIENT_STATE_SEND)
|
||||
|
||||
/*
|
||||
* Overall magic test that means we're not idle.
|
||||
*/
|
||||
#define CLIENT_ISRUNNING(c) (!CLIENT_ISIDLE(c))
|
||||
|
||||
#define CLIENT_SETIDLE(c) ((c)->state = CLIENT_STATE_IDLE)
|
||||
#define CLIENT_SETRECV(c) ((c)->state = CLIENT_STATE_RECV)
|
||||
#define CLIENT_SETRECVDONE(c) ((c)->state = CLIENT_STATE_RECVDONE)
|
||||
#define CLIENT_SETFINDWAIT(c) ((c)->state = CLIENT_STATE_FINDWAIT)
|
||||
#define CLIENT_SETSEND(c) ((c)->state = CLIENT_STATE_SEND)
|
||||
#define CLIENT_SETSENDDONE(c) ((c)->state = CLIENT_STATE_SENDDONE)
|
||||
|
||||
struct clientmgr_s {
|
||||
isc_mem_t *mctx;
|
||||
isc_task_t *task; /* owning task */
|
||||
isc_socket_t *sock; /* socket to use */
|
||||
dns_view_t *view;
|
||||
unsigned int flags;
|
||||
isc_event_t sdev; /* shutdown event */
|
||||
lwres_context_t *lwctx; /* lightweight proto context */
|
||||
ISC_LIST(client_t) idle; /* idle client slots */
|
||||
ISC_LIST(client_t) running; /* running clients */
|
||||
};
|
||||
|
||||
#define CLIENTMGR_FLAG_RECVPENDING 0x00000001
|
||||
#define CLIENTMGR_FLAG_SHUTTINGDOWN 0x00000002
|
||||
|
||||
void client_initialize(client_t *, clientmgr_t *);
|
||||
isc_result_t client_start_recv(clientmgr_t *);
|
||||
void client_state_idle(client_t *);
|
||||
|
||||
void client_recv(isc_task_t *, isc_event_t *);
|
||||
void client_shutdown(isc_task_t *, isc_event_t *);
|
||||
void client_send(isc_task_t *, isc_event_t *);
|
||||
|
||||
/*
|
||||
* Processing functions of various types.
|
||||
*/
|
||||
void process_gabn(client_t *, lwres_buffer_t *);
|
||||
void process_gnba(client_t *, lwres_buffer_t *);
|
||||
void process_noop(client_t *, lwres_buffer_t *);
|
||||
|
||||
void error_pkt_send(client_t *, isc_uint32_t);
|
||||
|
||||
void client_init_aliases(client_t *);
|
||||
void client_init_gabn(client_t *);
|
||||
void client_init_gnba(client_t *);
|
||||
|
||||
void DP(int level, const char *format, ...);
|
||||
void hexdump(char *msg, void *base, size_t len);
|
||||
|
||||
#endif /* LWD_CLIENT_H */
|
||||
81
bin/lwresd/err_pkt.c
Normal file
81
bin/lwresd/err_pkt.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: err_pkt.c,v 1.7.4.1 2001/01/09 22:31:41 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <isc/socket.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include "client.h"
|
||||
|
||||
/*
|
||||
* Generate an error packet for the client, schedule a send, and put us in
|
||||
* the SEND state.
|
||||
*
|
||||
* The client->pkt structure will be modified to form an error return.
|
||||
* The receiver needs to verify that it is in fact an error, and do the
|
||||
* right thing with it. The opcode will be unchanged. The result needs
|
||||
* to be set before calling this function.
|
||||
*
|
||||
* The only change this code makes is to set the receive buffer size to the
|
||||
* size we use, set the reply bit, and recompute any security information.
|
||||
*/
|
||||
void
|
||||
error_pkt_send(client_t *client, isc_uint32_t _result) {
|
||||
isc_result_t result;
|
||||
int lwres;
|
||||
isc_region_t r;
|
||||
lwres_buffer_t b;
|
||||
clientmgr_t *cm;
|
||||
|
||||
cm = client->clientmgr;
|
||||
|
||||
REQUIRE(CLIENT_ISRUNNING(client));
|
||||
|
||||
/*
|
||||
* Since we are only sending the packet header, we can safely toss
|
||||
* the receive buffer. This means we won't need to allocate space
|
||||
* for sending an error reply. This is a Good Thing.
|
||||
*/
|
||||
client->pkt.length = LWRES_LWPACKET_LENGTH;
|
||||
client->pkt.pktflags |= LWRES_LWPACKETFLAG_RESPONSE;
|
||||
client->pkt.recvlength = LWRES_RECVLENGTH;
|
||||
client->pkt.authtype = 0; /* XXXMLG */
|
||||
client->pkt.authlength = 0;
|
||||
client->pkt.result = _result;
|
||||
|
||||
lwres_buffer_init(&b, client->buffer, LWRES_RECVLENGTH);
|
||||
lwres = lwres_lwpacket_renderheader(&b, &client->pkt);
|
||||
if (lwres != LWRES_R_SUCCESS) {
|
||||
client_state_idle(client);
|
||||
return;
|
||||
}
|
||||
|
||||
r.base = client->buffer;
|
||||
r.length = b.used;
|
||||
client->sendbuf = client->buffer;
|
||||
result = isc_socket_sendto(cm->sock, &r, cm->task, client_send, client,
|
||||
&client->address, NULL);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
client_state_idle(client);
|
||||
return;
|
||||
}
|
||||
|
||||
CLIENT_SETSEND(client);
|
||||
}
|
||||
509
bin/lwresd/main.c
Normal file
509
bin/lwresd/main.c
Normal file
@@ -0,0 +1,509 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: main.c,v 1.45.4.1 2001/01/09 22:31:42 bwelling Exp $ */
|
||||
|
||||
/*
|
||||
* Main program for the Lightweight Resolver Daemon.
|
||||
*
|
||||
* To paraphrase the old saying about X11, "It's not a lightweight deamon
|
||||
* for resolvers, it's a deamon for lightweight resolvers".
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/app.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/timer.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/cache.h>
|
||||
#include <dns/db.h>
|
||||
#include <dns/dispatch.h>
|
||||
#include <dns/log.h>
|
||||
#include <dns/resolver.h>
|
||||
#include <dns/result.h>
|
||||
#include <dns/rootns.h>
|
||||
#include <dns/view.h>
|
||||
|
||||
#include "client.h"
|
||||
|
||||
/*
|
||||
* The goal number of clients we can handle will be NTASKS * NRECVS.
|
||||
*/
|
||||
#define NTASKS 20 /* tasks to create to handle lwres queries */
|
||||
#define NRECVS 5 /* max clients per task */
|
||||
#define NTHREADS 1 /* # threads to create in thread manager */
|
||||
|
||||
/*
|
||||
* Array of client managers. Each of these will have a task associated
|
||||
* with it.
|
||||
*/
|
||||
clientmgr_t *cmgr;
|
||||
unsigned int ntasks; /* number of tasks actually created */
|
||||
|
||||
dns_view_t *view;
|
||||
|
||||
isc_taskmgr_t *taskmgr;
|
||||
isc_socketmgr_t *sockmgr;
|
||||
isc_timermgr_t *timermgr;
|
||||
dns_dispatchmgr_t *dispatchmgr;
|
||||
|
||||
isc_sockaddrlist_t forwarders;
|
||||
|
||||
static isc_logmodule_t logmodules[] = {
|
||||
{ "main", 0 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
#define LWRES_LOGMODULE_MAIN (&logmodules[0])
|
||||
|
||||
static isc_logcategory_t logcategories[] = {
|
||||
{ "network", 0 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
#define LWRES_LOGCATEGORY_NETWORK (&logcategories[0])
|
||||
|
||||
|
||||
static isc_result_t
|
||||
create_view(isc_mem_t *mctx) {
|
||||
dns_cache_t *cache;
|
||||
isc_result_t result;
|
||||
dns_db_t *rootdb;
|
||||
unsigned int attrs;
|
||||
dns_dispatch_t *disp4 = NULL;
|
||||
dns_dispatch_t *disp6 = NULL;
|
||||
|
||||
view = NULL;
|
||||
cache = NULL;
|
||||
|
||||
/*
|
||||
* View.
|
||||
*/
|
||||
result = dns_view_create(mctx, dns_rdataclass_in, "_default", &view);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* Cache.
|
||||
*/
|
||||
result = dns_cache_create(mctx, taskmgr, timermgr, dns_rdataclass_in,
|
||||
"rbt", 0, NULL, &cache);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
dns_view_setcache(view, cache);
|
||||
dns_cache_detach(&cache);
|
||||
|
||||
/*
|
||||
* Resolver.
|
||||
*
|
||||
* XXXMLG hardwired number of tasks.
|
||||
*/
|
||||
|
||||
if (isc_net_probeipv4() == ISC_R_SUCCESS) {
|
||||
isc_sockaddr_t any4;
|
||||
|
||||
isc_sockaddr_any(&any4);
|
||||
attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP;
|
||||
result = dns_dispatch_getudp(dispatchmgr, sockmgr,
|
||||
taskmgr, &any4, 512, 6, 1024,
|
||||
17, 19, attrs, attrs, &disp4);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (isc_net_probeipv6() == ISC_R_SUCCESS) {
|
||||
isc_sockaddr_t any6;
|
||||
|
||||
isc_sockaddr_any6(&any6);
|
||||
|
||||
attrs = DNS_DISPATCHATTR_IPV6 | DNS_DISPATCHATTR_UDP;
|
||||
result = dns_dispatch_getudp(dispatchmgr, sockmgr,
|
||||
taskmgr, &any6, 512, 6, 1024,
|
||||
17, 19, attrs, attrs, &disp6);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
}
|
||||
|
||||
result = dns_view_createresolver(view, taskmgr, 16, sockmgr,
|
||||
timermgr, 0, dispatchmgr,
|
||||
disp4, disp6);
|
||||
|
||||
if (disp4 != NULL)
|
||||
dns_dispatch_detach(&disp4);
|
||||
if (disp6 != NULL)
|
||||
dns_dispatch_detach(&disp6);
|
||||
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
rootdb = NULL;
|
||||
result = dns_rootns_create(mctx, dns_rdataclass_in, NULL, &rootdb);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
dns_view_sethints(view, rootdb);
|
||||
dns_db_detach(&rootdb);
|
||||
|
||||
/*
|
||||
* If we have forwarders, set them here.
|
||||
*/
|
||||
if (ISC_LIST_HEAD(forwarders) != NULL) {
|
||||
isc_sockaddr_t *sa;
|
||||
|
||||
dns_resolver_setforwarders(view->resolver, &forwarders);
|
||||
dns_resolver_setfwdpolicy(view->resolver, dns_fwdpolicy_only);
|
||||
sa = ISC_LIST_HEAD(forwarders);
|
||||
while (sa != NULL) {
|
||||
ISC_LIST_UNLINK(forwarders, sa, link);
|
||||
isc_mem_put(mctx, sa, sizeof (*sa));
|
||||
sa = ISC_LIST_HEAD(forwarders);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dns_view_freeze(view);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
out:
|
||||
if (view != NULL)
|
||||
dns_view_detach(&view);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrappers around our memory management stuff, for the lwres functions.
|
||||
*/
|
||||
static void *
|
||||
mem_alloc(void *arg, size_t size) {
|
||||
return (isc_mem_get(arg, size));
|
||||
}
|
||||
|
||||
static void
|
||||
mem_free(void *arg, void *mem, size_t size) {
|
||||
isc_mem_put(arg, mem, size);
|
||||
}
|
||||
|
||||
static void
|
||||
parse_resolv_conf(isc_mem_t *mem) {
|
||||
lwres_context_t *lwctx;
|
||||
lwres_conf_t *lwc;
|
||||
int lwresult;
|
||||
struct in_addr ina;
|
||||
struct in6_addr ina6;
|
||||
isc_sockaddr_t *sa;
|
||||
int i;
|
||||
|
||||
lwctx = NULL;
|
||||
lwresult = lwres_context_create(&lwctx, mem, mem_alloc, mem_free,
|
||||
LWRES_CONTEXT_SERVERMODE);
|
||||
if (lwresult != LWRES_R_SUCCESS)
|
||||
return;
|
||||
|
||||
lwresult = lwres_conf_parse(lwctx, "/etc/resolv.conf");
|
||||
if (lwresult != LWRES_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
#if 1
|
||||
lwres_conf_print(lwctx, stderr);
|
||||
#endif
|
||||
|
||||
lwc = lwres_conf_get(lwctx);
|
||||
INSIST(lwc != NULL);
|
||||
|
||||
/*
|
||||
* Run through the list of nameservers, and set them to be our
|
||||
* forwarders.
|
||||
*/
|
||||
for (i = 0 ; i < lwc->nsnext ; i++) {
|
||||
switch (lwc->nameservers[i].family) {
|
||||
case AF_INET:
|
||||
sa = isc_mem_get(mem, sizeof *sa);
|
||||
INSIST(sa != NULL);
|
||||
memcpy(&ina.s_addr, lwc->nameservers[i].address, 4);
|
||||
isc_sockaddr_fromin(sa, &ina, 53);
|
||||
ISC_LIST_APPEND(forwarders, sa, link);
|
||||
sa = NULL;
|
||||
break;
|
||||
case AF_INET6:
|
||||
sa = isc_mem_get(mem, sizeof *sa);
|
||||
INSIST(sa != NULL);
|
||||
memcpy(&ina6.s6_addr, lwc->nameservers[i].address, 16);
|
||||
isc_sockaddr_fromin6(sa, &ina6, 53);
|
||||
ISC_LIST_APPEND(forwarders, sa, link);
|
||||
sa = NULL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
lwres_conf_clear(lwctx);
|
||||
lwres_context_destroy(&lwctx);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
isc_mem_t *mem;
|
||||
isc_socket_t *sock;
|
||||
isc_sockaddr_t localhost;
|
||||
struct in_addr lh_addr;
|
||||
isc_result_t result;
|
||||
unsigned int i, j;
|
||||
client_t *client;
|
||||
isc_logdestination_t destination;
|
||||
isc_log_t *lctx;
|
||||
isc_logconfig_t *lcfg;
|
||||
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
||||
dns_result_register();
|
||||
|
||||
result = isc_app_start();
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
||||
mem = NULL;
|
||||
result = isc_mem_create(0, 0, &mem);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
* Set up logging.
|
||||
*/
|
||||
lctx = NULL;
|
||||
result = isc_log_create(mem, &lctx, &lcfg);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
isc_log_registermodules(lctx, logmodules);
|
||||
isc_log_registercategories(lctx, logcategories);
|
||||
isc_log_setcontext(lctx);
|
||||
dns_log_init(lctx);
|
||||
dns_log_setcontext(lctx);
|
||||
|
||||
destination.file.stream = stderr;
|
||||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
destination.file.maximum_size = 0;
|
||||
result = isc_log_createchannel(lcfg, "_default",
|
||||
ISC_LOG_TOFILEDESC,
|
||||
ISC_LOG_DYNAMIC,
|
||||
&destination, ISC_LOG_PRINTTIME);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
result = isc_log_usechannel(lcfg, "_default", NULL, NULL);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
* Set the initial debug level.
|
||||
*/
|
||||
isc_log_setdebuglevel(lctx, 99);
|
||||
|
||||
/*
|
||||
* Create a task manager.
|
||||
*/
|
||||
taskmgr = NULL;
|
||||
result = isc_taskmgr_create(mem, NTHREADS, 0, &taskmgr);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
* Create a socket manager.
|
||||
*/
|
||||
sockmgr = NULL;
|
||||
result = isc_socketmgr_create(mem, &sockmgr);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
* Create a timer manager.
|
||||
*/
|
||||
timermgr = NULL;
|
||||
result = isc_timermgr_create(mem, &timermgr);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
* Create a dispatch manager.
|
||||
*/
|
||||
dispatchmgr = NULL;
|
||||
result = dns_dispatchmgr_create(mem, NULL, &dispatchmgr);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
* Read resolv.conf to get our forwarders.
|
||||
*/
|
||||
ISC_LIST_INIT(forwarders);
|
||||
parse_resolv_conf(mem);
|
||||
|
||||
/*
|
||||
* Initialize the DNS bits. Start by loading our built-in
|
||||
* root hints.
|
||||
*/
|
||||
result = create_view(mem);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
* We'll need a socket. It will be a UDP socket, and bound to
|
||||
* 127.0.0.1 port LWRES_UDP_PORT.
|
||||
*/
|
||||
sock = NULL;
|
||||
result = isc_socket_create(sockmgr, AF_INET, isc_sockettype_udp,
|
||||
&sock);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
||||
lh_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
isc_sockaddr_fromin(&localhost, &lh_addr, LWRES_UDP_PORT);
|
||||
|
||||
result = isc_socket_bind(sock, &localhost);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(lctx, LWRES_LOGCATEGORY_NETWORK,
|
||||
LWRES_LOGMODULE_MAIN, ISC_LOG_ERROR,
|
||||
"binding lwres protocol socket to port %d: %s",
|
||||
LWRES_UDP_PORT,
|
||||
isc_result_totext(result));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
||||
cmgr = isc_mem_get(mem, sizeof(clientmgr_t) * NTASKS);
|
||||
INSIST(cmgr != NULL);
|
||||
|
||||
/*
|
||||
* Create one task for each client manager.
|
||||
*/
|
||||
for (i = 0 ; i < NTASKS ; i++) {
|
||||
cmgr[i].task = NULL;
|
||||
cmgr[i].sock = sock;
|
||||
cmgr[i].view = NULL;
|
||||
cmgr[i].flags = 0;
|
||||
result = isc_task_create(taskmgr, 0, &cmgr[i].task);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
break;
|
||||
ISC_EVENT_INIT(&cmgr[i].sdev, sizeof(isc_event_t),
|
||||
ISC_EVENTATTR_NOPURGE,
|
||||
0, LWRD_SHUTDOWN,
|
||||
client_shutdown, &cmgr[i], cmgr[i].task,
|
||||
NULL, NULL);
|
||||
ISC_LIST_INIT(cmgr[i].idle);
|
||||
ISC_LIST_INIT(cmgr[i].running);
|
||||
isc_task_setname(cmgr[i].task, "lwresd client", &cmgr[i]);
|
||||
cmgr[i].mctx = mem;
|
||||
cmgr[i].lwctx = NULL;
|
||||
result = lwres_context_create(&cmgr[i].lwctx, mem,
|
||||
mem_alloc, mem_free,
|
||||
LWRES_CONTEXT_SERVERMODE);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_task_detach(&cmgr[i].task);
|
||||
break;
|
||||
}
|
||||
dns_view_attach(view, &cmgr[i].view);
|
||||
}
|
||||
INSIST(i > 0);
|
||||
ntasks = i; /* remember how many we managed to create */
|
||||
|
||||
/*
|
||||
* Now, run through each client manager and populate it with
|
||||
* client structures. Do this by creating one receive for each
|
||||
* task, in a loop, so each task has a chance of getting at least
|
||||
* one client structure.
|
||||
*/
|
||||
for (i = 0 ; i < NRECVS ; i++) {
|
||||
client = isc_mem_get(mem, sizeof(client_t) * ntasks);
|
||||
if (client == NULL)
|
||||
break;
|
||||
for (j = 0 ; j < ntasks ; j++)
|
||||
client_initialize(&client[j], &cmgr[j]);
|
||||
}
|
||||
INSIST(i > 0);
|
||||
|
||||
/*
|
||||
* Issue one read request for each task we have.
|
||||
*/
|
||||
for (j = 0 ; j < ntasks ; j++) {
|
||||
result = client_start_recv(&cmgr[j]);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for ^c or kill.
|
||||
*/
|
||||
isc_app_run();
|
||||
|
||||
/*
|
||||
* Send a shutdown event to every task.
|
||||
*/
|
||||
for (j = 0 ; j < ntasks ; j++) {
|
||||
isc_event_t *ev;
|
||||
|
||||
ev = &cmgr[j].sdev;
|
||||
isc_task_send(cmgr[j].task, &ev);
|
||||
}
|
||||
|
||||
/*
|
||||
* Kill off the view.
|
||||
*/
|
||||
dns_view_detach(&view);
|
||||
|
||||
/*
|
||||
* Wait for the tasks to all die.
|
||||
*/
|
||||
isc_taskmgr_destroy(&taskmgr);
|
||||
|
||||
/*
|
||||
* Wait for everything to die off by waiting for the sockets
|
||||
* to be detached.
|
||||
*/
|
||||
isc_socket_detach(&sock);
|
||||
isc_socketmgr_destroy(&sockmgr);
|
||||
|
||||
isc_timermgr_destroy(&timermgr);
|
||||
|
||||
/*
|
||||
* Free up memory allocated. This is somewhat magical. We allocated
|
||||
* the client_t's in blocks, but the first task always has the
|
||||
* first pointer. Just loop here, freeing them.
|
||||
*/
|
||||
client = ISC_LIST_HEAD(cmgr[0].idle);
|
||||
while (client != NULL) {
|
||||
ISC_LIST_UNLINK(cmgr[0].idle, client, link);
|
||||
isc_mem_put(mem, client, sizeof(client_t) * ntasks);
|
||||
client = ISC_LIST_HEAD(cmgr[0].idle);
|
||||
}
|
||||
INSIST(ISC_LIST_EMPTY(cmgr[0].running));
|
||||
|
||||
/*
|
||||
* Now, kill off the client manager structures.
|
||||
*/
|
||||
isc_mem_put(mem, cmgr, sizeof(clientmgr_t) * NTASKS);
|
||||
cmgr = NULL;
|
||||
|
||||
dns_dispatchmgr_destroy(&dispatchmgr);
|
||||
|
||||
isc_log_destroy(&lctx);
|
||||
|
||||
/*
|
||||
* Kill the memory system.
|
||||
*/
|
||||
isc_mem_destroy(&mem);
|
||||
|
||||
isc_app_finish();
|
||||
|
||||
return (0);
|
||||
}
|
||||
526
bin/lwresd/process_gabn.c
Normal file
526
bin/lwresd/process_gabn.c
Normal file
@@ -0,0 +1,526 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: process_gabn.c,v 1.31.4.1 2001/01/09 22:31:44 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <isc/socket.h>
|
||||
#include <isc/string.h> /* Required for HP/UX (and others?) */
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/adb.h>
|
||||
#include <dns/events.h>
|
||||
#include <dns/result.h>
|
||||
|
||||
#include "client.h"
|
||||
|
||||
#define NEED_V4(c) ((((c)->find_wanted & LWRES_ADDRTYPE_V4) != 0) \
|
||||
&& ((c)->v4find == NULL))
|
||||
#define NEED_V6(c) ((((c)->find_wanted & LWRES_ADDRTYPE_V6) != 0) \
|
||||
&& ((c)->v6find == NULL))
|
||||
|
||||
static void start_find(client_t *);
|
||||
|
||||
/*
|
||||
* Destroy any finds. This can be used to "start over from scratch" and
|
||||
* should only be called when events are _not_ being generated by the finds.
|
||||
*/
|
||||
static void
|
||||
cleanup_gabn(client_t *client) {
|
||||
dns_adbfind_t *v4;
|
||||
|
||||
DP(50, "cleaning up client %p", client);
|
||||
|
||||
v4 = client->v4find;
|
||||
|
||||
if (client->v4find != NULL)
|
||||
dns_adb_destroyfind(&client->v4find);
|
||||
if (client->v6find != NULL) {
|
||||
if (client->v6find == v4)
|
||||
client->v6find = NULL;
|
||||
else
|
||||
dns_adb_destroyfind(&client->v6find);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
setup_addresses(client_t *client, dns_adbfind_t *find, unsigned int at) {
|
||||
dns_adbaddrinfo_t *ai;
|
||||
lwres_addr_t *addr;
|
||||
int af;
|
||||
const struct sockaddr *sa;
|
||||
const struct sockaddr_in *sin;
|
||||
const struct sockaddr_in6 *sin6;
|
||||
|
||||
if (at == DNS_ADBFIND_INET)
|
||||
af = AF_INET;
|
||||
else
|
||||
af = AF_INET6;
|
||||
|
||||
ai = ISC_LIST_HEAD(find->list);
|
||||
while (ai != NULL && client->gabn.naddrs < LWRES_MAX_ADDRS) {
|
||||
sa = &ai->sockaddr.type.sa;
|
||||
if (sa->sa_family != af)
|
||||
goto next;
|
||||
|
||||
addr = &client->addrs[client->gabn.naddrs];
|
||||
|
||||
switch (sa->sa_family) {
|
||||
case AF_INET:
|
||||
sin = &ai->sockaddr.type.sin;
|
||||
addr->family = LWRES_ADDRTYPE_V4;
|
||||
memcpy(addr->address, &sin->sin_addr, 4);
|
||||
addr->length = 4;
|
||||
break;
|
||||
case AF_INET6:
|
||||
sin6 = &ai->sockaddr.type.sin6;
|
||||
addr->family = LWRES_ADDRTYPE_V6;
|
||||
memcpy(addr->address, &sin6->sin6_addr, 16);
|
||||
addr->length = 16;
|
||||
break;
|
||||
default:
|
||||
goto next;
|
||||
}
|
||||
|
||||
DP(50, "adding address %p, family %d, length %d",
|
||||
addr->address, addr->family, addr->length);
|
||||
|
||||
client->gabn.naddrs++;
|
||||
REQUIRE(!LWRES_LINK_LINKED(addr, link));
|
||||
LWRES_LIST_APPEND(client->gabn.addrs, addr, link);
|
||||
|
||||
next:
|
||||
ai = ISC_LIST_NEXT(ai, publink);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
generate_reply(client_t *client) {
|
||||
isc_result_t result;
|
||||
int lwres;
|
||||
isc_region_t r;
|
||||
lwres_buffer_t lwb;
|
||||
clientmgr_t *cm;
|
||||
|
||||
cm = client->clientmgr;
|
||||
lwb.base = NULL;
|
||||
|
||||
DP(50, "generating gabn reply for client %p", client);
|
||||
|
||||
/*
|
||||
* We must make certain the client->find is not still active.
|
||||
* If it is either the v4 or v6 answer, just set it to NULL and
|
||||
* let the cleanup code destroy it. Otherwise, destroy it now.
|
||||
*/
|
||||
if (client->find == client->v4find || client->find == client->v6find)
|
||||
client->find = NULL;
|
||||
else
|
||||
if (client->find != NULL)
|
||||
dns_adb_destroyfind(&client->find);
|
||||
|
||||
/*
|
||||
* perhaps there are some here?
|
||||
*/
|
||||
if (NEED_V6(client) && client->v4find != NULL)
|
||||
client->v6find = client->v4find;
|
||||
|
||||
/*
|
||||
* Run through the finds we have and wire them up to the gabn
|
||||
* structure.
|
||||
*/
|
||||
LWRES_LIST_INIT(client->gabn.addrs);
|
||||
if (client->v4find != NULL)
|
||||
setup_addresses(client, client->v4find, DNS_ADBFIND_INET);
|
||||
if (client->v6find != NULL)
|
||||
setup_addresses(client, client->v6find, DNS_ADBFIND_INET6);
|
||||
|
||||
/*
|
||||
* Render the packet.
|
||||
*/
|
||||
client->pkt.recvlength = LWRES_RECVLENGTH;
|
||||
client->pkt.authtype = 0; /* XXXMLG */
|
||||
client->pkt.authlength = 0;
|
||||
|
||||
/*
|
||||
* If there are no addresses and no aliases, return failure.
|
||||
*/
|
||||
if (client->gabn.naddrs == 0 && client->gabn.naliases == 0)
|
||||
client->pkt.result = LWRES_R_NOTFOUND;
|
||||
else
|
||||
client->pkt.result = LWRES_R_SUCCESS;
|
||||
|
||||
lwres = lwres_gabnresponse_render(cm->lwctx, &client->gabn,
|
||||
&client->pkt, &lwb);
|
||||
if (lwres != LWRES_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
r.base = lwb.base;
|
||||
r.length = lwb.used;
|
||||
client->sendbuf = r.base;
|
||||
client->sendlength = r.length;
|
||||
result = isc_socket_sendto(cm->sock, &r, cm->task, client_send, client,
|
||||
&client->address, NULL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
CLIENT_SETSEND(client);
|
||||
|
||||
/*
|
||||
* All done!
|
||||
*/
|
||||
cleanup_gabn(client);
|
||||
|
||||
return;
|
||||
|
||||
out:
|
||||
cleanup_gabn(client);
|
||||
|
||||
if (lwb.base != NULL)
|
||||
lwres_context_freemem(client->clientmgr->lwctx,
|
||||
lwb.base, lwb.length);
|
||||
|
||||
error_pkt_send(client, LWRES_R_FAILURE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Take the current real name, move it to an alias slot (if any are
|
||||
* open) then put this new name in as the real name for the target.
|
||||
*
|
||||
* Return success if it can be rendered, otherwise failure. Note that
|
||||
* not having enough alias slots open is NOT a failure.
|
||||
*/
|
||||
static isc_result_t
|
||||
add_alias(client_t *client) {
|
||||
isc_buffer_t b;
|
||||
isc_result_t result;
|
||||
isc_uint16_t naliases;
|
||||
|
||||
b = client->recv_buffer;
|
||||
|
||||
/*
|
||||
* Render the new name to the buffer.
|
||||
*/
|
||||
result = dns_name_totext(dns_fixedname_name(&client->target_name),
|
||||
ISC_TRUE, &client->recv_buffer);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
/*
|
||||
* Are there any open slots?
|
||||
*/
|
||||
naliases = client->gabn.naliases;
|
||||
if (naliases < LWRES_MAX_ALIASES) {
|
||||
client->gabn.aliases[naliases] = client->gabn.realname;
|
||||
client->gabn.aliaslen[naliases] = client->gabn.realnamelen;
|
||||
client->gabn.naliases++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save this name away as the current real name.
|
||||
*/
|
||||
client->gabn.realname = (char *)(b.base) + b.used;
|
||||
client->gabn.realnamelen = client->recv_buffer.used - b.used;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
store_realname(client_t *client) {
|
||||
isc_buffer_t b;
|
||||
isc_result_t result;
|
||||
|
||||
b = client->recv_buffer;
|
||||
|
||||
/*
|
||||
* Render the new name to the buffer.
|
||||
*/
|
||||
result = dns_name_totext(dns_fixedname_name(&client->target_name),
|
||||
ISC_TRUE, &client->recv_buffer);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
/*
|
||||
* Save this name away as the current real name.
|
||||
*/
|
||||
client->gabn.realname = (char *) b.base + b.used;
|
||||
client->gabn.realnamelen = client->recv_buffer.used - b.used;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
process_gabn_finddone(isc_task_t *task, isc_event_t *ev) {
|
||||
client_t *client = ev->ev_arg;
|
||||
isc_eventtype_t evtype;
|
||||
isc_boolean_t claimed;
|
||||
|
||||
DP(50, "find done for task %p, client %p", task, client);
|
||||
|
||||
evtype = ev->ev_type;
|
||||
isc_event_free(&ev);
|
||||
|
||||
/*
|
||||
* No more info to be had? If so, we have all the good stuff
|
||||
* right now, so we can render things.
|
||||
*/
|
||||
claimed = ISC_FALSE;
|
||||
if (evtype == DNS_EVENT_ADBNOMOREADDRESSES) {
|
||||
if (NEED_V4(client)) {
|
||||
client->v4find = client->find;
|
||||
claimed = ISC_TRUE;
|
||||
}
|
||||
if (NEED_V6(client)) {
|
||||
client->v6find = client->find;
|
||||
claimed = ISC_TRUE;
|
||||
}
|
||||
if (client->find != NULL) {
|
||||
if (claimed)
|
||||
client->find = NULL;
|
||||
else
|
||||
dns_adb_destroyfind(&client->find);
|
||||
|
||||
}
|
||||
generate_reply(client);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* We probably don't need this find anymore. We're either going to
|
||||
* reissue it, or an error occurred. Either way, we're done with
|
||||
* it.
|
||||
*/
|
||||
if ((client->find != client->v4find)
|
||||
&& (client->find != client->v6find)) {
|
||||
dns_adb_destroyfind(&client->find);
|
||||
} else {
|
||||
client->find = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* We have some new information we can gather. Run off and fetch
|
||||
* it.
|
||||
*/
|
||||
if (evtype == DNS_EVENT_ADBMOREADDRESSES) {
|
||||
start_find(client);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* An error or other strangeness happened. Drop this query.
|
||||
*/
|
||||
cleanup_gabn(client);
|
||||
error_pkt_send(client, LWRES_R_FAILURE);
|
||||
}
|
||||
|
||||
static void
|
||||
start_find(client_t *client) {
|
||||
unsigned int options;
|
||||
isc_result_t result;
|
||||
isc_boolean_t claimed;
|
||||
|
||||
DP(50, "starting find for client %p", client);
|
||||
|
||||
/*
|
||||
* Issue a find for the name contained in the request. We won't
|
||||
* set the bit that says "anything is good enough" -- we want it
|
||||
* all.
|
||||
*/
|
||||
options = 0;
|
||||
options |= DNS_ADBFIND_WANTEVENT;
|
||||
options |= DNS_ADBFIND_RETURNLAME;
|
||||
|
||||
/*
|
||||
* Set the bits up here to mark that we want this address family
|
||||
* and that we do not currently have a find pending. We will
|
||||
* set that bit again below if it turns out we will get an event.
|
||||
*/
|
||||
if (NEED_V4(client))
|
||||
options |= DNS_ADBFIND_INET;
|
||||
if (NEED_V6(client))
|
||||
options |= DNS_ADBFIND_INET6;
|
||||
|
||||
find_again:
|
||||
INSIST(client->find == NULL);
|
||||
result = dns_adb_createfind(client->clientmgr->view->adb,
|
||||
client->clientmgr->task,
|
||||
process_gabn_finddone, client,
|
||||
dns_fixedname_name(&client->target_name),
|
||||
dns_rootname, options, 0,
|
||||
dns_fixedname_name(&client->target_name),
|
||||
client->clientmgr->view->dstport,
|
||||
&client->find);
|
||||
|
||||
/*
|
||||
* Did we get an alias? If so, save it and re-issue the query.
|
||||
*/
|
||||
if (result == DNS_R_ALIAS) {
|
||||
DP(50, "found alias, restarting query");
|
||||
dns_adb_destroyfind(&client->find);
|
||||
cleanup_gabn(client);
|
||||
result = add_alias(client);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
DP(50, "out of buffer space adding alias");
|
||||
error_pkt_send(client, LWRES_R_FAILURE);
|
||||
return;
|
||||
}
|
||||
goto find_again;
|
||||
}
|
||||
|
||||
DP(50, "find returned %d (%s)", result, isc_result_totext(result));
|
||||
|
||||
/*
|
||||
* Did we get an error?
|
||||
*/
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
if (client->find != NULL)
|
||||
dns_adb_destroyfind(&client->find);
|
||||
cleanup_gabn(client);
|
||||
error_pkt_send(client, LWRES_R_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
claimed = ISC_FALSE;
|
||||
|
||||
/*
|
||||
* Did we get our answer to V4 addresses?
|
||||
*/
|
||||
if (NEED_V4(client)
|
||||
&& ((client->find->query_pending & DNS_ADBFIND_INET) == 0)) {
|
||||
DP(50, "client %p ipv4 satisfied by find %p", client,
|
||||
client->find);
|
||||
claimed = ISC_TRUE;
|
||||
client->v4find = client->find;
|
||||
}
|
||||
|
||||
/*
|
||||
* Did we get our answer to V6 addresses?
|
||||
*/
|
||||
if (NEED_V6(client)
|
||||
&& ((client->find->query_pending & DNS_ADBFIND_INET6) == 0)) {
|
||||
DP(50, "client %p ipv6 satisfied by find %p", client,
|
||||
client->find);
|
||||
claimed = ISC_TRUE;
|
||||
client->v6find = client->find;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we're going to get an event, set our internal pending flag
|
||||
* and return. When we get an event back we'll do the right
|
||||
* thing, basically by calling this function again, perhaps with a
|
||||
* new target name.
|
||||
*
|
||||
* If we have both v4 and v6, and we are still getting an event,
|
||||
* we have a programming error, so die hard.
|
||||
*/
|
||||
if ((client->find->options & DNS_ADBFIND_WANTEVENT) != 0) {
|
||||
DP(50, "event will be sent");
|
||||
INSIST(client->v4find == NULL || client->v6find == NULL);
|
||||
return;
|
||||
}
|
||||
DP(50, "no event will be sent");
|
||||
if (claimed)
|
||||
client->find = NULL;
|
||||
else
|
||||
dns_adb_destroyfind(&client->find);
|
||||
|
||||
/*
|
||||
* We seem to have everything we asked for, or at least we are
|
||||
* able to respond with things we've learned.
|
||||
*/
|
||||
|
||||
generate_reply(client);
|
||||
}
|
||||
|
||||
/*
|
||||
* When we are called, we can be assured that:
|
||||
*
|
||||
* client->sockaddr contains the address we need to reply to,
|
||||
*
|
||||
* client->pkt contains the packet header data,
|
||||
*
|
||||
* the packet "checks out" overall -- any MD5 hashes or crypto
|
||||
* bits have been verified,
|
||||
*
|
||||
* "b" points to the remaining data after the packet header
|
||||
* was parsed off.
|
||||
*
|
||||
* We are in a the RECVDONE state.
|
||||
*
|
||||
* From this state we will enter the SEND state if we happen to have
|
||||
* everything we need or we need to return an error packet, or to the
|
||||
* FINDWAIT state if we need to look things up.
|
||||
*/
|
||||
void
|
||||
process_gabn(client_t *client, lwres_buffer_t *b) {
|
||||
isc_result_t result;
|
||||
lwres_gabnrequest_t *req;
|
||||
isc_buffer_t namebuf;
|
||||
|
||||
REQUIRE(CLIENT_ISRECVDONE(client));
|
||||
|
||||
req = NULL;
|
||||
|
||||
result = lwres_gabnrequest_parse(client->clientmgr->lwctx,
|
||||
b, &client->pkt, &req);
|
||||
if (result != LWRES_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
isc_buffer_init(&namebuf, req->name, req->namelen);
|
||||
isc_buffer_add(&namebuf, req->namelen);
|
||||
|
||||
dns_fixedname_init(&client->target_name);
|
||||
result = dns_name_fromtext(dns_fixedname_name(&client->target_name),
|
||||
&namebuf, dns_rootname, ISC_FALSE, NULL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
client->find_wanted = req->addrtypes;
|
||||
DP(50, "client %p looking for addrtypes %08x",
|
||||
client, client->find_wanted);
|
||||
|
||||
/*
|
||||
* We no longer need to keep this around.
|
||||
*/
|
||||
lwres_gabnrequest_free(client->clientmgr->lwctx, &req);
|
||||
|
||||
/*
|
||||
* Initialize the real name and alias arrays in the reply we're
|
||||
* going to build up.
|
||||
*/
|
||||
client_init_gabn(client);
|
||||
|
||||
result = store_realname(client);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* Start the find.
|
||||
*/
|
||||
start_find(client);
|
||||
|
||||
return;
|
||||
|
||||
/*
|
||||
* We're screwed. Return an error packet to our caller.
|
||||
*/
|
||||
out:
|
||||
if (req != NULL)
|
||||
lwres_gabnrequest_free(client->clientmgr->lwctx, &req);
|
||||
|
||||
error_pkt_send(client, LWRES_R_FAILURE);
|
||||
}
|
||||
264
bin/lwresd/process_gnba.c
Normal file
264
bin/lwresd/process_gnba.c
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: process_gnba.c,v 1.26.4.1 2001/01/09 22:31:46 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <isc/socket.h>
|
||||
#include <isc/string.h> /* Required for HP/UX (and others?) */
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/adb.h>
|
||||
#include <dns/byaddr.h>
|
||||
#include <dns/result.h>
|
||||
|
||||
#include "client.h"
|
||||
|
||||
static void start_byaddr(client_t *);
|
||||
|
||||
static void
|
||||
byaddr_done(isc_task_t *task, isc_event_t *event) {
|
||||
client_t *client;
|
||||
clientmgr_t *cm;
|
||||
dns_byaddrevent_t *bevent;
|
||||
int lwres;
|
||||
lwres_buffer_t lwb;
|
||||
dns_name_t *name;
|
||||
isc_result_t result;
|
||||
isc_region_t r;
|
||||
isc_buffer_t b;
|
||||
lwres_gnbaresponse_t *gnba;
|
||||
isc_uint16_t naliases;
|
||||
isc_stdtime_t now;
|
||||
|
||||
UNUSED(task);
|
||||
|
||||
lwb.base = NULL;
|
||||
client = event->ev_arg;
|
||||
cm = client->clientmgr;
|
||||
INSIST(client->byaddr == (dns_byaddr_t *)event->ev_sender);
|
||||
|
||||
bevent = (dns_byaddrevent_t *)event;
|
||||
gnba = &client->gnba;
|
||||
|
||||
DP(50, "byaddr event result = %s",
|
||||
isc_result_totext(bevent->result));
|
||||
|
||||
result = bevent->result;
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dns_byaddr_destroy(&client->byaddr);
|
||||
isc_event_free(&event);
|
||||
bevent = NULL;
|
||||
|
||||
/*
|
||||
* Were we trying bitstring or nibble mode? If bitstring,
|
||||
* and we got FORMERROR or SERVFAIL, set the flag to
|
||||
* avoid bitstring lables for 10 minutes. If we got any
|
||||
* other error (NXDOMAIN, etc) just try again without
|
||||
* bitstrings, and let our cache handle the negative answer
|
||||
* for bitstrings.
|
||||
*/
|
||||
if ((client->options & DNS_BYADDROPT_IPV6NIBBLE) != 0) {
|
||||
dns_adb_freeaddrinfo(cm->view->adb, &client->addrinfo);
|
||||
error_pkt_send(client, LWRES_R_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
isc_stdtime_get(&now);
|
||||
if (result == DNS_R_FORMERR ||
|
||||
result == DNS_R_SERVFAIL ||
|
||||
result == ISC_R_FAILURE)
|
||||
dns_adb_setavoidbitstring(cm->view->adb,
|
||||
client->addrinfo, now + 600);
|
||||
|
||||
/*
|
||||
* Fall back to nibble reverse if the default of bitstrings
|
||||
* fails.
|
||||
*/
|
||||
client->options |= DNS_BYADDROPT_IPV6NIBBLE;
|
||||
|
||||
start_byaddr(client);
|
||||
return;
|
||||
}
|
||||
|
||||
name = ISC_LIST_HEAD(bevent->names);
|
||||
while (name != NULL) {
|
||||
b = client->recv_buffer;
|
||||
|
||||
result = dns_name_totext(name, ISC_TRUE, &client->recv_buffer);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
DP(50, "found name '%.*s'",
|
||||
client->recv_buffer.used - b.used,
|
||||
(char *)(b.base) + b.used);
|
||||
if (gnba->realname == NULL) {
|
||||
gnba->realname = (char *)(b.base) + b.used;
|
||||
gnba->realnamelen = client->recv_buffer.used - b.used;
|
||||
} else {
|
||||
naliases = gnba->naliases;
|
||||
if (naliases >= LWRES_MAX_ALIASES)
|
||||
break;
|
||||
gnba->aliases[naliases] = (char *)(b.base) + b.used;
|
||||
gnba->aliaslen[naliases] =
|
||||
client->recv_buffer.used - b.used;
|
||||
gnba->naliases++;
|
||||
}
|
||||
name = ISC_LIST_NEXT(name, link);
|
||||
}
|
||||
|
||||
dns_byaddr_destroy(&client->byaddr);
|
||||
dns_adb_freeaddrinfo(cm->view->adb, &client->addrinfo);
|
||||
isc_event_free(&event);
|
||||
|
||||
/*
|
||||
* Render the packet.
|
||||
*/
|
||||
client->pkt.recvlength = LWRES_RECVLENGTH;
|
||||
client->pkt.authtype = 0; /* XXXMLG */
|
||||
client->pkt.authlength = 0;
|
||||
client->pkt.result = LWRES_R_SUCCESS;
|
||||
|
||||
lwres = lwres_gnbaresponse_render(cm->lwctx,
|
||||
gnba, &client->pkt, &lwb);
|
||||
if (lwres != LWRES_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
r.base = lwb.base;
|
||||
r.length = lwb.used;
|
||||
client->sendbuf = r.base;
|
||||
client->sendlength = r.length;
|
||||
result = isc_socket_sendto(cm->sock, &r,
|
||||
cm->task, client_send,
|
||||
client, &client->address, NULL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
CLIENT_SETSEND(client);
|
||||
|
||||
return;
|
||||
|
||||
out:
|
||||
if (client->byaddr != NULL)
|
||||
dns_byaddr_destroy(&client->byaddr);
|
||||
if (client->addrinfo != NULL)
|
||||
dns_adb_freeaddrinfo(cm->view->adb, &client->addrinfo);
|
||||
if (lwb.base != NULL)
|
||||
lwres_context_freemem(cm->lwctx,
|
||||
lwb.base, lwb.length);
|
||||
|
||||
isc_event_free(&event);
|
||||
}
|
||||
|
||||
static void
|
||||
start_byaddr(client_t *client) {
|
||||
isc_result_t result;
|
||||
clientmgr_t *cm;
|
||||
|
||||
cm = client->clientmgr;
|
||||
|
||||
INSIST(client->byaddr == NULL);
|
||||
|
||||
result = dns_byaddr_create(cm->mctx, &client->na, cm->view,
|
||||
client->options, cm->task, byaddr_done,
|
||||
client, &client->byaddr);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dns_adb_freeaddrinfo(cm->view->adb, &client->addrinfo);
|
||||
error_pkt_send(client, LWRES_R_FAILURE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
process_gnba(client_t *client, lwres_buffer_t *b) {
|
||||
lwres_gnbarequest_t *req;
|
||||
isc_result_t result;
|
||||
isc_sockaddr_t sa;
|
||||
clientmgr_t *cm;
|
||||
|
||||
REQUIRE(CLIENT_ISRECVDONE(client));
|
||||
INSIST(client->byaddr == NULL);
|
||||
|
||||
cm = client->clientmgr;
|
||||
req = NULL;
|
||||
|
||||
result = lwres_gnbarequest_parse(cm->lwctx,
|
||||
b, &client->pkt, &req);
|
||||
if (result != LWRES_R_SUCCESS)
|
||||
goto out;
|
||||
if (req->addr.address == NULL)
|
||||
goto out;
|
||||
|
||||
client->options = 0;
|
||||
if (req->addr.family == LWRES_ADDRTYPE_V4) {
|
||||
client->na.family = AF_INET;
|
||||
if (req->addr.length != 4)
|
||||
goto out;
|
||||
memcpy(&client->na.type.in, req->addr.address, 4);
|
||||
} else if (req->addr.family == LWRES_ADDRTYPE_V6) {
|
||||
client->na.family = AF_INET6;
|
||||
if (req->addr.length != 16)
|
||||
goto out;
|
||||
memcpy(&client->na.type.in6, req->addr.address, 16);
|
||||
} else {
|
||||
goto out;
|
||||
}
|
||||
isc_sockaddr_fromnetaddr(&sa, &client->na, 53);
|
||||
|
||||
DP(50, "client %p looking for addrtype %08x",
|
||||
client, req->addr.family);
|
||||
|
||||
/*
|
||||
* We no longer need to keep this around.
|
||||
*/
|
||||
lwres_gnbarequest_free(cm->lwctx, &req);
|
||||
|
||||
/*
|
||||
* Initialize the real name and alias arrays in the reply we're
|
||||
* going to build up.
|
||||
*/
|
||||
client_init_gnba(client);
|
||||
client->options = 0;
|
||||
|
||||
/*
|
||||
* See if we should skip the byaddr bit.
|
||||
*/
|
||||
INSIST(client->addrinfo == NULL);
|
||||
result = dns_adb_findaddrinfo(cm->view->adb, &sa,
|
||||
&client->addrinfo, 0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
if (client->addrinfo->avoid_bitstring > 0)
|
||||
client->options |= DNS_BYADDROPT_IPV6NIBBLE;
|
||||
|
||||
/*
|
||||
* Start the find.
|
||||
*/
|
||||
start_byaddr(client);
|
||||
|
||||
return;
|
||||
|
||||
/*
|
||||
* We're screwed. Return an error packet to our caller.
|
||||
*/
|
||||
out:
|
||||
if (req != NULL)
|
||||
lwres_gnbarequest_free(cm->lwctx, &req);
|
||||
|
||||
error_pkt_send(client, LWRES_R_FAILURE);
|
||||
}
|
||||
87
bin/lwresd/process_noop.c
Normal file
87
bin/lwresd/process_noop.c
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: process_noop.c,v 1.9.4.1 2001/01/09 22:31:47 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <isc/socket.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include "client.h"
|
||||
|
||||
void
|
||||
process_noop(client_t *client, lwres_buffer_t *b) {
|
||||
lwres_nooprequest_t *req;
|
||||
lwres_noopresponse_t resp;
|
||||
isc_result_t result;
|
||||
lwres_result_t lwres;
|
||||
isc_region_t r;
|
||||
lwres_buffer_t lwb;
|
||||
|
||||
REQUIRE(CLIENT_ISRECVDONE(client));
|
||||
INSIST(client->byaddr == NULL);
|
||||
|
||||
req = NULL;
|
||||
|
||||
result = lwres_nooprequest_parse(client->clientmgr->lwctx,
|
||||
b, &client->pkt, &req);
|
||||
if (result != LWRES_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
client->pkt.recvlength = LWRES_RECVLENGTH;
|
||||
client->pkt.authtype = 0; /* XXXMLG */
|
||||
client->pkt.authlength = 0;
|
||||
client->pkt.result = LWRES_R_SUCCESS;
|
||||
|
||||
resp.datalength = req->datalength;
|
||||
resp.data = req->data;
|
||||
|
||||
lwres = lwres_noopresponse_render(client->clientmgr->lwctx, &resp,
|
||||
&client->pkt, &lwb);
|
||||
if (lwres != LWRES_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
r.base = lwb.base;
|
||||
r.length = lwb.used;
|
||||
client->sendbuf = r.base;
|
||||
client->sendlength = r.length;
|
||||
result = isc_socket_sendto(client->clientmgr->sock, &r,
|
||||
client->clientmgr->task, client_send,
|
||||
client, &client->address, NULL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* We can now destroy request.
|
||||
*/
|
||||
lwres_nooprequest_free(client->clientmgr->lwctx, &req);
|
||||
|
||||
CLIENT_SETSEND(client);
|
||||
|
||||
return;
|
||||
|
||||
out:
|
||||
if (req != NULL)
|
||||
lwres_nooprequest_free(client->clientmgr->lwctx, &req);
|
||||
|
||||
if (lwb.base != NULL)
|
||||
lwres_context_freemem(client->clientmgr->lwctx,
|
||||
lwb.base, lwb.length);
|
||||
|
||||
error_pkt_send(client, LWRES_R_FAILURE);
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.65 2001/01/18 01:33:50 bwelling Exp $
|
||||
# $Id: Makefile.in,v 1.63.4.1 2001/01/09 22:31:48 bwelling Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
@@ -77,8 +77,6 @@ SRCS = aclconf.c client.c interfacemgr.c listenlist.c \
|
||||
lwdgnba.c lwdgrbn.c lwdnoop.c lwsearch.c \
|
||||
$(DBDRIVER_SRCS)
|
||||
|
||||
MANPAGES = named.8 lwresd.8
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
main.@O@: main.c
|
||||
@@ -98,9 +96,7 @@ clean distclean::
|
||||
|
||||
installdirs:
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${sbindir}
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man8
|
||||
|
||||
install:: named lwresd installdirs
|
||||
${LIBTOOL} ${INSTALL_PROGRAM} named ${DESTDIR}${sbindir}
|
||||
(cd ${DESTDIR}${sbindir}; rm -f lwresd; @LN@ named lwresd)
|
||||
for m in ${MANPAGES}; do ${INSTALL_PROGRAM} $$m ${DESTDIR}${mandir}/man8; done
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: aclconf.c,v 1.25 2001/01/09 21:39:39 bwelling Exp $ */
|
||||
/* $Id: aclconf.c,v 1.24.4.1 2001/01/09 22:31:49 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: client.c,v 1.143 2001/01/29 19:49:48 bwelling Exp $ */
|
||||
/* $Id: client.c,v 1.136.2.2 2001/01/16 23:25:16 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/timer.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
@@ -134,10 +134,10 @@ struct ns_clientmgr {
|
||||
* client manager's list of active clients.
|
||||
*
|
||||
* If it is a TCP client object, it has a TCP listener socket
|
||||
* and an outstanding TCP listen request.
|
||||
* and an outstading TCP listen request.
|
||||
*
|
||||
* If it is a UDP client object, it has a UDP listener socket
|
||||
* and an outstanding UDP receive request.
|
||||
* If it is a UDP client object, it is associated with a
|
||||
* dispatch and has an outstanding dispatch request.
|
||||
*/
|
||||
|
||||
#define NS_CLIENTSTATE_READING 3
|
||||
@@ -152,7 +152,8 @@ struct ns_clientmgr {
|
||||
/*
|
||||
* The client object has received a request and is working
|
||||
* on it. It has a view, and it may have any of a non-reset OPT,
|
||||
* recursion quota, and an outstanding write request.
|
||||
* recursion quota, and an outstanding write request. If it
|
||||
* is a UDP client object, it has a dispatch event.
|
||||
*/
|
||||
|
||||
#define NS_CLIENTSTATE_MAX 9
|
||||
@@ -165,7 +166,6 @@ struct ns_clientmgr {
|
||||
|
||||
static void client_read(ns_client_t *client);
|
||||
static void client_accept(ns_client_t *client);
|
||||
static void client_udprecv(ns_client_t *client);
|
||||
static void clientmgr_destroy(ns_clientmgr_t *manager);
|
||||
static isc_boolean_t exit_check(ns_client_t *client);
|
||||
static void ns_client_endrequest(ns_client_t *client);
|
||||
@@ -191,9 +191,14 @@ client_deactivate(ns_client_t *client) {
|
||||
if (client->tcplistener != NULL)
|
||||
isc_socket_detach(&client->tcplistener);
|
||||
|
||||
if (client->udpsocket != NULL)
|
||||
isc_socket_detach(&client->udpsocket);
|
||||
|
||||
if (client->dispentry != NULL) {
|
||||
dns_dispatchevent_t **deventp;
|
||||
if (client->dispevent != NULL)
|
||||
deventp = &client->dispevent;
|
||||
else
|
||||
deventp = NULL;
|
||||
dns_dispatch_removerequest(&client->dispentry, deventp);
|
||||
}
|
||||
if (client->dispatch != NULL)
|
||||
dns_dispatch_detach(&client->dispatch);
|
||||
|
||||
@@ -232,7 +237,6 @@ client_free(ns_client_t *client) {
|
||||
|
||||
ns_query_free(client);
|
||||
isc_mem_put(client->mctx, client->sendbuf, SEND_BUFFER_SIZE);
|
||||
isc_mem_put(client->mctx, client->recvbuf, RECV_BUFFER_SIZE);
|
||||
isc_timer_detach(&client->timer);
|
||||
|
||||
if (client->tcpbuf != NULL)
|
||||
@@ -263,6 +267,7 @@ client_free(ns_client_t *client) {
|
||||
need_clientmgr_destroy = ISC_TRUE;
|
||||
UNLOCK(&manager->lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Detaching the task must be done after unlinking from
|
||||
* the manager's lists because the manager accesses
|
||||
@@ -279,15 +284,14 @@ client_free(ns_client_t *client) {
|
||||
clientmgr_destroy(manager);
|
||||
}
|
||||
|
||||
void
|
||||
ns_client_settimeout(ns_client_t *client, unsigned int seconds) {
|
||||
static void
|
||||
set_timeout(ns_client_t *client, unsigned int seconds) {
|
||||
isc_result_t result;
|
||||
isc_interval_t interval;
|
||||
|
||||
isc_interval_set(&interval, seconds, 0);
|
||||
result = isc_timer_reset(client->timer, isc_timertype_once, NULL,
|
||||
&interval, ISC_FALSE);
|
||||
client->timerset = ISC_TRUE;
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
ns_client_log(client, NS_LOGCATEGORY_CLIENT,
|
||||
NS_LOGMODULE_CLIENT, ISC_LOG_ERROR,
|
||||
@@ -335,14 +339,13 @@ exit_check(ns_client_t *client) {
|
||||
if (TCP_CLIENT(client))
|
||||
socket = client->tcpsocket;
|
||||
else
|
||||
socket = client->udpsocket;
|
||||
socket =
|
||||
dns_dispatch_getsocket(client->dispatch);
|
||||
isc_socket_cancel(socket, client->task,
|
||||
ISC_SOCKCANCEL_SEND);
|
||||
}
|
||||
|
||||
if (! (client->nsends == 0 && client->nrecvs == 0 &&
|
||||
client->references == 0))
|
||||
{
|
||||
if (! (client->nsends == 0 && client->references == 0)) {
|
||||
/*
|
||||
* Still waiting for I/O cancel completion.
|
||||
* or lingering references.
|
||||
@@ -390,12 +393,8 @@ exit_check(ns_client_t *client) {
|
||||
if (client->tcpquota != NULL)
|
||||
isc_quota_detach(&client->tcpquota);
|
||||
|
||||
if (client->timerset) {
|
||||
(void) isc_timer_reset(client->timer,
|
||||
isc_timertype_inactive,
|
||||
NULL, NULL, ISC_TRUE);
|
||||
client->timerset = ISC_FALSE;
|
||||
}
|
||||
(void) isc_timer_reset(client->timer, isc_timertype_inactive,
|
||||
NULL, NULL, ISC_TRUE);
|
||||
|
||||
client->peeraddr_valid = ISC_FALSE;
|
||||
|
||||
@@ -413,8 +412,16 @@ exit_check(ns_client_t *client) {
|
||||
if (NS_CLIENTSTATE_READY == client->newstate) {
|
||||
if (TCP_CLIENT(client)) {
|
||||
client_accept(client);
|
||||
} else
|
||||
client_udprecv(client);
|
||||
} else {
|
||||
/*
|
||||
* Give the processed dispatch event back to
|
||||
* the dispatch. This tells the dispatch
|
||||
* that we are ready to receive the next event.
|
||||
*/
|
||||
dns_dispatch_freeevent(client->dispatch,
|
||||
client->dispentry,
|
||||
&client->dispevent);
|
||||
}
|
||||
client->newstate = NS_CLIENTSTATE_MAX;
|
||||
return (ISC_TRUE);
|
||||
}
|
||||
@@ -434,16 +441,6 @@ exit_check(ns_client_t *client) {
|
||||
return (ISC_TRUE);
|
||||
}
|
||||
/* Accept cancel is complete. */
|
||||
|
||||
if (client->nrecvs > 0)
|
||||
isc_socket_cancel(client->udpsocket, client->task,
|
||||
ISC_SOCKCANCEL_RECV);
|
||||
if (! (client->nrecvs == 0)) {
|
||||
/* Still waiting for recv cancel completion. */
|
||||
return (ISC_TRUE);
|
||||
}
|
||||
/* Recv cancel is complete. */
|
||||
|
||||
client_deactivate(client);
|
||||
client->state = NS_CLIENTSTATE_INACTIVE;
|
||||
INSIST(client->recursionquota == NULL);
|
||||
@@ -472,6 +469,7 @@ exit_check(ns_client_t *client) {
|
||||
static void
|
||||
client_start(isc_task_t *task, isc_event_t *event) {
|
||||
ns_client_t *client = (ns_client_t *) event->ev_arg;
|
||||
isc_result_t result;
|
||||
|
||||
INSIST(task == client->task);
|
||||
|
||||
@@ -480,7 +478,25 @@ client_start(isc_task_t *task, isc_event_t *event) {
|
||||
if (TCP_CLIENT(client)) {
|
||||
client_accept(client);
|
||||
} else {
|
||||
client_udprecv(client);
|
||||
result = dns_dispatch_addrequest(client->dispatch,
|
||||
client->task,
|
||||
client_request,
|
||||
client,
|
||||
&client->dispentry);
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
ns_client_log(client,
|
||||
DNS_LOGCATEGORY_SECURITY,
|
||||
NS_LOGMODULE_CLIENT,
|
||||
ISC_LOG_DEBUG(3),
|
||||
"dns_dispatch_addrequest() "
|
||||
"failed: %s",
|
||||
isc_result_totext(result));
|
||||
/*
|
||||
* Not much we can do here but log the failure;
|
||||
* the client will effectively go idle.
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,7 +536,6 @@ ns_client_endrequest(ns_client_t *client) {
|
||||
INSIST(client->naccepts == 0);
|
||||
INSIST(client->nreads == 0);
|
||||
INSIST(client->nsends == 0);
|
||||
INSIST(client->nrecvs == 0);
|
||||
INSIST(client->state == NS_CLIENTSTATE_WORKING);
|
||||
|
||||
CTRACE("endrequest");
|
||||
@@ -717,8 +732,8 @@ client_sendpkg(ns_client_t *client, isc_buffer_t *buffer) {
|
||||
socket = client->tcpsocket;
|
||||
address = NULL;
|
||||
} else {
|
||||
socket = client->udpsocket;
|
||||
address = &client->peeraddr;
|
||||
socket = dns_dispatch_getsocket(client->dispatch);
|
||||
address = &client->dispevent->addr;
|
||||
|
||||
isc_netaddr_fromsockaddr(&netaddr, &client->peeraddr);
|
||||
if (ns_g_server->blackholeacl != NULL &&
|
||||
@@ -826,10 +841,6 @@ ns_client_send(ns_client_t *client) {
|
||||
}
|
||||
result = dns_message_rendersection(client->message,
|
||||
DNS_SECTION_QUESTION, 0);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
client->message->flags |= DNS_MESSAGEFLAG_TC;
|
||||
goto renderend;
|
||||
}
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto done;
|
||||
result = dns_message_rendersection(client->message,
|
||||
@@ -1011,7 +1022,7 @@ client_addopt(ns_client_t *client) {
|
||||
rdatalist->covers = 0;
|
||||
|
||||
/*
|
||||
* Set the maximum UDP buffer size.
|
||||
* Set Maximum UDP buffer size.
|
||||
*/
|
||||
rdatalist->rdclass = RECV_BUFFER_SIZE;
|
||||
|
||||
@@ -1121,17 +1132,16 @@ client_getoptattrs(ns_client_t *client, dns_rdataset_t *opt) {
|
||||
|
||||
|
||||
/*
|
||||
* Handle an incoming request event from the socket (UDP case)
|
||||
* Handle an incoming request event from the dispatch (UDP case)
|
||||
* or tcpmsg (TCP case).
|
||||
*/
|
||||
static void
|
||||
client_request(isc_task_t *task, isc_event_t *event) {
|
||||
ns_client_t *client;
|
||||
isc_socketevent_t *sevent;
|
||||
dns_dispatchevent_t *devent;
|
||||
isc_result_t result;
|
||||
isc_result_t sigresult;
|
||||
isc_buffer_t *buffer;
|
||||
isc_buffer_t tbuffer;
|
||||
dns_view_t *view;
|
||||
dns_rdataset_t *opt;
|
||||
isc_boolean_t ra; /* Recursion available. */
|
||||
@@ -1153,22 +1163,21 @@ client_request(isc_task_t *task, isc_event_t *event) {
|
||||
RWLOCK(&ns_g_server->conflock, isc_rwlocktype_read);
|
||||
dns_zonemgr_lockconf(ns_g_server->zonemgr, isc_rwlocktype_read);
|
||||
|
||||
if (event->ev_type == ISC_SOCKEVENT_RECVDONE) {
|
||||
if (event->ev_type == DNS_EVENT_DISPATCH) {
|
||||
INSIST(!TCP_CLIENT(client));
|
||||
sevent = (isc_socketevent_t *)event;
|
||||
isc_buffer_init(&tbuffer, sevent->region.base, sevent->n);
|
||||
isc_buffer_add(&tbuffer, sevent->n);
|
||||
buffer = &tbuffer;
|
||||
result = sevent->result;
|
||||
client->peeraddr = sevent->address;
|
||||
devent = (dns_dispatchevent_t *)event;
|
||||
REQUIRE(client->dispentry != NULL);
|
||||
client->dispevent = devent;
|
||||
buffer = &devent->buffer;
|
||||
result = devent->result;
|
||||
client->peeraddr = devent->addr;
|
||||
client->peeraddr_valid = ISC_TRUE;
|
||||
if ((sevent->attributes & ISC_SOCKEVENTATTR_PKTINFO) != 0) {
|
||||
if ((devent->attributes & ISC_SOCKEVENTATTR_PKTINFO) != 0) {
|
||||
client->attributes |= NS_CLIENTATTR_PKTINFO;
|
||||
client->pktinfo = sevent->pktinfo;
|
||||
client->pktinfo = devent->pktinfo;
|
||||
}
|
||||
if ((sevent->attributes & ISC_SOCKEVENTATTR_MULTICAST) != 0)
|
||||
if ((devent->attributes & ISC_SOCKEVENTATTR_MULTICAST) != 0)
|
||||
client->attributes |= NS_CLIENTATTR_MULTICAST;
|
||||
client->nrecvs--;
|
||||
} else {
|
||||
INSIST(TCP_CLIENT(client));
|
||||
REQUIRE(event->ev_type == DNS_EVENT_TCPMSG);
|
||||
@@ -1194,6 +1203,8 @@ client_request(isc_task_t *task, isc_event_t *event) {
|
||||
isc_stdtime_get(&client->requesttime);
|
||||
client->now = client->requesttime;
|
||||
|
||||
set_timeout(client, 60);
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
if (TCP_CLIENT(client))
|
||||
ns_client_next(client, result);
|
||||
@@ -1218,20 +1229,14 @@ client_request(isc_task_t *task, isc_event_t *event) {
|
||||
}
|
||||
|
||||
/*
|
||||
* We expect a query, not a response. If this is a UDP response,
|
||||
* forward it to the dispatcher. If it's a TCP response,
|
||||
* discarded it here.
|
||||
* We expect a query, not a response. Unexpected UDP responses
|
||||
* are discarded early by the dispatcher, but TCP responses
|
||||
* bypass the dispatcher and must be discarded here.
|
||||
*/
|
||||
if ((client->message->flags & DNS_MESSAGEFLAG_QR) != 0) {
|
||||
if (TCP_CLIENT(client)) {
|
||||
CTRACE("unexpected response");
|
||||
ns_client_next(client, DNS_R_FORMERR);
|
||||
goto cleanup_serverlock;
|
||||
} else {
|
||||
dns_dispatch_importrecv(client->dispatch, &event);
|
||||
ns_client_next(client, ISC_R_SUCCESS);
|
||||
goto cleanup_serverlock;
|
||||
}
|
||||
CTRACE("unexpected response");
|
||||
ns_client_next(client, DNS_R_FORMERR);
|
||||
goto cleanup_serverlock;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1439,12 +1444,10 @@ client_request(isc_task_t *task, isc_event_t *event) {
|
||||
break;
|
||||
case dns_opcode_update:
|
||||
CTRACE("update");
|
||||
ns_client_settimeout(client, 60);
|
||||
ns_update_start(client, sigresult);
|
||||
break;
|
||||
case dns_opcode_notify:
|
||||
CTRACE("notify");
|
||||
ns_client_settimeout(client, 60);
|
||||
ns_notify_start(client);
|
||||
break;
|
||||
case dns_opcode_iquery:
|
||||
@@ -1528,7 +1531,6 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp)
|
||||
client, &client->timer);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_task;
|
||||
client->timerset = ISC_FALSE;
|
||||
|
||||
client->message = NULL;
|
||||
result = dns_message_create(manager->mctx, DNS_MESSAGE_INTENTPARSE,
|
||||
@@ -1541,10 +1543,6 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp)
|
||||
if (client->sendbuf == NULL)
|
||||
goto cleanup_message;
|
||||
|
||||
client->recvbuf = isc_mem_get(manager->mctx, RECV_BUFFER_SIZE);
|
||||
if (client->recvbuf == NULL)
|
||||
goto cleanup_sendbuf;
|
||||
|
||||
client->magic = NS_CLIENT_MAGIC;
|
||||
client->mctx = manager->mctx;
|
||||
client->manager = NULL;
|
||||
@@ -1553,13 +1551,13 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp)
|
||||
client->naccepts = 0;
|
||||
client->nreads = 0;
|
||||
client->nsends = 0;
|
||||
client->nrecvs = 0;
|
||||
client->references = 0;
|
||||
client->attributes = 0;
|
||||
client->view = NULL;
|
||||
client->lockview = NULL;
|
||||
client->dispatch = NULL;
|
||||
client->udpsocket = NULL;
|
||||
client->dispentry = NULL;
|
||||
client->dispevent = NULL;
|
||||
client->tcplistener = NULL;
|
||||
client->tcpsocket = NULL;
|
||||
client->tcpmsg_valid = ISC_FALSE;
|
||||
@@ -1593,7 +1591,7 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp)
|
||||
*/
|
||||
result = ns_query_init(client);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_recvbuf;
|
||||
goto cleanup_sendbuf;
|
||||
|
||||
CTRACE("create");
|
||||
|
||||
@@ -1601,9 +1599,6 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp)
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup_recvbuf:
|
||||
isc_mem_put(manager->mctx, client->recvbuf, RECV_BUFFER_SIZE);
|
||||
|
||||
cleanup_sendbuf:
|
||||
isc_mem_put(manager->mctx, client->sendbuf, SEND_BUFFER_SIZE);
|
||||
|
||||
@@ -1639,7 +1634,7 @@ client_read(ns_client_t *client) {
|
||||
* Set a timeout to limit the amount of time we will wait
|
||||
* for a request on this TCP connection.
|
||||
*/
|
||||
ns_client_settimeout(client, 30);
|
||||
set_timeout(client, 30);
|
||||
|
||||
client->state = client->newstate = NS_CLIENTSTATE_READING;
|
||||
INSIST(client->nreads == 0);
|
||||
@@ -1784,34 +1779,6 @@ client_accept(ns_client_t *client) {
|
||||
UNLOCK(&client->interface->lock);
|
||||
}
|
||||
|
||||
static void
|
||||
client_udprecv(ns_client_t *client) {
|
||||
isc_result_t result;
|
||||
isc_region_t r;
|
||||
|
||||
CTRACE("udprecv");
|
||||
|
||||
r.base = client->recvbuf;
|
||||
r.length = RECV_BUFFER_SIZE;
|
||||
result = isc_socket_recv(client->udpsocket, &r, 1,
|
||||
client->task, client_request, client);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_socket_recv() failed: %s",
|
||||
isc_result_totext(result));
|
||||
/*
|
||||
* XXXBEW What should we do? We're trying to accept but
|
||||
* it didn't work. If we just give up, then UDP
|
||||
* service may eventually stop.
|
||||
*
|
||||
* For now, we just go idle.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
INSIST(client->nrecvs == 0);
|
||||
client->nrecvs++;
|
||||
}
|
||||
|
||||
void
|
||||
ns_client_attach(ns_client_t *source, ns_client_t **targetp) {
|
||||
REQUIRE(NS_CLIENT_VALID(source));
|
||||
@@ -2002,12 +1969,8 @@ ns_clientmgr_createclients(ns_clientmgr_t *manager, unsigned int n,
|
||||
isc_socket_attach(ifp->tcpsocket,
|
||||
&client->tcplistener);
|
||||
} else {
|
||||
isc_socket_t *sock;
|
||||
|
||||
dns_dispatch_attach(ifp->udpdispatch,
|
||||
&client->dispatch);
|
||||
sock = dns_dispatch_getsocket(client->dispatch);
|
||||
isc_socket_attach(sock, &client->udpsocket);
|
||||
}
|
||||
client->manager = manager;
|
||||
ISC_LIST_APPEND(manager->active, client, link);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: aclconf.h,v 1.11 2001/01/09 21:40:11 bwelling Exp $ */
|
||||
/* $Id: aclconf.h,v 1.10.4.1 2001/01/09 22:32:22 bwelling Exp $ */
|
||||
|
||||
#ifndef NS_ACLCONF_H
|
||||
#define NS_ACLCONF_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: client.h,v 1.51 2001/01/29 19:49:51 bwelling Exp $ */
|
||||
/* $Id: client.h,v 1.48.4.1 2001/01/09 22:32:23 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_CLIENT_H
|
||||
#define NAMED_CLIENT_H 1
|
||||
@@ -93,24 +93,22 @@ struct ns_client {
|
||||
int naccepts;
|
||||
int nreads;
|
||||
int nsends;
|
||||
int nrecvs;
|
||||
int references;
|
||||
unsigned int attributes;
|
||||
isc_task_t * task;
|
||||
dns_view_t * view;
|
||||
dns_view_t * lockview;
|
||||
dns_dispatch_t * dispatch;
|
||||
isc_socket_t * udpsocket;
|
||||
dns_dispentry_t * dispentry;
|
||||
dns_dispatchevent_t * dispevent;
|
||||
isc_socket_t * tcplistener;
|
||||
isc_socket_t * tcpsocket;
|
||||
unsigned char * tcpbuf;
|
||||
dns_tcpmsg_t tcpmsg;
|
||||
isc_boolean_t tcpmsg_valid;
|
||||
isc_timer_t * timer;
|
||||
isc_boolean_t timerset;
|
||||
dns_message_t * message;
|
||||
unsigned char * sendbuf;
|
||||
unsigned char * recvbuf;
|
||||
dns_rdataset_t * opt;
|
||||
isc_uint16_t udpsize;
|
||||
isc_uint16_t extflags;
|
||||
@@ -221,12 +219,6 @@ ns_client_replace(ns_client_t *client);
|
||||
* leaving the dispatch/socket without service.
|
||||
*/
|
||||
|
||||
void
|
||||
ns_client_settimeout(ns_client_t *client, unsigned int seconds);
|
||||
/*
|
||||
* Set a timer in the client to go off in the specified amount of time.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
ns_clientmgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
|
||||
isc_timermgr_t *timermgr, ns_clientmgr_t **managerp);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: globals.h,v 1.52 2001/01/09 21:40:13 bwelling Exp $ */
|
||||
/* $Id: globals.h,v 1.51.2.1 2001/01/09 22:32:25 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_GLOBALS_H
|
||||
#define NAMED_GLOBALS_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: interfacemgr.h,v 1.22 2001/01/09 21:40:14 bwelling Exp $ */
|
||||
/* $Id: interfacemgr.h,v 1.21.4.1 2001/01/09 22:32:26 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_INTERFACEMGR_H
|
||||
#define NAMED_INTERFACEMGR_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: listenlist.h,v 1.10 2001/01/09 21:40:16 bwelling Exp $ */
|
||||
/* $Id: listenlist.h,v 1.9.4.1 2001/01/09 22:32:27 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_LISTENLIST_H
|
||||
#define NAMED_LISTENLIST_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: log.h,v 1.17 2001/01/09 21:40:17 bwelling Exp $ */
|
||||
/* $Id: log.h,v 1.16.4.1 2001/01/09 22:32:28 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_LOG_H
|
||||
#define NAMED_LOG_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: logconf.h,v 1.9 2001/01/09 21:40:18 bwelling Exp $ */
|
||||
/* $Id: logconf.h,v 1.8.4.1 2001/01/09 22:32:29 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_LOGCONF_H
|
||||
#define NAMED_LOGCONF_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lwaddr.h,v 1.2 2001/01/09 21:40:19 bwelling Exp $ */
|
||||
/* $Id: lwaddr.h,v 1.1.4.1 2001/01/09 22:32:30 bwelling Exp $ */
|
||||
|
||||
#include <lwres/lwres.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lwdclient.h,v 1.12 2001/01/22 22:29:04 gson Exp $ */
|
||||
/* $Id: lwdclient.h,v 1.10.4.1 2001/01/09 22:32:31 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_LWDCLIENT_H
|
||||
#define NAMED_LWDCLIENT_H 1
|
||||
@@ -80,6 +80,7 @@ struct ns_lwdclient {
|
||||
dns_byaddr_t *byaddr;
|
||||
unsigned int options;
|
||||
isc_netaddr_t na;
|
||||
dns_adbaddrinfo_t *addrinfo;
|
||||
|
||||
/*
|
||||
* grbn (get rrset by name) state info.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lwresd.h,v 1.10 2001/01/09 21:40:21 bwelling Exp $ */
|
||||
/* $Id: lwresd.h,v 1.9.4.1 2001/01/09 22:32:33 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_LWRESD_H
|
||||
#define NAMED_LWRESD_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lwsearch.h,v 1.3 2001/01/09 21:40:22 bwelling Exp $ */
|
||||
/* $Id: lwsearch.h,v 1.2.4.1 2001/01/09 22:32:34 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_LWSEARCH_H
|
||||
#define NAMED_LWSEARCH_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: main.h,v 1.7 2001/01/09 21:40:23 bwelling Exp $ */
|
||||
/* $Id: main.h,v 1.6.4.1 2001/01/09 22:32:35 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_MAIN_H
|
||||
#define NAMED_MAIN_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: notify.h,v 1.9 2001/01/09 21:40:24 bwelling Exp $ */
|
||||
/* $Id: notify.h,v 1.8.4.1 2001/01/09 22:32:36 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_NOTIFY_H
|
||||
#define NAMED_NOTIFY_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: omapi.h,v 1.18 2001/01/09 21:40:26 bwelling Exp $ */
|
||||
/* $Id: omapi.h,v 1.17.2.1 2001/01/09 22:32:37 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_OMAPI_H
|
||||
#define NAMED_OMAPI_H 1
|
||||
|
||||
@@ -15,14 +15,13 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: query.h,v 1.27 2001/01/29 19:49:52 bwelling Exp $ */
|
||||
/* $Id: query.h,v 1.23.4.1 2001/01/09 22:32:38 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_QUERY_H
|
||||
#define NAMED_QUERY_H 1
|
||||
|
||||
#include <isc/types.h>
|
||||
#include <isc/buffer.h>
|
||||
#include <isc/netaddr.h>
|
||||
|
||||
#include <dns/types.h>
|
||||
#include <dns/a6.h>
|
||||
@@ -39,9 +38,9 @@ typedef struct ns_dbversion {
|
||||
struct ns_query {
|
||||
unsigned int attributes;
|
||||
unsigned int restarts;
|
||||
isc_boolean_t timerset;
|
||||
dns_name_t * qname;
|
||||
dns_name_t * origqname;
|
||||
dns_rdataset_t * qrdataset;
|
||||
unsigned int dboptions;
|
||||
unsigned int fetchoptions;
|
||||
dns_db_t * gluedb;
|
||||
@@ -51,12 +50,6 @@ struct ns_query {
|
||||
isc_bufferlist_t namebufs;
|
||||
ISC_LIST(ns_dbversion_t) activeversions;
|
||||
ISC_LIST(ns_dbversion_t) freeversions;
|
||||
/*
|
||||
* Additional state used during IPv6 response synthesis only.
|
||||
*/
|
||||
struct {
|
||||
isc_netaddr_t na;
|
||||
} synth;
|
||||
};
|
||||
|
||||
#define NS_QUERYATTR_RECURSIONOK 0x0001
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: server.h,v 1.50 2001/01/29 07:08:41 marka Exp $ */
|
||||
/* $Id: server.h,v 1.48.2.1 2001/01/09 22:32:39 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_SERVER_H
|
||||
#define NAMED_SERVER_H 1
|
||||
@@ -60,11 +60,8 @@ struct ns_server {
|
||||
ns_interfacemgr_t * interfacemgr;
|
||||
dns_db_t * in_roothints;
|
||||
dns_tkeyctx_t * tkeyctx;
|
||||
|
||||
isc_timer_t * interface_timer;
|
||||
isc_timer_t * heartbeat_timer;
|
||||
isc_uint32_t interface_interval;
|
||||
isc_uint32_t heartbeat_interval;
|
||||
|
||||
isc_mutex_t reload_event_lock;
|
||||
isc_event_t * reload_event;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: sortlist.h,v 1.4 2001/01/09 21:40:29 bwelling Exp $ */
|
||||
/* $Id: sortlist.h,v 1.3.4.1 2001/01/09 22:32:40 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_SORTLIST_H
|
||||
#define NAMED_SORTLIST_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: tkeyconf.h,v 1.8 2001/01/09 21:40:30 bwelling Exp $ */
|
||||
/* $Id: tkeyconf.h,v 1.7.4.1 2001/01/09 22:32:41 bwelling Exp $ */
|
||||
|
||||
#ifndef NS_TKEYCONF_H
|
||||
#define NS_TKEYCONF_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: tsigconf.h,v 1.8 2001/01/09 21:40:31 bwelling Exp $ */
|
||||
/* $Id: tsigconf.h,v 1.7.4.1 2001/01/09 22:32:43 bwelling Exp $ */
|
||||
|
||||
#ifndef NS_TSIGCONF_H
|
||||
#define NS_TSIGCONF_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: types.h,v 1.18 2001/01/09 21:40:32 bwelling Exp $ */
|
||||
/* $Id: types.h,v 1.17.4.1 2001/01/09 22:32:44 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_TYPES_H
|
||||
#define NAMED_TYPES_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: update.h,v 1.8 2001/01/09 21:40:33 bwelling Exp $ */
|
||||
/* $Id: update.h,v 1.7.4.1 2001/01/09 22:32:45 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_UPDATE_H
|
||||
#define NAMED_UPDATE_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: xfrout.h,v 1.7 2001/01/09 21:40:34 bwelling Exp $ */
|
||||
/* $Id: xfrout.h,v 1.6.4.1 2001/01/09 22:32:46 bwelling Exp $ */
|
||||
|
||||
#ifndef NAMED_XFROUT_H
|
||||
#define NAMED_XFROUT_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: zoneconf.h,v 1.15 2001/01/09 21:40:36 bwelling Exp $ */
|
||||
/* $Id: zoneconf.h,v 1.14.4.1 2001/01/09 22:32:47 bwelling Exp $ */
|
||||
|
||||
#ifndef NS_ZONECONF_H
|
||||
#define NS_ZONECONF_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: interfacemgr.c,v 1.56 2001/01/27 02:08:01 bwelling Exp $ */
|
||||
/* $Id: interfacemgr.c,v 1.54.2.1 2001/01/09 22:31:52 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -244,7 +244,6 @@ ns_interface_listenudp(ns_interface_t *ifp) {
|
||||
attrs |= DNS_DISPATCHATTR_IPV4;
|
||||
else
|
||||
attrs |= DNS_DISPATCHATTR_IPV6;
|
||||
attrs |= DNS_DISPATCHATTR_NOLISTEN;
|
||||
attrmask = 0;
|
||||
attrmask |= DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_TCP;
|
||||
attrmask |= DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_IPV6;
|
||||
@@ -270,8 +269,6 @@ ns_interface_listenudp(ns_interface_t *ifp) {
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
addtodispatch_failure:
|
||||
dns_dispatch_changeattributes(ifp->udpdispatch, 0,
|
||||
DNS_DISPATCHATTR_NOLISTEN);
|
||||
dns_dispatch_detach(&ifp->udpdispatch);
|
||||
udp_dispatch_failure:
|
||||
return (result);
|
||||
@@ -376,11 +373,8 @@ ns_interface_destroy(ns_interface_t *ifp) {
|
||||
|
||||
ns_interface_shutdown(ifp);
|
||||
|
||||
if (ifp->udpdispatch != NULL) {
|
||||
dns_dispatch_changeattributes(ifp->udpdispatch, 0,
|
||||
DNS_DISPATCHATTR_NOLISTEN);
|
||||
if (ifp->udpdispatch != NULL)
|
||||
dns_dispatch_detach(&ifp->udpdispatch);
|
||||
}
|
||||
if (ifp->tcpsocket != NULL)
|
||||
isc_socket_detach(&ifp->tcpsocket);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: listenlist.c,v 1.9 2001/01/09 21:39:43 bwelling Exp $ */
|
||||
/* $Id: listenlist.c,v 1.8.4.1 2001/01/09 22:31:53 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: log.c,v 1.28 2001/01/09 21:39:44 bwelling Exp $ */
|
||||
/* $Id: log.c,v 1.27.2.1 2001/01/09 22:31:54 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: logconf.c,v 1.27 2001/01/09 21:39:45 bwelling Exp $ */
|
||||
/* $Id: logconf.c,v 1.26.4.1 2001/01/09 22:31:55 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lwaddr.c,v 1.3 2001/01/09 21:39:46 bwelling Exp $ */
|
||||
/* $Id: lwaddr.c,v 1.2.2.1 2001/01/09 22:31:56 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lwdclient.c,v 1.13 2001/01/22 22:29:02 gson Exp $ */
|
||||
/* $Id: lwdclient.c,v 1.11.4.1 2001/01/09 22:31:57 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -441,6 +441,7 @@ ns_lwdclient_initialize(ns_lwdclient_t *client, ns_lwdclientmgr_t *cmgr) {
|
||||
|
||||
client->options = 0;
|
||||
client->byaddr = NULL;
|
||||
client->addrinfo = NULL;
|
||||
|
||||
client->lookup = NULL;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lwderror.c,v 1.7 2001/01/09 21:39:49 bwelling Exp $ */
|
||||
/* $Id: lwderror.c,v 1.6.4.1 2001/01/09 22:31:58 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lwdgabn.c,v 1.13 2001/01/22 22:12:16 bwelling Exp $ */
|
||||
/* $Id: lwdgabn.c,v 1.10.4.1 2001/01/09 22:32:00 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -608,8 +608,6 @@ ns_lwdclient_processgabn(ns_lwdclient_t *client, lwres_buffer_t *b) {
|
||||
b, &client->pkt, &req);
|
||||
if (result != LWRES_R_SUCCESS)
|
||||
goto out;
|
||||
if (req->name == NULL)
|
||||
goto out;
|
||||
|
||||
isc_buffer_init(&namebuf, req->name, req->namelen);
|
||||
isc_buffer_add(&namebuf, req->namelen);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lwdgnba.c,v 1.12 2001/01/22 22:29:01 gson Exp $ */
|
||||
/* $Id: lwdgnba.c,v 1.8.4.1 2001/01/09 22:32:01 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -46,6 +46,7 @@ byaddr_done(isc_task_t *task, isc_event_t *event) {
|
||||
isc_buffer_t b;
|
||||
lwres_gnbaresponse_t *gnba;
|
||||
isc_uint16_t naliases;
|
||||
isc_stdtime_t now;
|
||||
|
||||
UNUSED(task);
|
||||
|
||||
@@ -66,7 +67,16 @@ byaddr_done(isc_task_t *task, isc_event_t *event) {
|
||||
isc_event_free(&event);
|
||||
bevent = NULL;
|
||||
|
||||
/*
|
||||
* Were we trying bitstring or nibble mode? If bitstring,
|
||||
* and we got FORMERROR or SERVFAIL, set the flag to
|
||||
* avoid bitstring labels for 10 minutes. If we got any
|
||||
* other error (NXDOMAIN, etc) just try again without
|
||||
* bitstrings, and let our cache handle the negative answer
|
||||
* for bitstrings.
|
||||
*/
|
||||
if ((client->options & DNS_BYADDROPT_IPV6NIBBLE) != 0) {
|
||||
dns_adb_freeaddrinfo(cm->view->adb, &client->addrinfo);
|
||||
if (result == DNS_R_NCACHENXDOMAIN ||
|
||||
result == DNS_R_NCACHENXRRSET ||
|
||||
result == DNS_R_NXDOMAIN ||
|
||||
@@ -78,6 +88,13 @@ byaddr_done(isc_task_t *task, isc_event_t *event) {
|
||||
return;
|
||||
}
|
||||
|
||||
isc_stdtime_get(&now);
|
||||
if (result == DNS_R_FORMERR ||
|
||||
result == DNS_R_SERVFAIL ||
|
||||
result == ISC_R_FAILURE)
|
||||
dns_adb_setavoidbitstring(cm->view->adb,
|
||||
client->addrinfo, now + 600);
|
||||
|
||||
/*
|
||||
* Fall back to nibble reverse if the default of bitstrings
|
||||
* fails.
|
||||
@@ -88,10 +105,8 @@ byaddr_done(isc_task_t *task, isc_event_t *event) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (name = ISC_LIST_HEAD(bevent->names);
|
||||
name != NULL;
|
||||
name = ISC_LIST_NEXT(name, link))
|
||||
{
|
||||
name = ISC_LIST_HEAD(bevent->names);
|
||||
while (name != NULL) {
|
||||
b = client->recv_buffer;
|
||||
|
||||
result = dns_name_totext(name, ISC_TRUE, &client->recv_buffer);
|
||||
@@ -112,9 +127,11 @@ byaddr_done(isc_task_t *task, isc_event_t *event) {
|
||||
client->recv_buffer.used - b.used;
|
||||
gnba->naliases++;
|
||||
}
|
||||
name = ISC_LIST_NEXT(name, link);
|
||||
}
|
||||
|
||||
dns_byaddr_destroy(&client->byaddr);
|
||||
dns_adb_freeaddrinfo(cm->view->adb, &client->addrinfo);
|
||||
isc_event_free(&event);
|
||||
|
||||
/*
|
||||
@@ -145,6 +162,8 @@ byaddr_done(isc_task_t *task, isc_event_t *event) {
|
||||
out:
|
||||
if (client->byaddr != NULL)
|
||||
dns_byaddr_destroy(&client->byaddr);
|
||||
if (client->addrinfo != NULL)
|
||||
dns_adb_freeaddrinfo(cm->view->adb, &client->addrinfo);
|
||||
if (lwb.base != NULL)
|
||||
lwres_context_freemem(cm->lwctx,
|
||||
lwb.base, lwb.length);
|
||||
@@ -166,6 +185,7 @@ start_byaddr(ns_lwdclient_t *client) {
|
||||
client->options, cm->task, byaddr_done,
|
||||
client, &client->byaddr);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dns_adb_freeaddrinfo(cm->view->adb, &client->addrinfo);
|
||||
ns_lwdclient_errorpktsend(client, LWRES_R_FAILURE);
|
||||
return;
|
||||
}
|
||||
@@ -251,6 +271,18 @@ ns_lwdclient_processgnba(ns_lwdclient_t *client, lwres_buffer_t *b) {
|
||||
init_gnba(client);
|
||||
client->options = 0;
|
||||
|
||||
/*
|
||||
* See if we should skip the byaddr bit.
|
||||
*/
|
||||
INSIST(client->addrinfo == NULL);
|
||||
result = dns_adb_findaddrinfo(cm->view->adb, &sa,
|
||||
&client->addrinfo, 0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
if (client->addrinfo->avoid_bitstring > 0)
|
||||
client->options |= DNS_BYADDROPT_IPV6NIBBLE;
|
||||
|
||||
/*
|
||||
* Start the find.
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lwdgrbn.c,v 1.11 2001/01/24 01:42:41 bwelling Exp $ */
|
||||
/* $Id: lwdgrbn.c,v 1.6.2.2 2001/01/23 02:05:11 gson Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -39,6 +39,37 @@
|
||||
|
||||
static void start_lookup(ns_lwdclient_t *);
|
||||
|
||||
static isc_result_t
|
||||
count_rdatasets(dns_db_t *db, dns_dbnode_t *node, lwres_uint16_t *count) {
|
||||
dns_rdatasetiter_t *iter = NULL;
|
||||
int n = 0;
|
||||
isc_result_t result;
|
||||
|
||||
result = dns_db_allrdatasets(db, node, NULL, 0, &iter);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
for (result = dns_rdatasetiter_first(iter);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdatasetiter_next(iter))
|
||||
{
|
||||
dns_rdataset_t set;
|
||||
|
||||
dns_rdataset_init(&set);
|
||||
dns_rdatasetiter_current(iter, &set);
|
||||
if (set.type == dns_rdatatype_sig)
|
||||
n += dns_rdataset_count(&set);
|
||||
dns_rdataset_disassociate(&set);
|
||||
}
|
||||
if (result != ISC_R_NOMORE)
|
||||
goto cleanup;
|
||||
*count = n;
|
||||
result = ISC_R_SUCCESS;
|
||||
cleanup:
|
||||
if (iter != NULL)
|
||||
dns_rdatasetiter_destroy(&iter);
|
||||
return (result);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
fill_array(int *pos, dns_rdataset_t *rdataset,
|
||||
int size, unsigned char **rdatas, lwres_uint16_t *rdatalen)
|
||||
@@ -67,127 +98,6 @@ fill_array(int *pos, dns_rdataset_t *rdataset,
|
||||
return (result);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
iterate_node(lwres_grbnresponse_t *grbn, dns_db_t *db, dns_dbnode_t *node,
|
||||
isc_mem_t *mctx)
|
||||
{
|
||||
int used = 0, count;
|
||||
int size = 8, oldsize = 0;
|
||||
unsigned char **rdatas = NULL, **oldrdatas = NULL, **newrdatas = NULL;
|
||||
lwres_uint16_t *lens = NULL, *oldlens = NULL, *newlens = NULL;
|
||||
dns_rdatasetiter_t *iter = NULL;
|
||||
dns_rdataset_t set;
|
||||
dns_ttl_t ttl = ISC_INT32_MAX;
|
||||
lwres_uint32_t flags = LWRDATA_VALIDATED;
|
||||
isc_result_t result = ISC_R_NOMEMORY;
|
||||
|
||||
result = dns_db_allrdatasets(db, node, NULL, 0, &iter);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
rdatas = isc_mem_get(mctx, size * sizeof(*rdatas));
|
||||
if (rdatas == NULL)
|
||||
goto out;
|
||||
lens = isc_mem_get(mctx, size * sizeof(*lens));
|
||||
if (lens == NULL)
|
||||
goto out;
|
||||
|
||||
for (result = dns_rdatasetiter_first(iter);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdatasetiter_next(iter))
|
||||
{
|
||||
result = ISC_R_NOMEMORY;
|
||||
dns_rdataset_init(&set);
|
||||
dns_rdatasetiter_current(iter, &set);
|
||||
|
||||
if (set.type != dns_rdatatype_sig) {
|
||||
dns_rdataset_disassociate(&set);
|
||||
continue;
|
||||
}
|
||||
|
||||
count = dns_rdataset_count(&set);
|
||||
if (used + count > size) {
|
||||
/* copy & reallocate */
|
||||
oldsize = size;
|
||||
oldrdatas = rdatas;
|
||||
oldlens = lens;
|
||||
rdatas = NULL;
|
||||
lens = NULL;
|
||||
|
||||
size *= 2;
|
||||
|
||||
rdatas = isc_mem_get(mctx, size * sizeof(*rdatas));
|
||||
if (rdatas == NULL)
|
||||
goto out;
|
||||
lens = isc_mem_get(mctx, size * sizeof(*lens));
|
||||
if (lens == NULL)
|
||||
goto out;
|
||||
memcpy(rdatas, oldrdatas, used * sizeof(*rdatas));
|
||||
memcpy(lens, oldlens, used * sizeof(*lens));
|
||||
isc_mem_put(mctx, oldrdatas,
|
||||
oldsize * sizeof(*oldrdatas));
|
||||
isc_mem_put(mctx, oldlens, oldsize * sizeof(*oldlens));
|
||||
oldrdatas = NULL;
|
||||
oldlens = NULL;
|
||||
}
|
||||
if (set.ttl < ttl)
|
||||
ttl = set.ttl;
|
||||
if (set.trust != dns_trust_secure)
|
||||
flags &= (~LWRDATA_VALIDATED);
|
||||
result = fill_array(&used, &set, size, rdatas, lens);
|
||||
dns_rdataset_disassociate(&set);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
}
|
||||
if (result == ISC_R_NOMORE)
|
||||
result = ISC_R_SUCCESS;
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
dns_rdatasetiter_destroy(&iter);
|
||||
|
||||
/*
|
||||
* If necessary, shrink and copy the arrays.
|
||||
*/
|
||||
if (size != used) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
newrdatas = isc_mem_get(mctx, used * sizeof(*rdatas));
|
||||
if (newrdatas == NULL)
|
||||
goto out;
|
||||
newlens = isc_mem_get(mctx, used * sizeof(*lens));
|
||||
if (newlens == NULL)
|
||||
goto out;
|
||||
memcpy(newrdatas, rdatas, used * sizeof(*rdatas));
|
||||
memcpy(newlens, lens, used * sizeof(*lens));
|
||||
isc_mem_put(mctx, rdatas, size * sizeof(*rdatas));
|
||||
isc_mem_put(mctx, lens, size * sizeof(*lens));
|
||||
grbn->rdatas = newrdatas;
|
||||
grbn->rdatalen = newlens;
|
||||
} else {
|
||||
grbn->rdatas = rdatas;
|
||||
grbn->rdatalen = lens;
|
||||
}
|
||||
grbn->nrdatas = used;
|
||||
grbn->ttl = ttl;
|
||||
grbn->flags = flags;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
out:
|
||||
dns_rdatasetiter_destroy(&iter);
|
||||
if (rdatas != NULL)
|
||||
isc_mem_put(mctx, rdatas, size * sizeof(*rdatas));
|
||||
if (lens != NULL)
|
||||
isc_mem_put(mctx, lens, size * sizeof(*lens));
|
||||
if (oldrdatas != NULL)
|
||||
isc_mem_put(mctx, oldrdatas, oldsize * sizeof(*oldrdatas));
|
||||
if (oldlens != NULL)
|
||||
isc_mem_put(mctx, oldlens, oldsize * sizeof(*oldlens));
|
||||
if (newrdatas != NULL)
|
||||
isc_mem_put(mctx, newrdatas, used * sizeof(*oldrdatas));
|
||||
if (newlens != NULL)
|
||||
isc_mem_put(mctx, newlens, used * sizeof(*oldlens));
|
||||
return (result);
|
||||
}
|
||||
|
||||
static void
|
||||
lookup_done(isc_task_t *task, isc_event_t *event) {
|
||||
ns_lwdclient_t *client;
|
||||
@@ -250,17 +160,30 @@ lookup_done(isc_task_t *task, isc_event_t *event) {
|
||||
|
||||
grbn->flags = 0;
|
||||
|
||||
grbn->nrdatas = 0;
|
||||
rdataset = levent->rdataset;
|
||||
if (rdataset != NULL)
|
||||
grbn->nrdatas = dns_rdataset_count(rdataset);
|
||||
else {
|
||||
result = count_rdatasets(levent->db, levent->node,
|
||||
&grbn->nrdatas);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
}
|
||||
grbn->rdatas = NULL;
|
||||
grbn->rdatalen = NULL;
|
||||
|
||||
grbn->nsigs = 0;
|
||||
sigrdataset = levent->sigrdataset;
|
||||
if (sigrdataset != NULL)
|
||||
grbn->nsigs = dns_rdataset_count(sigrdataset);
|
||||
else
|
||||
grbn->nsigs = 0;
|
||||
|
||||
grbn->sigs = NULL;
|
||||
grbn->siglen = NULL;
|
||||
|
||||
result = dns_name_totext(name, ISC_TRUE, &client->recv_buffer);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
goto out;
|
||||
grbn->realname = (char *)isc_buffer_used(&b);
|
||||
grbn->realnamelen = isc_buffer_usedlength(&client->recv_buffer) -
|
||||
isc_buffer_usedlength(&b);
|
||||
@@ -270,58 +193,82 @@ lookup_done(isc_task_t *task, isc_event_t *event) {
|
||||
grbn->rdclass = cm->view->rdclass;
|
||||
grbn->rdtype = client->rdtype;
|
||||
|
||||
rdataset = levent->rdataset;
|
||||
if (rdataset != NULL) {
|
||||
/* The normal case */
|
||||
grbn->nrdatas = dns_rdataset_count(rdataset);
|
||||
grbn->rdatas = isc_mem_get(cm->mctx, grbn->nrdatas *
|
||||
sizeof(unsigned char *));
|
||||
if (grbn->rdatas == NULL)
|
||||
goto out;
|
||||
grbn->rdatalen = isc_mem_get(cm->mctx, grbn->nrdatas *
|
||||
sizeof(lwres_uint16_t));
|
||||
if (grbn->rdatalen == NULL)
|
||||
goto out;
|
||||
/* If rdataset is NULL, get this later. */
|
||||
if (rdataset == NULL)
|
||||
grbn->ttl = ISC_INT32_MAX;
|
||||
else
|
||||
grbn->ttl = rdataset->ttl;
|
||||
|
||||
/* If rdataset is NULL, remove this later. */
|
||||
if (rdataset == NULL || rdataset->trust == dns_trust_secure)
|
||||
grbn->flags |= LWRDATA_VALIDATED;
|
||||
|
||||
grbn->rdatas = isc_mem_get(cm->mctx,
|
||||
grbn->nrdatas * sizeof(unsigned char *));
|
||||
if (grbn->rdatas == NULL)
|
||||
goto out;
|
||||
grbn->rdatalen = isc_mem_get(cm->mctx,
|
||||
grbn->nrdatas * sizeof(lwres_uint16_t));
|
||||
if (grbn->rdatalen == NULL)
|
||||
goto out;
|
||||
|
||||
if (rdataset != NULL) {
|
||||
i = 0;
|
||||
result = fill_array(&i, rdataset, grbn->nrdatas, grbn->rdatas,
|
||||
grbn->rdatalen);
|
||||
if (result != ISC_R_SUCCESS || i != grbn->nrdatas)
|
||||
goto out;
|
||||
} else {
|
||||
dns_rdatasetiter_t *iter = NULL;
|
||||
dns_rdataset_t set;
|
||||
|
||||
result = dns_db_allrdatasets(levent->db, levent->node,
|
||||
NULL, 0, &iter);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
INSIST(i == grbn->nrdatas);
|
||||
grbn->ttl = rdataset->ttl;
|
||||
if (rdataset->trust == dns_trust_secure)
|
||||
grbn->flags |= LWRDATA_VALIDATED;
|
||||
} else {
|
||||
/* The SIG query case */
|
||||
result = iterate_node(grbn, levent->db, levent->node,
|
||||
cm->mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
i = 0;
|
||||
for (result = dns_rdatasetiter_first(iter);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdatasetiter_next(iter))
|
||||
{
|
||||
dns_rdataset_init(&set);
|
||||
dns_rdatasetiter_current(iter, &set);
|
||||
if (set.type != dns_rdatatype_sig) {
|
||||
dns_rdataset_disassociate(&set);
|
||||
continue;
|
||||
}
|
||||
if (set.ttl < grbn->ttl)
|
||||
grbn->ttl = set.ttl;
|
||||
if (set.trust < dns_trust_secure)
|
||||
grbn->flags &= (~LWRDATA_VALIDATED);
|
||||
result = fill_array(&i, &set, grbn->nrdatas,
|
||||
grbn->rdatas, grbn->rdatalen);
|
||||
dns_rdataset_disassociate(&set);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
break;
|
||||
}
|
||||
dns_rdatasetiter_destroy(&iter);
|
||||
if (result == ISC_R_NOMORE)
|
||||
result = ISC_R_SUCCESS;
|
||||
if (result != ISC_R_SUCCESS || i != grbn->nrdatas)
|
||||
goto out;
|
||||
}
|
||||
ns_lwdclient_log(50, "filled in %d rdata%s", grbn->nrdatas,
|
||||
(grbn->nrdatas == 1) ? "" : "s");
|
||||
|
||||
sigrdataset = levent->sigrdataset;
|
||||
grbn->sigs = isc_mem_get(cm->mctx, grbn->nsigs *
|
||||
sizeof(unsigned char *));
|
||||
if (grbn->sigs == NULL)
|
||||
goto out;
|
||||
grbn->siglen = isc_mem_get(cm->mctx, grbn->nsigs *
|
||||
sizeof(lwres_uint16_t));
|
||||
if (grbn->siglen == NULL)
|
||||
goto out;
|
||||
|
||||
if (sigrdataset != NULL) {
|
||||
grbn->nsigs = dns_rdataset_count(sigrdataset);
|
||||
grbn->sigs = isc_mem_get(cm->mctx, grbn->nsigs *
|
||||
sizeof(unsigned char *));
|
||||
if (grbn->sigs == NULL)
|
||||
goto out;
|
||||
grbn->siglen = isc_mem_get(cm->mctx, grbn->nsigs *
|
||||
sizeof(lwres_uint16_t));
|
||||
if (grbn->siglen == NULL)
|
||||
goto out;
|
||||
|
||||
i = 0;
|
||||
result = fill_array(&i, sigrdataset, grbn->nsigs, grbn->sigs,
|
||||
grbn->siglen);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS || i != grbn->nsigs)
|
||||
goto out;
|
||||
INSIST(i == grbn->nsigs);
|
||||
ns_lwdclient_log(50, "filled in %d signature%s", grbn->nsigs,
|
||||
(grbn->nsigs == 1) ? "" : "s");
|
||||
}
|
||||
|
||||
dns_lookup_destroy(&client->lookup);
|
||||
@@ -345,12 +292,10 @@ lookup_done(isc_task_t *task, isc_event_t *event) {
|
||||
isc_mem_put(cm->mctx, grbn->rdatalen,
|
||||
grbn->nrdatas * sizeof(lwres_uint16_t));
|
||||
|
||||
if (grbn->sigs != NULL)
|
||||
isc_mem_put(cm->mctx, grbn->sigs,
|
||||
grbn->nsigs * sizeof(unsigned char *));
|
||||
if (grbn->siglen != NULL)
|
||||
isc_mem_put(cm->mctx, grbn->siglen,
|
||||
grbn->nsigs * sizeof(lwres_uint16_t));
|
||||
isc_mem_put(cm->mctx, grbn->sigs,
|
||||
grbn->nsigs * sizeof(unsigned char *));
|
||||
isc_mem_put(cm->mctx, grbn->siglen,
|
||||
grbn->nsigs * sizeof(lwres_uint16_t));
|
||||
|
||||
r.base = lwb.base;
|
||||
r.length = lwb.used;
|
||||
@@ -386,9 +331,6 @@ lookup_done(isc_task_t *task, isc_event_t *event) {
|
||||
|
||||
if (event != NULL)
|
||||
isc_event_free(&event);
|
||||
|
||||
ns_lwdclient_log(50, "error constructing getrrsetbyname response");
|
||||
ns_lwdclient_errorpktsend(client, LWRES_R_FAILURE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lwdnoop.c,v 1.6 2001/01/09 21:39:53 bwelling Exp $ */
|
||||
/* $Id: lwdnoop.c,v 1.5.4.1 2001/01/09 22:32:03 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lwresd.c,v 1.30 2001/01/25 02:33:39 bwelling Exp $ */
|
||||
/* $Id: lwresd.c,v 1.27.2.2 2001/01/19 02:37:51 gson Exp $ */
|
||||
|
||||
/*
|
||||
* Main program for the Lightweight Resolver Daemon.
|
||||
@@ -218,8 +218,9 @@ ns_lwresd_parseresolvconf(isc_mem_t *mctx, dns_c_ctx_t **ctxp) {
|
||||
}
|
||||
|
||||
if (forwarders->nextidx != 0) {
|
||||
CHECK(dns_c_ctx_setforwarders(ctx, forwarders));
|
||||
dns_c_iplist_detach(&forwarders);
|
||||
CHECK(dns_c_ctx_setforwarders(ctx, ISC_FALSE,
|
||||
forwarders));
|
||||
forwarders = NULL;
|
||||
CHECK(dns_c_ctx_setforward(ctx, dns_c_forw_first));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lwsearch.c,v 1.7 2001/01/09 21:39:55 bwelling Exp $ */
|
||||
/* $Id: lwsearch.c,v 1.6.2.1 2001/01/09 22:32:06 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: main.c,v 1.103 2001/01/11 23:46:10 bwelling Exp $ */
|
||||
/* $Id: main.c,v 1.97.2.1 2001/01/09 22:32:07 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/entropy.h>
|
||||
#include <isc/os.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/resource.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/timer.h>
|
||||
@@ -369,12 +368,8 @@ static isc_result_t
|
||||
create_managers(void) {
|
||||
isc_result_t result;
|
||||
|
||||
#ifdef ISC_PLATFORM_USETHREADS
|
||||
if (ns_g_cpus == 0)
|
||||
ns_g_cpus = isc_os_ncpus();
|
||||
#else
|
||||
ns_g_cpus = 1;
|
||||
#endif
|
||||
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
|
||||
ISC_LOG_INFO, "using %u CPU%s",
|
||||
ns_g_cpus, ns_g_cpus == 1 ? "" : "s");
|
||||
@@ -410,6 +405,10 @@ create_managers(void) {
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
|
||||
#ifdef PATH_RANDOMDEV
|
||||
(void)isc_entropy_createfilesource(ns_g_entropy, PATH_RANDOMDEV);
|
||||
#endif
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -573,10 +572,8 @@ main(int argc, char *argv[]) {
|
||||
|
||||
cleanup();
|
||||
|
||||
if (want_stats) {
|
||||
if (want_stats)
|
||||
isc_mem_stats(ns_g_mctx, stdout);
|
||||
isc_mutex_stats(stdout);
|
||||
}
|
||||
isc_mem_destroy(&ns_g_mctx);
|
||||
|
||||
isc_app_finish();
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: notify.c,v 1.23 2001/01/09 21:39:58 bwelling Exp $ */
|
||||
/* $Id: notify.c,v 1.22.2.1 2001/01/09 22:32:08 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: omapi.c,v 1.30 2001/01/09 21:39:59 bwelling Exp $ */
|
||||
/* $Id: omapi.c,v 1.29.2.1 2001/01/09 22:32:09 bwelling Exp $ */
|
||||
|
||||
/*
|
||||
* Principal Author: DCL
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: omapiconf.c,v 1.15 2001/01/09 21:40:00 bwelling Exp $ */
|
||||
/* $Id: omapiconf.c,v 1.14.4.1 2001/01/09 22:32:10 bwelling Exp $ */
|
||||
|
||||
/*
|
||||
* Principal Author: DCL
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: query.c,v 1.178 2001/01/29 19:49:50 bwelling Exp $ */
|
||||
/* $Id: query.c,v 1.163.2.2 2001/01/09 22:32:12 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
#include <isc/mem.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/adb.h>
|
||||
#include <dns/byaddr.h>
|
||||
#include <dns/db.h>
|
||||
#include <dns/events.h>
|
||||
#include <dns/message.h>
|
||||
@@ -87,18 +85,6 @@
|
||||
#define DNS_GETDB_NOEXACT 0x01U
|
||||
#define DNS_GETDB_NOLOG 0x02U
|
||||
|
||||
static unsigned char ip6int_ndata[] = "\003ip6\003int";
|
||||
static unsigned char ip6int_offsets[] = { 0, 4, 8 };
|
||||
|
||||
static dns_name_t ip6int_name = {
|
||||
DNS_NAME_MAGIC,
|
||||
ip6int_ndata, 9, 3,
|
||||
DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE,
|
||||
ip6int_offsets, NULL,
|
||||
{(void *)-1, (void *)-1},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static isc_result_t
|
||||
query_simplefind(void *arg, dns_name_t *name, dns_rdatatype_t type,
|
||||
isc_stdtime_t now,
|
||||
@@ -109,43 +95,15 @@ query_adda6rrset(void *arg, dns_name_t *name, dns_rdataset_t *rdataset,
|
||||
dns_rdataset_t *sigrdataset);
|
||||
|
||||
static void
|
||||
query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype);
|
||||
|
||||
static void
|
||||
synth_fwd_start(ns_client_t *client);
|
||||
|
||||
static void
|
||||
synth_fwd_startfind(ns_client_t *client);
|
||||
|
||||
static void
|
||||
synth_fwd_respond(ns_client_t *client, dns_adbfind_t *find);
|
||||
|
||||
static void
|
||||
synth_fwd_finddone(isc_task_t *task, isc_event_t *ev);
|
||||
|
||||
static void
|
||||
synth_finish(ns_client_t *client, isc_result_t result);
|
||||
|
||||
static void
|
||||
synth_rev_start(ns_client_t *client);
|
||||
|
||||
static void
|
||||
synth_rev_byaddrdone_arpa(isc_task_t *task, isc_event_t *event);
|
||||
|
||||
static void
|
||||
synth_rev_byaddrdone_int(isc_task_t *task, isc_event_t *event);
|
||||
|
||||
static void
|
||||
synth_rev_respond(ns_client_t *client, dns_byaddrevent_t *bevent);
|
||||
query_find(ns_client_t *client, dns_fetchevent_t *event);
|
||||
|
||||
/*
|
||||
* Increment query statistics counters.
|
||||
*/
|
||||
static inline void
|
||||
count_query(dns_zone_t *zone, isc_boolean_t is_zone,
|
||||
dns_statscounter_t counter)
|
||||
static void
|
||||
count_query(dns_zone_t *zone, isc_boolean_t is_zone, dns_statscounter_t counter)
|
||||
{
|
||||
REQUIRE(counter < DNS_STATS_NCOUNTERS);
|
||||
REQUIRE(counter < dns_stats_ncounters());
|
||||
|
||||
ns_g_server->querystats[counter]++;
|
||||
|
||||
@@ -239,9 +197,9 @@ query_reset(ns_client_t *client, isc_boolean_t everything) {
|
||||
client->query.attributes = (NS_QUERYATTR_RECURSIONOK |
|
||||
NS_QUERYATTR_CACHEOK);
|
||||
client->query.restarts = 0;
|
||||
client->query.timerset = ISC_FALSE;
|
||||
client->query.origqname = NULL;
|
||||
client->query.qname = NULL;
|
||||
client->query.qrdataset = NULL;
|
||||
client->query.dboptions = 0;
|
||||
client->query.fetchoptions = 0;
|
||||
client->query.gluedb = NULL;
|
||||
@@ -468,7 +426,6 @@ ns_query_init(ns_client_t *client) {
|
||||
ISC_LIST_INIT(client->query.activeversions);
|
||||
ISC_LIST_INIT(client->query.freeversions);
|
||||
client->query.restarts = 0;
|
||||
client->query.timerset = ISC_FALSE;
|
||||
client->query.qname = NULL;
|
||||
client->query.fetch = NULL;
|
||||
client->query.authdb = NULL;
|
||||
@@ -1421,7 +1378,7 @@ query_adda6rrset(void *arg, dns_name_t *name, dns_rdataset_t *rdataset,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (dns_name_copy(name, fname, NULL) != ISC_R_SUCCESS)
|
||||
if (dns_name_concatenate(name, NULL, fname, NULL) != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
dns_rdataset_clone(rdataset, crdataset);
|
||||
if (sigrdataset != NULL && dns_rdataset_isassociated(sigrdataset))
|
||||
@@ -1512,6 +1469,8 @@ query_addrdataset(ns_client_t *client, dns_name_t *fname,
|
||||
CTRACE("query_addrdataset: done");
|
||||
}
|
||||
|
||||
#define ANSWERED(rds) (((rds)->attributes & DNS_RDATASETATTR_ANSWERED) != 0)
|
||||
|
||||
static void
|
||||
query_addrrset(ns_client_t *client, dns_name_t **namep,
|
||||
dns_rdataset_t **rdatasetp, dns_rdataset_t **sigrdatasetp,
|
||||
@@ -1767,8 +1726,8 @@ query_addns(ns_client_t *client, dns_db_t *db) {
|
||||
}
|
||||
|
||||
static inline isc_result_t
|
||||
query_addcnamelike(ns_client_t *client, dns_name_t *qname, dns_name_t *tname,
|
||||
dns_ttl_t ttl, dns_name_t **anamep, dns_rdatatype_t type)
|
||||
query_addcname(ns_client_t *client, dns_name_t *qname, dns_name_t *tname,
|
||||
dns_ttl_t ttl, dns_name_t **anamep)
|
||||
{
|
||||
dns_rdataset_t *rdataset;
|
||||
dns_rdatalist_t *rdatalist;
|
||||
@@ -1776,6 +1735,7 @@ query_addcnamelike(ns_client_t *client, dns_name_t *qname, dns_name_t *tname,
|
||||
isc_result_t result;
|
||||
isc_region_t r;
|
||||
|
||||
CTRACE("query_addcname");
|
||||
/*
|
||||
* We assume the name data referred to by qname and tname won't
|
||||
* go away.
|
||||
@@ -1798,7 +1758,7 @@ query_addcnamelike(ns_client_t *client, dns_name_t *qname, dns_name_t *tname,
|
||||
dns_rdataset_init(rdataset);
|
||||
dns_name_clone(qname, *anamep);
|
||||
|
||||
rdatalist->type = type;
|
||||
rdatalist->type = dns_rdatatype_cname;
|
||||
rdatalist->covers = 0;
|
||||
rdatalist->rdclass = client->message->rdclass;
|
||||
rdatalist->ttl = ttl;
|
||||
@@ -1975,6 +1935,30 @@ query_addbestns(ns_client_t *client) {
|
||||
}
|
||||
}
|
||||
|
||||
static inline isc_result_t
|
||||
query_checktype(dns_rdatatype_t type) {
|
||||
|
||||
/*
|
||||
* XXXRTH OPT still needs to be added.
|
||||
* Should get help with this from rdata.c
|
||||
*/
|
||||
switch (type) {
|
||||
case dns_rdatatype_tkey:
|
||||
return (DNS_R_NOTIMP);
|
||||
case dns_rdatatype_tsig:
|
||||
return (DNS_R_FORMERR);
|
||||
case dns_rdatatype_ixfr:
|
||||
case dns_rdatatype_axfr:
|
||||
case dns_rdatatype_mailb:
|
||||
case dns_rdatatype_maila:
|
||||
return (DNS_R_REFUSED);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
query_resume(isc_task_t *task, isc_event_t *event) {
|
||||
dns_fetchevent_t *devent = (dns_fetchevent_t *)event;
|
||||
@@ -2042,7 +2026,7 @@ query_resume(isc_task_t *task, isc_event_t *event) {
|
||||
dns_view_attach(client->view, &client->lockview);
|
||||
RWLOCK(&client->lockview->conflock, isc_rwlocktype_read);
|
||||
|
||||
query_find(client, devent, 0);
|
||||
query_find(client, devent);
|
||||
|
||||
RWUNLOCK(&client->lockview->conflock, isc_rwlocktype_read);
|
||||
dns_view_detach(&client->lockview);
|
||||
@@ -2099,8 +2083,6 @@ query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qdomain,
|
||||
} else
|
||||
sigrdataset = NULL;
|
||||
|
||||
if (client->query.timerset == ISC_FALSE)
|
||||
ns_client_settimeout(client, 60);
|
||||
result = dns_resolver_createfetch(client->view->resolver,
|
||||
client->query.qname,
|
||||
qtype, qdomain, nameservers,
|
||||
@@ -2310,16 +2292,11 @@ setup_query_sortlist(ns_client_t *client) {
|
||||
dns_message_setsortorder(client->message, order, order_arg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Do the bulk of query processing for the current query of 'client'.
|
||||
* If 'event' is non-NULL, we are returning from recursion and 'qtype'
|
||||
* is ignored. Otherwise, 'qtype' is the query type.
|
||||
*/
|
||||
static void
|
||||
query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype) {
|
||||
query_find(ns_client_t *client, dns_fetchevent_t *event) {
|
||||
dns_db_t *db, *zdb;
|
||||
dns_dbnode_t *node;
|
||||
dns_rdatatype_t type;
|
||||
dns_rdatatype_t qtype, type;
|
||||
dns_name_t *fname, *zfname, *tname, *prefix;
|
||||
dns_rdataset_t *rdataset, *trdataset;
|
||||
dns_rdataset_t *sigrdataset, *zrdataset, *zsigrdataset;
|
||||
@@ -2327,7 +2304,7 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
dns_rdatasetiter_t *rdsiter;
|
||||
isc_boolean_t want_restart, authoritative, is_zone;
|
||||
unsigned int n, nlabels, nbits;
|
||||
unsigned int qcount, n, nlabels, nbits;
|
||||
dns_namereln_t namereln;
|
||||
int order;
|
||||
isc_buffer_t *dbuf;
|
||||
@@ -2392,12 +2369,13 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
|
||||
}
|
||||
fname = query_newname(client, dbuf, &b);
|
||||
if (fname == NULL) {
|
||||
count_query(zone, is_zone, dns_statscounter_failure);
|
||||
count_query(zone, is_zone,
|
||||
dns_statscounter_failure);
|
||||
QUERY_ERROR(DNS_R_SERVFAIL);
|
||||
goto cleanup;
|
||||
}
|
||||
tname = dns_fixedname_name(&event->foundname);
|
||||
result = dns_name_copy(tname, fname, NULL);
|
||||
result = dns_name_concatenate(tname, NULL, fname, NULL);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
count_query(zone, is_zone, dns_statscounter_failure);
|
||||
QUERY_ERROR(DNS_R_SERVFAIL);
|
||||
@@ -2407,19 +2385,8 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
|
||||
result = event->result;
|
||||
|
||||
goto resume;
|
||||
}
|
||||
|
||||
/*
|
||||
* Not returning from recursion.
|
||||
*/
|
||||
|
||||
/*
|
||||
* If it's a SIG query, we'll iterate the node.
|
||||
*/
|
||||
if (qtype == dns_rdatatype_sig)
|
||||
type = dns_rdatatype_any;
|
||||
else
|
||||
type = qtype;
|
||||
} else
|
||||
client->query.qrdataset = NULL;
|
||||
|
||||
restart:
|
||||
CTRACE("query_find: restart");
|
||||
@@ -2444,6 +2411,59 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
|
||||
if (is_zone)
|
||||
authoritative = ISC_TRUE;
|
||||
|
||||
/*
|
||||
* Find the first unanswered type in the question section.
|
||||
*/
|
||||
qtype = 0;
|
||||
qcount = 0;
|
||||
client->query.qrdataset = NULL;
|
||||
for (trdataset = ISC_LIST_HEAD(client->query.origqname->list);
|
||||
trdataset != NULL;
|
||||
trdataset = ISC_LIST_NEXT(trdataset, link)) {
|
||||
if (!ANSWERED(trdataset)) {
|
||||
if (client->query.qrdataset == NULL) {
|
||||
client->query.qrdataset = trdataset;
|
||||
qtype = trdataset->type;
|
||||
}
|
||||
qcount++;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* We had better have found something!
|
||||
*/
|
||||
INSIST(client->query.qrdataset != NULL && qcount > 0);
|
||||
|
||||
/*
|
||||
* If there's more than one question, we'll eventually retrieve the
|
||||
* node and iterate it, trying to find answers. For now, we simply
|
||||
* refuse requests with more than one question.
|
||||
*/
|
||||
if (qcount == 1)
|
||||
type = qtype;
|
||||
else {
|
||||
CTRACE("find_query: REFUSED: qcount != 1");
|
||||
count_query(zone, is_zone, dns_statscounter_failure);
|
||||
QUERY_ERROR(DNS_R_REFUSED);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
* See if the type is OK.
|
||||
*/
|
||||
result = query_checktype(qtype);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
CTRACE("find_query: non supported query type");
|
||||
count_query(zone, is_zone, dns_statscounter_failure);
|
||||
QUERY_ERROR(result);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
* If it's a SIG query, we'll iterate the node.
|
||||
*/
|
||||
if (qtype == dns_rdatatype_sig)
|
||||
type = dns_rdatatype_any;
|
||||
|
||||
db_find:
|
||||
CTRACE("query_find: db_find");
|
||||
/*
|
||||
@@ -2519,11 +2539,10 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
|
||||
* dns_name_concatenate() can fail (though it shouldn't
|
||||
* ever do so since we should have enough space).
|
||||
*/
|
||||
result = dns_name_copy(client->query.qname,
|
||||
fname, NULL);
|
||||
result = dns_name_concatenate(client->query.qname,
|
||||
NULL, fname, NULL);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
count_query(zone, is_zone,
|
||||
dns_statscounter_failure);
|
||||
count_query(zone, is_zone, dns_statscounter_failure);
|
||||
QUERY_ERROR(DNS_R_SERVFAIL);
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -2572,19 +2591,13 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
|
||||
* the hints DB.
|
||||
*/
|
||||
INSIST(!is_zone);
|
||||
INSIST(client->view->hints != NULL);
|
||||
if (db != NULL)
|
||||
dns_db_detach(&db);
|
||||
|
||||
if (client->view->hints == NULL) {
|
||||
/* We have no hints. */
|
||||
result = ISC_R_FAILURE;
|
||||
} else {
|
||||
dns_db_attach(client->view->hints, &db);
|
||||
result = dns_db_find(db, dns_rootname,
|
||||
NULL, dns_rdatatype_ns,
|
||||
0, client->now, &node, fname,
|
||||
rdataset, sigrdataset);
|
||||
}
|
||||
dns_db_attach(client->view->hints, &db);
|
||||
result = dns_db_find(db, dns_rootname, NULL, dns_rdatatype_ns,
|
||||
0, client->now, &node, fname,
|
||||
rdataset, sigrdataset);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
/*
|
||||
* We can't even find the hints for the root
|
||||
@@ -2709,7 +2722,7 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
|
||||
NS_QUERYATTR_RECURSING;
|
||||
else {
|
||||
count_query(zone, is_zone,
|
||||
dns_statscounter_failure);
|
||||
dns_statscounter_failure);
|
||||
QUERY_ERROR(DNS_R_SERVFAIL);
|
||||
}
|
||||
} else {
|
||||
@@ -2763,7 +2776,8 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
|
||||
*/
|
||||
result = query_addsoa(client, db, ISC_FALSE);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
count_query(zone, is_zone, dns_statscounter_failure);
|
||||
count_query(zone, is_zone,
|
||||
dns_statscounter_failure);
|
||||
QUERY_ERROR(result);
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -2821,7 +2835,8 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
|
||||
else
|
||||
result = query_addsoa(client, db, ISC_FALSE);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
count_query(zone, is_zone, dns_statscounter_failure);
|
||||
count_query(zone, is_zone,
|
||||
dns_statscounter_failure);
|
||||
QUERY_ERROR(result);
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -3014,9 +3029,8 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
|
||||
* since the synthesized CNAME is NOT in the zone.
|
||||
*/
|
||||
dns_name_init(tname, NULL);
|
||||
query_addcnamelike(client, client->query.qname, fname,
|
||||
trdataset->ttl, &tname,
|
||||
dns_rdatatype_cname);
|
||||
query_addcname(client, client->query.qname, fname,
|
||||
trdataset->ttl, &tname);
|
||||
if (tname != NULL)
|
||||
dns_message_puttempname(client->message, &tname);
|
||||
/*
|
||||
@@ -3045,7 +3059,8 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
|
||||
rdsiter = NULL;
|
||||
result = dns_db_allrdatasets(db, node, version, 0, &rdsiter);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
count_query(zone, is_zone, dns_statscounter_failure);
|
||||
count_query(zone, is_zone,
|
||||
dns_statscounter_failure);
|
||||
QUERY_ERROR(DNS_R_SERVFAIL);
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -3146,6 +3161,11 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
|
||||
* because it's already in the answer.
|
||||
*/
|
||||
INSIST(rdataset == NULL);
|
||||
/*
|
||||
* Remember that we've answered this question.
|
||||
*/
|
||||
client->query.qrdataset->attributes |=
|
||||
DNS_RDATASETATTR_ANSWERED;
|
||||
}
|
||||
|
||||
addauth:
|
||||
@@ -3268,7 +3288,6 @@ ns_query_start(ns_client_t *client) {
|
||||
dns_message_t *message = client->message;
|
||||
dns_rdataset_t *rdataset;
|
||||
ns_client_t *qclient;
|
||||
dns_rdatatype_t qtype;
|
||||
|
||||
CTRACE("ns_query_start");
|
||||
|
||||
@@ -3343,9 +3362,8 @@ ns_query_start(ns_client_t *client) {
|
||||
*/
|
||||
rdataset = ISC_LIST_HEAD(client->query.qname->list);
|
||||
INSIST(rdataset != NULL);
|
||||
qtype = rdataset->type;
|
||||
if (dns_rdatatype_ismeta(qtype)) {
|
||||
switch (qtype) {
|
||||
if (dns_rdatatype_ismeta(rdataset->type)) {
|
||||
switch (rdataset->type) {
|
||||
case dns_rdatatype_any:
|
||||
break; /* Let query_find handle it. */
|
||||
case dns_rdatatype_ixfr:
|
||||
@@ -3403,442 +3421,8 @@ ns_query_start(ns_client_t *client) {
|
||||
if (WANTDNSSEC(client))
|
||||
message->flags |= DNS_MESSAGEFLAG_AD;
|
||||
|
||||
/*
|
||||
* Synthesize IPv6 responses if appropriate.
|
||||
*/
|
||||
if (RECURSIONOK(client) &&
|
||||
(qtype == dns_rdatatype_aaaa || qtype == dns_rdatatype_ptr) &&
|
||||
client->message->rdclass == dns_rdataclass_in &&
|
||||
ns_client_checkacl(client, "v6 synthesis",
|
||||
client->view->v6synthesisacl,
|
||||
ISC_FALSE, ISC_LOG_DEBUG(9)) == ISC_R_SUCCESS)
|
||||
{
|
||||
if (qtype == dns_rdatatype_aaaa) {
|
||||
qclient = NULL;
|
||||
ns_client_attach(client, &qclient);
|
||||
synth_fwd_start(qclient);
|
||||
return;
|
||||
} else {
|
||||
INSIST(qtype == dns_rdatatype_ptr);
|
||||
/* Must be 32 nibbles + "ip6" + "int" + root */
|
||||
if (dns_name_countlabels(client->query.qname) == 32 + 3 &&
|
||||
dns_name_issubdomain(client->query.qname, &ip6int_name)) {
|
||||
qclient = NULL;
|
||||
ns_client_attach(client, &qclient);
|
||||
synth_rev_start(qclient);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qclient = NULL;
|
||||
ns_client_attach(client, &qclient);
|
||||
query_find(qclient, NULL, qtype);
|
||||
query_find(qclient, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate a synthetic IPv6 forward mapping response for the current
|
||||
* query of 'client'.
|
||||
*/
|
||||
static void
|
||||
synth_fwd_start(ns_client_t *client) {
|
||||
ns_client_log(client, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_QUERY,
|
||||
ISC_LOG_DEBUG(5), "generating synthetic AAAA response");
|
||||
|
||||
synth_fwd_startfind(client);
|
||||
}
|
||||
|
||||
/*
|
||||
* Start an ADB find to get addresses, or more addresses, for
|
||||
* a synthetic IPv6 forward mapping response.
|
||||
*/
|
||||
static void
|
||||
synth_fwd_startfind(ns_client_t *client) {
|
||||
dns_adbfind_t *find = NULL;
|
||||
isc_result_t result;
|
||||
dns_fixedname_t target_fixed;
|
||||
dns_name_t *target;
|
||||
|
||||
dns_fixedname_init(&target_fixed);
|
||||
target = dns_fixedname_name(&target_fixed);
|
||||
|
||||
find_again:
|
||||
result = dns_adb_createfind(client->view->adb, client->task,
|
||||
synth_fwd_finddone, client, client->query.qname,
|
||||
dns_rootname,
|
||||
DNS_ADBFIND_WANTEVENT | DNS_ADBFIND_RETURNLAME |
|
||||
DNS_ADBFIND_INET6, client->now,
|
||||
target, 0, &find);
|
||||
|
||||
ns_client_log(client, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_QUERY,
|
||||
ISC_LOG_DEBUG(5), "find returned %s",
|
||||
isc_result_totext(result));
|
||||
|
||||
if (result == DNS_R_ALIAS) {
|
||||
dns_name_t *ptarget = NULL;
|
||||
dns_name_t *tname = NULL;
|
||||
isc_buffer_t *dbuf;
|
||||
isc_buffer_t b;
|
||||
|
||||
/*
|
||||
* Make a persistent copy of the 'target' name data in 'ptarget';
|
||||
* it will become the new query name.
|
||||
*/
|
||||
dbuf = query_getnamebuf(client);
|
||||
if (dbuf == NULL)
|
||||
goto fail;
|
||||
ptarget = query_newname(client, dbuf, &b);
|
||||
if (ptarget == NULL)
|
||||
goto fail;
|
||||
dns_name_copy(target, ptarget, NULL);
|
||||
|
||||
dns_adb_destroyfind(&find);
|
||||
|
||||
/*
|
||||
* Get another temporary name 'tname' for insertion into the
|
||||
* response message.
|
||||
*/
|
||||
result = dns_message_gettempname(client->message, &tname);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto fail;
|
||||
dns_name_init(tname, NULL);
|
||||
result = query_addcnamelike(client, client->query.qname, ptarget,
|
||||
0 /* XXX ttl */, &tname,
|
||||
dns_rdatatype_cname);
|
||||
if (tname != NULL)
|
||||
dns_message_puttempname(client->message, &tname);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
query_maybeputqname(client);
|
||||
client->query.qname = ptarget;
|
||||
query_keepname(client, ptarget, dbuf);
|
||||
ptarget = NULL;
|
||||
if (client->query.restarts < MAX_RESTARTS) {
|
||||
client->query.restarts++;
|
||||
goto find_again;
|
||||
} else {
|
||||
/*
|
||||
* Probably a CNAME loop. Reply with partial
|
||||
* CNAME chain.
|
||||
*/
|
||||
result = ISC_R_SUCCESS;
|
||||
goto done;
|
||||
}
|
||||
} else if (result != ISC_R_SUCCESS) {
|
||||
if (find != NULL)
|
||||
dns_adb_destroyfind(&find);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((find->options & DNS_ADBFIND_WANTEVENT) != 0) {
|
||||
ns_client_log(client, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_QUERY,
|
||||
ISC_LOG_DEBUG(5), "find will send event");
|
||||
} else {
|
||||
synth_fwd_respond(client, find);
|
||||
dns_adb_destroyfind(&find);
|
||||
}
|
||||
return;
|
||||
|
||||
fail:
|
||||
result = DNS_R_SERVFAIL;
|
||||
done:
|
||||
synth_finish(client, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle an ADB finddone event generated as part of synthetic IPv6
|
||||
* forward mapping processing.
|
||||
*/
|
||||
static void
|
||||
synth_fwd_finddone(isc_task_t *task, isc_event_t *ev) {
|
||||
ns_client_t *client = ev->ev_arg;
|
||||
dns_adbfind_t *find = ev->ev_sender;
|
||||
isc_eventtype_t evtype = ev->ev_type;
|
||||
|
||||
UNUSED(task);
|
||||
|
||||
ns_client_log(client, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_QUERY,
|
||||
ISC_LOG_DEBUG(5), "got find event");
|
||||
|
||||
if (evtype == DNS_EVENT_ADBNOMOREADDRESSES)
|
||||
synth_fwd_respond(client, find);
|
||||
else if (evtype == DNS_EVENT_ADBMOREADDRESSES)
|
||||
synth_fwd_startfind(client);
|
||||
else
|
||||
synth_finish(client, DNS_R_SERVFAIL);
|
||||
|
||||
isc_event_free(&ev);
|
||||
dns_adb_destroyfind(&find);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate a synthetic IPv6 forward mapping response based on
|
||||
* a completed ADB lookup.
|
||||
*/
|
||||
static void
|
||||
synth_fwd_respond(ns_client_t *client, dns_adbfind_t *find) {
|
||||
dns_adbaddrinfo_t *ai;
|
||||
dns_name_t *tname = NULL;
|
||||
dns_rdataset_t *rdataset = NULL;
|
||||
dns_rdatalist_t *rdatalist = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
result = dns_message_gettempname(client->message, &tname);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
dns_name_init(tname, NULL);
|
||||
|
||||
result = dns_message_gettemprdatalist(client->message, &rdatalist);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
|
||||
result = dns_message_gettemprdataset(client->message, &rdataset);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
dns_rdataset_init(rdataset);
|
||||
|
||||
ISC_LIST_INIT(rdatalist->rdata);
|
||||
|
||||
rdatalist->type = dns_rdatatype_aaaa;
|
||||
rdatalist->covers = 0;
|
||||
rdatalist->rdclass = client->message->rdclass;
|
||||
rdatalist->ttl = 0;
|
||||
|
||||
dns_name_clone(client->query.qname, tname);
|
||||
|
||||
for (ai = ISC_LIST_HEAD(find->list);
|
||||
ai != NULL;
|
||||
ai = ISC_LIST_NEXT(ai, publink)) {
|
||||
dns_rdata_t *rdata = NULL;
|
||||
|
||||
struct sockaddr_in6 *sin6 = &ai->sockaddr.type.sin6;
|
||||
/*
|
||||
* Could it be useful to return IPv4 addresses as A records?
|
||||
*/
|
||||
if (sin6->sin6_family != AF_INET6)
|
||||
continue;
|
||||
|
||||
result = dns_message_gettemprdata(client->message, &rdata);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
|
||||
rdata->data = (unsigned char *) &sin6->sin6_addr;
|
||||
rdata->length = 16;
|
||||
rdata->rdclass = client->message->rdclass;
|
||||
rdata->type = dns_rdatatype_aaaa;
|
||||
ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
|
||||
}
|
||||
|
||||
dns_rdatalist_tordataset(rdatalist, rdataset);
|
||||
|
||||
query_addrrset(client, &tname, &rdataset, NULL, NULL,
|
||||
DNS_SECTION_ANSWER);
|
||||
|
||||
cleanup:
|
||||
if (tname != NULL)
|
||||
dns_message_puttempname(client->message, &tname);
|
||||
|
||||
if (rdataset != NULL) {
|
||||
if (dns_rdataset_isassociated(rdataset))
|
||||
dns_rdataset_disassociate(rdataset);
|
||||
dns_message_puttemprdataset(client->message, &rdataset);
|
||||
}
|
||||
|
||||
synth_finish(client, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Finish synthetic IPv6 forward mapping processing.
|
||||
*/
|
||||
static void
|
||||
synth_finish(ns_client_t *client, isc_result_t result) {
|
||||
if (result == ISC_R_SUCCESS)
|
||||
ns_client_send(client);
|
||||
else
|
||||
ns_client_error(client, result);
|
||||
ns_client_detach(&client);
|
||||
}
|
||||
|
||||
static signed char ascii2hex[256] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
|
||||
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
};
|
||||
|
||||
/*
|
||||
* Convert label 'i' of 'name' into its hexadecimal value, storing it
|
||||
* in '*hexp'. If the label is not a valid hex nibble, return ISC_R_FAILURE.
|
||||
*/
|
||||
static isc_result_t
|
||||
label2hex(dns_name_t *name, int i, int *hexp) {
|
||||
isc_region_t label;
|
||||
int hexval;
|
||||
dns_name_getlabel(name, i, &label);
|
||||
if (label.length != 2 || label.base[0] != '\001')
|
||||
return (ISC_R_FAILURE);
|
||||
hexval = ascii2hex[label.base[1]];
|
||||
if (hexval == -1)
|
||||
return (ISC_R_FAILURE);
|
||||
*hexp = hexval;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert the ip6.int name 'name' into the corresponding IPv6 address
|
||||
* in 'na'.
|
||||
*/
|
||||
static isc_result_t
|
||||
nibbles2netaddr(dns_name_t *name, isc_netaddr_t *na) {
|
||||
isc_result_t result;
|
||||
struct in6_addr ina6;
|
||||
unsigned char *addrdata = (unsigned char *) &ina6;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
int hex0, hex1;
|
||||
result = label2hex(name, 2 * i, &hex0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
result = label2hex(name, 2 * i + 1, &hex1);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
addrdata[15-i] = (hex1 << 4) | hex0;
|
||||
}
|
||||
isc_netaddr_fromin6(na, &ina6);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate a synthetic IPv6 reverse mapping response for the current
|
||||
* query of 'client'.
|
||||
*/
|
||||
static void
|
||||
synth_rev_start(ns_client_t *client) {
|
||||
isc_result_t result;
|
||||
dns_byaddr_t *byaddr_dummy = NULL;
|
||||
|
||||
ns_client_log(client, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_QUERY,
|
||||
ISC_LOG_DEBUG(5), "generating synthetic PTR response");
|
||||
|
||||
result = nibbles2netaddr(client->query.qname, &client->query.synth.na);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
result = DNS_R_NXDOMAIN;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Try IP6.ARPA first. */
|
||||
result = dns_byaddr_create(client->mctx,
|
||||
&client->query.synth.na,
|
||||
client->view,
|
||||
0, client->task,
|
||||
synth_rev_byaddrdone_arpa,
|
||||
client, &byaddr_dummy);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
return; /* Wait for completion event. */
|
||||
cleanup:
|
||||
synth_finish(client, result);
|
||||
}
|
||||
|
||||
static void
|
||||
synth_rev_byaddrdone_arpa(isc_task_t *task, isc_event_t *event) {
|
||||
isc_result_t result;
|
||||
dns_byaddrevent_t *bevent = (dns_byaddrevent_t *)event;
|
||||
ns_client_t *client = event->ev_arg;
|
||||
dns_byaddr_t *byaddr = event->ev_sender;
|
||||
dns_byaddr_t *byaddr_dummy = NULL;
|
||||
|
||||
UNUSED(task);
|
||||
|
||||
if (bevent->result == ISC_R_SUCCESS) {
|
||||
synth_rev_respond(client, bevent);
|
||||
} else {
|
||||
/* Try IP6.INT next. */
|
||||
result = dns_byaddr_create(client->mctx,
|
||||
&client->query.synth.na,
|
||||
client->view,
|
||||
DNS_BYADDROPT_IPV6NIBBLE,
|
||||
client->task,
|
||||
synth_rev_byaddrdone_int,
|
||||
client, &byaddr_dummy);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
synth_finish(client, result);
|
||||
}
|
||||
dns_byaddr_destroy(&byaddr);
|
||||
isc_event_free(&event);
|
||||
}
|
||||
|
||||
static void
|
||||
synth_rev_byaddrdone_int(isc_task_t *task, isc_event_t *event) {
|
||||
dns_byaddrevent_t *bevent = (dns_byaddrevent_t *)event;
|
||||
ns_client_t *client = event->ev_arg;
|
||||
dns_byaddr_t *byaddr = event->ev_sender;
|
||||
|
||||
UNUSED(task);
|
||||
|
||||
if (bevent->result == ISC_R_SUCCESS) {
|
||||
synth_rev_respond(client, bevent);
|
||||
} else if (bevent->result == DNS_R_NCACHENXDOMAIN ||
|
||||
bevent->result == DNS_R_NCACHENXRRSET ||
|
||||
bevent->result == DNS_R_NXDOMAIN ||
|
||||
bevent->result == DNS_R_NXRRSET) {
|
||||
/*
|
||||
* We could give a NOERROR/NODATA response instead
|
||||
* in some cases, but since there may be any combination
|
||||
* of NXDOMAIN and NXRRSET results from the IP6.INT
|
||||
* and IP6.ARPA lookups, it could still be wrong with
|
||||
* respect to one or the other.
|
||||
*/
|
||||
synth_finish(client, DNS_R_NXDOMAIN);
|
||||
} else {
|
||||
synth_finish(client, bevent->result);
|
||||
}
|
||||
isc_event_free(&event);
|
||||
dns_byaddr_destroy(&byaddr);
|
||||
}
|
||||
|
||||
static void
|
||||
synth_rev_respond(ns_client_t *client, dns_byaddrevent_t *bevent) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
dns_name_t *name;
|
||||
|
||||
for (name = ISC_LIST_HEAD(bevent->names);
|
||||
name != NULL;
|
||||
name = ISC_LIST_NEXT(name, link))
|
||||
{
|
||||
dns_name_t *tname = NULL;
|
||||
|
||||
/*
|
||||
* Get a temporary name 'tname' for insertion into the
|
||||
* response message.
|
||||
*/
|
||||
result = dns_message_gettempname(client->message, &tname);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto fail;
|
||||
dns_name_init(tname, NULL);
|
||||
|
||||
result = query_addcnamelike(client, client->query.qname,
|
||||
name, 0 /* XXX ttl */,
|
||||
&tname, dns_rdatatype_ptr);
|
||||
if (tname != NULL)
|
||||
dns_message_puttempname(client->message, &tname);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto fail;
|
||||
}
|
||||
fail:
|
||||
synth_finish(client, result);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: server.c,v 1.287 2001/01/29 17:25:12 halley Exp $ */
|
||||
/* $Id: server.c,v 1.276.2.1 2001/01/09 22:32:13 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -417,8 +417,6 @@ configure_view(dns_view_t *view, dns_c_ctx_t *cctx, dns_c_view_t *cview,
|
||||
dns_dispatch_t *dispatch4 = NULL;
|
||||
dns_dispatch_t *dispatch6 = NULL;
|
||||
in_port_t port;
|
||||
isc_boolean_t reused_cache = ISC_FALSE;
|
||||
char *cachefile = NULL;
|
||||
|
||||
REQUIRE(DNS_VIEW_VALID(view));
|
||||
|
||||
@@ -462,7 +460,6 @@ configure_view(dns_view_t *view, dns_c_ctx_t *cctx, dns_c_view_t *cview,
|
||||
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
||||
NS_LOGMODULE_SERVER, ISC_LOG_DEBUG(3),
|
||||
"reusing existing cache");
|
||||
reused_cache = ISC_TRUE;
|
||||
dns_cache_attach(pview->cache, &cache);
|
||||
dns_view_detach(&pview);
|
||||
} else {
|
||||
@@ -472,18 +469,6 @@ configure_view(dns_view_t *view, dns_c_ctx_t *cctx, dns_c_view_t *cview,
|
||||
}
|
||||
dns_view_setcache(view, cache);
|
||||
|
||||
if (cview != NULL)
|
||||
result = dns_c_view_getcachefile(cview, &cachefile);
|
||||
else
|
||||
result = dns_c_ctx_getcachefile(cctx, &cachefile);
|
||||
if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND)
|
||||
goto cleanup;
|
||||
if (cachefile != NULL) {
|
||||
dns_cache_setfilename(cache, cachefile);
|
||||
if (!reused_cache)
|
||||
CHECK(dns_cache_load(cache));
|
||||
}
|
||||
|
||||
result = ISC_R_NOTFOUND;
|
||||
if (cview != NULL)
|
||||
result = dns_c_view_getcleaninterval(cview,
|
||||
@@ -562,23 +547,15 @@ configure_view(dns_view_t *view, dns_c_ctx_t *cctx, dns_c_view_t *cview,
|
||||
|
||||
/*
|
||||
* If we still have no hints, this is a non-IN view with no
|
||||
* "hints zone" configured. Issue a warning, except if this
|
||||
* is a root server. Root servers never need to consult
|
||||
* their hints, so it's no point requireing users to configure
|
||||
* them.
|
||||
* "hints zone" configured. That's an error.
|
||||
*/
|
||||
if (view->hints == NULL) {
|
||||
dns_zone_t *rootzone = NULL;
|
||||
dns_view_findzone(view, dns_rootname, &rootzone);
|
||||
if (rootzone != NULL) {
|
||||
dns_zone_detach(&rootzone);
|
||||
} else {
|
||||
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
||||
NS_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
||||
"no root hints for view '%s'",
|
||||
cview == NULL ? "<default>" :
|
||||
cview->name);
|
||||
}
|
||||
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
||||
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
||||
"no root hints for view '%s'",
|
||||
cview == NULL ? "<default>" : cview->name);
|
||||
result = ISC_R_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -670,11 +647,6 @@ configure_view(dns_view_t *view, dns_c_ctx_t *cctx, dns_c_view_t *cview,
|
||||
dns_c_ctx_getallowrecursion,
|
||||
&view->recursionacl));
|
||||
|
||||
CHECK(configure_view_acl(cview, cctx, actx, ns_g_mctx,
|
||||
dns_c_view_getv6synthesisacl,
|
||||
dns_c_ctx_getallowv6synthesis,
|
||||
&view->v6synthesisacl));
|
||||
|
||||
CHECK(configure_view_acl(cview, cctx, actx, ns_g_mctx,
|
||||
dns_c_view_getsortlist,
|
||||
dns_c_ctx_getsortlist,
|
||||
@@ -729,6 +701,32 @@ configure_view(dns_view_t *view, dns_c_ctx_t *cctx, dns_c_view_t *cview,
|
||||
val = 7 * 24 * 3600;
|
||||
view->maxncachettl = val;
|
||||
}
|
||||
{
|
||||
char *cachefile = NULL, *p = NULL;
|
||||
if (cview != NULL)
|
||||
result = dns_c_view_getcachefile(cview, &cachefile);
|
||||
else
|
||||
result = dns_c_ctx_getcachefile(cctx, &cachefile);
|
||||
if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND)
|
||||
goto cleanup;
|
||||
if (cachefile != NULL) {
|
||||
p = isc_mem_strdup(view->mctx, cachefile);
|
||||
if (p == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if (view->cachefile != NULL)
|
||||
isc_mem_free(view->mctx, view->cachefile);
|
||||
view->cachefile = p;
|
||||
if (view->cachefile != NULL) {
|
||||
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
||||
NS_LOGMODULE_SERVER, ISC_LOG_DEBUG(1),
|
||||
"loading cache '%s'", view->cachefile);
|
||||
/* DNS_R_SEENINCLUDE should be impossible here. */
|
||||
CHECK(dns_db_load(view->cachedb, view->cachefile));
|
||||
}
|
||||
}
|
||||
|
||||
result = ISC_R_SUCCESS;
|
||||
|
||||
@@ -862,7 +860,7 @@ create_version_zone(dns_c_ctx_t *cctx, dns_zonemgr_t *zmgr, dns_view_t *view)
|
||||
* the BIND 9 authors.
|
||||
*/
|
||||
static isc_result_t
|
||||
create_authors_zone(dns_c_ctx_t *cctx, dns_zonemgr_t *zmgr, dns_view_t *view) {
|
||||
create_authors_zone(dns_zonemgr_t *zmgr, dns_view_t *view) {
|
||||
isc_result_t result;
|
||||
dns_db_t *db = NULL;
|
||||
dns_zone_t *zone = NULL;
|
||||
@@ -875,7 +873,6 @@ create_authors_zone(dns_c_ctx_t *cctx, dns_zonemgr_t *zmgr, dns_view_t *view) {
|
||||
static const char origindata[] = "\007authors\004bind";
|
||||
dns_name_t origin;
|
||||
int i;
|
||||
char *versiontext;
|
||||
static const char *authors[] = {
|
||||
"\014Mark Andrews",
|
||||
"\015James Brister",
|
||||
@@ -883,19 +880,11 @@ create_authors_zone(dns_c_ctx_t *cctx, dns_zonemgr_t *zmgr, dns_view_t *view) {
|
||||
"\022Andreas Gustafsson",
|
||||
"\012Bob Halley",
|
||||
"\016David Lawrence",
|
||||
"\013Damien Neil",
|
||||
"\016Michael Sawyer",
|
||||
"\020Brian Wellington",
|
||||
NULL,
|
||||
};
|
||||
|
||||
/*
|
||||
* If a version string is specified, disable the authors.bind zone.
|
||||
*/
|
||||
result = dns_c_ctx_getversion(cctx, &versiontext);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
dns_diff_init(ns_g_mctx, &diff);
|
||||
|
||||
dns_name_init(&origin, NULL);
|
||||
@@ -1000,6 +989,7 @@ configure_forward(dns_c_ctx_t *cctx, dns_c_zone_t *czone, dns_c_view_t *cview,
|
||||
goto cleanup;
|
||||
}
|
||||
*sa = forwarders->ips[i];
|
||||
isc_sockaddr_setport(sa, port);
|
||||
ISC_LINK_INIT(sa, link);
|
||||
ISC_LIST_APPEND(addresses, sa, link);
|
||||
}
|
||||
@@ -1421,13 +1411,9 @@ load_configuration(const char *filename, ns_server_t *server,
|
||||
char *pidfilename;
|
||||
char *statsfilename;
|
||||
char *dumpfilename;
|
||||
char *randomdev;
|
||||
isc_uint32_t interface_interval;
|
||||
isc_uint32_t heartbeat_interval;
|
||||
in_port_t listen_port;
|
||||
#ifdef PATH_RANDOMDEV
|
||||
char path_randomdev[] = PATH_RANDOMDEV;
|
||||
#endif
|
||||
|
||||
ns_aclconfctx_init(&aclconfctx);
|
||||
|
||||
@@ -1594,13 +1580,12 @@ load_configuration(const char *filename, ns_server_t *server,
|
||||
isc_timer_reset(server->interface_timer,
|
||||
isc_timertype_inactive,
|
||||
NULL, NULL, ISC_TRUE);
|
||||
} else if (server->interface_interval != interface_interval) {
|
||||
} else {
|
||||
isc_interval_t interval;
|
||||
isc_interval_set(&interval, interface_interval, 0);
|
||||
isc_timer_reset(server->interface_timer, isc_timertype_ticker,
|
||||
NULL, &interval, ISC_FALSE);
|
||||
}
|
||||
server->interface_interval = interface_interval;
|
||||
|
||||
/*
|
||||
* Configure the dialup heartbeat timer.
|
||||
@@ -1612,13 +1597,12 @@ load_configuration(const char *filename, ns_server_t *server,
|
||||
isc_timer_reset(server->heartbeat_timer,
|
||||
isc_timertype_inactive,
|
||||
NULL, NULL, ISC_TRUE);
|
||||
} else if (server->heartbeat_interval != heartbeat_interval) {
|
||||
} else {
|
||||
isc_interval_t interval;
|
||||
isc_interval_set(&interval, heartbeat_interval, 0);
|
||||
isc_timer_reset(server->heartbeat_timer, isc_timertype_ticker,
|
||||
NULL, &interval, ISC_FALSE);
|
||||
}
|
||||
server->heartbeat_interval = heartbeat_interval;
|
||||
|
||||
/*
|
||||
* Configure and freeze all explicit views. Explicit
|
||||
@@ -1683,7 +1667,7 @@ load_configuration(const char *filename, ns_server_t *server,
|
||||
CHECK(create_bind_view(&view));
|
||||
ISC_LIST_APPEND(lctx.viewlist, view, link);
|
||||
CHECK(create_version_zone(cctx, server->zonemgr, view));
|
||||
CHECK(create_authors_zone(cctx, server->zonemgr, view));
|
||||
CHECK(create_authors_zone(server->zonemgr, view));
|
||||
dns_view_freeze(view);
|
||||
view = NULL;
|
||||
|
||||
@@ -1719,35 +1703,6 @@ load_configuration(const char *filename, ns_server_t *server,
|
||||
CHECKM(ns_lwresd_configure(ns_g_mctx, cctx),
|
||||
"binding lightweight resolver ports");
|
||||
|
||||
/*
|
||||
* Open the source of entropy.
|
||||
*/
|
||||
if (first_time) {
|
||||
randomdev = NULL;
|
||||
(void)dns_c_ctx_getrandomdevice(cctx, &randomdev);
|
||||
#ifdef PATH_RANDOMDEV
|
||||
if (randomdev == NULL)
|
||||
randomdev = path_randomdev;
|
||||
#endif
|
||||
if (randomdev == NULL)
|
||||
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
||||
NS_LOGMODULE_SERVER, ISC_LOG_INFO,
|
||||
"no source of entropy found");
|
||||
else {
|
||||
result = isc_entropy_createfilesource(ns_g_entropy,
|
||||
randomdev);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
isc_log_write(ns_g_lctx,
|
||||
NS_LOGCATEGORY_GENERAL,
|
||||
NS_LOGMODULE_SERVER,
|
||||
ISC_LOG_INFO,
|
||||
"could not open entropy source "
|
||||
"%s: %s",
|
||||
randomdev,
|
||||
isc_result_totext(result));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Relinquish root privileges.
|
||||
*/
|
||||
@@ -2071,9 +2026,6 @@ ns_server_create(isc_mem_t *mctx, ns_server_t **serverp) {
|
||||
|
||||
server->interface_timer = NULL;
|
||||
server->heartbeat_timer = NULL;
|
||||
|
||||
server->interface_interval = 0;
|
||||
server->heartbeat_interval = 0;
|
||||
|
||||
CHECKFATAL(dns_zonemgr_create(ns_g_mctx, ns_g_taskmgr, ns_g_timermgr,
|
||||
ns_g_socketmgr, &server->zonemgr),
|
||||
@@ -2399,7 +2351,7 @@ ns_server_dumpstats(ns_server_t *server) {
|
||||
CHECKM(isc_stdio_open(server->statsfile, "a", &fp),
|
||||
"could not open statistics dump file");
|
||||
|
||||
ncounters = DNS_STATS_NCOUNTERS;
|
||||
ncounters = dns_stats_ncounters();
|
||||
fprintf(fp, "+++ Statistics Dump +++ (%lu)\n", (unsigned long)now);
|
||||
|
||||
for (i = 0; i < ncounters; i++)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: sortlist.c,v 1.4 2001/01/09 21:40:04 bwelling Exp $ */
|
||||
/* $Id: sortlist.c,v 1.3.4.1 2001/01/09 22:32:14 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: tkeyconf.c,v 1.17 2001/01/09 21:40:05 bwelling Exp $ */
|
||||
/* $Id: tkeyconf.c,v 1.16.4.1 2001/01/09 22:32:16 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: tsigconf.c,v 1.15 2001/01/09 21:40:06 bwelling Exp $ */
|
||||
/* $Id: tsigconf.c,v 1.14.4.1 2001/01/09 22:32:17 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.6 2001/01/09 21:40:37 bwelling Exp $
|
||||
# $Id: Makefile.in,v 1.5.4.1 2001/01/09 22:32:49 bwelling Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: os.h,v 1.14 2001/01/09 21:40:39 bwelling Exp $ */
|
||||
/* $Id: os.h,v 1.13.4.1 2001/01/09 22:32:51 bwelling Exp $ */
|
||||
|
||||
#ifndef NS_OS_H
|
||||
#define NS_OS_H 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: os.c,v 1.38 2001/01/09 21:40:38 bwelling Exp $ */
|
||||
/* $Id: os.c,v 1.36.2.2 2001/01/09 22:32:50 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -15,11 +15,10 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: update.c,v 1.82 2001/01/22 18:59:06 gson Exp $ */
|
||||
/* $Id: update.c,v 1.79.2.1 2001/01/09 22:32:18 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <isc/print.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/taskpool.h>
|
||||
#include <isc/util.h>
|
||||
@@ -33,7 +32,6 @@
|
||||
#include <dns/journal.h>
|
||||
#include <dns/message.h>
|
||||
#include <dns/nxt.h>
|
||||
#include <dns/rdataclass.h>
|
||||
#include <dns/rdataset.h>
|
||||
#include <dns/rdatasetiter.h>
|
||||
#include <dns/ssu.h>
|
||||
@@ -57,14 +55,28 @@
|
||||
/**************************************************************************/
|
||||
|
||||
/*
|
||||
* Log level for tracing dynamic update protocol requests.
|
||||
* Convenience macro of common isc_log_write() arguments
|
||||
* to use in reportings server errors.
|
||||
*/
|
||||
#define LOGLEVEL_PROTOCOL ISC_LOG_INFO
|
||||
#define UPDATE_ERROR_LOGARGS \
|
||||
ns_g_lctx, NS_LOGCATEGORY_UPDATE, NS_LOGMODULE_UPDATE, \
|
||||
ISC_LOG_ERROR
|
||||
|
||||
/*
|
||||
* Log level for low-level debug tracing.
|
||||
* Convenience macro of common isc_log_write() arguments
|
||||
* to use in tracing dynamic update protocol requests.
|
||||
*/
|
||||
#define LOGLEVEL_DEBUG ISC_LOG_DEBUG(8)
|
||||
#define UPDATE_PROTOCOL_LOGARGS \
|
||||
ns_g_lctx, NS_LOGCATEGORY_UPDATE, NS_LOGMODULE_UPDATE, \
|
||||
ISC_LOG_INFO
|
||||
|
||||
/*
|
||||
* Convenience macro of common isc_log_write() arguments
|
||||
* to use in low-level debug tracing.
|
||||
*/
|
||||
#define UPDATE_DEBUG_LOGARGS \
|
||||
ns_g_lctx, NS_LOGCATEGORY_UPDATE, NS_LOGMODULE_UPDATE, \
|
||||
ISC_LOG_DEBUG(8)
|
||||
|
||||
/*
|
||||
* Check an operation for failure. These macros all assume that
|
||||
@@ -99,8 +111,8 @@
|
||||
#define FAILC(code, msg) \
|
||||
do { \
|
||||
result = (code); \
|
||||
update_log(client, zone, LOGLEVEL_PROTOCOL, \
|
||||
"update failed: %s (%s)", \
|
||||
isc_log_write(UPDATE_PROTOCOL_LOGARGS, \
|
||||
"dynamic update failed: %s (%s)", \
|
||||
msg, isc_result_totext(result)); \
|
||||
if (result != ISC_R_SUCCESS) goto failure; \
|
||||
} while (0)
|
||||
@@ -113,8 +125,8 @@
|
||||
#define FAILS(code, msg) \
|
||||
do { \
|
||||
result = (code); \
|
||||
update_log(client, zone, LOGLEVEL_PROTOCOL, \
|
||||
"error: %s: %s", \
|
||||
isc_log_write(UPDATE_PROTOCOL_LOGARGS, \
|
||||
"dynamic update error: %s: %s", \
|
||||
msg, isc_result_totext(result)); \
|
||||
if (result != ISC_R_SUCCESS) goto failure; \
|
||||
} while (0)
|
||||
@@ -149,36 +161,6 @@ static isc_result_t send_forward_event(ns_client_t *client, dns_zone_t *zone);
|
||||
static void forward_done(isc_task_t *task, isc_event_t *event);
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
static void
|
||||
update_log(ns_client_t *client, dns_zone_t *zone,
|
||||
int level, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char message[4096];
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
char classbuf[DNS_RDATACLASS_FORMATSIZE];
|
||||
|
||||
if (client == NULL || zone == NULL)
|
||||
return;
|
||||
|
||||
if (isc_log_wouldlog(ns_g_lctx, level) == ISC_FALSE)
|
||||
return;
|
||||
|
||||
dns_name_format(dns_zone_getorigin(zone), namebuf,
|
||||
sizeof(namebuf));
|
||||
dns_rdataclass_format(dns_zone_getclass(zone), classbuf,
|
||||
sizeof(classbuf));
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(message, sizeof message, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
ns_client_log(client, NS_LOGCATEGORY_UPDATE, NS_LOGMODULE_UPDATE,
|
||||
level, "updating zone %s/%s: %s",
|
||||
namebuf, classbuf, message);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update a single RR in version 'ver' of 'db' and log the
|
||||
* update in 'diff'.
|
||||
@@ -2111,8 +2093,7 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
FAILC(result, "'RRset exists (value dependent)' "
|
||||
"prerequisite not satisfied");
|
||||
|
||||
update_log(client, zone, LOGLEVEL_DEBUG,
|
||||
"prerequisites are OK");
|
||||
isc_log_write(UPDATE_DEBUG_LOGARGS, "prerequisites are OK");
|
||||
|
||||
/*
|
||||
* Check Requestor's Permissions. It seems a bit silly to do this
|
||||
@@ -2168,9 +2149,10 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
FAILC(DNS_R_FORMERR,
|
||||
"meta-RR in update");
|
||||
} else {
|
||||
update_log(client, zone, ISC_LOG_WARNING,
|
||||
"update RR has incorrect class %d",
|
||||
update_class);
|
||||
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_UPDATE,
|
||||
NS_LOGMODULE_UPDATE, ISC_LOG_WARNING,
|
||||
"update RR has incorrect class %d",
|
||||
update_class);
|
||||
FAIL(DNS_R_FORMERR);
|
||||
}
|
||||
/*
|
||||
@@ -2210,8 +2192,7 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
if (result != ISC_R_NOMORE)
|
||||
FAIL(result);
|
||||
|
||||
update_log(client, zone, LOGLEVEL_DEBUG,
|
||||
"update section prescan OK");
|
||||
isc_log_write(UPDATE_DEBUG_LOGARGS, "update section prescan OK");
|
||||
|
||||
/*
|
||||
* Process the Update Section.
|
||||
@@ -2236,11 +2217,10 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
name,
|
||||
&flag));
|
||||
if (flag) {
|
||||
update_log(client, zone,
|
||||
LOGLEVEL_PROTOCOL,
|
||||
"attempt to add CNAME "
|
||||
"alongside non-CNAME "
|
||||
"ignored");
|
||||
isc_log_write(UPDATE_PROTOCOL_LOGARGS,
|
||||
"attempt to add CNAME "
|
||||
"alongside non-CNAME "
|
||||
"ignored");
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
@@ -2250,10 +2230,9 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
if (flag &&
|
||||
! dns_rdatatype_isdnssec(rdata.type))
|
||||
{
|
||||
update_log(client, zone,
|
||||
LOGLEVEL_PROTOCOL,
|
||||
"attempt to add non-CNAME "
|
||||
"alongside CNAME ignored");
|
||||
isc_log_write(UPDATE_PROTOCOL_LOGARGS,
|
||||
"attempt to add non-CNAME "
|
||||
"alongside CNAME ignored");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -2263,27 +2242,24 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
dns_rdatatype_soa, 0,
|
||||
&flag));
|
||||
if (! flag) {
|
||||
update_log(client, zone,
|
||||
LOGLEVEL_PROTOCOL,
|
||||
"attempt to create 2nd "
|
||||
"SOA ignored");
|
||||
isc_log_write(UPDATE_PROTOCOL_LOGARGS,
|
||||
"attempt to create 2nd "
|
||||
"SOA ignored");
|
||||
continue;
|
||||
}
|
||||
CHECK(check_soa_increment(db, ver, &rdata,
|
||||
&ok));
|
||||
if (! ok) {
|
||||
update_log(client, zone,
|
||||
LOGLEVEL_PROTOCOL,
|
||||
"SOA update failed to "
|
||||
"increment serial, "
|
||||
"ignoring it");
|
||||
isc_log_write(UPDATE_PROTOCOL_LOGARGS,
|
||||
"SOA update failed to "
|
||||
"increment serial, "
|
||||
"ignoring it");
|
||||
continue;
|
||||
}
|
||||
soa_serial_changed = ISC_TRUE;
|
||||
}
|
||||
|
||||
update_log(client, zone,
|
||||
LOGLEVEL_PROTOCOL, "adding an RR");
|
||||
isc_log_write(UPDATE_PROTOCOL_LOGARGS, "adding an RR");
|
||||
|
||||
/* Prepare the affected RRset for the addition. */
|
||||
{
|
||||
@@ -2313,9 +2289,8 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
}
|
||||
} else if (update_class == dns_rdataclass_any) {
|
||||
if (rdata.type == dns_rdatatype_any) {
|
||||
update_log(client, zone,
|
||||
LOGLEVEL_PROTOCOL,
|
||||
"delete all rrsets from a name");
|
||||
isc_log_write(UPDATE_PROTOCOL_LOGARGS,
|
||||
"delete all rrsets from a name");
|
||||
if (dns_name_equal(name, zonename)) {
|
||||
CHECK(delete_if(type_not_soa_nor_ns_p,
|
||||
db, ver, name,
|
||||
@@ -2329,15 +2304,13 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
} else if (dns_name_equal(name, zonename) &&
|
||||
(rdata.type == dns_rdatatype_soa ||
|
||||
rdata.type == dns_rdatatype_ns)) {
|
||||
update_log(client, zone,
|
||||
LOGLEVEL_PROTOCOL,
|
||||
"attempt to delete all SOA "
|
||||
"or NS records ignored");
|
||||
isc_log_write(UPDATE_PROTOCOL_LOGARGS,
|
||||
"attempt to delete all SOA "
|
||||
"or NS records ignored");
|
||||
continue;
|
||||
} else {
|
||||
update_log(client, zone,
|
||||
LOGLEVEL_PROTOCOL,
|
||||
"deleting an rrset");
|
||||
isc_log_write(UPDATE_PROTOCOL_LOGARGS,
|
||||
"deleting an rrset");
|
||||
CHECK(delete_if(true_p, db, ver, name,
|
||||
rdata.type, covers, &rdata,
|
||||
&diff));
|
||||
@@ -2349,10 +2322,9 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
*/
|
||||
if (dns_name_equal(name, zonename)) {
|
||||
if (rdata.type == dns_rdatatype_soa) {
|
||||
update_log(client, zone,
|
||||
LOGLEVEL_PROTOCOL,
|
||||
"attempt to delete SOA "
|
||||
"ignored");
|
||||
isc_log_write(UPDATE_PROTOCOL_LOGARGS,
|
||||
"attempt to delete SOA "
|
||||
"ignored");
|
||||
continue;
|
||||
}
|
||||
if (rdata.type == dns_rdatatype_ns) {
|
||||
@@ -2361,18 +2333,16 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
dns_rdatatype_ns,
|
||||
0, &count));
|
||||
if (count == 1) {
|
||||
update_log(client, zone,
|
||||
LOGLEVEL_PROTOCOL,
|
||||
"attempt to "
|
||||
"delete last "
|
||||
"NS ignored");
|
||||
isc_log_write(
|
||||
UPDATE_PROTOCOL_LOGARGS,
|
||||
"attempt to delete last "
|
||||
"NS ignored");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
update_log(client, zone,
|
||||
LOGLEVEL_PROTOCOL,
|
||||
"deleting an RR");
|
||||
isc_log_write(UPDATE_PROTOCOL_LOGARGS,
|
||||
"deleting an RR");
|
||||
CHECK(delete_if(rr_equal_p, db, ver, name,
|
||||
rdata.type, covers, &rdata, &diff));
|
||||
}
|
||||
@@ -2401,17 +2371,17 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
result = update_signatures(mctx, db, oldver, ver,
|
||||
&diff, dns_zone_getsigvalidityinterval(zone));
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
update_log(client, zone,
|
||||
ISC_LOG_ERROR,
|
||||
"SIG/NXT update failed: %s",
|
||||
isc_result_totext(result));
|
||||
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_UPDATE,
|
||||
NS_LOGMODULE_UPDATE,
|
||||
ISC_LOG_ERROR,
|
||||
"SIG/NXT update failed: %s",
|
||||
isc_result_totext(result));
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
||||
update_log(client, zone, LOGLEVEL_DEBUG,
|
||||
"writing journal %s",
|
||||
dns_zone_getjournal(zone));
|
||||
isc_log_write(UPDATE_DEBUG_LOGARGS, "writing journal %s",
|
||||
dns_zone_getjournal(zone));
|
||||
|
||||
journal = NULL;
|
||||
result = dns_journal_open(mctx, dns_zone_getjournal(zone),
|
||||
@@ -2433,8 +2403,7 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
* to handle databases that need two-phase commit, but this
|
||||
* isn't a priority.
|
||||
*/
|
||||
update_log(client, zone, LOGLEVEL_DEBUG,
|
||||
"committing update transaction");
|
||||
isc_log_write(UPDATE_DEBUG_LOGARGS, "committing update transaction");
|
||||
dns_db_closeversion(db, &ver, ISC_TRUE);
|
||||
|
||||
/*
|
||||
@@ -2446,6 +2415,7 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
* Notify slaves of the change we just made.
|
||||
*/
|
||||
dns_zone_notify(zone);
|
||||
|
||||
result = ISC_R_SUCCESS;
|
||||
goto common;
|
||||
|
||||
@@ -2454,8 +2424,8 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
||||
* The reason for failure should have been logged at this point.
|
||||
*/
|
||||
if (ver != NULL) {
|
||||
update_log(client, zone, LOGLEVEL_DEBUG,
|
||||
"rolling back");
|
||||
isc_log_write(UPDATE_DEBUG_LOGARGS,
|
||||
"rolling back");
|
||||
dns_db_closeversion(db, &ver, ISC_FALSE);
|
||||
}
|
||||
|
||||
@@ -2589,5 +2559,3 @@ send_forward_event(ns_client_t *client, dns_zone_t *zone) {
|
||||
isc_event_free((isc_event_t **)&event);
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: xfrout.c,v 1.93 2001/01/12 19:01:39 gson Exp $ */
|
||||
/* $Id: xfrout.c,v 1.87.2.5 2001/01/12 20:33:17 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: zoneconf.c,v 1.80 2001/01/25 02:33:42 bwelling Exp $ */
|
||||
/* $Id: zoneconf.c,v 1.78.2.1 2001/01/09 22:32:21 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -420,7 +420,7 @@ ns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
|
||||
case dns_c_zone_stub:
|
||||
iplist = NULL;
|
||||
result = dns_c_zone_getmasterips(czone, &iplist);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
if (result == ISC_R_SUCCESS)
|
||||
#ifndef NOMINUM_PUBLIC
|
||||
result = dns_zone_setmasterswithkeys(zone,
|
||||
iplist->ips,
|
||||
@@ -430,8 +430,7 @@ ns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
|
||||
result = dns_zone_setmasters(zone, iplist->ips,
|
||||
iplist->nextidx);
|
||||
#endif /* NOMINUM_PUBLIC */
|
||||
dns_c_iplist_detach(&iplist);
|
||||
} else
|
||||
else
|
||||
result = dns_zone_setmasters(zone, NULL, 0);
|
||||
RETERR(result);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.11 2001/01/18 01:33:51 bwelling Exp $
|
||||
# $Id: Makefile.in,v 1.8.4.1 2001/01/09 22:32:52 bwelling Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
@@ -23,7 +23,7 @@ top_srcdir = @top_srcdir@
|
||||
|
||||
@BIND9_INCLUDES@
|
||||
|
||||
CINCLUDES = ${LWRES_INCLUDES} ${DNS_INCLUDES} ${ISC_INCLUDES}
|
||||
CINCLUDES = -I${srcdir}/include ${LWRES_INCLUDES} ${DNS_INCLUDES} ${ISC_INCLUDES}
|
||||
|
||||
CDEFINES =
|
||||
CWARNINGS =
|
||||
@@ -50,8 +50,6 @@ UOBJS =
|
||||
|
||||
SRCS = nsupdate.c
|
||||
|
||||
MANPAGES = nsupdate.8
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
nsupdate: nsupdate.@O@ ${UOBJS} ${DEPLIBS}
|
||||
@@ -62,8 +60,6 @@ clean distclean::
|
||||
|
||||
installdirs:
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${bindir}
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man8
|
||||
|
||||
install:: nsupdate installdirs
|
||||
install:: nsupdate
|
||||
${LIBTOOL} ${INSTALL_PROGRAM} nsupdate ${DESTDIR}${bindir}
|
||||
${INSTALL_PROGRAM} nsupdate.8 ${DESTDIR}${mandir}/man8
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: nsupdate.c,v 1.81 2001/01/23 19:55:04 gson Exp $ */
|
||||
/* $Id: nsupdate.c,v 1.75.2.3 2001/02/07 19:26:22 gson Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -1003,52 +1003,35 @@ update_addordelete(char *cmdline, isc_boolean_t isdelete) {
|
||||
|
||||
/*
|
||||
* If this is an add, read the TTL and verify that it's in range.
|
||||
* If it's a delete, ignore a TTL if present (for compatibility).
|
||||
*/
|
||||
word = nsu_strsep(&cmdline, " \t\r\n");
|
||||
if (*word == 0) {
|
||||
if (!isdelete) {
|
||||
if (!isdelete) {
|
||||
word = nsu_strsep(&cmdline, " \t\r\n");
|
||||
if (*word == 0) {
|
||||
fprintf(stderr, "failed to read owner ttl\n");
|
||||
goto failure;
|
||||
}
|
||||
else {
|
||||
ttl = 0;
|
||||
rdataclass = dns_rdataclass_any;
|
||||
rdatatype = dns_rdatatype_any;
|
||||
rdata->flags = DNS_RDATA_UPDATE;
|
||||
goto doneparsing;
|
||||
}
|
||||
}
|
||||
ttl = strtol(word, &endp, 0);
|
||||
if (*endp != '\0') {
|
||||
if (isdelete) {
|
||||
ttl = 0;
|
||||
goto parseclass;
|
||||
} else {
|
||||
ttl = strtol(word, &endp, 0);
|
||||
if (*endp != '\0') {
|
||||
fprintf(stderr, "ttl '%s' is not numeric\n", word);
|
||||
goto failure;
|
||||
} else if (ttl < 0 || ttl > TTL_MAX || errno == ERANGE) {
|
||||
/*
|
||||
* The errno test is needed to catch when strtol()
|
||||
* overflows on a platform where sizeof(int) ==
|
||||
* sizeof(long), because ttl will be set to LONG_MAX,
|
||||
* which will be equal to TTL_MAX.
|
||||
*/
|
||||
fprintf(stderr, "ttl '%s' is out of range "
|
||||
"(0 to %d)\n", word, TTL_MAX);
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
||||
if (isdelete)
|
||||
} else
|
||||
ttl = 0;
|
||||
else if (ttl < 0 || ttl > TTL_MAX || errno == ERANGE) {
|
||||
/*
|
||||
* The errno test is needed to catch when strtol()
|
||||
* overflows on a platform where sizeof(int) ==
|
||||
* sizeof(long), because ttl will be set to LONG_MAX,
|
||||
* which will be equal to TTL_MAX.
|
||||
*/
|
||||
fprintf(stderr, "ttl '%s' is out of range (0 to %d)\n",
|
||||
word, TTL_MAX);
|
||||
goto failure;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the class or type.
|
||||
*/
|
||||
word = nsu_strsep(&cmdline, " \t\r\n");
|
||||
parseclass:
|
||||
if (*word == 0) {
|
||||
if (isdelete) {
|
||||
rdataclass = dns_rdataclass_any;
|
||||
@@ -1082,19 +1065,11 @@ update_addordelete(char *cmdline, isc_boolean_t isdelete) {
|
||||
region.base = word;
|
||||
region.length = strlen(word);
|
||||
result = dns_rdatatype_fromtext(&rdatatype, ®ion);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "'%s' is not a valid type: %s\n",
|
||||
word, isc_result_totext(result));
|
||||
goto failure;
|
||||
}
|
||||
check_result(result, "dns_rdatatype_fromtext");
|
||||
} else {
|
||||
rdataclass = dns_rdataclass_in;
|
||||
result = dns_rdatatype_fromtext(&rdatatype, ®ion);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "'%s' is not a valid class or type: "
|
||||
"%s\n", word, isc_result_totext(result));
|
||||
goto failure;
|
||||
}
|
||||
check_result(result, "dns_rdatatype_fromtext");
|
||||
}
|
||||
|
||||
retval = parse_rdata(&cmdline, rdataclass, rdatatype, updatemsg,
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.16 2001/01/18 01:33:53 bwelling Exp $
|
||||
# $Id: Makefile.in,v 1.14.4.1 2001/01/09 22:32:55 bwelling Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
@@ -47,8 +47,6 @@ OBJS = rndc.@O@
|
||||
|
||||
SRCS = rndc.c
|
||||
|
||||
MANPAGES = rndc.8 rndc.conf.5
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
rndc.@O@: rndc.c
|
||||
@@ -60,13 +58,9 @@ rndc: ${OBJS} ${DEPLIBS}
|
||||
|
||||
installdirs:
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${sbindir}
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man8
|
||||
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man5
|
||||
|
||||
install:: rndc installdirs
|
||||
install:: rndc
|
||||
${LIBTOOL} ${INSTALL_PROGRAM} rndc ${DESTDIR}${sbindir}
|
||||
${INSTALL_PROGRAM} rndc.8 ${DESTDIR}${mandir}/man8
|
||||
${INSTALL_PROGRAM} rndc.conf.5 ${DESTDIR}${mandir}/man5
|
||||
|
||||
clean distclean::
|
||||
rm -f ${TARGETS}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: rndc.c,v 1.38 2001/01/09 21:40:44 bwelling Exp $ */
|
||||
/* $Id: rndc.c,v 1.37.2.1 2001/01/09 22:32:56 bwelling Exp $ */
|
||||
|
||||
/*
|
||||
* Principal Author: DCL
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: rndc.conf,v 1.7 2001/01/09 21:40:45 bwelling Exp $ */
|
||||
/* $Id: rndc.conf,v 1.6.4.1 2001/01/09 22:32:57 bwelling Exp $ */
|
||||
|
||||
/*
|
||||
* Sample rndc configuration file.
|
||||
|
||||
1
bin/tests/Kclient.+002+02982.key
Normal file
1
bin/tests/Kclient.+002+02982.key
Normal file
@@ -0,0 +1 @@
|
||||
client. IN KEY 512 3 2 AAEBAAAAYDD6OLNNCn5OvnpBzMKzinDEFwpPpRofgSOXX87uho4sdyYK eFpgvl5md5h7m6vWNNni6cVfMBkqOftcQzxxPN1FNnabc9sUu4MxLvyf usOrXtZ5Nsv/0ei2tmnuesXM/w==
|
||||
6
bin/tests/Kclient.+002+02982.private
Normal file
6
bin/tests/Kclient.+002+02982.private
Normal file
@@ -0,0 +1,6 @@
|
||||
Private-key-format: v1.2
|
||||
Algorithm: 2 (DH)
|
||||
Prime(p): ///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxObIlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjo2IP//////////
|
||||
Generator(g): Ag==
|
||||
Private_value(x): XSrO/o1a0LHRp3JBT2N+vxjvHIkPL8Qz8s8ecKhaGr2DiXdYC2h8ifPE5v8l4sEKIfwq4xy0KIH/gfurmdmuHvCvgnFo33IzQARzaPXJWAqsnwhdY2vb8bxEB+OP/S0h
|
||||
Public_value(y): MPo4s00Kfk6+ekHMwrOKcMQXCk+lGh+BI5dfzu6Gjix3Jgp4WmC+XmZ3mHubq9Y02eLpxV8wGSo5+1xDPHE83UU2dptz2xS7gzEu/J+6w6te1nk2y//R6La2ae56xcz/
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.106 2001/01/24 03:18:35 bwelling Exp $
|
||||
# $Id: Makefile.in,v 1.103.4.2 2001/01/24 00:05:24 gson Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
@@ -83,6 +83,7 @@ XTARGETS = adb_test \
|
||||
sym_test \
|
||||
task_test \
|
||||
timer_test \
|
||||
tkey_test \
|
||||
wire_test \
|
||||
zone_test
|
||||
|
||||
@@ -127,6 +128,7 @@ SRCS = adb_test.c \
|
||||
sym_test.c \
|
||||
task_test.c \
|
||||
timer_test.c \
|
||||
tkey_test.c \
|
||||
wire_test.c \
|
||||
zone_test.c
|
||||
|
||||
@@ -265,6 +267,10 @@ ndcconf_test: ndcconf_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
|
||||
${LIBTOOL} ${CC} ${CFLAGS} -o $@ ndcconf_test.@O@ \
|
||||
${DNSLIBS} ${ISCLIBS} ${LIBS}
|
||||
|
||||
tkey_test: tkey_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
|
||||
${LIBTOOL} ${CC} ${CFLAGS} -o $@ tkey_test.@O@ \
|
||||
${DNSLIBS} ${ISCLIBS} ${LIBS}
|
||||
|
||||
fsaccess_test: fsaccess_test.@O@ ${ISCDEPLIBS}
|
||||
${LIBTOOL} ${CC} ${CFLAGS} -o $@ fsaccess_test.@O@ \
|
||||
${ISCLIBS} ${LIBS}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: adb_test.c,v 1.61 2001/01/09 21:40:48 bwelling Exp $ */
|
||||
/* $Id: adb_test.c,v 1.60.2.1 2001/01/09 22:33:00 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
524
bin/tests/b8status.pl
Executable file
524
bin/tests/b8status.pl
Executable file
@@ -0,0 +1,524 @@
|
||||
# Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
# INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: b8status.pl,v 1.7.4.1 2001/01/09 22:33:01 bwelling Exp $
|
||||
|
||||
#
|
||||
# aggregate reports from all bind8 build environments
|
||||
# write a summary of results in html format
|
||||
#
|
||||
|
||||
$Debug = 0;
|
||||
$Home = $ENV{"HOME"};
|
||||
$DebugFile = "$Home/b8t/b8tsummary.dbg";
|
||||
$HasTests = 0;
|
||||
$NoPort = 0;
|
||||
|
||||
$HaltLevel = 2;
|
||||
|
||||
$ConfigFile = ".config";
|
||||
$BuildFile = ".build";
|
||||
$BstatusFile = "bstatus.html";
|
||||
$TestFile = ".test";
|
||||
$TstatusFile = "tstatus.html";
|
||||
$WkbpFile = ".wkbp";
|
||||
$WktpFile = ".wktp";
|
||||
$RxFile = ".b8trx";
|
||||
$UnameFile = "uname";
|
||||
|
||||
$Nfbp = 0;
|
||||
$Nobp = 0;
|
||||
$Nftp = 0;
|
||||
$Notp = 0;
|
||||
$BadTest = 0;
|
||||
$BadTestReason = "";
|
||||
|
||||
$Module = "bind8";
|
||||
$MasterDir = "$Home/b8t";
|
||||
$DataDir = "/proj/build-reports/$Module";
|
||||
$HttpHomeURL = "http://status.isc.org/$Module";
|
||||
|
||||
#
|
||||
# initialize the host array
|
||||
#
|
||||
|
||||
open(DEBUG, "> $DebugFile") if ($Debug);
|
||||
|
||||
opendir(HDIR, "$MasterDir/hosts");
|
||||
@entries = readdir(HDIR);
|
||||
closedir(HDIR);
|
||||
|
||||
foreach $entry (@entries) {
|
||||
next if $entry =~ /^\.\.*$/;
|
||||
next unless -d "$MasterDir/hosts/$entry";
|
||||
push(hosts, $entry);
|
||||
}
|
||||
|
||||
#
|
||||
# put the page top
|
||||
#
|
||||
|
||||
$when = `date`;
|
||||
chop $when;
|
||||
$Ncols = 3;
|
||||
$Ncols = 4 if ($HasTests);
|
||||
|
||||
|
||||
printf("<?php \$title = \"ISC Status Server\"; ?>\n");
|
||||
printf("<?php include(\"status-isc-header.inc\") ?>\n");
|
||||
printf("\n");
|
||||
|
||||
printf("<CENTER>\n");
|
||||
printf("<TABLE BORDER=0>\n");
|
||||
printf("\t<TR HEIGHT=36><TD COLSPAN=4> </TD></TR>\n");
|
||||
printf("\t<TR><TD COLSPAN=%d ALIGN=CENTER><FONT SIZE=+1><EM>bind8 status %s</EM></FONT></TD></TR>\n", $Ncols, $when);
|
||||
printf("\t<TR HEIGHT=36><TD COLSPAN=4> </TD></TR>\n");
|
||||
printf("\t<TR>\n");
|
||||
printf("\t\t<TD WIDTH=150 ALIGN=LEFT><B>host</B></TD>\n");
|
||||
printf("\t\t<TD WIDTH=100 ALIGN=LEFT><B>build status</B></TD>\n");
|
||||
printf("\t\t<TD WIDTH=100 ALIGN=LEFT><B>fatal/other</B></TD>\n");
|
||||
printf("\t\t<TD WIDTH=100 ALIGN=LEFT><B>test status</B></TD>\n") if ($HasTests);
|
||||
printf("\t</TR>\n");
|
||||
printf("<TR><TD COLSPAN=%d><HR></TD></TR>\n", $Ncols);
|
||||
|
||||
|
||||
#
|
||||
# produce status info for each host
|
||||
#
|
||||
|
||||
foreach $host (sort @hosts) {
|
||||
&doHost($host);
|
||||
}
|
||||
|
||||
#
|
||||
# output end of page
|
||||
#
|
||||
|
||||
printf("\n");
|
||||
printf("</TABLE>\n");
|
||||
printf("\n");
|
||||
printf("<?php include(\"isc-footer.inc\") ?>\n");
|
||||
|
||||
close(DEBUG) if ($Debug);
|
||||
|
||||
#
|
||||
# produce status for host @ $hostpath
|
||||
#
|
||||
|
||||
sub doHost {
|
||||
local($hostid) = @_;
|
||||
local($entry, $prob, $line, $bstatus, $tstatus);
|
||||
local(@junk, $junk, $hostname, $bcolor, $tcolor);
|
||||
local(%buildprobs, %testprobs);
|
||||
local($severity, $filename, $linenumber, $message, $lastfilename);
|
||||
|
||||
#
|
||||
# get the host name
|
||||
#
|
||||
|
||||
$hostname = "n/a";
|
||||
if ((-r "$MasterDir/hosts/$hostid/$UnameFile") && (-s _)) {
|
||||
open(XXX, "< $MasterDir/hosts/$hostid/$UnameFile");
|
||||
$junk = <XXX>;
|
||||
close(XXX);
|
||||
@junk = split(/\s/, $junk);
|
||||
($hostname = $junk[1]) =~ s/\..*//;
|
||||
}
|
||||
|
||||
print DEBUG "Host: $hostid, Hostname: $hostname\n" if ($Debug);
|
||||
|
||||
#
|
||||
# scan the build and test results files for problems
|
||||
#
|
||||
|
||||
$Nfbp = 0;
|
||||
$Nobp = 0;
|
||||
$Nftp = 0;
|
||||
$Notp = 0;
|
||||
$BadTest = 0;
|
||||
$BadTestReason = "";
|
||||
|
||||
if ((-r "$DataDir/hosts/$hostid/$BuildFile") && (-s _ )) {
|
||||
%buildprobs = &buildCheck("$hostid");
|
||||
if ($NoPort) {
|
||||
$bstatus = "none (no port)";
|
||||
$bcolor = "black";
|
||||
}
|
||||
elsif ($Nfbp == 0) {
|
||||
$bstatus = "ok";
|
||||
$bcolor = "green";
|
||||
$tstatus = "n/a";
|
||||
|
||||
if ($HasTests) {
|
||||
if ((-r "$DataDir/hosts/$hostid/$TestFile") && (-s _)) {
|
||||
%testprobs = &testCheck("$hostid");
|
||||
if ($BadTest) {
|
||||
$tstatus = "inspect ($BadTestReason)";
|
||||
$tcolor = "blue";
|
||||
}
|
||||
else {
|
||||
if ($Nftp) {
|
||||
$tstatus = "fail";
|
||||
$tcolor = "red";
|
||||
}
|
||||
else {
|
||||
$tstatus = "pass";
|
||||
$tcolor = "green";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$tstatus = "none (no journal)";
|
||||
$tcolor = "red";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$bstatus = "broken";
|
||||
$tstatus = "none (build status)";
|
||||
$bcolor = "red";
|
||||
$tcolor = "black";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$bstatus = "none";
|
||||
$tstatus = "none (build status)";
|
||||
$bcolor = "red";
|
||||
$tcolor = "black";
|
||||
}
|
||||
|
||||
printf(DEBUG "Host %s(%s) STATUS: bstatus %s, tstatus %s, badtest %d, reason %s\n", $hostid, $hostname, $bstatus, $tstatus, $BadTest, $BadTestReason) if ($Debug);
|
||||
|
||||
printf("\t<TR>\n");
|
||||
printf("\t\t<TD><B>%s</B> %s</TD>\n", $hostid, $hostname);
|
||||
if ($bstatus =~ /none/) {
|
||||
printf("\t\t<TD>%s</TD>\n", $bstatus);
|
||||
printf("\t\t<TD> </TD>\n");
|
||||
}
|
||||
else {
|
||||
printf("\t\t<TD>");
|
||||
printf("<A HREF=\"$HttpHomeURL/hosts/$hostid/$BuildFile\"><FONT COLOR=\"%s\">%s</FONT></A>", $bcolor, $bstatus);
|
||||
printf("</TD>\n");
|
||||
printf("\t\t<TD>");
|
||||
printf("<A HREF=\"$HttpHomeURL/hosts/$hostid/$BstatusFile\"><FONT COLOR=\"%s\">%d/%d</FONT></A>", $bcolor, $Nfbp, $Nobp);
|
||||
printf("</TD>\n");
|
||||
}
|
||||
if ($HasTests) {
|
||||
if ($tstatus =~ /none/) {
|
||||
printf("\t\t<TD><FONT COLOR=\"%s\">%s</FONT></TD>\n", $tcolor, $tstatus);
|
||||
}
|
||||
else {
|
||||
printf("\t\t<TD><A HREF=\"$HttpHomeURL/hosts/$hostid/$TstatusFile\"><FONT COLOR=\"%s\">%s</FONT></A></TD>\n", $tcolor, $tstatus);
|
||||
}
|
||||
}
|
||||
printf("\t</TR>\n");
|
||||
|
||||
|
||||
#
|
||||
# write the build problems file
|
||||
#
|
||||
|
||||
&wbpf($hostid, %buildprobs);
|
||||
}
|
||||
|
||||
#
|
||||
# scan the build results file for hostid for build problems
|
||||
# return %probs
|
||||
# format key == filename:linenumber:severity, content == text of problem line
|
||||
# set $Nfbp and $Nobp as a side effect
|
||||
#
|
||||
|
||||
sub buildCheck {
|
||||
local($hostid) = @_;
|
||||
local($filename, $linenumber, $severity);
|
||||
local(%probs, %wkbp, @rxset);
|
||||
local($matched, $exp, $entry, $ccrx);
|
||||
|
||||
$NoPort = 0;
|
||||
|
||||
# initialize the well known build problems array, if available
|
||||
if (-r "$MasterDir/hosts/$hostid/$WkbpFile") {
|
||||
open(XXX, "< _");
|
||||
while(<XXX>) {
|
||||
next if /^\#/; # skip comments
|
||||
next if /^\s*$/; # and blank lines
|
||||
chop;
|
||||
($filename, $linenumber) = split;
|
||||
$wkbp{"$filename:$linenumber"} = 1;
|
||||
}
|
||||
close(XXX);
|
||||
}
|
||||
|
||||
# initialize the host specific regex array, if available
|
||||
if (-r "$MasterDir/hosts/$hostid/$RxFile") {
|
||||
open(XXX, "< _");
|
||||
while(<XXX>) {
|
||||
next if /^\#/; # skip comments
|
||||
next if /^\s*$/; # and blank lines
|
||||
chop;
|
||||
printf(DEBUG "RX: <%s>\n", $_) if ($Debug);
|
||||
push(@rxset, $_);
|
||||
}
|
||||
close(XXX);
|
||||
}
|
||||
|
||||
# scan stdout/stderr of make all for problems
|
||||
open(XXX, "< $DataDir/hosts/$hostid/$BuildFile");
|
||||
while (<XXX>) {
|
||||
|
||||
undef $filename;
|
||||
undef $linenumber;
|
||||
undef $severity;
|
||||
undef $1;
|
||||
undef $2;
|
||||
|
||||
$matched = 0;
|
||||
|
||||
chop;
|
||||
|
||||
if (/no BIND port/) {
|
||||
$NoPort = 1;
|
||||
last;
|
||||
}
|
||||
|
||||
foreach $entry (@rxset) {
|
||||
($severity, $exp) = split(/\s/, $entry, 2);
|
||||
if (/$exp/) {
|
||||
$filename = $1 if defined($1);
|
||||
$linenumber = $2 if defined($2);
|
||||
$matched = 1;
|
||||
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
next unless $matched;
|
||||
|
||||
if ($Debug) {
|
||||
printf(DEBUG "LINE %d: %s\n", $., $_);
|
||||
printf(DEBUG "MATCHES: exp<%s>\tfn<%s>\tln<%s>\tsev<%s>\n", $exp, $filename, $linenumber, $severity);
|
||||
}
|
||||
|
||||
if (length($filename) && length($linenumber)) {
|
||||
|
||||
$filename = $1 if ($filename =~ /.*(bind.*)/);
|
||||
|
||||
# ignore it if its in the well known build problems list
|
||||
if (defined($wkbp{"$filename:$linenumber"})) {
|
||||
print DEBUG "IGNORED\n" if ($Debug);
|
||||
# by convention, ignore all severity 0 problems
|
||||
$severity = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$filename = "MISC";
|
||||
$linenumber = "0";
|
||||
}
|
||||
|
||||
# avoid duplicates
|
||||
next if (index($probs{"$filename:$linenumber:$severity"}, $_) >= 0);
|
||||
|
||||
$probs{"$filename:$linenumber:$severity"} .= "$_\n";
|
||||
if ($severity >= $HaltLevel) {
|
||||
++$Nfbp;
|
||||
}
|
||||
else {
|
||||
++$Nobp;
|
||||
}
|
||||
printf(DEBUG "PROBLEM: fn<%s>\tln<%s>\tsev<%s>\n\n", $filename, $linenumber, $severity) if ($Debug);
|
||||
}
|
||||
close(XXX);
|
||||
return(%probs);
|
||||
}
|
||||
|
||||
#
|
||||
# run thru the test results file for hostid
|
||||
# write the test results file
|
||||
# return %probs
|
||||
# format key == funcname:assertion_number, value == test_result
|
||||
# set $Nftp and $Notp as a side effect
|
||||
#
|
||||
|
||||
sub testCheck {
|
||||
local($hostid) = @_;
|
||||
local($funcname, $anum, $atext);
|
||||
local(%probs, @junk, $junk);
|
||||
local($intest, $intestcase, $inassert, $ininfo, $inresult, $ntestsets);
|
||||
|
||||
# initialize the well known test problems array
|
||||
if (-f "$MasterDir/hosts/$hostid/$WktpFile") {
|
||||
open(XXX, "< _");
|
||||
while(<XXX>) {
|
||||
next if /^\#/; # skip comments
|
||||
chop;
|
||||
($funcname, $anum) = split;
|
||||
$wktp{"$funcname:$anum"} = 1;
|
||||
}
|
||||
close(XXX);
|
||||
}
|
||||
|
||||
if (! -r "$MasterDir/hosts/$hostid/$TestFile") {
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "no journal file";
|
||||
printf(DEBUG "No test journal at %s\n", "$hostpath/$TestFile") if ($Debug);
|
||||
return;
|
||||
}
|
||||
|
||||
$intest = 0;
|
||||
|
||||
open(XXX, "< $DataDir/hosts/$hostid/$TestFile");
|
||||
open(YYY, "> $DataDir/hosts/$hostid/$TstatusFile");
|
||||
|
||||
printf(YYY "<?php \$title = \"ISC Status Server $hostid Bind8 Test Results\"; ?>\n");
|
||||
printf(YYY "<?php include(\"status-isc-header.inc\") ?>\n");
|
||||
printf(YYY "\n");
|
||||
|
||||
while (<XXX>) {
|
||||
next unless ($_ =~ /^(S|I|T|A|R|E):/);
|
||||
chop;
|
||||
|
||||
if (/^S:([^:]*):(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/) {
|
||||
$intest = 1;
|
||||
$testname = $1;
|
||||
++$ntestsets;
|
||||
printf(YYY "%s\n<BR>\n", $_);
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^E:(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/) {
|
||||
$intest = 0;
|
||||
printf(YYY "%s\n<BR>\n", $_);
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^T:([^:]*):([^:]*):/) {
|
||||
if ($intest == 0) {
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "T$.";
|
||||
}
|
||||
$funcname = $1;
|
||||
$anum = $2;
|
||||
$intestcase = 1;
|
||||
$inassert = 0;
|
||||
$ininfo = 0;
|
||||
$inresult = 0;
|
||||
($junk = $funcname) =~ s/\//\\\//g;
|
||||
s/$junk/<B>$1<\/B>/;
|
||||
printf(YYY "%s\n<BR>\n", $_);
|
||||
next;
|
||||
}
|
||||
if (/^A:(.*)$/) {
|
||||
if (($intest == 0) || ($intestcase == 0) || ($inresult == 1)) {
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "A$.";
|
||||
}
|
||||
$atext = $1;
|
||||
$inassert = 1;
|
||||
s/A:(.*)/A:<FONT COLOR=\"blue\">$1<\/FONT>/;
|
||||
printf(YYY "%s\n<BR>\n", $_);
|
||||
next;
|
||||
}
|
||||
if (/^I:(.*)$/) {
|
||||
if (($intest == 0) || ($intestcase == 0) || ($inassert == 0)) {
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "I$.";
|
||||
}
|
||||
$ininfo = 1;
|
||||
s/</\</g;
|
||||
s/>/\>/g;
|
||||
printf(YYY "%s\n<BR>\n", $_);
|
||||
next;
|
||||
}
|
||||
if (/^R:(.*)$/) {
|
||||
if (($intest == 0) || ($intestcase == 0) || ($inassert == 0)) {
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "R:$intest:$intestcase:$inassert:$.";
|
||||
}
|
||||
$result = $1;
|
||||
$inresult = 1;
|
||||
if ($result =~ /FAIL|UNRESOLVED|UNINITIATED/) {
|
||||
#
|
||||
# skip if in the (ignorable) well known test problems list
|
||||
#
|
||||
if (defined($wktp{"$funcname:$anum"})) {
|
||||
++$Notp;
|
||||
}
|
||||
else {
|
||||
$probs{"$funcname:$anum"} = $result;
|
||||
++$Nftp;
|
||||
s/(FAIL|UNINITIATED)/<FONT COLOR=\"red\">$1<\/FONT>/;
|
||||
s/(UNRESOLVED)/<FONT COLOR=\"yellow\">$1<\/FONT>/;
|
||||
|
||||
}
|
||||
}
|
||||
elsif ($result =~ /PASS|UNTESTED/) {
|
||||
s/(PASS|UNTESTED)/<FONT COLOR=\"green\">$1<\/FONT>/;
|
||||
}
|
||||
printf(YYY "%s\n<BR>\n", $_);
|
||||
next;
|
||||
}
|
||||
}
|
||||
close(XXX);
|
||||
printf(YYY "<?php include(\"isc-footer.inc\") ?>\n");
|
||||
close(YYY);
|
||||
|
||||
if ($ntestsets == 0) {
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "no tests";
|
||||
}
|
||||
return(%probs);
|
||||
}
|
||||
|
||||
#
|
||||
# write the build problems file
|
||||
#
|
||||
|
||||
sub wbpf {
|
||||
local($hostid, %buildprobs) = @_;
|
||||
local($prob, $filename, $lastfilename, $linenumber, $severity);
|
||||
local(@messageset, $message);
|
||||
|
||||
open(XXX, "> $DataDir/hosts/$hostid/$BstatusFile");
|
||||
|
||||
printf(XXX "<?php \$title = \"ISC Status Server $hostid Bind8 Build Problems\"; ?>\n");
|
||||
printf(XXX "<?php include(\"status-isc-header.inc\") ?>\n");
|
||||
printf(XXX "\n");
|
||||
|
||||
foreach $prob (sort keys %buildprobs) {
|
||||
|
||||
($filename, $linenumber, $severity) = split(/\:/, $prob);
|
||||
|
||||
printf(XXX "<P><B>%s</B>\n<BR>\n", $filename) if ($filename ne $lastfilename);
|
||||
|
||||
@messageset = split(/\n/, $buildprobs{$prob});
|
||||
foreach $message (@messageset) {
|
||||
if ($severity >= $HaltLevel) {
|
||||
printf(XXX "<FONT COLOR=\"red\">%s</FONT>\n<BR>\n", $message);
|
||||
}
|
||||
elsif ($severity == 0) {
|
||||
printf(XXX "<FONT COLOR=\"yellow\">%s</FONT>\n<BR>\n", $message);
|
||||
}
|
||||
else {
|
||||
printf(XXX "%s\n<BR>\n", $message);
|
||||
}
|
||||
}
|
||||
$lastfilename = $filename;
|
||||
}
|
||||
|
||||
printf(XXX "<?php include(\"isc-footer.inc\") ?>\n");
|
||||
close(XXX);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: b8t.mk,v 1.8 2001/01/09 21:40:50 bwelling Exp $
|
||||
# $Id: b8t.mk,v 1.7.4.1 2001/01/09 22:33:02 bwelling Exp $
|
||||
|
||||
#
|
||||
# bind 8 multi-host make
|
||||
|
||||
529
bin/tests/b9status.pl
Executable file
529
bin/tests/b9status.pl
Executable file
@@ -0,0 +1,529 @@
|
||||
# Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
# INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: b9status.pl,v 1.10.4.1 2001/01/09 22:33:03 bwelling Exp $
|
||||
|
||||
#
|
||||
# aggregate reports from all bind9 build environments
|
||||
# write a summary of results in html format
|
||||
#
|
||||
|
||||
$Debug = 1;
|
||||
$Home = $ENV{"HOME"};
|
||||
$DebugFile = "$Home/b9t/b9tsummary.dbg";
|
||||
|
||||
#
|
||||
# level of severity at which a fatal error is considered to have occurred
|
||||
#
|
||||
|
||||
$HaltLevel = 2;
|
||||
|
||||
$Module = "bind9";
|
||||
$HttpHostURL = "http://status.isc.org/$Module/hosts";
|
||||
|
||||
# path to directory containing host specific control info
|
||||
$HomePath = "$Home/b9t/hosts";
|
||||
$WkbpFile = ".wkbp";
|
||||
$WktpFile = ".wktp";
|
||||
$RxFile = ".b9trx";
|
||||
$UnameFile = "uname";
|
||||
|
||||
# path to directory containing host specific data files and www reports
|
||||
$HostPath = "/proj/build-reports/$Module/hosts";
|
||||
$ConfigFile = ".config";
|
||||
$BuildFile = ".build";
|
||||
$TestFile = ".test";
|
||||
$TestStatusFile = "tstatus.html";
|
||||
$BuildStatusFile = "bstatus.html";
|
||||
|
||||
# number of fatal build problems
|
||||
$Nfbp = 0;
|
||||
|
||||
# number of other build problems
|
||||
$Nobp = 0;
|
||||
|
||||
# number of fatal test problems
|
||||
$Nftp = 0;
|
||||
|
||||
# number of other test problems
|
||||
$Notp = 0;
|
||||
|
||||
# flag to signal bad test journal format
|
||||
$BadTest = 0;
|
||||
$BadTestReason = "";
|
||||
|
||||
#
|
||||
# initialize the host array
|
||||
#
|
||||
|
||||
open(DEBUG, "> $DebugFile") if ($Debug);
|
||||
|
||||
opendir(HDIR, $HostPath);
|
||||
@entries = readdir(HDIR);
|
||||
closedir(HDIR);
|
||||
|
||||
foreach $entry (@entries) {
|
||||
next if $entry =~ /^\.\.*$/;
|
||||
next unless -d "$HostPath/$entry";
|
||||
push(hosts, $entry);
|
||||
}
|
||||
|
||||
#
|
||||
# put the page top
|
||||
#
|
||||
|
||||
$when = `date`;
|
||||
chop $when;
|
||||
|
||||
printf("<?php \$title = \"ISC Status Server\"; ?>\n");
|
||||
printf("<?php include(\"status-isc-header.inc\") ?>\n");
|
||||
printf("\n");
|
||||
|
||||
printf("<CENTER>\n");
|
||||
printf("<TABLE BORDER=0>\n");
|
||||
printf("\t<TR HEIGHT=36><TD COLSPAN=4> </TD></TR>\n");
|
||||
printf("\t<TR><TD COLSPAN=4 ALIGN=CENTER><FONT SIZE=+1><EM>bind9 status %s</EM></FONT></TD></TR>\n", $when);
|
||||
printf("\t<TR HEIGHT=36><TD COLSPAN=4> </TD></TR>\n");
|
||||
printf("\t<TR>\n");
|
||||
printf("\t\t<TD WIDTH=150 ALIGN=LEFT><B>host</B></TD>\n");
|
||||
printf("\t\t<TD WIDTH=100 ALIGN=LEFT><B>build status</B></TD>\n");
|
||||
printf("\t\t<TD WIDTH=100 ALIGN=LEFT><B>fatal/other</B></TD>\n");
|
||||
printf("\t\t<TD WIDTH=100 ALIGN=LEFT><B>test status</B></TD>\n");
|
||||
printf("\t</TR>\n");
|
||||
printf("<TR><TD COLSPAN=4><HR></TD></TR>\n");
|
||||
|
||||
#
|
||||
# produce status info for each host
|
||||
#
|
||||
|
||||
foreach $host (sort @hosts) {
|
||||
&doHost($host);
|
||||
}
|
||||
|
||||
#
|
||||
# output end of page
|
||||
#
|
||||
|
||||
printf("\n");
|
||||
printf("</TABLE>\n");
|
||||
printf("\n");
|
||||
printf("<?php include(\"isc-footer.inc\") ?>\n");
|
||||
|
||||
close(DEBUG) if ($Debug);
|
||||
|
||||
#
|
||||
# produce status for host @ $hostpath
|
||||
#
|
||||
|
||||
sub doHost {
|
||||
local($hostid) = @_;
|
||||
local($entry, $prob, $line, $bstatus, $tstatus);
|
||||
local(@junk, $junk, $hostname, $bcolor, $tcolor);
|
||||
local(%buildprobs, %testprobs);
|
||||
local($severity, $filename, $linenumber, $message, $lastfilename);
|
||||
|
||||
mkdir("$HostPath/$hostid", 0755) if (! -d "$HostPath/$hostid");
|
||||
|
||||
#
|
||||
# get the host name
|
||||
#
|
||||
|
||||
$hostname = "n/a";
|
||||
if ((-r "$HomePath/$hostid/$UnameFile") && (-s _)) {
|
||||
open(XXX, "< $HomePath/$hostid/$UnameFile");
|
||||
$junk = <XXX>;
|
||||
close(XXX);
|
||||
@junk = split(/\s/, $junk);
|
||||
$hostname = $junk[1];
|
||||
$hostname =~ s/\..*//;
|
||||
}
|
||||
|
||||
print DEBUG "Host: $hostid, Hostname: $hostname\n" if ($Debug);
|
||||
|
||||
#
|
||||
# scan the build and test results files for problems
|
||||
#
|
||||
|
||||
$Nfbp = 0;
|
||||
$Nobp = 0;
|
||||
$Nftp = 0;
|
||||
$Notp = 0;
|
||||
$BadTest = 0;
|
||||
$BadTestReason = "";
|
||||
|
||||
if ((-r "$HostPath/$hostid/$BuildFile") && (-s _)) {
|
||||
%buildprobs = &buildCheck($hostid);
|
||||
if ($Nfbp == 0) {
|
||||
$bstatus = "ok";
|
||||
$bcolor = "green";
|
||||
|
||||
if ((-r "$HostPath/$hostid/$TestFile") && (-s _)) {
|
||||
%testprobs = &testCheck($hostid);
|
||||
if ($BadTest) {
|
||||
$tstatus = "inspect ($BadTestReason)";
|
||||
$tcolor = "blue";
|
||||
}
|
||||
else {
|
||||
if ($Nftp) {
|
||||
$tstatus = "fail";
|
||||
$tcolor = "red";
|
||||
}
|
||||
else {
|
||||
$tstatus = "pass";
|
||||
$tcolor = "green";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$tstatus = "none (no journal)";
|
||||
$tcolor = "red";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$bstatus = "broken";
|
||||
$tstatus = "none (build status)";
|
||||
$bcolor = "red";
|
||||
$tcolor = "black";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$bstatus = "none";
|
||||
$tstatus = "none (build status)";
|
||||
$bcolor = "red";
|
||||
$tcolor = "black";
|
||||
}
|
||||
|
||||
printf(DEBUG "Host %s(%s) STATUS: bstatus %s, tstatus %s, badtest %d, reason %s\n", $hostid, $hostname, $bstatus, $tstatus, $BadTest, $BadTestReason) if ($Debug);
|
||||
|
||||
printf("\t<TR>\n");
|
||||
printf("\t\t<TD><B>%s</B> %s</TD>\n", $hostid, $hostname);
|
||||
if ($bstatus =~ /none/) {
|
||||
printf("\t\t<TD>%s</TD>\n", $bstatus);
|
||||
printf("\t\t<TD> </TD>\n");
|
||||
}
|
||||
else {
|
||||
printf("\t\t<TD>");
|
||||
printf("<A HREF=\"$HttpHostURL/$hostid/$BuildFile\"><FONT COLOR=\"%s\">%s</FONT></A>", $bcolor, $bstatus);
|
||||
printf("</TD>\n");
|
||||
printf("\t\t<TD>");
|
||||
printf("<A HREF=\"$HttpHostURL/$hostid/$BuildStatusFile\"><FONT COLOR=\"%s\">%d/%d</FONT></A>", $bcolor, $Nfbp, $Nobp);
|
||||
printf("</TD>\n");
|
||||
}
|
||||
if ($tstatus =~ /none/) {
|
||||
printf("\t\t<TD><FONT COLOR=\"%s\">%s</FONT></TD>\n", $tcolor, $tstatus);
|
||||
}
|
||||
else {
|
||||
printf("\t\t<TD><A HREF=\"$HttpHostURL/$hostid/$TestStatusFile\"><FONT COLOR=\"%s\">%s</FONT></A></TD>\n", $tcolor, $tstatus);
|
||||
}
|
||||
printf("\t</TR>\n");
|
||||
|
||||
#
|
||||
# write the build problems file
|
||||
#
|
||||
|
||||
&wbpf($hostid, %buildprobs) if ($Nfbp + $Nobp);
|
||||
}
|
||||
|
||||
#
|
||||
# scan the build results file for host at $hostpath for build problems
|
||||
# return %probs
|
||||
# format key == filename:linenumber:severity, content == text of problem line
|
||||
# set $Nfbp and $Nobp as a side effect
|
||||
#
|
||||
|
||||
sub buildCheck {
|
||||
local($hostid) = @_;
|
||||
local($filename, $linenumber, $severity);
|
||||
local(%probs, %wkbp, @rxset);
|
||||
local($matched, $exp, $entry, $ccrx);
|
||||
|
||||
# initialize the well known build problems array, if available
|
||||
if (-r "$HomePath/$hostid/$WkbpFile") {
|
||||
open(XXX, "< $HomePath/$hostid/$WkbpFile");
|
||||
while(<XXX>) {
|
||||
next if /^\#/; # skip comments
|
||||
next if /^\s*$/; # and blank lines
|
||||
chop;
|
||||
($filename, $linenumber) = split;
|
||||
$wkbp{"$filename:$linenumber"} = 1;
|
||||
}
|
||||
close(XXX);
|
||||
}
|
||||
|
||||
# initialize the host specific regex array, if available
|
||||
if (-r "$HomePath/$hostid/$RxFile") {
|
||||
open(XXX, "< $HomePath/$hostid/$RxFile");
|
||||
while(<XXX>) {
|
||||
next if /^\#/; # skip comments
|
||||
next if /^\s*$/; # and blank lines
|
||||
chop;
|
||||
printf(DEBUG "RX: <%s>\n", $_) if ($Debug);
|
||||
push(@rxset, $_);
|
||||
}
|
||||
close(XXX);
|
||||
}
|
||||
|
||||
# scan stdout/stderr of make all for problems
|
||||
open(XXX, "< $HostPath/$hostid/$BuildFile");
|
||||
while (<XXX>) {
|
||||
|
||||
undef $filename;
|
||||
undef $linenumber;
|
||||
undef $severity;
|
||||
undef $1;
|
||||
undef $2;
|
||||
|
||||
$matched = 0;
|
||||
|
||||
chop;
|
||||
|
||||
foreach $entry (@rxset) {
|
||||
($severity, $exp) = split(/\s/, $entry, 2);
|
||||
if (/$exp/) {
|
||||
$filename = $1 if defined($1);
|
||||
$linenumber = $2 if defined($2);
|
||||
$matched = 1;
|
||||
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
next unless $matched;
|
||||
|
||||
if ($Debug) {
|
||||
printf(DEBUG "LINE %d: %s\n", $., $_);
|
||||
printf(DEBUG "MATCHES: exp<%s>\tfn<%s>\tln<%s>\tsev<%s>\n", $exp, $filename, $linenumber, $severity);
|
||||
}
|
||||
|
||||
if (length($filename) && length($linenumber)) {
|
||||
|
||||
$filename = $1 if ($filename =~ /.*(bind9.*)/);
|
||||
|
||||
# ignore it if its in the well known build problems list
|
||||
if (defined($wkbp{"$filename:$linenumber"})) {
|
||||
print DEBUG "IGNORED\n" if ($Debug);
|
||||
# by convention, ignore all severity 0 problems
|
||||
$severity = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$filename = "MISC";
|
||||
$linenumber = "0";
|
||||
}
|
||||
|
||||
# avoid duplicates
|
||||
next if (index($probs{"$filename:$linenumber:$severity"}, $_) >= 0);
|
||||
|
||||
$probs{"$filename:$linenumber:$severity"} .= "$_\n";
|
||||
if ($severity >= $HaltLevel) {
|
||||
++$Nfbp;
|
||||
}
|
||||
else {
|
||||
++$Nobp;
|
||||
}
|
||||
printf(DEBUG "PROBLEM: fn<%s>\tln<%s>\tsev<%s>\n\n", $filename, $linenumber, $severity) if ($Debug);
|
||||
}
|
||||
close(XXX);
|
||||
return(%probs);
|
||||
}
|
||||
|
||||
#
|
||||
# run thru the test results file for $hostid
|
||||
# write the test results file
|
||||
# return %probs
|
||||
# format key == funcname:assertion_number, value == test_result
|
||||
# set $Nftp and $Notp as a side effect
|
||||
#
|
||||
|
||||
sub testCheck {
|
||||
local($hostid) = @_;
|
||||
local($funcname, $anum, $atext);
|
||||
local(%probs, @junk, $junk);
|
||||
local($intest, $intestcase, $inassert, $ininfo, $inresult, $ntestsets);
|
||||
|
||||
# initialize the well known test problems array
|
||||
if (-f "$HomePath/$hostid/$WktpFile") {
|
||||
open(XXX, "< $HomePath/$hostid/$WktpFile");
|
||||
while(<XXX>) {
|
||||
next if /^\#/; # skip comments
|
||||
chop;
|
||||
($funcname, $anum) = split;
|
||||
$wktp{"$funcname:$anum"} = 1;
|
||||
}
|
||||
close(XXX);
|
||||
}
|
||||
|
||||
if (! -r "$HostPath/$hostid/$TestFile") {
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "no journal file";
|
||||
printf(DEBUG "No test journal at %s\n", "$hostpath/$TestFile") if ($Debug);
|
||||
return;
|
||||
}
|
||||
|
||||
$intest = 0;
|
||||
|
||||
open(XXX, "< $HostPath/$hostid/$TestFile");
|
||||
open(YYY, "> $HostPath/$hostid/$TestStatusFile");
|
||||
|
||||
printf(YYY "<?php \$title = \"ISC Status Server $hostid Bind9 Test Results\"; ?>\n");
|
||||
printf(YYY "<?php include(\"status-isc-header.inc\") ?>\n");
|
||||
printf(YYY "\n");
|
||||
|
||||
while (<XXX>) {
|
||||
next unless ($_ =~ /^(S|I|T|A|R|E):/);
|
||||
chop;
|
||||
|
||||
if (/^S:([^:]*):(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/) {
|
||||
$intest = 1;
|
||||
$testname = $1;
|
||||
++$ntestsets;
|
||||
printf(YYY "%s\n<BR>\n", $_);
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^E:[^:]*:(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/) {
|
||||
if ($inresult == 0) {
|
||||
# no reported result
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "E$.";
|
||||
}
|
||||
$intest = 0;
|
||||
printf(YYY "%s\n<BR>\n", $_);
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^T:([^:]*):([^:]*):/) {
|
||||
if ($intest == 0) {
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "T$.";
|
||||
}
|
||||
$funcname = $1;
|
||||
$anum = $2;
|
||||
$intestcase = 1;
|
||||
$inassert = 0;
|
||||
$ininfo = 0;
|
||||
$inresult = 0;
|
||||
($junk = $funcname) =~ s/\//\\\//g;
|
||||
s/$junk/<B>$1<\/B>/;
|
||||
printf(YYY "%s\n<BR>\n", $_);
|
||||
next;
|
||||
}
|
||||
if (/^A:(.*)$/) {
|
||||
if (($intest == 0) || ($intestcase == 0) || ($inresult == 1)) {
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "A$.";
|
||||
}
|
||||
$atext = $1;
|
||||
$inassert = 1;
|
||||
s/A:(.*)/A:<FONT COLOR=\"blue\">$1<\/FONT>/;
|
||||
printf(YYY "%s\n<BR>\n", $_);
|
||||
next;
|
||||
}
|
||||
if (/^I:(.*)$/) {
|
||||
if (($intest == 0) || ($intestcase == 0) || ($inassert == 0)) {
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "I$.";
|
||||
}
|
||||
$ininfo = 1;
|
||||
s/</\</g;
|
||||
s/>/\>/g;
|
||||
printf(YYY "%s\n<BR>\n", $_);
|
||||
next;
|
||||
}
|
||||
if (/^R:(.*)$/) {
|
||||
if (($intest == 0) || ($intestcase == 0) || ($inassert == 0)) {
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "R:$intest:$intestcase:$inassert:$.";
|
||||
}
|
||||
$result = $1;
|
||||
$inresult = 1;
|
||||
if ($result =~ /FAIL|UNRESOLVED|UNINITIATED/) {
|
||||
#
|
||||
# skip if in the (ignorable) well known test problems list
|
||||
#
|
||||
if (defined($wktp{"$funcname:$anum"})) {
|
||||
++$Notp;
|
||||
}
|
||||
else {
|
||||
$probs{"$funcname:$anum"} = $result;
|
||||
++$Nftp;
|
||||
s/(FAIL|UNINITIATED)/<FONT COLOR=\"red\">$1<\/FONT>/;
|
||||
s/(UNRESOLVED)/<FONT COLOR=\"orange\">$1<\/FONT>/;
|
||||
|
||||
}
|
||||
}
|
||||
elsif ($result =~ /PASS|UNTESTED/) {
|
||||
s/(PASS|UNTESTED)/<FONT COLOR=\"green\">$1<\/FONT>/;
|
||||
}
|
||||
printf(YYY "%s\n<BR>\n", $_);
|
||||
next;
|
||||
}
|
||||
}
|
||||
close(XXX);
|
||||
printf(YYY "<?php include(\"isc-footer.inc\") ?>\n");
|
||||
close(YYY);
|
||||
|
||||
if ($ntestsets == 0) {
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "no tests";
|
||||
}
|
||||
if ($intest) {
|
||||
$BadTest = 1;
|
||||
$BadTestReason = "incomplete";
|
||||
}
|
||||
return(%probs);
|
||||
}
|
||||
|
||||
#
|
||||
# write the build problems file
|
||||
#
|
||||
|
||||
sub wbpf {
|
||||
local($hostid, %buildprobs) = @_;
|
||||
local($prob, $filename, $lastfilename, $linenumber, $severity);
|
||||
local(@messageset, $message);
|
||||
|
||||
open(XXX, "> $HostPath/$hostid/$BuildStatusFile");
|
||||
|
||||
printf(XXX "<?php \$title = \"ISC Status Server $hostid Bind9 Build Problems\"; ?>\n");
|
||||
printf(XXX "<?php include(\"status-isc-header.inc\") ?>\n");
|
||||
printf(XXX "\n");
|
||||
|
||||
foreach $prob (sort keys %buildprobs) {
|
||||
|
||||
($filename, $linenumber, $severity) = split(/\:/, $prob);
|
||||
|
||||
printf(XXX "<P><B>%s</B>\n<BR>\n", $filename) if ($filename ne $lastfilename);
|
||||
|
||||
@messageset = split(/\n/, $buildprobs{$prob});
|
||||
foreach $message (@messageset) {
|
||||
if ($severity >= $HaltLevel) {
|
||||
printf(XXX "<FONT COLOR=\"red\">%s</FONT>\n<BR>\n", $message);
|
||||
}
|
||||
elsif ($severity == 0) {
|
||||
printf(XXX "<FONT COLOR=\"orange\">%s</FONT>\n<BR>\n", $message);
|
||||
}
|
||||
else {
|
||||
printf(XXX "%s\n<BR>\n", $message);
|
||||
}
|
||||
}
|
||||
$lastfilename = $filename;
|
||||
}
|
||||
|
||||
printf(XXX "<?php include(\"isc-footer.inc\") ?>\n");
|
||||
close(XXX);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: b9t.mk,v 1.10 2001/01/09 21:40:53 bwelling Exp $
|
||||
# $Id: b9t.mk,v 1.9.4.1 2001/01/09 22:33:04 bwelling Exp $
|
||||
|
||||
#
|
||||
# makefile to configure, build and test bind9
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: byaddr_test.c,v 1.22 2001/01/09 21:40:54 bwelling Exp $ */
|
||||
/* $Id: byaddr_test.c,v 1.21.4.1 2001/01/09 22:33:06 bwelling Exp $ */
|
||||
|
||||
/*
|
||||
* Principal Author: Bob Halley
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user