Exemple #1
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();
 }
Exemple #2
0
 Record rdataFromString(Name name, short dclass, int ttl, MyStringTokenizer st, Name origin)
     throws TextParseException {
   SIGRecord rec = new SIGRecord(name, dclass, ttl);
   rec.covered = Type.value(st.nextToken());
   rec.alg = Byte.parseByte(st.nextToken());
   rec.labels = Byte.parseByte(st.nextToken());
   rec.origttl = TTL.parseTTL(st.nextToken());
   rec.expire = parseDate(st.nextToken());
   rec.timeSigned = parseDate(st.nextToken());
   rec.footprint = (short) Integer.parseInt(st.nextToken());
   rec.signer = Name.fromString(st.nextToken(), origin);
   if (st.hasMoreTokens()) rec.signature = base64.fromString(st.remainingTokens());
   return rec;
 }
Exemple #3
0
 Record rrFromWire(
     Name name, short type, short dclass, int ttl, int length, DataByteInputStream in)
     throws IOException {
   SIGRecord rec = new SIGRecord(name, dclass, ttl);
   if (in == null) return rec;
   int start = in.getPos();
   rec.covered = in.readShort();
   rec.alg = in.readByte();
   rec.labels = in.readByte();
   rec.origttl = in.readInt();
   rec.expire = new Date(1000 * (long) in.readInt());
   rec.timeSigned = new Date(1000 * (long) in.readInt());
   rec.footprint = in.readShort();
   rec.signer = new Name(in);
   rec.signature = new byte[length - (in.getPos() - start)];
   in.read(rec.signature);
   return rec;
 }