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.encoder; 022 023 024import org.apache.directory.server.dns.messages.ResourceRecord; 025import org.apache.directory.server.dns.store.DnsAttribute; 026import org.apache.mina.core.buffer.IoBuffer; 027 028 029/** 030 * 3.3.13. SOA RDATA format 031 * 032 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 033 * / MNAME / 034 * / / 035 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 036 * / RNAME / 037 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 038 * | SERIAL | 039 * | | 040 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 041 * | REFRESH | 042 * | | 043 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 044 * | RETRY | 045 * | | 046 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 047 * | EXPIRE | 048 * | | 049 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 050 * | MINIMUM | 051 * | | 052 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 053 * 054 * where: 055 * 056 * MNAME The <domain-name> of the name server that was the 057 * original or primary source of data for this zone. 058 * 059 * RNAME A <domain-name> which specifies the mailbox of the 060 * person responsible for this zone. 061 * 062 * SERIAL The unsigned 32 bit version number of the original copy 063 * of the zone. Zone transfers preserve this value. This 064 * value wraps and should be compared using sequence space 065 * arithmetic. 066 * 067 * REFRESH A 32 bit time interval before the zone should be 068 * refreshed. 069 * 070 * RETRY A 32 bit time interval that should elapse before a 071 * failed refresh should be retried. 072 * 073 * EXPIRE A 32 bit time value that specifies the upper limit on 074 * the time interval that can elapse before the zone is no 075 * longer authoritative. 076 * 077 * MINIMUM The unsigned 32 bit minimum TTL field that should be 078 * exported with any RR from this zone. 079 * 080 * SOA records cause no additional section processing. 081 * 082 * All times are in units of seconds. 083 * 084 * Most of these fields are pertinent only for name server maintenance 085 * operations. However, MINIMUM is used in all query operations that 086 * retrieve RRs from a zone. Whenever a RR is sent in a response to a 087 * query, the TTL field is set to the maximum of the TTL field from the RR 088 * and the MINIMUM field in the appropriate SOA. Thus MINIMUM is a lower 089 * bound on the TTL field for all RRs in a zone. Note that this use of 090 * MINIMUM should occur when the RRs are copied into the response and not 091 * when the zone is loaded from a master file or via a zone transfer. The 092 * reason for this provison is to allow future dynamic update facilities to 093 * change the SOA RR with known semantics. 094 * 095 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 096 */ 097public class StartOfAuthorityRecordEncoder extends ResourceRecordEncoder 098{ 099 protected void putResourceRecordData( IoBuffer byteBuffer, ResourceRecord record ) 100 { 101 String mName = record.get( DnsAttribute.SOA_M_NAME ); 102 String rName = record.get( DnsAttribute.SOA_R_NAME ); 103 long serial = Long.parseLong( record.get( DnsAttribute.SOA_SERIAL ) ); 104 int refresh = Integer.parseInt( record.get( DnsAttribute.SOA_REFRESH ) ); 105 int retry = Integer.parseInt( record.get( DnsAttribute.SOA_RETRY ) ); 106 int expire = Integer.parseInt( record.get( DnsAttribute.SOA_EXPIRE ) ); 107 long minimum = Long.parseLong( record.get( DnsAttribute.SOA_MINIMUM ) ); 108 109 putDomainName( byteBuffer, mName ); 110 putDomainName( byteBuffer, rName ); 111 112 byteBuffer.putInt( ( int ) serial ); 113 114 byteBuffer.putInt( refresh ); 115 byteBuffer.putInt( retry ); 116 byteBuffer.putInt( expire ); 117 118 byteBuffer.putInt( ( int ) minimum ); 119 } 120}