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 import java.net.InetAddress;
24
25 import org.apache.directory.server.dhcp.options.OptionsField;
26
27
28
29
30
31
32
33
34 public class DhcpMessage {
35
36
37
38 public static final int FLAG_BROADCAST = 0x01;
39
40
41
42
43 private InetAddress assignedClientAddress;
44
45
46
47
48
49 private String bootFileName;
50
51
52
53
54
55 private InetAddress currentClientAddress;
56
57
58
59
60 private short flags;
61
62
63
64
65
66 private short hopCount;
67
68
69
70
71 private byte op;
72
73
74
75
76
77
78 public static final byte OP_BOOTREQUEST = 1;
79
80
81
82
83
84
85 public static final byte OP_BOOTREPLY = 2;
86
87
88
89
90
91 private InetAddress nextServerAddress;
92
93
94
95
96
97 private OptionsField options = new OptionsField();
98
99
100
101
102 private InetAddress relayAgentAddress;
103
104
105
106
107
108 private int seconds;
109
110
111
112
113 private String serverHostname;
114
115
116
117
118
119
120 private int transactionId;
121
122
123
124
125 private MessageType messageType;
126
127 private HardwareAddress hardwareAddress;
128
129
130
131
132 public DhcpMessage() {
133
134 }
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154 public DhcpMessage(MessageType messageType, byte op,
155 HardwareAddress hardwareAddress, short hops, int transactionId,
156 int seconds, short flags, InetAddress currentClientAddress,
157 InetAddress assignedClientAddress, InetAddress nextServerAddress,
158 InetAddress relayAgentAddress, String serverHostname,
159 String bootFileName, OptionsField options) {
160 this.messageType = messageType;
161 this.op = op;
162 this.hardwareAddress = hardwareAddress;
163 this.hopCount = hops;
164 this.transactionId = transactionId;
165 this.seconds = seconds;
166 this.flags = flags;
167 this.currentClientAddress = currentClientAddress;
168 this.assignedClientAddress = assignedClientAddress;
169 this.nextServerAddress = nextServerAddress;
170 this.relayAgentAddress = relayAgentAddress;
171 this.serverHostname = serverHostname;
172 this.bootFileName = bootFileName;
173 this.options = options;
174 }
175
176 public InetAddress getAssignedClientAddress() {
177 return assignedClientAddress;
178 }
179
180 public String getBootFileName() {
181 return bootFileName;
182 }
183
184 public InetAddress getCurrentClientAddress() {
185 return currentClientAddress;
186 }
187
188 public short getFlags() {
189 return flags;
190 }
191
192 public short getHopCount() {
193 return hopCount;
194 }
195
196 public MessageType getMessageType() {
197 return messageType;
198 }
199
200 public InetAddress getNextServerAddress() {
201 return nextServerAddress;
202 }
203
204 public OptionsField getOptions() {
205 return options;
206 }
207
208 public InetAddress getRelayAgentAddress() {
209 return relayAgentAddress;
210 }
211
212 public int getSeconds() {
213 return seconds;
214 }
215
216 public String getServerHostname() {
217 return serverHostname;
218 }
219
220 public int getTransactionId() {
221 return transactionId;
222 }
223
224 public void setAssignedClientAddress(InetAddress assignedClientAddress) {
225 this.assignedClientAddress = assignedClientAddress;
226 }
227
228 public void setBootFileName(String bootFileName) {
229 this.bootFileName = bootFileName;
230 }
231
232 public void setCurrentClientAddress(InetAddress currentClientAddress) {
233 this.currentClientAddress = currentClientAddress;
234 }
235
236 public void setFlags(short flags) {
237 this.flags = flags;
238 }
239
240 public void setHopCount(short hopCount) {
241 this.hopCount = hopCount;
242 }
243
244 public void setMessageType(MessageType messageType) {
245 this.messageType = messageType;
246 }
247
248 public void setNextServerAddress(InetAddress nextServerAddress) {
249 this.nextServerAddress = nextServerAddress;
250 }
251
252 public void setOptions(OptionsField options) {
253 this.options = options;
254 }
255
256 public void setRelayAgentAddress(InetAddress relayAgentAddress) {
257 this.relayAgentAddress = relayAgentAddress;
258 }
259
260 public void setSeconds(int seconds) {
261 this.seconds = seconds;
262 }
263
264 public void setServerHostname(String serverHostname) {
265 this.serverHostname = serverHostname;
266 }
267
268 public void setTransactionId(int transactionId) {
269 this.transactionId = transactionId;
270 }
271
272 public byte getOp() {
273 return op;
274 }
275
276 public void setOp(byte op) {
277 this.op = op;
278 }
279
280 public HardwareAddress getHardwareAddress() {
281 return hardwareAddress;
282 }
283
284 public void setHardwareAddress(HardwareAddress hardwareAddress) {
285 this.hardwareAddress = hardwareAddress;
286 }
287
288 public String toString() {
289 StringBuilder sb = new StringBuilder();
290 sb.append(messageType).append(": hwAddress=").append(hardwareAddress)
291 .append(", tx=").append(transactionId).append(", options=").append(
292 options);
293
294 return sb.toString();
295 }
296 }