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
ppp-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008 University of Washington
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*/
6
7
#include "
ppp-header.h
"
8
9
#include "ns3/abort.h"
10
#include "ns3/assert.h"
11
#include "ns3/header.h"
12
#include "ns3/log.h"
13
14
#include <iostream>
15
16
namespace
ns3
17
{
18
19
NS_LOG_COMPONENT_DEFINE
(
"PppHeader"
);
20
21
NS_OBJECT_ENSURE_REGISTERED
(PppHeader);
22
23
PppHeader::PppHeader
()
24
{
25
}
26
27
PppHeader::~PppHeader
()
28
{
29
}
30
31
TypeId
32
PppHeader::GetTypeId
()
33
{
34
static
TypeId
tid =
TypeId
(
"ns3::PppHeader"
)
35
.
SetParent
<
Header
>()
36
.SetGroupName(
"PointToPoint"
)
37
.AddConstructor<
PppHeader
>();
38
return
tid;
39
}
40
41
TypeId
42
PppHeader::GetInstanceTypeId
()
const
43
{
44
return
GetTypeId
();
45
}
46
47
void
48
PppHeader::Print
(std::ostream& os)
const
49
{
50
std::string proto;
51
52
switch
(
m_protocol
)
53
{
54
case
0x0021:
/* IPv4 */
55
proto =
"IP (0x0021)"
;
56
break
;
57
case
0x0057:
/* IPv6 */
58
proto =
"IPv6 (0x0057)"
;
59
break
;
60
default
:
61
NS_ASSERT_MSG
(
false
,
"PPP Protocol number not defined!"
);
62
}
63
os <<
"Point-to-Point Protocol: "
<< proto;
64
}
65
66
uint32_t
67
PppHeader::GetSerializedSize
()
const
68
{
69
return
2;
70
}
71
72
void
73
PppHeader::Serialize
(
Buffer::Iterator
start)
const
74
{
75
start.WriteHtonU16(
m_protocol
);
76
}
77
78
uint32_t
79
PppHeader::Deserialize
(
Buffer::Iterator
start)
80
{
81
m_protocol
= start.ReadNtohU16();
82
return
GetSerializedSize
();
83
}
84
85
void
86
PppHeader::SetProtocol
(uint16_t protocol)
87
{
88
m_protocol
= protocol;
89
}
90
91
uint16_t
92
PppHeader::GetProtocol
()
const
93
{
94
return
m_protocol
;
95
}
96
97
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::PppHeader
Packet header for PPP.
Definition
ppp-header.h:38
ns3::PppHeader::m_protocol
uint16_t m_protocol
The PPP protocol type of the payload packet.
Definition
ppp-header.h:91
ns3::PppHeader::SetProtocol
void SetProtocol(uint16_t protocol)
Set the protocol type carried by this PPP packet.
Definition
ppp-header.cc:86
ns3::PppHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
ppp-header.cc:79
ns3::PppHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the TypeId of the instance.
Definition
ppp-header.cc:42
ns3::PppHeader::GetTypeId
static TypeId GetTypeId()
Get the TypeId.
Definition
ppp-header.cc:32
ns3::PppHeader::~PppHeader
~PppHeader() override
Destroy a PPP header.
Definition
ppp-header.cc:27
ns3::PppHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
ppp-header.cc:67
ns3::PppHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
ppp-header.cc:73
ns3::PppHeader::GetProtocol
uint16_t GetProtocol() const
Get the protocol type carried by this PPP packet.
Definition
ppp-header.cc:92
ns3::PppHeader::PppHeader
PppHeader()
Construct a PPP header.
Definition
ppp-header.cc:23
ns3::PppHeader::Print
void Print(std::ostream &os) const override
Definition
ppp-header.cc:48
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_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition
assert.h:75
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ppp-header.h
src
point-to-point
model
ppp-header.cc
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0