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
sll-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Université Pierre et Marie Curie
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Matthieu Coudron <matthieu.coudron@lip6.fr>
7
*/
8
#include "
sll-header.h
"
9
10
#include "ns3/log.h"
11
12
namespace
ns3
13
{
14
15
NS_LOG_COMPONENT_DEFINE
(
"SllHeader"
);
16
17
NS_OBJECT_ENSURE_REGISTERED
(SllHeader);
18
19
SllHeader::SllHeader
()
20
: m_packetType(UNICAST_FROM_PEER_TO_ME),
21
m_arphdType(0),
22
m_addressLength(0),
23
m_address(0),
24
m_protocolType(0)
25
{
26
NS_LOG_FUNCTION
(
this
);
27
}
28
29
SllHeader::~SllHeader
()
30
{
31
NS_LOG_FUNCTION
(
this
);
32
}
33
34
TypeId
35
SllHeader::GetTypeId
()
36
{
37
static
TypeId
tid =
TypeId
(
"ns3::SllHeader"
)
38
.
SetParent
<
Header
>()
39
.SetGroupName(
"Network"
)
40
.AddConstructor<
SllHeader
>();
41
return
tid;
42
}
43
44
TypeId
45
SllHeader::GetInstanceTypeId
()
const
46
{
47
return
GetTypeId
();
48
}
49
50
uint16_t
51
SllHeader::GetArpType
()
const
52
{
53
return
m_arphdType
;
54
}
55
56
void
57
SllHeader::SetArpType
(uint16_t arphdType)
58
{
59
NS_LOG_FUNCTION
(arphdType);
60
m_arphdType
= arphdType;
61
}
62
63
SllHeader::PacketType
64
SllHeader::GetPacketType
()
const
65
{
66
return
m_packetType
;
67
}
68
69
void
70
SllHeader::SetPacketType
(
PacketType
type)
71
{
72
NS_LOG_FUNCTION
(type);
73
m_packetType
= type;
74
}
75
76
void
77
SllHeader::Print
(std::ostream& os)
const
78
{
79
os <<
"SLLHeader packetType="
<<
m_packetType
<<
" protocol="
<<
m_protocolType
;
80
}
81
82
uint32_t
83
SllHeader::GetSerializedSize
()
const
84
{
85
return
2 + 2 + 2 + 8 + 2;
86
}
87
88
void
89
SllHeader::Serialize
(
Buffer::Iterator
start)
const
90
{
91
Buffer::Iterator
i = start;
92
i.
WriteHtonU16
(
m_packetType
);
93
i.
WriteHtonU16
(
m_arphdType
);
94
i.
WriteHtonU16
(
m_addressLength
);
95
i.
WriteHtonU64
(
m_address
);
96
i.
WriteHtonU16
(
m_protocolType
);
97
}
98
99
uint32_t
100
SllHeader::Deserialize
(
Buffer::Iterator
start)
101
{
102
Buffer::Iterator
i = start;
103
m_packetType
=
static_cast<
PacketType
>
(i.
ReadNtohU16
());
104
m_arphdType
= i.
ReadNtohU16
();
105
m_addressLength
= i.
ReadNtohU16
();
106
m_address
= i.
ReadNtohU64
();
107
m_protocolType
= i.
ReadNtohU16
();
108
109
return
GetSerializedSize
();
110
}
111
112
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Buffer::Iterator::WriteHtonU64
void WriteHtonU64(uint64_t data)
Definition
buffer.cc:923
ns3::Buffer::Iterator::ReadNtohU64
uint64_t ReadNtohU64()
Definition
buffer.cc:1030
ns3::Buffer::Iterator::WriteHtonU16
void WriteHtonU16(uint16_t data)
Definition
buffer.h:904
ns3::Buffer::Iterator::ReadNtohU16
uint16_t ReadNtohU16()
Definition
buffer.h:943
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::SllHeader
Protocol header serialization and deserialization.
Definition
sll-header.h:55
ns3::SllHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
sll-header.cc:45
ns3::SllHeader::SetArpType
void SetArpType(uint16_t arphdType)
Definition
sll-header.cc:57
ns3::SllHeader::m_addressLength
uint16_t m_addressLength
Address length.
Definition
sll-header.h:112
ns3::SllHeader::GetArpType
uint16_t GetArpType() const
Definition
sll-header.cc:51
ns3::SllHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
sll-header.cc:83
ns3::SllHeader::m_packetType
PacketType m_packetType
Packet type.
Definition
sll-header.h:110
ns3::SllHeader::~SllHeader
~SllHeader() override
Definition
sll-header.cc:29
ns3::SllHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
sll-header.cc:35
ns3::SllHeader::PacketType
PacketType
Type of the packet.
Definition
sll-header.h:61
ns3::SllHeader::m_arphdType
uint16_t m_arphdType
ARP protocol hardware identifier.
Definition
sll-header.h:111
ns3::SllHeader::GetPacketType
PacketType GetPacketType() const
Definition
sll-header.cc:64
ns3::SllHeader::SetPacketType
void SetPacketType(PacketType type)
Definition
sll-header.cc:70
ns3::SllHeader::m_protocolType
uint16_t m_protocolType
protocol type
Definition
sll-header.h:114
ns3::SllHeader::m_address
uint64_t m_address
Address.
Definition
sll-header.h:113
ns3::SllHeader::SllHeader
SllHeader()
Definition
sll-header.cc:19
ns3::SllHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
sll-header.cc:100
ns3::SllHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
sll-header.cc:89
ns3::SllHeader::Print
void Print(std::ostream &os) const override
Definition
sll-header.cc:77
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
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:229
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.
sll-header.h
src
network
utils
sll-header.cc
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0