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