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