Package org.xbill.DNS

Examples of org.xbill.DNS.Header


          (byte)0x65, (byte)0x1C, // QDCOUNT
          (byte)0x10, (byte)0xF0, // ANCOUNT
          (byte)0x98, (byte)0xBA, // NSCOUNT
          (byte)0x71, (byte)0x90 }; // ARCOUNT
 
  m_h = new Header(raw);
 
  DNSOutput dout = new DNSOutput();
  m_h.toWire(dout);
 
  byte[] out = dout.toByteArray();
View Full Code Here


    public void test_ID()
    {
  assertEquals(0xABCD, m_h.getID());

  m_h = new Header();
 
  int id = m_h.getID();
  assertEquals(id, m_h.getID());
  assertTrue(id >= 0 && id < 0xffff);
View Full Code Here

  m_h.setFlag(8); // ra
  m_h.setFlag(11); // cd
  m_h.setCount(1, 0xFF);
  m_h.setCount(2, 0x0A);

  Header h2 = (Header)m_h.clone();

  assertNotSame(m_h, h2);
  assertEquals(m_h.getID(), h2.getID());
  for( int i=0; i<16; ++i){
      if( (i>0 && i<5) || i > 11){
    continue;
      }
      assertEquals(m_h.getFlag(i), h2.getFlag(i));
  }
  for( int i=0; i<4; ++i){
      assertEquals(m_h.getCount(i), h2.getCount(i));
  }
    } 
View Full Code Here

  }
 
  public static String toJson(Message resp)
  {
    Map<String, Object> map = new HashMap<String, Object>();
    Header header = resp.getHeader();
    map.put("opcode", Opcode.string(header.getOpcode()));
    map.put("rcode", Rcode.string(header.getRcode()));
    map.put("flags", header.printFlags().trim().split("\\s+"));
    map.put("id", header.getID());
    addRecords(resp, Section.QUESTION, map, "question");
    addRecords(resp, Section.ANSWER, map, "answers");
    addRecords(resp, Section.ADDITIONAL, map, "additional");
    addRecords(resp, Section.AUTHORITY, map, "authority");
   
View Full Code Here

        return rcode;
    }

    public byte[] generateReply(Message query, int length, Socket s)
            throws IOException {
        Header header;
        int maxLength;
        int flags = 0;

        header = query.getHeader();
        if (header.getFlag(Flags.QR))
            return null;
        if (header.getRcode() != Rcode.NOERROR)
            return errorMessage(query, Rcode.FORMERR);
        if (header.getOpcode() != Opcode.QUERY)
            return errorMessage(query, Rcode.NOTIMP);

        Record queryRecord = query.getQuestion();

        OPTRecord queryOPT = query.getOPT();
View Full Code Here

        header.setRcode(rcode);
        return response.toWire();
    }

    public byte[] formerrMessage(byte[] in) {
        Header header;
        try {
            header = new Header(in);
        } catch (IOException e) {
            return null;
        }
        return buildErrorMessage(header, Rcode.FORMERR, null);
    }
View Full Code Here

      dataOut = new DataOutputStream(s.getOutputStream());
      int id = query.getHeader().getID();
      while (it.hasNext()) {
        RRset rrset = (RRset) it.next();
        Message response = new Message(id);
        Header header = response.getHeader();
        header.setFlag(Flags.QR);
        header.setFlag(Flags.AA);
        addRRset(rrset.getName(), response, rrset, Section.ANSWER, FLAG_DNSSECOK);
        if (tsig != null) {
          tsig.applyStream(response, qtsig, first);
          qtsig = response.getTSIG();
        }
View Full Code Here

   * Note: a null return value means that the caller doesn't need to do
   * anything.  Currently this only happens if this is an AXFR request over
   * TCP.
   */
  byte[] generateReply(Message query, byte[] in, int length, Socket socket) throws IOException {
    Header header;
    // boolean badversion;
    int maxLength;
    int flags = 0;

    header = query.getHeader();
    if (header.getFlag(Flags.QR)) {
      return null;
    }
    if (header.getRcode() != Rcode.NOERROR) {
      return errorMessage(query, Rcode.FORMERR);
    }
    if (header.getOpcode() != Opcode.QUERY) {
      return errorMessage(query, Rcode.NOTIMP);
    }

    Record queryRecord = query.getQuestion();

View Full Code Here

    header.setRcode(rcode);
    return response.toWire();
  }

  byte[] formerrMessage(byte[] in) {
    Header header;
    try {
      header = new Header(in);
    } catch (IOException e) {
      return null;
    }
    return buildErrorMessage(header, Rcode.FORMERR, null);
  }
View Full Code Here

            dataOut = new DataOutputStream(s.getOutputStream());
            int id = query.getHeader().getID();
            while (it.hasNext()) {
                RRset rrset = (RRset) it.next();
                Message response = new Message(id);
                Header header = response.getHeader();
                header.setFlag(Flags.QR);
                header.setFlag(Flags.AA);
                addRRset(rrset.getName(), response, rrset,
                        Section.ANSWER, FLAG_DNSSECOK);
                if (tsig != null) {
                    tsig.applyStream(response, qtsig, first);
                    qtsig = response.getTSIG();
View Full Code Here

TOP

Related Classes of org.xbill.DNS.Header

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.