Home | History | Annotate | Download | only in DNS
      1 // Copyright (c) 1999-2004 Brian Wellington (bwelling (at) xbill.org)
      2 
      3 package org.xbill.DNS;
      4 
      5 import java.io.*;
      6 import java.net.*;
      7 
      8 /**
      9  * 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 static final long serialVersionUID = -4588601512069748050L;
     17 
     18 private InetAddress address;
     19 
     20 AAAARecord() {}
     21 
     22 Record
     23 getObject() {
     24 	return new AAAARecord();
     25 }
     26 
     27 /**
     28  * Creates an AAAA Record from the given data
     29  * @param address The address suffix
     30  */
     31 public
     32 AAAARecord(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 
     39 void
     40 rrFromWire(DNSInput in) throws IOException {
     41 	address = InetAddress.getByAddress(name.toString(),
     42 					   in.readByteArray(16));
     43 }
     44 
     45 void
     46 rdataFromString(Tokenizer st, Name origin) throws IOException {
     47 	address = st.getAddress(Address.IPv6);
     48 }
     49 
     50 /** Converts rdata to a String */
     51 String
     52 rrToString() {
     53 	return address.getHostAddress();
     54 }
     55 
     56 /** Returns the address */
     57 public InetAddress
     58 getAddress() {
     59 	return address;
     60 }
     61 
     62 void
     63 rrToWire(DNSOutput out, Compression c, boolean canonical) {
     64 	out.writeByteArray(address.getAddress());
     65 }
     66 
     67 }
     68