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