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
sll-header.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Université Pierre et Marie Curie
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: Matthieu Coudron <matthieu.coudron@lip6.fr>
18
*/
19
#ifndef SLL_HEADER_H
20
#define SLL_HEADER_H
21
22
#include "ns3/buffer.h"
23
#include "ns3/header.h"
24
25
#include <stdint.h>
26
27
namespace
ns3
28
{
29
30
/**
31
* \ingroup packet
32
*
33
* \brief Protocol header serialization and deserialization.
34
*
35
* Libpcap sometimes add an additional header to provide information that would be
36
* lost otherwise due to the link-layer/capture mechanism, for instance when capturing from
37
* "nlmon" device on linux
38
*
39
* \see http://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL.html
40
* \see https://wiki.wireshark.org/SLL
41
*
42
\verbatim
43
+---------------------------+
44
| Packet type |
45
| (2 Octets) |
46
+---------------------------+
47
| ARPHRD_ type |
48
| (2 Octets) |
49
+---------------------------+
50
| Link-layer address length |
51
| (2 Octets) |
52
+---------------------------+
53
| Link-layer address |
54
| (8 Octets) |
55
+---------------------------+
56
| Protocol type |
57
| (2 Octets) |
58
+---------------------------+
59
| Payload |
60
. .
61
. .
62
. .
63
\endverbatim
64
*/
65
class
SllHeader
:
public
Header
66
{
67
public
:
68
/**
69
* Type of the packet.
70
*/
71
enum
PacketType
72
{
73
UNICAST_FROM_PEER_TO_ME
= 0,
/**< the packet was specifically sent to us by somebody else */
74
BROADCAST_BY_PEER
= 1,
/**< packet was broadcast by somebody else */
75
MULTICAST_BY_PEER
= 2,
/**< packet was multicast, but not broadcast, by somebody else */
76
INTERCEPTED_PACKET
= 3,
/**< packet was sent to somebody else by somebody else **/
77
SENT_BY_US
/**< the packet was sent by us */
78
};
79
80
/**
81
* \brief Get the type ID.
82
* \return the object TypeId
83
*/
84
static
TypeId
GetTypeId
();
85
86
SllHeader
();
87
~SllHeader
()
override
;
88
89
/**
90
* \return ARP header type field in network byte order
91
* The ARPHRD_ type field is in network byte order; it contains a Linux ARPHRD_ value for the
92
* link-layer device type.
93
*/
94
uint16_t
GetArpType
()
const
;
95
96
/**
97
* \param arphdType ARP protocol hardware identifier
98
*/
99
void
SetArpType
(uint16_t arphdType);
100
101
/**
102
* \return Packet type
103
*/
104
PacketType
GetPacketType
()
const
;
105
106
/**
107
* \param type Depends on source and address of the packet
108
*/
109
void
SetPacketType
(
PacketType
type);
110
111
// Inherited from ObjectBase
112
TypeId
GetInstanceTypeId
()
const override
;
113
// Inherited from Header
114
uint32_t
GetSerializedSize
()
const override
;
115
void
Serialize
(
Buffer::Iterator
start)
const override
;
116
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
117
void
Print
(std::ostream& os)
const override
;
118
119
protected
:
120
// declared in packet order
121
PacketType
m_packetType
;
/**< Packet type */
122
uint16_t
m_arphdType
;
/**< ARP protocol hardware identifier */
123
uint16_t
m_addressLength
;
/**< Address length */
124
uint64_t
m_address
;
/**< Address */
125
uint16_t
m_protocolType
;
/**< protocol type */
126
};
127
128
}
// namespace ns3
129
130
#endif
/* SLL_HEADER_H */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:100
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:44
ns3::SllHeader
Protocol header serialization and deserialization.
Definition:
sll-header.h:66
ns3::SllHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
sll-header.cc:56
ns3::SllHeader::SetArpType
void SetArpType(uint16_t arphdType)
Definition:
sll-header.cc:68
ns3::SllHeader::m_addressLength
uint16_t m_addressLength
Address length.
Definition:
sll-header.h:123
ns3::SllHeader::GetArpType
uint16_t GetArpType() const
Definition:
sll-header.cc:62
ns3::SllHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
sll-header.cc:94
ns3::SllHeader::m_packetType
PacketType m_packetType
Packet type.
Definition:
sll-header.h:121
ns3::SllHeader::~SllHeader
~SllHeader() override
Definition:
sll-header.cc:40
ns3::SllHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
sll-header.cc:46
ns3::SllHeader::PacketType
PacketType
Type of the packet.
Definition:
sll-header.h:72
ns3::SllHeader::BROADCAST_BY_PEER
@ BROADCAST_BY_PEER
packet was broadcast by somebody else
Definition:
sll-header.h:74
ns3::SllHeader::INTERCEPTED_PACKET
@ INTERCEPTED_PACKET
packet was sent to somebody else by somebody else
Definition:
sll-header.h:76
ns3::SllHeader::UNICAST_FROM_PEER_TO_ME
@ UNICAST_FROM_PEER_TO_ME
the packet was specifically sent to us by somebody else
Definition:
sll-header.h:73
ns3::SllHeader::MULTICAST_BY_PEER
@ MULTICAST_BY_PEER
packet was multicast, but not broadcast, by somebody else
Definition:
sll-header.h:75
ns3::SllHeader::SENT_BY_US
@ SENT_BY_US
the packet was sent by us
Definition:
sll-header.h:77
ns3::SllHeader::m_arphdType
uint16_t m_arphdType
ARP protocol hardware identifier.
Definition:
sll-header.h:122
ns3::SllHeader::GetPacketType
PacketType GetPacketType() const
Definition:
sll-header.cc:75
ns3::SllHeader::SetPacketType
void SetPacketType(PacketType type)
Definition:
sll-header.cc:81
ns3::SllHeader::m_protocolType
uint16_t m_protocolType
protocol type
Definition:
sll-header.h:125
ns3::SllHeader::m_address
uint64_t m_address
Address.
Definition:
sll-header.h:124
ns3::SllHeader::SllHeader
SllHeader()
Definition:
sll-header.cc:30
ns3::SllHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition:
sll-header.cc:111
ns3::SllHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition:
sll-header.cc:100
ns3::SllHeader::Print
void Print(std::ostream &os) const override
Definition:
sll-header.cc:88
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
network
utils
sll-header.h
Generated on Tue May 28 2024 23:38:51 for ns-3 by
1.9.6