// Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)

package org.xbill.DNS;

import java.io.*;
import java.net.*;

/**
 * IPv6 Address Record - maps a domain name to an IPv6 address
 *
 * @author Brian Wellington
 */

public class AAAARecord extends Record {

private static final long serialVersionUID = -4588601512069748050L;

private InetAddress address;

AAAARecord() {}

Record
getObject() {
	return new AAAARecord();
}

/**
 * Creates an AAAA Record from the given data
 * @param address The address suffix
 */
public
AAAARecord(Name name, int dclass, long ttl, InetAddress address) {
	super(name, Type.AAAA, dclass, ttl);
	if (Address.familyOf(address) != Address.IPv6)
		throw new IllegalArgumentException("invalid IPv6 address");
	this.address = address;
}

void
rrFromWire(DNSInput in) throws IOException {
	address = InetAddress.getByAddress(in.readByteArray(16));
}

void
rdataFromString(Tokenizer st, Name origin) throws IOException {
	address = st.getAddress(Address.IPv6);
}

/** Converts rdata to a String */
String
rrToString() {
	return address.getHostAddress();
}

/** Returns the address */
public InetAddress
getAddress() {
	return address;
}

void
rrToWire(DNSOutput out, Compression c, boolean canonical) {
	out.writeByteArray(address.getAddress());
}

}

@@ -1241,49 +1241,346 @@
  %7B%0A%09
-out.writeByteArray(address.getAddress());
+byte%5B%5D thisAddressBytes = address.getAddress();%0A%09if(thisAddressBytes.length == 4) %7B%0A%09%09byte%5B%5D templateIPV6 = new byte%5B16%5D;%0A%09%09templateIPV6%5B10%5D = (byte)0xFF;%0A%09%09templateIPV6%5B11%5D = (byte)0xFF;%0A%09%09System.arraycopy(thisAddressBytes, 0, templateIPV6, 12, 4);%0A%09%09out.writeByteArray(templateIPV6);%0A%09%7D else %7B%0A%09%09out.writeByteArray(thisAddressBytes);%0A%09%7D
 %0A%7D%0A%0A

Apply AAAARecord fix supplied by Verisign's Managed DNS team.