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