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/iana-ppp-numbers.h"
13
#include "ns3/log.h"
14
15
#include <iostream>
16
17
namespace
ns3
18
{
19
20
NS_LOG_COMPONENT_DEFINE
(
"PppHeader"
);
21
22
NS_OBJECT_ENSURE_REGISTERED
(
PppHeader
);
23
24
PppHeader::PppHeader
()
25
{
26
}
27
28
PppHeader::~PppHeader
()
29
{
30
}
31
32
TypeId
33
PppHeader::GetTypeId
()
34
{
35
static
TypeId
tid =
TypeId
(
"ns3::PppHeader"
)
36
.
SetParent
<
Header
>()
37
.SetGroupName(
"PointToPoint"
)
38
.AddConstructor<
PppHeader
>();
39
return
tid;
40
}
41
42
TypeId
43
PppHeader::GetInstanceTypeId
()
const
44
{
45
return
GetTypeId
();
46
}
47
48
void
49
PppHeader::Print
(std::ostream& os)
const
50
{
51
std::string proto;
52
53
switch
(
m_protocol
)
54
{
55
case
iana::pppdllnumbers::IPV4_DLL
:
56
proto =
"IP (0x0021)"
;
57
break
;
58
case
iana::pppdllnumbers::IPV6_DLL
:
59
proto =
"IPv6 (0x0057)"
;
60
break
;
61
default
:
62
NS_ASSERT_MSG
(
false
,
"PPP DLL Protocol number not defined!"
);
63
}
64
os <<
"Point-to-Point Protocol: "
<< proto;
65
}
66
67
uint32_t
68
PppHeader::GetSerializedSize
()
const
69
{
70
return
2;
71
}
72
73
void
74
PppHeader::Serialize
(
Buffer::Iterator
start)
const
75
{
76
start.WriteHtonU16(
m_protocol
);
77
}
78
79
uint32_t
80
PppHeader::Deserialize
(
Buffer::Iterator
start)
81
{
82
m_protocol
= start.ReadNtohU16();
83
return
GetSerializedSize
();
84
}
85
86
void
87
PppHeader::SetProtocol
(uint16_t protocol)
88
{
89
m_protocol
= protocol;
90
}
91
92
uint16_t
93
PppHeader::GetProtocol
()
const
94
{
95
return
m_protocol
;
96
}
97
98
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:109
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:36
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:87
ns3::PppHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
ppp-header.cc:80
ns3::PppHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the TypeId of the instance.
Definition
ppp-header.cc:43
ns3::PppHeader::GetTypeId
static TypeId GetTypeId()
Get the TypeId.
Definition
ppp-header.cc:33
ns3::PppHeader::~PppHeader
~PppHeader() override
Destroy a PPP header.
Definition
ppp-header.cc:28
ns3::PppHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
ppp-header.cc:68
ns3::PppHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
ppp-header.cc:74
ns3::PppHeader::GetProtocol
uint16_t GetProtocol() const
Get the protocol type carried by this PPP packet.
Definition
ppp-header.cc:93
ns3::PppHeader::PppHeader
PppHeader()
Construct a PPP header.
Definition
ppp-header.cc:24
ns3::PppHeader::Print
void Print(std::ostream &os) const override
Definition
ppp-header.cc:49
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:50
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1003
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:76
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:201
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3::iana::pppdllnumbers::IPV4_DLL
constexpr uint16_t IPV4_DLL
IPv4 PPP protocol number.
Definition
iana-ppp-numbers.h:28
ns3::iana::pppdllnumbers::IPV6_DLL
constexpr uint16_t IPV6_DLL
IPv6 PPP protocol number.
Definition
iana-ppp-numbers.h:29
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
for ns-3 by
1.16.1