001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020 021package org.apache.directory.server.dns.io.decoder; 022 023 024import java.io.IOException; 025import java.net.InetAddress; 026import java.util.HashMap; 027import java.util.Map; 028 029import org.apache.directory.api.util.Strings; 030import org.apache.directory.server.dns.store.DnsAttribute; 031import org.apache.mina.core.buffer.IoBuffer; 032 033 034/** 035 * A decoder for AAAA records. AAAA records are encoded as per RFC-3596: 036 * 037 * <pre> 038 * 2.2. AAAA data format 039 * 040 * A 128 bit IPv6 address is encoded in the data portion of an AAAA 041 * resource record in network byte order (high-order byte first). 042 * </pre> 043 * 044 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 045 */ 046public class IPv6RecordDecoder implements RecordDecoder 047{ 048 049 public Map<String, Object> decode( IoBuffer byteBuffer, short length ) throws IOException 050 { 051 Map<String, Object> attributes = new HashMap<>(); 052 byte[] addressBytes = new byte[length]; 053 byteBuffer.get( addressBytes ); 054 attributes.put( Strings.toLowerCaseAscii( DnsAttribute.IP_ADDRESS ), InetAddress.getByAddress( addressBytes ) ); 055 056 return attributes; 057 } 058 059}