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
24namespace ns3 {
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
45
48{
49 static TypeId tid = TypeId ("ns3::SllHeader")
50 .SetParent<Header> ()
51 .SetGroupName ("Network")
52 .AddConstructor<SllHeader> ()
53 ;
54 return tid;
55}
56
59{
60 return GetTypeId ();
61}
62
63uint16_t
65{
66 return m_arphdType;
67}
68
69void
70SllHeader::SetArpType (uint16_t arphdType)
71{
72 NS_LOG_FUNCTION (arphdType);
73 m_arphdType = arphdType;
74}
75
78{
79 return m_packetType;
80}
81
82void
84{
85 NS_LOG_FUNCTION (type);
86 m_packetType = type;
87}
88
89void
90SllHeader::Print (std::ostream &os) const
91{
92 os << "SLLHeader packetType=" << m_packetType << " protocol=" << m_protocolType;
93}
94
97{
98 return 2 + 2 + 2 + 8 + 2;
99}
100
101void
103{
110}
111
114{
116 m_packetType = static_cast<PacketType> (i.ReadNtohU16 ());
119 m_address = i.ReadNtohU64 ();
121
122 return GetSerializedSize ();
123}
124
125}
iterator in a Buffer instance
Definition: buffer.h:99
uint16_t ReadNtohU16(void)
Definition: buffer.h:946
void WriteHtonU64(uint64_t data)
Definition: buffer.cc:941
uint64_t ReadNtohU64(void)
Definition: buffer.cc:1044
void WriteHtonU16(uint16_t data)
Definition: buffer.h:905
Protocol header serialization and deserialization.
Definition: header.h:43
Protocol header serialization and deserialization.
Definition: sll-header.h:65
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: sll-header.cc:58
static TypeId GetTypeId(void)
Get the type ID.
Definition: sll-header.cc:47
void SetArpType(uint16_t arphdType)
Definition: sll-header.cc:70
uint16_t m_addressLength
Address length.
Definition: sll-header.h:122
virtual ~SllHeader()
Definition: sll-header.cc:40
uint16_t GetArpType() const
Definition: sll-header.cc:64
PacketType m_packetType
Packet type.
Definition: sll-header.h:120
PacketType
Type of the packet.
Definition: sll-header.h:72
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition: sll-header.cc:113
uint16_t m_arphdType
ARP protocol hardware identifier.
Definition: sll-header.h:121
virtual uint32_t GetSerializedSize(void) const
Definition: sll-header.cc:96
enum PacketType GetPacketType() const
Definition: sll-header.cc:77
void SetPacketType(PacketType type)
Definition: sll-header.cc:83
uint16_t m_protocolType
protocol type
Definition: sll-header.h:124
uint64_t m_address
Address.
Definition: sll-header.h:123
virtual void Print(std::ostream &os) const
Definition: sll-header.cc:90
virtual void Serialize(Buffer::Iterator start) const
Definition: sll-header.cc:102
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1853