A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
dhcp-header.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 UPB
4
* Copyright (c) 2017 NITK Surathkal
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation;
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
*
19
* Author: Radu Lupu <rlupu@elcom.pub.ro>
20
* Ankit Deepak <adadeepak8@gmail.com>
21
* Deepti Rajagopal <deeptir96@gmail.com>
22
*
23
*/
24
25
#ifndef DHCP_HEADER_H
26
#define DHCP_HEADER_H
27
28
#include "ns3/header.h"
29
30
namespace
ns3
{
31
81
class
DhcpHeader
:
public
Header
82
{
83
public
:
88
static
TypeId
GetTypeId
(
void
);
89
93
DhcpHeader
();
94
98
~DhcpHeader
();
99
101
enum
Options
102
{
103
OP_MASK
= 1,
104
OP_ROUTE
= 3,
105
OP_ADDREQ
= 50,
106
OP_LEASE
= 51,
107
OP_MSGTYPE
= 53,
108
OP_SERVID
= 54,
109
OP_RENEW
= 58,
110
OP_REBIND
= 59,
111
OP_END
= 255
112
};
113
115
enum
Messages
116
{
117
DHCPDISCOVER
= 0,
118
DHCPOFFER
= 1,
119
DHCPREQ
= 2,
120
DHCPACK
= 4,
121
DHCPNACK
= 5
122
};
123
128
void
SetType
(uint8_t type);
129
134
uint8_t
GetType
(
void
)
const
;
135
141
void
SetHWType
(uint8_t htype, uint8_t hlen);
142
147
void
SetTran
(uint32_t tran);
148
153
uint32_t
GetTran
(
void
)
const
;
154
158
void
SetTime
();
159
167
void
SetChaddr
(
Address
addr);
168
174
void
SetChaddr
(uint8_t* addr, uint8_t len);
175
183
Address
GetChaddr
(
void
);
184
189
void
SetYiaddr
(
Ipv4Address
addr);
190
195
Ipv4Address
GetYiaddr
(
void
)
const
;
196
201
void
SetDhcps
(
Ipv4Address
addr);
202
207
Ipv4Address
GetDhcps
(
void
)
const
;
208
213
void
SetReq
(
Ipv4Address
addr);
214
219
Ipv4Address
GetReq
(
void
)
const
;
220
225
void
SetMask
(uint32_t addr);
226
231
uint32_t
GetMask
(
void
)
const
;
232
237
void
SetRouter
(
Ipv4Address
addr);
238
243
Ipv4Address
GetRouter
(
void
)
const
;
244
249
void
SetLease
(uint32_t time);
250
255
uint32_t
GetLease
(
void
)
const
;
256
261
void
SetRenew
(uint32_t time);
262
267
uint32_t
GetRenew
(
void
)
const
;
268
273
void
SetRebind
(uint32_t time);
274
279
uint32_t
GetRebind
(
void
)
const
;
280
284
void
ResetOpt
();
285
286
private
:
287
virtual
TypeId
GetInstanceTypeId
(
void
)
const
;
288
virtual
void
Print
(std::ostream &os)
const
;
289
virtual
uint32_t
GetSerializedSize
(
void
)
const
;
290
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
291
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start
);
292
293
uint8_t
m_op
;
294
uint8_t
m_bootp
;
295
uint8_t
m_hType
;
296
uint8_t
m_hLen
;
297
uint8_t
m_hops
;
298
uint32_t
m_xid
;
299
uint32_t
m_mask
;
300
uint32_t
m_len
;
301
uint16_t
m_secs
;
302
uint16_t
m_flags
;
303
uint8_t
m_chaddr
[16];
304
Ipv4Address
m_yiAddr
;
305
Ipv4Address
m_ciAddr
;
306
Ipv4Address
m_siAddr
;
307
Ipv4Address
m_giAddr
;
308
Ipv4Address
m_dhcps
;
309
Ipv4Address
m_req
;
310
Ipv4Address
m_route
;
311
uint8_t
m_sname
[64];
312
uint8_t
m_file
[128];
313
uint8_t
m_magic_cookie
[4];
314
uint32_t
m_lease
;
315
uint32_t
m_renew
;
316
uint32_t
m_rebind
;
317
bool
m_opt
[255];
318
};
319
320
}
// namespace ns3
321
322
#endif
/* DHCP_HEADER_H */
ns3::Address
a polymophic address class
Definition:
address.h:91
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:99
ns3::DhcpHeader
BOOTP header with DHCP messages supports the following options: Subnet Mask (1), Address Request (50)...
Definition:
dhcp-header.h:82
ns3::DhcpHeader::SetTime
void SetTime()
Set the time when message is sent.
Definition:
dhcp-header.cc:106
ns3::DhcpHeader::m_ciAddr
Ipv4Address m_ciAddr
The IP address of the client.
Definition:
dhcp-header.h:305
ns3::DhcpHeader::m_rebind
uint32_t m_rebind
The rebinding time for the client.
Definition:
dhcp-header.h:316
ns3::DhcpHeader::m_chaddr
uint8_t m_chaddr[16]
The address identifier.
Definition:
dhcp-header.h:303
ns3::DhcpHeader::GetDhcps
Ipv4Address GetDhcps(void) const
Get the information about the DHCP server.
Definition:
dhcp-header.cc:152
ns3::DhcpHeader::m_giAddr
Ipv4Address m_giAddr
Relay Agent IP address.
Definition:
dhcp-header.h:307
ns3::DhcpHeader::ResetOpt
void ResetOpt()
Reset the BOOTP options.
Definition:
dhcp-header.cc:247
ns3::DhcpHeader::m_hops
uint8_t m_hops
The number of hops covered by the message.
Definition:
dhcp-header.h:297
ns3::DhcpHeader::GetRebind
uint32_t GetRebind(void) const
Return the Rebind time of the address.
Definition:
dhcp-header.cc:242
ns3::DhcpHeader::m_bootp
uint8_t m_bootp
The BOOTP Message type.
Definition:
dhcp-header.h:294
ns3::DhcpHeader::m_lease
uint32_t m_lease
The lease time of the address.
Definition:
dhcp-header.h:314
ns3::DhcpHeader::SetType
void SetType(uint8_t type)
Set the type of BOOTP and DHCP messages.
Definition:
dhcp-header.cc:74
ns3::DhcpHeader::~DhcpHeader
~DhcpHeader()
Destructor.
Definition:
dhcp-header.cc:70
ns3::DhcpHeader::Messages
Messages
DHCP messages.
Definition:
dhcp-header.h:116
ns3::DhcpHeader::DHCPACK
@ DHCPACK
Code for DHCP ACK.
Definition:
dhcp-header.h:120
ns3::DhcpHeader::DHCPOFFER
@ DHCPOFFER
Code for DHCP Offer.
Definition:
dhcp-header.h:118
ns3::DhcpHeader::DHCPDISCOVER
@ DHCPDISCOVER
Code for DHCP Discover.
Definition:
dhcp-header.h:117
ns3::DhcpHeader::DHCPREQ
@ DHCPREQ
Code for DHCP Request.
Definition:
dhcp-header.h:119
ns3::DhcpHeader::DHCPNACK
@ DHCPNACK
Code for DHCP NACK.
Definition:
dhcp-header.h:121
ns3::DhcpHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
dhcp-header.cc:272
ns3::DhcpHeader::SetTran
void SetTran(uint32_t tran)
Set the transaction ID.
Definition:
dhcp-header.cc:96
ns3::DhcpHeader::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
dhcp-header.cc:283
ns3::DhcpHeader::m_sname
uint8_t m_sname[64]
Server name (Padded for now)
Definition:
dhcp-header.h:311
ns3::DhcpHeader::m_yiAddr
Ipv4Address m_yiAddr
Your (client) IP address.
Definition:
dhcp-header.h:304
ns3::DhcpHeader::GetMask
uint32_t GetMask(void) const
Return the mask of the network.
Definition:
dhcp-header.cc:182
ns3::DhcpHeader::SetYiaddr
void SetYiaddr(Ipv4Address addr)
Set the IPv4Address of the client.
Definition:
dhcp-header.cc:132
ns3::DhcpHeader::m_len
uint32_t m_len
The length of the header.
Definition:
dhcp-header.h:300
ns3::DhcpHeader::SetDhcps
void SetDhcps(Ipv4Address addr)
Set the DHCP server information.
Definition:
dhcp-header.cc:142
ns3::DhcpHeader::m_secs
uint16_t m_secs
Seconds elapsed.
Definition:
dhcp-header.h:301
ns3::DhcpHeader::m_mask
uint32_t m_mask
The mask of the network.
Definition:
dhcp-header.h:299
ns3::DhcpHeader::m_dhcps
Ipv4Address m_dhcps
DHCP server IP address.
Definition:
dhcp-header.h:308
ns3::DhcpHeader::m_siAddr
Ipv4Address m_siAddr
Next Server IP address.
Definition:
dhcp-header.h:306
ns3::DhcpHeader::SetRenew
void SetRenew(uint32_t time)
Set the Renewal time of the IPv4Address.
Definition:
dhcp-header.cc:217
ns3::DhcpHeader::m_opt
bool m_opt[255]
BOOTP option list.
Definition:
dhcp-header.h:317
ns3::DhcpHeader::GetReq
Ipv4Address GetReq(void) const
Get the IPv4Address requested by the client.
Definition:
dhcp-header.cc:167
ns3::DhcpHeader::m_magic_cookie
uint8_t m_magic_cookie[4]
DHCP Magic Cookie.
Definition:
dhcp-header.h:313
ns3::DhcpHeader::SetLease
void SetLease(uint32_t time)
Set the lease time of the IPv4Address.
Definition:
dhcp-header.cc:202
ns3::DhcpHeader::Options
Options
BOOTP options.
Definition:
dhcp-header.h:102
ns3::DhcpHeader::OP_SERVID
@ OP_SERVID
BOOTP Option 54: Server Identifier.
Definition:
dhcp-header.h:108
ns3::DhcpHeader::OP_MASK
@ OP_MASK
BOOTP Option 1: Address Mask.
Definition:
dhcp-header.h:103
ns3::DhcpHeader::OP_REBIND
@ OP_REBIND
BOOTP Option 59: Address Rebind Time.
Definition:
dhcp-header.h:110
ns3::DhcpHeader::OP_MSGTYPE
@ OP_MSGTYPE
BOOTP Option 53: DHCP Message Type.
Definition:
dhcp-header.h:107
ns3::DhcpHeader::OP_RENEW
@ OP_RENEW
BOOTP Option 58: Address Renewal Time.
Definition:
dhcp-header.h:109
ns3::DhcpHeader::OP_ADDREQ
@ OP_ADDREQ
BOOTP Option 50: Requested Address.
Definition:
dhcp-header.h:105
ns3::DhcpHeader::OP_ROUTE
@ OP_ROUTE
BOOTP Option 3: Router Option.
Definition:
dhcp-header.h:104
ns3::DhcpHeader::OP_END
@ OP_END
BOOTP Option 255: END.
Definition:
dhcp-header.h:111
ns3::DhcpHeader::OP_LEASE
@ OP_LEASE
BOOTP Option 51: Address Lease Time.
Definition:
dhcp-header.h:106
ns3::DhcpHeader::m_hLen
uint8_t m_hLen
The hardware length.
Definition:
dhcp-header.h:296
ns3::DhcpHeader::DhcpHeader
DhcpHeader()
Constructor.
Definition:
dhcp-header.cc:36
ns3::DhcpHeader::SetRouter
void SetRouter(Ipv4Address addr)
Set the Ipv4Address of gateway to be used.
Definition:
dhcp-header.cc:187
ns3::DhcpHeader::SetMask
void SetMask(uint32_t addr)
Set the mask of the IPv4Address.
Definition:
dhcp-header.cc:172
ns3::DhcpHeader::GetTran
uint32_t GetTran(void) const
Get the transaction id.
Definition:
dhcp-header.cc:101
ns3::DhcpHeader::m_renew
uint32_t m_renew
The renewal time for the client.
Definition:
dhcp-header.h:315
ns3::DhcpHeader::m_hType
uint8_t m_hType
The hardware type.
Definition:
dhcp-header.h:295
ns3::DhcpHeader::GetType
uint8_t GetType(void) const
Return the type of DHCP message.
Definition:
dhcp-header.cc:85
ns3::DhcpHeader::GetLease
uint32_t GetLease(void) const
Return the lease time of the IPv4Address.
Definition:
dhcp-header.cc:212
ns3::DhcpHeader::GetRouter
Ipv4Address GetRouter(void) const
Return the Ipv4Address of gateway to be used.
Definition:
dhcp-header.cc:197
ns3::DhcpHeader::SetReq
void SetReq(Ipv4Address addr)
Set the Ipv4Address requested by the client.
Definition:
dhcp-header.cc:157
ns3::DhcpHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
dhcp-header.cc:262
ns3::DhcpHeader::m_flags
uint16_t m_flags
BOOTP flags.
Definition:
dhcp-header.h:302
ns3::DhcpHeader::GetYiaddr
Ipv4Address GetYiaddr(void) const
Get the IPv4Address of the client.
Definition:
dhcp-header.cc:137
ns3::DhcpHeader::Print
virtual void Print(std::ostream &os) const
Definition:
dhcp-header.cc:277
ns3::DhcpHeader::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
dhcp-header.cc:257
ns3::DhcpHeader::SetRebind
void SetRebind(uint32_t time)
Set the Rebind time of the IPv4Address.
Definition:
dhcp-header.cc:232
ns3::DhcpHeader::m_route
Ipv4Address m_route
Router Option Address.
Definition:
dhcp-header.h:310
ns3::DhcpHeader::m_op
uint8_t m_op
The DHCP Message type.
Definition:
dhcp-header.h:293
ns3::DhcpHeader::m_xid
uint32_t m_xid
The transaction number.
Definition:
dhcp-header.h:298
ns3::DhcpHeader::m_req
Ipv4Address m_req
Requested Address.
Definition:
dhcp-header.h:309
ns3::DhcpHeader::GetChaddr
Address GetChaddr(void)
Get the Address of the client.
Definition:
dhcp-header.cc:125
ns3::DhcpHeader::SetChaddr
void SetChaddr(Address addr)
Set the Address of the device.
Definition:
dhcp-header.cc:111
ns3::DhcpHeader::GetRenew
uint32_t GetRenew(void) const
Return the Renewal time of the address.
Definition:
dhcp-header.cc:227
ns3::DhcpHeader::m_file
uint8_t m_file[128]
File name (Padded for now)
Definition:
dhcp-header.h:312
ns3::DhcpHeader::SetHWType
void SetHWType(uint8_t htype, uint8_t hlen)
Set the hardware information.
Definition:
dhcp-header.cc:90
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:43
ns3::Header::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:41
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
visualizer.core.start
def start()
Definition:
core.py:1853
src
internet-apps
model
dhcp-header.h
Generated on Tue Feb 6 2024 19:21:18 for ns-3 by
1.9.1