001/*
002 * Copyright 2015-2020 the original author or authors
003 *
004 * This software is licensed under the Apache License, Version 2.0,
005 * the GNU Lesser General Public License version 2 or later ("LGPL")
006 * and the WTFPL.
007 * You may choose either license to govern your use of this software only
008 * upon the condition that you accept all of the terms of either
009 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
010 */
011package org.minidns.iterative;
012
013import java.net.InetAddress;
014
015import org.minidns.MiniDnsException;
016import org.minidns.dnsmessage.DnsMessage;
017import org.minidns.dnsmessage.Question;
018import org.minidns.dnsname.DnsName;
019import org.minidns.dnsqueryresult.DnsQueryResult;
020
021public abstract class IterativeClientException extends MiniDnsException {
022
023    /**
024     * 
025     */
026    private static final long serialVersionUID = 1L;
027
028    protected IterativeClientException(String message) {
029        super(message);
030    }
031
032    public static class LoopDetected extends IterativeClientException {
033
034        /**
035         * 
036         */
037        private static final long serialVersionUID = 1L;
038
039        public final InetAddress address;
040        public final Question question;
041
042        public LoopDetected(InetAddress address, Question question) {
043            super("Resolution loop detected: We already asked " + address + " about " + question);
044            this.address = address;
045            this.question = question;
046        }
047
048    }
049
050    public static class MaxIterativeStepsReached extends IterativeClientException {
051
052        /**
053         * 
054         */
055        private static final long serialVersionUID = 1L;
056
057        public MaxIterativeStepsReached() {
058            super("Maxmimum steps reached");
059        }
060
061    }
062
063    public static class NotAuthoritativeNorGlueRrFound extends IterativeClientException {
064
065        /**
066         * 
067         */
068        private static final long serialVersionUID = 1L;
069
070        private final DnsMessage request;
071        private final DnsQueryResult result;
072        private final DnsName authoritativeZone;
073
074        public NotAuthoritativeNorGlueRrFound(DnsMessage request, DnsQueryResult result, DnsName authoritativeZone) {
075            super("Did not receive an authoritative answer, nor did the result contain any glue records");
076            this.request = request;
077            this.result = result;
078            this.authoritativeZone = authoritativeZone;
079        }
080
081        public DnsMessage getRequest() {
082            return request;
083        }
084
085        public DnsQueryResult getResult() {
086            return result;
087        }
088
089        public DnsName getAuthoritativeZone() {
090            return authoritativeZone;
091        }
092    }
093}