A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
llc-snap-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2005 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
*/
19
20
#include "
llc-snap-header.h
"
21
22
#include "ns3/assert.h"
23
#include "ns3/log.h"
24
25
#include <string>
26
27
namespace
ns3
28
{
29
30
NS_LOG_COMPONENT_DEFINE
(
"LlcSnalHeader"
);
31
32
NS_OBJECT_ENSURE_REGISTERED
(LlcSnapHeader);
33
34
LlcSnapHeader::LlcSnapHeader
()
35
{
36
NS_LOG_FUNCTION
(
this
);
37
}
38
39
void
40
LlcSnapHeader::SetType
(uint16_t
type
)
41
{
42
NS_LOG_FUNCTION
(
this
);
43
m_etherType
=
type
;
44
}
45
46
uint16_t
47
LlcSnapHeader::GetType
()
48
{
49
NS_LOG_FUNCTION
(
this
);
50
return
m_etherType
;
51
}
52
53
uint32_t
54
LlcSnapHeader::GetSerializedSize
()
const
55
{
56
NS_LOG_FUNCTION
(
this
);
57
return
LLC_SNAP_HEADER_LENGTH
;
58
}
59
60
TypeId
61
LlcSnapHeader::GetTypeId
()
62
{
63
static
TypeId
tid =
TypeId
(
"ns3::LlcSnapHeader"
)
64
.
SetParent
<
Header
>()
65
.SetGroupName(
"Network"
)
66
.AddConstructor<
LlcSnapHeader
>();
67
return
tid;
68
}
69
70
TypeId
71
LlcSnapHeader::GetInstanceTypeId
()
const
72
{
73
return
GetTypeId
();
74
}
75
76
void
77
LlcSnapHeader::Print
(std::ostream& os)
const
78
{
79
NS_LOG_FUNCTION
(
this
<< &os);
80
os <<
"type 0x"
;
81
os.setf(std::ios::hex, std::ios::basefield);
82
os <<
m_etherType
;
83
os.setf(std::ios::dec, std::ios::basefield);
84
}
85
86
void
87
LlcSnapHeader::Serialize
(
Buffer::Iterator
start
)
const
88
{
89
NS_LOG_FUNCTION
(
this
<< &
start
);
90
Buffer::Iterator
i =
start
;
91
uint8_t buf[] = {0xaa, 0xaa, 0x03, 0, 0, 0};
92
i.
Write
(buf, 6);
93
i.
WriteHtonU16
(
m_etherType
);
94
}
95
96
uint32_t
97
LlcSnapHeader::Deserialize
(
Buffer::Iterator
start
)
98
{
99
NS_LOG_FUNCTION
(
this
<< &
start
);
100
Buffer::Iterator
i =
start
;
101
i.
Next
(5 + 1);
102
m_etherType
= i.
ReadNtohU16
();
103
return
GetSerializedSize
();
104
}
105
106
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:100
ns3::Buffer::Iterator::Write
void Write(const uint8_t *buffer, uint32_t size)
Definition:
buffer.cc:948
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::Buffer::Iterator::Next
void Next()
go forward by one byte
Definition:
buffer.h:853
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::LlcSnapHeader
Header for the LLC/SNAP encapsulation.
Definition:
llc-snap-header.h:45
ns3::LlcSnapHeader::m_etherType
uint16_t m_etherType
the Ethertype
Definition:
llc-snap-header.h:72
ns3::LlcSnapHeader::Print
void Print(std::ostream &os) const override
Definition:
llc-snap-header.cc:77
ns3::LlcSnapHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
llc-snap-header.cc:61
ns3::LlcSnapHeader::GetType
uint16_t GetType()
Return the Ethertype.
Definition:
llc-snap-header.cc:47
ns3::LlcSnapHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
llc-snap-header.cc:71
ns3::LlcSnapHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
llc-snap-header.cc:54
ns3::LlcSnapHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition:
llc-snap-header.cc:87
ns3::LlcSnapHeader::SetType
void SetType(uint16_t type)
Set the Ethertype.
Definition:
llc-snap-header.cc:40
ns3::LlcSnapHeader::LlcSnapHeader
LlcSnapHeader()
Definition:
llc-snap-header.cc:34
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
llc-snap-header.h
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.
ns3::LLC_SNAP_HEADER_LENGTH
static const uint16_t LLC_SNAP_HEADER_LENGTH
The length in octets of the LLC/SNAP header.
Definition:
llc-snap-header.h:34
two-ray-to-three-gpp-ch-calibration.start
start
Definition:
two-ray-to-three-gpp-ch-calibration.py:520
src
network
utils
llc-snap-header.cc
Generated on Sun Mar 3 2024 17:11:06 for ns-3 by
1.9.1