A Discrete-Event Network Simulator
API
sll-header.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2015 Universit√© Pierre et Marie Curie
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Matthieu Coudron <matthieu.coudron@lip6.fr>
19  */
20 #include "sll-header.h"
21 #include "ns3/log.h"
22 
23 
24 namespace ns3 {
25 
26 NS_LOG_COMPONENT_DEFINE ("SllHeader");
27 
28 NS_OBJECT_ENSURE_REGISTERED (SllHeader);
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 
45 
46 TypeId
48 {
49  static TypeId tid = TypeId ("ns3::SllHeader")
50  .SetParent<Header> ()
51  .SetGroupName ("Network")
52  .AddConstructor<SllHeader> ()
53  ;
54  return tid;
55 }
56 
57 TypeId
59 {
60  return GetTypeId ();
61 }
62 
63 uint16_t
65 {
66  return m_arphdType;
67 }
68 
69 void
70 SllHeader::SetArpType (uint16_t arphdType)
71 {
72  NS_LOG_FUNCTION (arphdType);
73  m_arphdType = arphdType;
74 }
75 
78 {
79  return m_packetType;
80 }
81 
82 void
84 {
85  NS_LOG_FUNCTION (type);
86  m_packetType = type;
87 }
88 
89 void
90 SllHeader::Print (std::ostream &os) const
91 {
92  os << "SLLHeader packetType=" << m_packetType << " protocol=" << m_protocolType;
93 }
94 
95 uint32_t
97 {
98  return 2 + 2 + 2 + 8 + 2;
99 }
100 
101 void
103 {
110 }
111 
112 uint32_t
114 {
116  m_packetType = static_cast<PacketType> (i.ReadNtohU16 ());
117  m_arphdType = i.ReadNtohU16 ();
119  m_address = i.ReadNtohU64 ();
121 
122  return GetSerializedSize ();
123 }
124 
125 }
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::SllHeader::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition: sll-header.cc:96
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SllHeader
Protocol header serialization and deserialization.
Definition: sll-header.h:65
ns3::Buffer::Iterator::ReadNtohU16
uint16_t ReadNtohU16(void)
Definition: buffer.h:946
ns3::SllHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: sll-header.cc:58
ns3::Buffer::Iterator::ReadNtohU64
uint64_t ReadNtohU64(void)
Definition: buffer.cc:1044
ns3::SllHeader::SllHeader
SllHeader()
Definition: sll-header.cc:30
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::Buffer::Iterator::WriteHtonU16
void WriteHtonU16(uint16_t data)
Definition: buffer.h:905
ns3::SllHeader::m_arphdType
uint16_t m_arphdType
ARP protocol hardware identifier.
Definition: sll-header.h:121
sll-header.h
ns3::SllHeader::PacketType
PacketType
Type of the packet.
Definition: sll-header.h:72
visualizer.core.start
def start()
Definition: core.py:1855
ns3::SllHeader::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition: sll-header.cc:102
ns3::Header
Protocol header serialization and deserialization.
Definition: header.h:43
ns3::SllHeader::m_packetType
PacketType m_packetType
Packet type.
Definition: sll-header.h:120
ns3::Header::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
ns3::SllHeader::GetArpType
uint16_t GetArpType() const
Definition: sll-header.cc:64
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition: buffer.h:99
ns3::SllHeader::SetArpType
void SetArpType(uint16_t arphdType)
Definition: sll-header.cc:70
ns3::SllHeader::m_addressLength
uint16_t m_addressLength
Address length.
Definition: sll-header.h:122
ns3::SllHeader::~SllHeader
virtual ~SllHeader()
Definition: sll-header.cc:40
ns3::SllHeader::m_protocolType
uint16_t m_protocolType
protocol type
Definition: sll-header.h:124
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:244
ns3::SllHeader::SetPacketType
void SetPacketType(PacketType type)
Definition: sll-header.cc:83
ns3::SllHeader::Print
virtual void Print(std::ostream &os) const
Definition: sll-header.cc:90
ns3::SllHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: sll-header.cc:47
ns3::SllHeader::GetPacketType
enum PacketType GetPacketType() const
Definition: sll-header.cc:77
ns3::Buffer::Iterator::WriteHtonU64
void WriteHtonU64(uint64_t data)
Definition: buffer.cc:941
ns3::SllHeader::m_address
uint64_t m_address
Address.
Definition: sll-header.h:123