A Discrete-Event Network Simulator
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 * 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
23namespace ns3
24{
25
26NS_LOG_COMPONENT_DEFINE("SllHeader");
27
29
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
41{
42 NS_LOG_FUNCTION(this);
43}
44
47{
48 static TypeId tid = TypeId("ns3::SllHeader")
50 .SetGroupName("Network")
51 .AddConstructor<SllHeader>();
52 return tid;
53}
54
57{
58 return GetTypeId();
59}
60
61uint16_t
63{
64 return m_arphdType;
65}
66
67void
68SllHeader::SetArpType(uint16_t arphdType)
69{
70 NS_LOG_FUNCTION(arphdType);
71 m_arphdType = arphdType;
72}
73
76{
77 return m_packetType;
78}
79
80void
82{
83 NS_LOG_FUNCTION(type);
84 m_packetType = type;
85}
86
87void
88SllHeader::Print(std::ostream& os) const
89{
90 os << "SLLHeader packetType=" << m_packetType << " protocol=" << m_protocolType;
91}
92
95{
96 return 2 + 2 + 2 + 8 + 2;
97}
98
99void
101{
102 Buffer::Iterator i = start;
108}
109
112{
113 Buffer::Iterator i = start;
114 m_packetType = static_cast<PacketType>(i.ReadNtohU16());
119
120 return GetSerializedSize();
121}
122
123} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
void WriteHtonU64(uint64_t data)
Definition: buffer.cc:940
uint64_t ReadNtohU64()
Definition: buffer.cc:1047
void WriteHtonU16(uint16_t data)
Definition: buffer.h:915
uint16_t ReadNtohU16()
Definition: buffer.h:954
Protocol header serialization and deserialization.
Definition: header.h:44
Protocol header serialization and deserialization.
Definition: sll-header.h:66
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: sll-header.cc:56
void SetArpType(uint16_t arphdType)
Definition: sll-header.cc:68
uint16_t m_addressLength
Address length.
Definition: sll-header.h:123
uint16_t GetArpType() const
Definition: sll-header.cc:62
uint32_t GetSerializedSize() const override
Definition: sll-header.cc:94
PacketType m_packetType
Packet type.
Definition: sll-header.h:121
~SllHeader() override
Definition: sll-header.cc:40
static TypeId GetTypeId()
Get the type ID.
Definition: sll-header.cc:46
PacketType
Type of the packet.
Definition: sll-header.h:72
uint16_t m_arphdType
ARP protocol hardware identifier.
Definition: sll-header.h:122
PacketType GetPacketType() const
Definition: sll-header.cc:75
void SetPacketType(PacketType type)
Definition: sll-header.cc:81
uint16_t m_protocolType
protocol type
Definition: sll-header.h:125
uint64_t m_address
Address.
Definition: sll-header.h:124
uint32_t Deserialize(Buffer::Iterator start) override
Definition: sll-header.cc:111
void Serialize(Buffer::Iterator start) const override
Definition: sll-header.cc:100
void Print(std::ostream &os) const override
Definition: sll-header.cc:88
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:936
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.