Example #1
0
 /** Parses a Header from a stream containing DNS wire format. */
 Header(DNSInput in) throws IOException {
   this(in.readU16());
   flags = in.readU16();
   for (int i = 0; i < counts.length; i++) {
     counts[i] = in.readU16();
   }
 }
Example #2
0
 Message(DNSInput in) throws IOException {
   this(new Header(in));
   boolean isUpdate = (header.getOpcode() == Opcode.UPDATE);
   boolean truncated = header.getFlag(Flags.TC);
   try {
     for (int i = 0; i < 4; i++) {
       int count = header.getCount(i);
       if (count > 0) sections[i] = new ArrayList(count);
       for (int j = 0; j < count; j++) {
         int pos = in.current();
         Record rec = Record.fromWire(in, i, isUpdate);
         sections[i].add(rec);
         if (i == Section.ADDITIONAL) {
           if (rec.getType() == Type.TSIG) tsigstart = pos;
           if (rec.getType() == Type.SIG) {
             SIGRecord sig = (SIGRecord) rec;
             if (sig.getTypeCovered() == 0) sig0start = pos;
           }
         }
       }
     }
   } catch (WireParseException e) {
     if (!truncated) throw e;
   }
   size = in.current();
 }
Example #3
0
 void rrFromWire(DNSInput in) throws IOException {
   order = in.readU16();
   preference = in.readU16();
   flags = in.readCountedString();
   service = in.readCountedString();
   regexp = in.readCountedString();
   replacement = new Name(in);
 }
Example #4
0
 void rrFromWire(DNSInput in) throws IOException {
   host = new Name(in);
   admin = new Name(in);
   serial = in.readU32();
   refresh = in.readU32();
   retry = in.readU32();
   expire = in.readU32();
   minimum = in.readU32();
 }
Example #5
0
 void rrFromWire(DNSInput in) throws IOException {
   if (in.remaining() > 0) options = new ArrayList();
   while (in.remaining() > 0) {
     int code = in.readU16();
     int len = in.readU16();
     byte[] data = in.readByteArray(len);
     options.add(new Option(code, data));
   }
 }
  private static Record newRecord(
      Name name, int type, int dclass, long ttl, int length, DNSInput in) throws IOException {
    Record rec;
    int recstart;
    rec = getEmptyRecord(name, type, dclass, ttl, in != null);
    if (in != null) {
      if (in.remaining() < length) throw new WireParseException("truncated record");
      in.setActive(length);

      rec.rrFromWire(in);

      if (in.remaining() > 0) throw new WireParseException("invalid record length");
      in.clearActive();
    }
    return rec;
  }
  static Record fromWire(DNSInput in, int section, boolean isUpdate) throws IOException {
    int type, dclass;
    long ttl;
    int length;
    Name name;
    Record rec;

    name = new Name(in);
    type = in.readU16();
    dclass = in.readU16();

    if (section == Section.QUESTION) return newRecord(name, type, dclass);

    ttl = in.readU32();
    length = in.readU16();
    if (length == 0 && isUpdate) return newRecord(name, type, dclass, ttl);
    rec = newRecord(name, type, dclass, ttl, length, in);
    return rec;
  }
Example #8
0
  void rrFromWire(DNSInput in) throws IOException {
    hashAlg = in.readU8();
    flags = in.readU8();
    iterations = in.readU16();

    int salt_length = in.readU8();
    if (salt_length > 0) salt = in.readByteArray(salt_length);
    else salt = null;

    int next_length = in.readU8();
    next = in.readByteArray(next_length);
    types = new TypeBitmap(in);
  }
Example #9
0
  void rrFromWire(DNSInput in) throws IOException {
    int version;

    version = in.readU8();
    if (version != 0) throw new WireParseException("Invalid LOC version");

    size = parseLOCformat(in.readU8());
    hPrecision = parseLOCformat(in.readU8());
    vPrecision = parseLOCformat(in.readU8());
    latitude = in.readU32();
    longitude = in.readU32();
    altitude = in.readU32();
  }
Example #10
0
 public TypeBitmap(DNSInput in) throws WireParseException {
   this();
   int lastbase = -1;
   while (in.remaining() > 0) {
     if (in.remaining() < 2) throw new WireParseException("invalid bitmap descriptor");
     int mapbase = in.readU8();
     if (mapbase < lastbase) throw new WireParseException("invalid ordering");
     int maplength = in.readU8();
     if (maplength > in.remaining()) throw new WireParseException("invalid bitmap");
     for (int i = 0; i < maplength; i++) {
       int current = in.readU8();
       if (current == 0) continue;
       for (int j = 0; j < 8; j++) {
         if ((current & (1 << (7 - j))) == 0) continue;
         int typecode = mapbase * 256 + +i * 8 + j;
         types.add(Mnemonic.toInteger(typecode));
       }
     }
   }
 }
Example #11
0
 @Override
 void rrFromWire(DNSInput in) throws IOException {
   address = in.readByteArray();
 }
Example #12
0
 void rrFromWire(DNSInput in) throws IOException {
   certType = in.readU16();
   keyTag = in.readU16();
   alg = in.readU8();
   cert = in.readByteArray();
 }
Example #13
0
 void rrFromWire(DNSInput in) throws IOException {
   address = in.readCountedString();
   if (in.remaining() > 0) subAddress = in.readCountedString();
 }
Example #14
0
 void rrFromWire(DNSInput in) throws IOException {
   data = in.readByteArray();
 }
Example #15
0
 void rrFromWire(DNSInput in) throws IOException {
   addr = fromArray(in.readByteArray(4));
 }
 void rrFromWire(DNSInput in) throws IOException {
   u16Field = in.readU16();
   nameField = new Name(in);
 }
Example #17
0
 void rrFromWire(DNSInput in) throws IOException {
   address = InetAddress.getByAddress(name.toString(), in.readByteArray(16));
 }