A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
dhcp-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 UPB
3
* Copyright (c) 2017 NITK Surathkal
4
*
5
* SPDX-License-Identifier: GPL-2.0-only
6
*
7
* Author: Radu Lupu <rlupu@elcom.pub.ro>
8
* Ankit Deepak <adadeepak8@gmail.com>
9
* Deepti Rajagopal <deeptir96@gmail.com>
10
*
11
*/
12
13
#include "
dhcp-header.h
"
14
15
#include "ns3/address-utils.h"
16
#include "ns3/assert.h"
17
#include "ns3/log.h"
18
#include "ns3/simulator.h"
19
20
#include <iomanip>
21
#include <sstream>
22
23
/**
24
* @file
25
* @ingroup internet-apps
26
* DhcpHeader classes implementation.
27
*/
28
29
namespace
ns3
30
{
31
32
NS_LOG_COMPONENT_DEFINE
(
"DhcpHeader"
);
33
NS_OBJECT_ENSURE_REGISTERED
(
DhcpHeader
);
34
35
std::string
36
DhcpChaddrToString
(
const
DhcpChaddr
& chaddr)
37
{
38
std::ostringstream outStream;
39
outStream.fill(
'0'
);
40
outStream.setf(std::ios::hex, std::ios::basefield);
41
42
for
(std::size_t i = 0; i < chaddr.size(); ++i)
43
{
44
outStream << std::setw(2) << (
uint32_t
)chaddr[i] << (i < chaddr.size() - 1 ?
":"
:
""
);
45
}
46
return
outStream.str();
47
}
48
49
DhcpHeader::DhcpHeader
()
50
{
51
m_hType
= 1;
52
m_hLen
= 6;
53
m_xid
= 0;
54
m_secs
= 0;
55
m_hops
= 0;
56
m_flags
= 0;
57
Ipv4Address
addr(
"0.0.0.0"
);
58
m_yiAddr
= addr;
59
m_ciAddr
= addr;
60
m_siAddr
= addr;
61
m_giAddr
= addr;
62
m_dhcps
= addr;
63
m_req
= addr;
64
m_route
= addr;
65
m_len
= 240;
66
67
uint32_t
i;
68
69
for
(i = 0; i < 64; i++)
70
{
71
m_sname
[i] = 0;
72
}
73
for
(i = 0; i < 128; i++)
74
{
75
m_file
[i] = 0;
76
}
77
m_magic_cookie
[0] = 99;
78
m_magic_cookie
[1] = 130;
79
m_magic_cookie
[2] = 83;
80
m_magic_cookie
[3] = 99;
81
}
82
83
DhcpHeader::~DhcpHeader
()
84
{
85
}
86
87
void
88
DhcpHeader::SetType
(uint8_t type)
89
{
90
if
(!
m_opt
[
OP_MSGTYPE
])
91
{
92
m_len
+= 3;
93
m_opt
[
OP_MSGTYPE
] =
true
;
94
}
95
m_op
= type;
96
m_bootp
= (
m_op
== 0 ||
m_op
== 2) ? 1 : 2;
97
}
98
99
uint8_t
100
DhcpHeader::GetType
()
const
101
{
102
return
m_op
;
103
}
104
105
void
106
DhcpHeader::SetHWType
(uint8_t htype, uint8_t hlen)
107
{
108
m_hType
= htype;
109
m_hLen
= hlen;
110
}
111
112
void
113
DhcpHeader::SetTran
(
uint32_t
tran)
114
{
115
m_xid
= tran;
116
}
117
118
uint32_t
119
DhcpHeader::GetTran
()
const
120
{
121
return
m_xid
;
122
}
123
124
void
125
DhcpHeader::SetTime
()
126
{
127
m_secs
= (uint16_t)
Simulator::Now
().GetSeconds();
128
}
129
130
void
131
DhcpHeader::SetChaddr
(
DhcpChaddr
addr)
132
{
133
m_chaddr
= addr;
134
}
135
136
DhcpChaddr
137
DhcpHeader::GetChaddr
()
138
{
139
return
m_chaddr
;
140
}
141
142
void
143
DhcpHeader::SetYiaddr
(
Ipv4Address
addr)
144
{
145
m_yiAddr
= addr;
146
}
147
148
Ipv4Address
149
DhcpHeader::GetYiaddr
()
const
150
{
151
return
m_yiAddr
;
152
}
153
154
void
155
DhcpHeader::SetDhcps
(
Ipv4Address
addr)
156
{
157
if
(!
m_opt
[
OP_SERVID
])
158
{
159
m_len
+= 6;
160
m_opt
[
OP_SERVID
] =
true
;
161
}
162
m_dhcps
= addr;
163
}
164
165
Ipv4Address
166
DhcpHeader::GetDhcps
()
const
167
{
168
return
m_dhcps
;
169
}
170
171
void
172
DhcpHeader::SetReq
(
Ipv4Address
addr)
173
{
174
if
(!
m_opt
[
OP_ADDREQ
])
175
{
176
m_len
+= 6;
177
m_opt
[
OP_ADDREQ
] =
true
;
178
}
179
m_req
= addr;
180
}
181
182
Ipv4Address
183
DhcpHeader::GetReq
()
const
184
{
185
return
m_req
;
186
}
187
188
void
189
DhcpHeader::SetMask
(
uint32_t
addr)
190
{
191
if
(!
m_opt
[
OP_MASK
])
192
{
193
m_len
+= 6;
194
m_opt
[
OP_MASK
] =
true
;
195
}
196
m_mask
= addr;
197
}
198
199
uint32_t
200
DhcpHeader::GetMask
()
const
201
{
202
return
m_mask
;
203
}
204
205
void
206
DhcpHeader::SetRouter
(
Ipv4Address
addr)
207
{
208
if
(!
m_opt
[
OP_ROUTE
])
209
{
210
m_len
+= 6;
211
m_opt
[
OP_ROUTE
] =
true
;
212
}
213
m_route
= addr;
214
}
215
216
Ipv4Address
217
DhcpHeader::GetRouter
()
const
218
{
219
return
m_route
;
220
}
221
222
void
223
DhcpHeader::SetLease
(
uint32_t
time)
224
{
225
if
(!
m_opt
[
OP_LEASE
])
226
{
227
m_len
+= 6;
228
m_opt
[
OP_LEASE
] =
true
;
229
}
230
m_lease
= time;
231
}
232
233
uint32_t
234
DhcpHeader::GetLease
()
const
235
{
236
return
m_lease
;
237
}
238
239
void
240
DhcpHeader::SetRenew
(
uint32_t
time)
241
{
242
if
(!
m_opt
[
OP_RENEW
])
243
{
244
m_len
+= 6;
245
m_opt
[
OP_RENEW
] =
true
;
246
}
247
m_renew
= time;
248
}
249
250
uint32_t
251
DhcpHeader::GetRenew
()
const
252
{
253
return
m_renew
;
254
}
255
256
void
257
DhcpHeader::SetRebind
(
uint32_t
time)
258
{
259
if
(!
m_opt
[
OP_REBIND
])
260
{
261
m_len
+= 6;
262
m_opt
[
OP_REBIND
] =
true
;
263
}
264
m_rebind
= time;
265
}
266
267
uint32_t
268
DhcpHeader::GetRebind
()
const
269
{
270
return
m_rebind
;
271
}
272
273
void
274
DhcpHeader::ResetOpt
()
275
{
276
m_len
= 241;
277
int
i;
278
for
(i = 0; i <
OP_END
; i++)
279
{
280
m_opt
[i] =
false
;
281
}
282
}
283
284
uint32_t
285
DhcpHeader::GetSerializedSize
()
const
286
{
287
return
m_len
;
288
}
289
290
TypeId
291
DhcpHeader::GetTypeId
()
292
{
293
static
TypeId
tid =
TypeId
(
"ns3::DhcpHeader"
)
294
.
SetParent
<
Header
>()
295
.SetGroupName(
"Internet-Apps"
)
296
.AddConstructor<
DhcpHeader
>();
297
return
tid;
298
}
299
300
TypeId
301
DhcpHeader::GetInstanceTypeId
()
const
302
{
303
return
GetTypeId
();
304
}
305
306
void
307
DhcpHeader::Print
(std::ostream& os)
const
308
{
309
os <<
"(type="
<<
m_op
<<
")"
;
310
}
311
312
void
313
DhcpHeader::Serialize
(
Buffer::Iterator
start)
const
314
{
315
Buffer::Iterator
i = start;
316
i.
WriteU8
(
m_bootp
);
317
i.
WriteU8
(
m_hType
);
318
i.
WriteU8
(
m_hLen
);
319
i.
WriteU8
(
m_hops
);
320
i.
WriteU32
(
m_xid
);
321
i.
WriteHtonU16
(
m_secs
);
322
i.
WriteU16
(
m_flags
);
323
WriteTo
(i,
m_ciAddr
);
324
WriteTo
(i,
m_yiAddr
);
325
WriteTo
(i,
m_siAddr
);
326
WriteTo
(i,
m_giAddr
);
327
i.
Write
(
m_chaddr
.data(), 16);
328
i.
Write
(
m_sname
, 64);
329
i.
Write
(
m_file
, 128);
330
i.
Write
(
m_magic_cookie
, 4);
331
if
(
m_opt
[
OP_MASK
])
332
{
333
i.
WriteU8
(
OP_MASK
);
334
i.
WriteU8
(4);
335
i.
WriteHtonU32
(
m_mask
);
336
}
337
if
(
m_opt
[
OP_MSGTYPE
])
338
{
339
i.
WriteU8
(
OP_MSGTYPE
);
340
i.
WriteU8
(1);
341
i.
WriteU8
(
m_op
+ 1);
342
}
343
if
(
m_opt
[
OP_ADDREQ
])
344
{
345
i.
WriteU8
(
OP_ADDREQ
);
346
i.
WriteU8
(4);
347
WriteTo
(i,
m_req
);
348
}
349
if
(
m_opt
[
OP_SERVID
])
350
{
351
i.
WriteU8
(
OP_SERVID
);
352
i.
WriteU8
(4);
353
WriteTo
(i,
m_dhcps
);
354
}
355
if
(
m_opt
[
OP_ROUTE
])
356
{
357
i.
WriteU8
(
OP_ROUTE
);
358
i.
WriteU8
(4);
359
WriteTo
(i,
m_route
);
360
}
361
if
(
m_opt
[
OP_LEASE
])
362
{
363
i.
WriteU8
(
OP_LEASE
);
364
i.
WriteU8
(4);
365
i.
WriteHtonU32
(
m_lease
);
366
}
367
if
(
m_opt
[
OP_RENEW
])
368
{
369
i.
WriteU8
(
OP_RENEW
);
370
i.
WriteU8
(4);
371
i.
WriteHtonU32
(
m_renew
);
372
}
373
if
(
m_opt
[
OP_REBIND
])
374
{
375
i.
WriteU8
(
OP_REBIND
);
376
i.
WriteU8
(4);
377
i.
WriteHtonU32
(
m_rebind
);
378
}
379
i.
WriteU8
(
OP_END
);
380
}
381
382
uint32_t
383
DhcpHeader::Deserialize
(
Buffer::Iterator
start)
384
{
385
uint32_t
len;
386
uint32_t
cLen = start.GetSize();
387
if
(cLen < 240)
388
{
389
NS_LOG_WARN
(
"Malformed Packet"
);
390
return
0;
391
}
392
Buffer::Iterator
i = start;
393
m_bootp
= i.
ReadU8
();
394
m_hType
= i.
ReadU8
();
395
m_hLen
= i.
ReadU8
();
396
m_hops
= i.
ReadU8
();
397
m_xid
= i.
ReadU32
();
398
m_secs
= i.
ReadNtohU16
();
399
m_flags
= i.
ReadU16
();
400
ReadFrom
(i,
m_ciAddr
);
401
ReadFrom
(i,
m_yiAddr
);
402
ReadFrom
(i,
m_siAddr
);
403
ReadFrom
(i,
m_giAddr
);
404
i.
Read
(
m_chaddr
.data(), 16);
405
i.
Read
(
m_sname
, 64);
406
i.
Read
(
m_file
, 128);
407
i.
Read
(
m_magic_cookie
, 4);
408
if
(
m_magic_cookie
[0] != 99 ||
m_magic_cookie
[1] != 130 ||
m_magic_cookie
[2] != 83 ||
409
m_magic_cookie
[3] != 99)
410
{
411
NS_LOG_WARN
(
"Malformed Packet"
);
412
return
0;
413
}
414
len = 240;
415
uint8_t option;
416
bool
loop =
true
;
417
do
418
{
419
if
(len + 1 <= cLen)
420
{
421
option = i.
ReadU8
();
422
len += 1;
423
}
424
else
425
{
426
NS_LOG_WARN
(
"Malformed Packet"
);
427
return
0;
428
}
429
switch
(option)
430
{
431
case
OP_MASK
:
432
if
(len + 5 < cLen)
433
{
434
i.
ReadU8
();
435
m_mask
= i.
ReadNtohU32
();
436
len += 5;
437
}
438
else
439
{
440
NS_LOG_WARN
(
"Malformed Packet"
);
441
return
0;
442
}
443
break
;
444
case
OP_ROUTE
:
445
if
(len + 5 < cLen)
446
{
447
i.
ReadU8
();
448
ReadFrom
(i,
m_route
);
449
len += 5;
450
}
451
else
452
{
453
NS_LOG_WARN
(
"Malformed Packet"
);
454
return
0;
455
}
456
break
;
457
case
OP_MSGTYPE
:
458
if
(len + 2 < cLen)
459
{
460
i.
ReadU8
();
461
m_op
= (i.
ReadU8
() - 1);
462
len += 2;
463
}
464
else
465
{
466
NS_LOG_WARN
(
"Malformed Packet"
);
467
return
0;
468
}
469
break
;
470
case
OP_SERVID
:
471
if
(len + 5 < cLen)
472
{
473
i.
ReadU8
();
474
ReadFrom
(i,
m_dhcps
);
475
len += 5;
476
}
477
else
478
{
479
NS_LOG_WARN
(
"Malformed Packet"
);
480
return
0;
481
}
482
break
;
483
case
OP_ADDREQ
:
484
if
(len + 5 < cLen)
485
{
486
i.
ReadU8
();
487
ReadFrom
(i,
m_req
);
488
len += 5;
489
}
490
else
491
{
492
NS_LOG_WARN
(
"Malformed Packet"
);
493
return
0;
494
}
495
break
;
496
case
OP_LEASE
:
497
if
(len + 5 < cLen)
498
{
499
i.
ReadU8
();
500
m_lease
= i.
ReadNtohU32
();
501
len += 5;
502
}
503
else
504
{
505
NS_LOG_WARN
(
"Malformed Packet"
);
506
return
0;
507
}
508
break
;
509
case
OP_RENEW
:
510
if
(len + 5 < cLen)
511
{
512
i.
ReadU8
();
513
m_renew
= i.
ReadNtohU32
();
514
len += 5;
515
}
516
else
517
{
518
NS_LOG_WARN
(
"Malformed Packet"
);
519
return
0;
520
}
521
break
;
522
case
OP_REBIND
:
523
if
(len + 5 < cLen)
524
{
525
i.
ReadU8
();
526
m_rebind
= i.
ReadNtohU32
();
527
len += 5;
528
}
529
else
530
{
531
NS_LOG_WARN
(
"Malformed Packet"
);
532
return
0;
533
}
534
break
;
535
case
OP_END
:
536
loop =
false
;
537
break
;
538
default
:
539
NS_LOG_WARN
(
"Malformed Packet"
);
540
return
0;
541
}
542
}
while
(loop);
543
544
m_len
= len;
545
return
m_len
;
546
}
547
548
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Buffer::Iterator::WriteU32
void WriteU32(uint32_t data)
Definition
buffer.cc:857
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8()
Definition
buffer.h:1016
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition
buffer.h:870
ns3::Buffer::Iterator::Write
void Write(const uint8_t *buffer, uint32_t size)
Definition
buffer.cc:937
ns3::Buffer::Iterator::WriteU16
void WriteU16(uint16_t data)
Definition
buffer.cc:848
ns3::Buffer::Iterator::Read
void Read(uint8_t *buffer, uint32_t size)
Definition
buffer.cc:1114
ns3::Buffer::Iterator::WriteHtonU16
void WriteHtonU16(uint16_t data)
Definition
buffer.h:904
ns3::Buffer::Iterator::ReadNtohU32
uint32_t ReadNtohU32()
Definition
buffer.h:967
ns3::Buffer::Iterator::ReadU32
uint32_t ReadU32()
Definition
buffer.cc:955
ns3::Buffer::Iterator::WriteHtonU32
void WriteHtonU32(uint32_t data)
Definition
buffer.h:922
ns3::Buffer::Iterator::ReadNtohU16
uint16_t ReadNtohU16()
Definition
buffer.h:943
ns3::Buffer::Iterator::ReadU16
uint16_t ReadU16()
Definition
buffer.h:1024
ns3::DhcpHeader
BOOTP header with DHCP messages.
Definition
dhcp-header.h:99
ns3::DhcpHeader::GetLease
uint32_t GetLease() const
Return the lease time of the IPv4Address.
Definition
dhcp-header.cc:234
ns3::DhcpHeader::SetTime
void SetTime()
Set the time when message is sent.
Definition
dhcp-header.cc:125
ns3::DhcpHeader::m_ciAddr
Ipv4Address m_ciAddr
The IP address of the client.
Definition
dhcp-header.h:313
ns3::DhcpHeader::GetReq
Ipv4Address GetReq() const
Get the IPv4Address requested by the client.
Definition
dhcp-header.cc:183
ns3::DhcpHeader::m_rebind
uint32_t m_rebind
The rebinding time for the client.
Definition
dhcp-header.h:324
ns3::DhcpHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
dhcp-header.cc:313
ns3::DhcpHeader::m_giAddr
Ipv4Address m_giAddr
Relay Agent IP address.
Definition
dhcp-header.h:315
ns3::DhcpHeader::ResetOpt
void ResetOpt()
Reset the BOOTP options.
Definition
dhcp-header.cc:274
ns3::DhcpHeader::m_hops
uint8_t m_hops
The number of hops covered by the message.
Definition
dhcp-header.h:305
ns3::DhcpHeader::GetRouter
Ipv4Address GetRouter() const
Return the Ipv4Address of gateway to be used.
Definition
dhcp-header.cc:217
ns3::DhcpHeader::m_bootp
uint8_t m_bootp
The BOOTP Message type.
Definition
dhcp-header.h:302
ns3::DhcpHeader::m_lease
uint32_t m_lease
The lease time of the address.
Definition
dhcp-header.h:322
ns3::DhcpHeader::SetType
void SetType(uint8_t type)
Set the type of BOOTP and DHCP messages.
Definition
dhcp-header.cc:88
ns3::DhcpHeader::SetTran
void SetTran(uint32_t tran)
Set the transaction ID.
Definition
dhcp-header.cc:113
ns3::DhcpHeader::m_sname
uint8_t m_sname[64]
Server name (Padded for now).
Definition
dhcp-header.h:319
ns3::DhcpHeader::GetDhcps
Ipv4Address GetDhcps() const
Get the information about the DHCP server.
Definition
dhcp-header.cc:166
ns3::DhcpHeader::m_yiAddr
Ipv4Address m_yiAddr
Your (client) IP address.
Definition
dhcp-header.h:312
ns3::DhcpHeader::~DhcpHeader
~DhcpHeader() override
Destructor.
Definition
dhcp-header.cc:83
ns3::DhcpHeader::SetYiaddr
void SetYiaddr(Ipv4Address addr)
Set the IPv4Address of the client.
Definition
dhcp-header.cc:143
ns3::DhcpHeader::m_chaddr
DhcpChaddr m_chaddr
The client identifier.
Definition
dhcp-header.h:311
ns3::DhcpHeader::m_len
uint32_t m_len
The length of the header.
Definition
dhcp-header.h:308
ns3::DhcpHeader::SetDhcps
void SetDhcps(Ipv4Address addr)
Set the DHCP server information.
Definition
dhcp-header.cc:155
ns3::DhcpHeader::m_secs
uint16_t m_secs
Seconds elapsed.
Definition
dhcp-header.h:309
ns3::DhcpHeader::GetMask
uint32_t GetMask() const
Return the mask of the network.
Definition
dhcp-header.cc:200
ns3::DhcpHeader::m_mask
uint32_t m_mask
The mask of the network.
Definition
dhcp-header.h:307
ns3::DhcpHeader::m_dhcps
Ipv4Address m_dhcps
DHCP server IP address.
Definition
dhcp-header.h:316
ns3::DhcpHeader::m_siAddr
Ipv4Address m_siAddr
Next Server IP address.
Definition
dhcp-header.h:314
ns3::DhcpHeader::GetType
uint8_t GetType() const
Return the type of DHCP message.
Definition
dhcp-header.cc:100
ns3::DhcpHeader::SetRenew
void SetRenew(uint32_t time)
Set the Renewal time of the IPv4Address.
Definition
dhcp-header.cc:240
ns3::DhcpHeader::GetTran
uint32_t GetTran() const
Get the transaction id.
Definition
dhcp-header.cc:119
ns3::DhcpHeader::m_opt
bool m_opt[255]
BOOTP option list.
Definition
dhcp-header.h:325
ns3::DhcpHeader::m_magic_cookie
uint8_t m_magic_cookie[4]
DHCP Magic Cookie.
Definition
dhcp-header.h:321
ns3::DhcpHeader::SetLease
void SetLease(uint32_t time)
Set the lease time of the IPv4Address.
Definition
dhcp-header.cc:223
ns3::DhcpHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
dhcp-header.cc:291
ns3::DhcpHeader::OP_SERVID
@ OP_SERVID
BOOTP Option 54: Server Identifier.
Definition
dhcp-header.h:125
ns3::DhcpHeader::OP_MASK
@ OP_MASK
BOOTP Option 1: Address Mask.
Definition
dhcp-header.h:120
ns3::DhcpHeader::OP_REBIND
@ OP_REBIND
BOOTP Option 59: Address Rebind Time.
Definition
dhcp-header.h:127
ns3::DhcpHeader::OP_MSGTYPE
@ OP_MSGTYPE
BOOTP Option 53: DHCP Message Type.
Definition
dhcp-header.h:124
ns3::DhcpHeader::OP_RENEW
@ OP_RENEW
BOOTP Option 58: Address Renewal Time.
Definition
dhcp-header.h:126
ns3::DhcpHeader::OP_ADDREQ
@ OP_ADDREQ
BOOTP Option 50: Requested Address.
Definition
dhcp-header.h:122
ns3::DhcpHeader::OP_ROUTE
@ OP_ROUTE
BOOTP Option 3: Router Option.
Definition
dhcp-header.h:121
ns3::DhcpHeader::OP_END
@ OP_END
BOOTP Option 255: END.
Definition
dhcp-header.h:128
ns3::DhcpHeader::OP_LEASE
@ OP_LEASE
BOOTP Option 51: Address Lease Time.
Definition
dhcp-header.h:123
ns3::DhcpHeader::m_hLen
uint8_t m_hLen
The hardware length.
Definition
dhcp-header.h:304
ns3::DhcpHeader::DhcpHeader
DhcpHeader()
Constructor.
Definition
dhcp-header.cc:49
ns3::DhcpHeader::SetRouter
void SetRouter(Ipv4Address addr)
Set the Ipv4Address of gateway to be used.
Definition
dhcp-header.cc:206
ns3::DhcpHeader::SetMask
void SetMask(uint32_t addr)
Set the mask of the IPv4Address.
Definition
dhcp-header.cc:189
ns3::DhcpHeader::m_renew
uint32_t m_renew
The renewal time for the client.
Definition
dhcp-header.h:323
ns3::DhcpHeader::GetChaddr
DhcpChaddr GetChaddr()
Get the Address of the client.
Definition
dhcp-header.cc:137
ns3::DhcpHeader::m_hType
uint8_t m_hType
The hardware type.
Definition
dhcp-header.h:303
ns3::DhcpHeader::SetReq
void SetReq(Ipv4Address addr)
Set the Ipv4Address requested by the client.
Definition
dhcp-header.cc:172
ns3::DhcpHeader::m_flags
uint16_t m_flags
BOOTP flags.
Definition
dhcp-header.h:310
ns3::DhcpHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
dhcp-header.cc:383
ns3::DhcpHeader::GetYiaddr
Ipv4Address GetYiaddr() const
Get the IPv4Address of the client.
Definition
dhcp-header.cc:149
ns3::DhcpHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
dhcp-header.cc:301
ns3::DhcpHeader::SetRebind
void SetRebind(uint32_t time)
Set the Rebind time of the IPv4Address.
Definition
dhcp-header.cc:257
ns3::DhcpHeader::Print
void Print(std::ostream &os) const override
Definition
dhcp-header.cc:307
ns3::DhcpHeader::m_route
Ipv4Address m_route
Router Option Address.
Definition
dhcp-header.h:318
ns3::DhcpHeader::m_op
uint8_t m_op
The DHCP Message type.
Definition
dhcp-header.h:301
ns3::DhcpHeader::m_xid
uint32_t m_xid
The transaction number.
Definition
dhcp-header.h:306
ns3::DhcpHeader::GetRebind
uint32_t GetRebind() const
Return the Rebind time of the address.
Definition
dhcp-header.cc:268
ns3::DhcpHeader::m_req
Ipv4Address m_req
Requested Address.
Definition
dhcp-header.h:317
ns3::DhcpHeader::GetRenew
uint32_t GetRenew() const
Return the Renewal time of the address.
Definition
dhcp-header.cc:251
ns3::DhcpHeader::m_file
uint8_t m_file[128]
File name (Padded for now).
Definition
dhcp-header.h:320
ns3::DhcpHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
dhcp-header.cc:285
ns3::DhcpHeader::SetChaddr
void SetChaddr(DhcpChaddr addr)
Set the Chaddress of the device.
Definition
dhcp-header.cc:131
ns3::DhcpHeader::SetHWType
void SetHWType(uint8_t htype, uint8_t hlen)
Set the hardware information.
Definition
dhcp-header.cc:106
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::Simulator::Now
static Time Now()
Return the current simulation virtual time.
Definition
simulator.cc:197
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
uint32_t
dhcp-header.h
DhcpHeader classes declaration.
ns3::DhcpChaddr
std::array< uint8_t, 16 > DhcpChaddr
This is the Chaddr field, which is 16 bytes long.
Definition
dhcp-header.h:44
ns3::DhcpChaddrToString
std::string DhcpChaddrToString(const DhcpChaddr &chaddr)
Function to pretty-print a Chaddr.
Definition
dhcp-header.cc:36
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_WARN
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition
log.h:250
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WriteTo
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
Definition
address-utils.cc:21
ns3::ReadFrom
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
Definition
address-utils.cc:74
src
internet-apps
model
dhcp-header.cc
Generated on
for ns-3 by
1.15.0