A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
sll-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Université Pierre et Marie Curie
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Matthieu Coudron <matthieu.coudron@lip6.fr>
18
*/
19
#include "
sll-header.h
"
20
21
#include "ns3/log.h"
22
23
namespace
ns3
24
{
25
26
NS_LOG_COMPONENT_DEFINE
(
"SllHeader"
);
27
28
NS_OBJECT_ENSURE_REGISTERED
(SllHeader);
29
30
SllHeader::SllHeader
()
31
: m_packetType(UNICAST_FROM_PEER_TO_ME),
32
m_arphdType(0),
33
m_addressLength(0),
34
m_address(0),
35
m_protocolType(0)
36
{
37
NS_LOG_FUNCTION
(
this
);
38
}
39
40
SllHeader::~SllHeader
()
41
{
42
NS_LOG_FUNCTION
(
this
);
43
}
44
45
TypeId
46
SllHeader::GetTypeId
()
47
{
48
static
TypeId
tid =
TypeId
(
"ns3::SllHeader"
)
49
.
SetParent
<
Header
>()
50
.SetGroupName(
"Network"
)
51
.AddConstructor<
SllHeader
>();
52
return
tid;
53
}
54
55
TypeId
56
SllHeader::GetInstanceTypeId
()
const
57
{
58
return
GetTypeId
();
59
}
60
61
uint16_t
62
SllHeader::GetArpType
()
const
63
{
64
return
m_arphdType
;
65
}
66
67
void
68
SllHeader::SetArpType
(uint16_t arphdType)
69
{
70
NS_LOG_FUNCTION
(arphdType);
71
m_arphdType
= arphdType;
72
}
73
74
SllHeader::PacketType
75
SllHeader::GetPacketType
()
const
76
{
77
return
m_packetType
;
78
}
79
80
void
81
SllHeader::SetPacketType
(
PacketType
type
)
82
{
83
NS_LOG_FUNCTION
(
type
);
84
m_packetType
=
type
;
85
}
86
87
void
88
SllHeader::Print
(std::ostream& os)
const
89
{
90
os <<
"SLLHeader packetType="
<<
m_packetType
<<
" protocol="
<<
m_protocolType
;
91
}
92
93
uint32_t
94
SllHeader::GetSerializedSize
()
const
95
{
96
return
2 + 2 + 2 + 8 + 2;
97
}
98
99
void
100
SllHeader::Serialize
(
Buffer::Iterator
start
)
const
101
{
102
Buffer::Iterator
i =
start
;
103
i.
WriteHtonU16
(
m_packetType
);
104
i.
WriteHtonU16
(
m_arphdType
);
105
i.
WriteHtonU16
(
m_addressLength
);
106
i.
WriteHtonU64
(
m_address
);
107
i.
WriteHtonU16
(
m_protocolType
);
108
}
109
110
uint32_t
111
SllHeader::Deserialize
(
Buffer::Iterator
start
)
112
{
113
Buffer::Iterator
i =
start
;
114
m_packetType
=
static_cast<
PacketType
>
(i.
ReadNtohU16
());
115
m_arphdType
= i.
ReadNtohU16
();
116
m_addressLength
= i.
ReadNtohU16
();
117
m_address
= i.
ReadNtohU64
();
118
m_protocolType
= i.
ReadNtohU16
();
119
120
return
GetSerializedSize
();
121
}
122
123
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:100
ns3::Buffer::Iterator::WriteHtonU64
void WriteHtonU64(uint64_t data)
Definition:
buffer.cc:934
ns3::Buffer::Iterator::ReadNtohU64
uint64_t ReadNtohU64()
Definition:
buffer.cc:1041
ns3::Buffer::Iterator::WriteHtonU16
void WriteHtonU16(uint16_t data)
Definition:
buffer.h:915
ns3::Buffer::Iterator::ReadNtohU16
uint16_t ReadNtohU16()
Definition:
buffer.h:954
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:44
ns3::Header::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
ns3::SllHeader
Protocol header serialization and deserialization.
Definition:
sll-header.h:66
ns3::SllHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
sll-header.cc:56
ns3::SllHeader::SetArpType
void SetArpType(uint16_t arphdType)
Definition:
sll-header.cc:68
ns3::SllHeader::m_addressLength
uint16_t m_addressLength
Address length.
Definition:
sll-header.h:123
ns3::SllHeader::GetArpType
uint16_t GetArpType() const
Definition:
sll-header.cc:62
ns3::SllHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
sll-header.cc:94
ns3::SllHeader::m_packetType
PacketType m_packetType
Packet type.
Definition:
sll-header.h:121
ns3::SllHeader::~SllHeader
~SllHeader() override
Definition:
sll-header.cc:40
ns3::SllHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
sll-header.cc:46
ns3::SllHeader::PacketType
PacketType
Type of the packet.
Definition:
sll-header.h:72
ns3::SllHeader::m_arphdType
uint16_t m_arphdType
ARP protocol hardware identifier.
Definition:
sll-header.h:122
ns3::SllHeader::GetPacketType
PacketType GetPacketType() const
Definition:
sll-header.cc:75
ns3::SllHeader::SetPacketType
void SetPacketType(PacketType type)
Definition:
sll-header.cc:81
ns3::SllHeader::m_protocolType
uint16_t m_protocolType
protocol type
Definition:
sll-header.h:125
ns3::SllHeader::m_address
uint64_t m_address
Address.
Definition:
sll-header.h:124
ns3::SllHeader::SllHeader
SllHeader()
Definition:
sll-header.cc:30
ns3::SllHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition:
sll-header.cc:100
ns3::SllHeader::Print
void Print(std::ostream &os) const override
Definition:
sll-header.cc:88
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:240
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
check-style-clang-format.type
type
Definition:
check-style-clang-format.py:704
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
two-ray-to-three-gpp-ch-calibration.start
start
Definition:
two-ray-to-three-gpp-ch-calibration.py:520
sll-header.h
src
network
utils
sll-header.cc
Generated on Sun Mar 3 2024 17:11:06 for ns-3 by
1.9.1