Package org.arch.dns.exception

Examples of org.arch.dns.exception.CommunicationException


                  tcp.close();
                }
                Header hdr2 = new Header(msg2, msg2.length);
                if (hdr2.query)
                {
                  throw new CommunicationException(
                          "DNS error: expecting response");
                }
                checkResponseCode(hdr2);
               
                if (!auth || hdr2.authoritative)
                {
                  // Got a valid response
                  hdr = hdr2;
                  msg = msg2;
                  break;
                }
                else
                {
                  doNotRetry[ij] = true;
                }
              }
              catch (Exception e)
              {
                // Try next server, or use UDP response
              }
            } // servers
          }
          return new ResourceRecords(msg, msg.length, hdr, false);
         
        }
        catch (IOException e)
        {
          if (debug)
          {
            dprint("Caught IOException:" + e);
          }
          if (caughtException == null)
          {
            caughtException = e;
          }
          // Use reflection to allow pre-1.4 compilation.
          // This won't be needed much longer.
          if (e.getClass().getName()
                  .equals("java.net.PortUnreachableException"))
          {
            doNotRetry[i] = true;
          }
        }
        catch (NameNotFoundException e)
        {
          throw e;
        }
        catch (CommunicationException e)
        {
          if (caughtException == null)
          {
            caughtException = e;
          }
        }
        catch (NamingException e)
        {
          if (caughtException == null)
          {
            caughtException = e;
          }
          doNotRetry[i] = true;
        }
      } // servers
    } // retries
   
    reqs.remove(xid);
    if (caughtException instanceof NamingException)
    {
      throw (NamingException) caughtException;
    }
    // A network timeout or other error occurred.
    NamingException ne = new CommunicationException("DNS error");
    ne.setRootCause(caughtException);
    throw ne;
  }
View Full Code Here


          checkResponseCode(hdr);
          ResourceRecords rrs = new ResourceRecords(msg, msg.length,
                  hdr, true);
          if (rrs.getFirstAnsType() != ResourceRecord.TYPE_SOA)
          {
            throw new CommunicationException(
                    "DNS error: zone xfer doesn't begin with SOA");
          }
         
          if (rrs.answer.size() == 1
                  || rrs.getLastAnsType() != ResourceRecord.TYPE_SOA)
          {
            // The response is split into multiple DNS messages.
            do
            {
              msg = continueTcpQuery(tcp);
              if (msg == null)
              {
                throw new CommunicationException(
                        "DNS error: incomplete zone transfer");
              }
              hdr = new Header(msg, msg.length);
              checkResponseCode(hdr);
              rrs.add(msg, msg.length, hdr);
            } while (rrs.getLastAnsType() != ResourceRecord.TYPE_SOA);
          }
         
          // Delete the duplicate SOA record.
          rrs.answer.removeElementAt(rrs.answer.size() - 1);
          return rrs;
         
        }
        finally
        {
          tcp.close();
        }
       
      }
      catch (IOException e)
      {
        caughtException = e;
      }
      catch (NameNotFoundException e)
      {
        throw e;
      }
      catch (NamingException e)
      {
        caughtException = e;
      }
    }
    if (caughtException instanceof NamingException)
    {
      throw (NamingException) caughtException;
    }
    NamingException ne = new CommunicationException(
            "DNS error during zone transfer");
    ne.setRootCause(caughtException);
    throw ne;
  }
View Full Code Here

  {
   
    Header hdr = new Header(pkt, pkt.length);
    if (hdr.query)
    {
      throw new CommunicationException("DNS error: expecting response");
    }
   
    if (!reqs.contains(xid))
    { // already received, ignore the response
      return false;
View Full Code Here

        try {
            int pos = 0;        // current offset into msg

            if (msgLen < HEADER_SIZE) {
                throw new CommunicationException(
                        "DNS error: corrupted message header");
            }

            xid = getShort(msg, pos);
            pos += 2;

            // Flags
            short flags = (short) getShort(msg, pos);
            pos += 2;
            query = (flags & QR_BIT) == 0;
            opcode = (flags & OPCODE_MASK) >>> OPCODE_SHIFT;
            authoritative = (flags & AA_BIT) != 0;
            truncated = (flags & TC_BIT) != 0;
            recursionDesired = (flags & RD_BIT) != 0;
            recursionAvail = (flags & RA_BIT) != 0;
            rcode = (flags & RCODE_MASK);

            // RR counts
            numQuestions = getShort(msg, pos);
            pos += 2;
            numAnswers = getShort(msg, pos);
            pos += 2;
            numAuthorities = getShort(msg, pos);
            pos += 2;
            numAdditionals = getShort(msg, pos);
            pos += 2;

        } catch (IndexOutOfBoundsException e) {
            throw new CommunicationException(
                    "DNS error: corrupted message header");
        }
    }
View Full Code Here

      // The additional records section is currently ignored.
     
    }
    catch (IndexOutOfBoundsException e)
    {
      throw new CommunicationException("DNS error: corrupted message");
    }
  }
View Full Code Here

TOP

Related Classes of org.arch.dns.exception.CommunicationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.