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 package org.apache.directory.server.dhcp.service; 021 022 023 import java.net.InetAddress; 024 025 import org.apache.directory.server.dhcp.messages.HardwareAddress; 026 import org.apache.directory.server.dhcp.options.OptionsField; 027 028 029 /** 030 * Leases represent a temporary assignment of an IP address to a DHCP client. 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 * @version $Rev: 545042 $, $Date: 2007-06-06 22:32:01 -0500 (Mi, 06 Jun 2007) $ 034 */ 035 public class Lease 036 { 037 /** Lease state: newly created */ 038 public static final int STATE_NEW = 1; 039 040 /** Lease state: offered to client */ 041 public static final int STATE_OFFERED = 2; 042 043 /** Lease state: active - assigned to client */ 044 public static final int STATE_ACTIVE = 3; 045 046 /** Lease state: released by client */ 047 public static final int STATE_RELEASED = 4; 048 049 /** Lease state: expired */ 050 public static final int STATE_EXPIRED = 5; 051 052 /** 053 * The lease's state. 054 * 055 * @see #STATE_NEW 056 * @see #STATE_OFFERED 057 * @see #STATE_ACTIVE 058 * @see #STATE_RELEASED 059 * @see #STATE_EXPIRED 060 */ 061 private int state; 062 063 /** 064 * The assigned client address. 065 */ 066 private InetAddress clientAddress; 067 068 /** 069 * The client's hardware address. 070 */ 071 private HardwareAddress hardwareAddress; 072 073 /** 074 * The next-server (boot-server) address. 075 */ 076 private InetAddress nextServerAddress; 077 078 /** 079 * The DhcpOptions to provide to the client along with the lease. 080 */ 081 private OptionsField options = new OptionsField(); 082 083 private long acquired = -1; 084 085 private long expires = -1; 086 087 088 /** 089 * @return InetAddress 090 */ 091 public InetAddress getClientAddress() 092 { 093 return clientAddress; 094 } 095 096 097 /** 098 * @return InetAddress 099 */ 100 public InetAddress getNextServerAddress() 101 { 102 return nextServerAddress; 103 } 104 105 106 /** 107 * @return OptionsField 108 */ 109 public OptionsField getOptions() 110 { 111 return options; 112 } 113 114 115 /** 116 * @return int 117 */ 118 public int getState() 119 { 120 return state; 121 } 122 123 124 /** 125 * @param state 126 */ 127 public void setState( int state ) 128 { 129 this.state = state; 130 } 131 132 133 public HardwareAddress getHardwareAddress() 134 { 135 return hardwareAddress; 136 } 137 138 139 public void setHardwareAddress( HardwareAddress hardwareAddress ) 140 { 141 this.hardwareAddress = hardwareAddress; 142 } 143 144 145 public long getAcquired() 146 { 147 return acquired; 148 } 149 150 151 public void setAcquired( long acquired ) 152 { 153 this.acquired = acquired; 154 } 155 156 157 public long getExpires() 158 { 159 return expires; 160 } 161 162 163 public void setExpires( long expires ) 164 { 165 this.expires = expires; 166 } 167 168 169 public void setClientAddress( InetAddress clientAddress ) 170 { 171 this.clientAddress = clientAddress; 172 } 173 174 }