1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19 */
20 package org.apache.directory.server.dhcp.service;
21
22
23 import java.net.InetAddress;
24
25 import org.apache.directory.server.dhcp.messages.HardwareAddress;
26 import org.apache.directory.server.dhcp.options.OptionsField;
27
28
29 /**
30 * Leases represent a temporary assignment of an IP address to a DHCP client.
31 *
32 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33 * @version $Rev: 545042 $, $Date: 2007-06-06 22:32:01 -0500 (Mi, 06 Jun 2007) $
34 */
35 public class Lease
36 {
37 /** Lease state: newly created */
38 public static final int STATE_NEW = 1;
39
40 /** Lease state: offered to client */
41 public static final int STATE_OFFERED = 2;
42
43 /** Lease state: active - assigned to client */
44 public static final int STATE_ACTIVE = 3;
45
46 /** Lease state: released by client */
47 public static final int STATE_RELEASED = 4;
48
49 /** Lease state: expired */
50 public static final int STATE_EXPIRED = 5;
51
52 /**
53 * The lease's state.
54 *
55 * @see #STATE_NEW
56 * @see #STATE_OFFERED
57 * @see #STATE_ACTIVE
58 * @see #STATE_RELEASED
59 * @see #STATE_EXPIRED
60 */
61 private int state;
62
63 /**
64 * The assigned client address.
65 */
66 private InetAddress clientAddress;
67
68 /**
69 * The client's hardware address.
70 */
71 private HardwareAddress hardwareAddress;
72
73 /**
74 * The next-server (boot-server) address.
75 */
76 private InetAddress nextServerAddress;
77
78 /**
79 * The DhcpOptions to provide to the client along with the lease.
80 */
81 private OptionsField options = new OptionsField();
82
83 private long acquired = -1;
84
85 private long expires = -1;
86
87
88 /**
89 * @return InetAddress
90 */
91 public InetAddress getClientAddress()
92 {
93 return clientAddress;
94 }
95
96
97 /**
98 * @return InetAddress
99 */
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 }