1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.directory.server.dhcp.messages;
22
23
24 import java.net.InetAddress;
25
26 import org.apache.directory.server.dhcp.options.OptionsField;
27
28
29
30
31
32
33
34
35 public class DhcpMessage
36 {
37
38
39
40 public static final int FLAG_BROADCAST = 0x01;
41
42
43
44
45 private InetAddress assignedClientAddress;
46
47
48
49
50
51 private String bootFileName;
52
53
54
55
56
57 private InetAddress currentClientAddress;
58
59
60
61
62 private short flags;
63
64
65
66
67
68 private short hopCount;
69
70
71
72
73 private byte op;
74
75
76
77
78
79
80 public static final byte OP_BOOTREQUEST = 1;
81
82
83
84
85
86
87 public static final byte OP_BOOTREPLY = 2;
88
89
90
91
92
93 private InetAddress nextServerAddress;
94
95
96
97
98
99 private OptionsFieldhcp/options/OptionsField.html#OptionsField">OptionsField options = new OptionsField();
100
101
102
103
104 private InetAddress relayAgentAddress;
105
106
107
108
109
110 private int seconds;
111
112
113
114
115 private String serverHostname;
116
117
118
119
120
121
122 private int transactionId;
123
124
125
126
127 private MessageType messageType;
128
129 private HardwareAddress hardwareAddress;
130
131
132
133
134
135 public DhcpMessage()
136 {
137
138 }
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159 public DhcpMessage( MessageType messageType, byte op,
160 HardwareAddress hardwareAddress, short hops, int transactionId,
161 int seconds, short flags, InetAddress currentClientAddress,
162 InetAddress assignedClientAddress, InetAddress nextServerAddress,
163 InetAddress relayAgentAddress, String serverHostname,
164 String bootFileName, OptionsField options )
165 {
166 this.messageType = messageType;
167 this.op = op;
168 this.hardwareAddress = hardwareAddress;
169 this.hopCount = hops;
170 this.transactionId = transactionId;
171 this.seconds = seconds;
172 this.flags = flags;
173 this.currentClientAddress = currentClientAddress;
174 this.assignedClientAddress = assignedClientAddress;
175 this.nextServerAddress = nextServerAddress;
176 this.relayAgentAddress = relayAgentAddress;
177 this.serverHostname = serverHostname;
178 this.bootFileName = bootFileName;
179 this.options = options;
180 }
181
182
183 public InetAddress getAssignedClientAddress()
184 {
185 return assignedClientAddress;
186 }
187
188
189 public String getBootFileName()
190 {
191 return bootFileName;
192 }
193
194
195 public InetAddress getCurrentClientAddress()
196 {
197 return currentClientAddress;
198 }
199
200
201 public short getFlags()
202 {
203 return flags;
204 }
205
206
207 public short getHopCount()
208 {
209 return hopCount;
210 }
211
212
213 public MessageType getMessageType()
214 {
215 return messageType;
216 }
217
218
219 public InetAddress getNextServerAddress()
220 {
221 return nextServerAddress;
222 }
223
224
225 public OptionsField getOptions()
226 {
227 return options;
228 }
229
230
231 public InetAddress getRelayAgentAddress()
232 {
233 return relayAgentAddress;
234 }
235
236
237 public int getSeconds()
238 {
239 return seconds;
240 }
241
242
243 public String getServerHostname()
244 {
245 return serverHostname;
246 }
247
248
249 public int getTransactionId()
250 {
251 return transactionId;
252 }
253
254
255 public void setAssignedClientAddress( InetAddress assignedClientAddress )
256 {
257 this.assignedClientAddress = assignedClientAddress;
258 }
259
260
261 public void setBootFileName( String bootFileName )
262 {
263 this.bootFileName = bootFileName;
264 }
265
266
267 public void setCurrentClientAddress( InetAddress currentClientAddress )
268 {
269 this.currentClientAddress = currentClientAddress;
270 }
271
272
273 public void setFlags( short flags )
274 {
275 this.flags = flags;
276 }
277
278
279 public void setHopCount( short hopCount )
280 {
281 this.hopCount = hopCount;
282 }
283
284
285 public void setMessageType( MessageType messageType )
286 {
287 this.messageType = messageType;
288 }
289
290
291 public void setNextServerAddress( InetAddress nextServerAddress )
292 {
293 this.nextServerAddress = nextServerAddress;
294 }
295
296
297 public void setOptions( OptionsField options )
298 {
299 this.options = options;
300 }
301
302
303 public void setRelayAgentAddress( InetAddress relayAgentAddress )
304 {
305 this.relayAgentAddress = relayAgentAddress;
306 }
307
308
309 public void setSeconds( int seconds )
310 {
311 this.seconds = seconds;
312 }
313
314
315 public void setServerHostname( String serverHostname )
316 {
317 this.serverHostname = serverHostname;
318 }
319
320
321 public void setTransactionId( int transactionId )
322 {
323 this.transactionId = transactionId;
324 }
325
326
327 public byte getOp()
328 {
329 return op;
330 }
331
332
333 public void setOp( byte op )
334 {
335 this.op = op;
336 }
337
338
339 public HardwareAddress getHardwareAddress()
340 {
341 return hardwareAddress;
342 }
343
344
345 public void setHardwareAddress( HardwareAddress hardwareAddress )
346 {
347 this.hardwareAddress = hardwareAddress;
348 }
349
350
351 public String toString()
352 {
353 StringBuilder sb = new StringBuilder();
354 sb.append( messageType ).append( ": hwAddress=" ).append( hardwareAddress )
355 .append( ", tx=" ).append( transactionId ).append( ", options=" ).append(
356 options );
357
358 return sb.toString();
359 }
360 }