1// Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
2
3package org.xbill.DNS;
4
5import java.io.*;
6import java.net.*;
7
8/**
9 * IPv6 Address Record - maps a domain name to an IPv6 address
10 *
11 * @author Brian Wellington
12 */
13
14public class AAAARecord extends Record {
15
16private static final long serialVersionUID = -4588601512069748050L;
17
18private InetAddress address;
19
20AAAARecord() {}
21
22Record
23getObject() {
24	return new AAAARecord();
25}
26
27/**
28 * Creates an AAAA Record from the given data
29 * @param address The address suffix
30 */
31public
32AAAARecord(Name name, int dclass, long ttl, InetAddress address) {
33	super(name, Type.AAAA, dclass, ttl);
34	if (Address.familyOf(address) != Address.IPv6)
35		throw new IllegalArgumentException("invalid IPv6 address");
36	this.address = address;
37}
38
39void
40rrFromWire(DNSInput in) throws IOException {
41	address = InetAddress.getByAddress(name.toString(),
42					   in.readByteArray(16));
43}
44
45void
46rdataFromString(Tokenizer st, Name origin) throws IOException {
47	address = st.getAddress(Address.IPv6);
48}
49
50/** Converts rdata to a String */
51String
52rrToString() {
53	return address.getHostAddress();
54}
55
56/** Returns the address */
57public InetAddress
58getAddress() {
59	return address;
60}
61
62void
63rrToWire(DNSOutput out, Compression c, boolean canonical) {
64	out.writeByteArray(address.getAddress());
65}
66
67}
68