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
llc-snap-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2005 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
9
#include "
llc-snap-header.h
"
10
11
#include "ns3/assert.h"
12
#include "ns3/log.h"
13
14
#include <string>
15
16
namespace
ns3
17
{
18
19
NS_LOG_COMPONENT_DEFINE
(
"LlcSnalHeader"
);
20
21
NS_OBJECT_ENSURE_REGISTERED
(LlcSnapHeader);
22
23
LlcSnapHeader::LlcSnapHeader
()
24
{
25
NS_LOG_FUNCTION
(
this
);
26
}
27
28
void
29
LlcSnapHeader::SetType
(uint16_t type)
30
{
31
NS_LOG_FUNCTION
(
this
);
32
m_etherType
= type;
33
}
34
35
uint16_t
36
LlcSnapHeader::GetType
()
37
{
38
NS_LOG_FUNCTION
(
this
);
39
return
m_etherType
;
40
}
41
42
uint32_t
43
LlcSnapHeader::GetSerializedSize
()
const
44
{
45
NS_LOG_FUNCTION
(
this
);
46
return
LLC_SNAP_HEADER_LENGTH
;
47
}
48
49
TypeId
50
LlcSnapHeader::GetTypeId
()
51
{
52
static
TypeId
tid =
TypeId
(
"ns3::LlcSnapHeader"
)
53
.
SetParent
<
Header
>()
54
.SetGroupName(
"Network"
)
55
.AddConstructor<
LlcSnapHeader
>();
56
return
tid;
57
}
58
59
TypeId
60
LlcSnapHeader::GetInstanceTypeId
()
const
61
{
62
return
GetTypeId
();
63
}
64
65
void
66
LlcSnapHeader::Print
(std::ostream& os)
const
67
{
68
NS_LOG_FUNCTION
(
this
<< &os);
69
os <<
"type 0x"
;
70
os.setf(std::ios::hex, std::ios::basefield);
71
os <<
m_etherType
;
72
os.setf(std::ios::dec, std::ios::basefield);
73
}
74
75
void
76
LlcSnapHeader::Serialize
(
Buffer::Iterator
start)
const
77
{
78
NS_LOG_FUNCTION
(
this
<< &start);
79
Buffer::Iterator
i = start;
80
uint8_t buf[] = {0xaa, 0xaa, 0x03, 0, 0, 0};
81
i.
Write
(buf, 6);
82
i.
WriteHtonU16
(
m_etherType
);
83
}
84
85
uint32_t
86
LlcSnapHeader::Deserialize
(
Buffer::Iterator
start)
87
{
88
NS_LOG_FUNCTION
(
this
<< &start);
89
Buffer::Iterator
i = start;
90
i.
Next
(5 + 1);
91
m_etherType
= i.
ReadNtohU16
();
92
return
GetSerializedSize
();
93
}
94
95
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Buffer::Iterator::Write
void Write(const uint8_t *buffer, uint32_t size)
Definition
buffer.cc:937
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::Buffer::Iterator::Next
void Next()
go forward by one byte
Definition
buffer.h:842
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::LlcSnapHeader
Header for the LLC/SNAP encapsulation.
Definition
llc-snap-header.h:34
ns3::LlcSnapHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
llc-snap-header.cc:86
ns3::LlcSnapHeader::m_etherType
uint16_t m_etherType
the Ethertype
Definition
llc-snap-header.h:61
ns3::LlcSnapHeader::Print
void Print(std::ostream &os) const override
Definition
llc-snap-header.cc:66
ns3::LlcSnapHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
llc-snap-header.cc:50
ns3::LlcSnapHeader::GetType
uint16_t GetType()
Return the Ethertype.
Definition
llc-snap-header.cc:36
ns3::LlcSnapHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
llc-snap-header.cc:60
ns3::LlcSnapHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
llc-snap-header.cc:43
ns3::LlcSnapHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
llc-snap-header.cc:76
ns3::LlcSnapHeader::SetType
void SetType(uint16_t type)
Set the Ethertype.
Definition
llc-snap-header.cc:29
ns3::LlcSnapHeader::LlcSnapHeader
LlcSnapHeader()
Definition
llc-snap-header.cc:23
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
llc-snap-header.h
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:23
src
network
utils
llc-snap-header.cc
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0