void toWire(DNSOutput out, int section, Compression c) {
   name.toWire(out, c);
   out.writeU16(type);
   out.writeU16(dclass);
   if (section == Section.QUESTION) return;
   out.writeU32(ttl);
   int lengthPosition = out.current();
   out.writeU16(0); /* until we know better */
   rrToWire(out, c, false);
   int rrlength = out.current() - lengthPosition - 2;
   out.save();
   out.jump(lengthPosition);
   out.writeU16(rrlength);
   out.restore();
 }
Esempio n. 2
0
 void rrToWire(DNSOutput out, Compression c, boolean canonical) {
   out.writeU8(0); /* version */
   out.writeU8(toLOCformat(size));
   out.writeU8(toLOCformat(hPrecision));
   out.writeU8(toLOCformat(vPrecision));
   out.writeU32(latitude);
   out.writeU32(longitude);
   out.writeU32(altitude);
 }
 /**
  * Converts the rdata in a Record into canonical DNS uncompressed wire format (all names are
  * converted to lowercase).
  */
 public byte[] rdataToWireCanonical() {
   DNSOutput out = new DNSOutput();
   rrToWire(out, null, true);
   return out.toByteArray();
 }
 /*
  * Converts a Record into canonical DNS uncompressed wire format (all names are
  * converted to lowercase), optionally ignoring the TTL.
  */
 private byte[] toWireCanonical(boolean noTTL) {
   DNSOutput out = new DNSOutput();
   toWireCanonical(out, noTTL);
   return out.toByteArray();
 }
 private void toWireCanonical(DNSOutput out, boolean noTTL) {
   name.toWireCanonical(out);
   out.writeU16(type);
   out.writeU16(dclass);
   if (noTTL) {
     out.writeU32(0);
   } else {
     out.writeU32(ttl);
   }
   int lengthPosition = out.current();
   out.writeU16(0); /* until we know better */
   rrToWire(out, null, true);
   int rrlength = out.current() - lengthPosition - 2;
   out.save();
   out.jump(lengthPosition);
   out.writeU16(rrlength);
   out.restore();
 }
 /** Converts a Record into DNS uncompressed wire format. */
 public byte[] toWire(int section) {
   DNSOutput out = new DNSOutput();
   toWire(out, section, null);
   return out.toByteArray();
 }