A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
sll-header.cc
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#include "sll-header.h"
9
10#include "ns3/log.h"
11
12namespace ns3
13{
14
15NS_LOG_COMPONENT_DEFINE("SllHeader");
16
18
20 : m_packetType(UNICAST_FROM_PEER_TO_ME),
21 m_arphdType(0),
22 m_addressLength(0),
23 m_address(0),
24 m_protocolType(0)
25{
26 NS_LOG_FUNCTION(this);
27}
28
33
36{
37 static TypeId tid = TypeId("ns3::SllHeader")
39 .SetGroupName("Network")
40 .AddConstructor<SllHeader>();
41 return tid;
42}
43
46{
47 return GetTypeId();
48}
49
50uint16_t
52{
53 return m_arphdType;
54}
55
56void
57SllHeader::SetArpType(uint16_t arphdType)
58{
59 NS_LOG_FUNCTION(arphdType);
60 m_arphdType = arphdType;
61}
62
65{
66 return m_packetType;
67}
68
69void
75
76void
77SllHeader::Print(std::ostream& os) const
78{
79 os << "SLLHeader packetType=" << m_packetType << " protocol=" << m_protocolType;
80}
81
84{
85 return 2 + 2 + 2 + 8 + 2;
86}
87
88void
98
101{
102 Buffer::Iterator i = start;
103 m_packetType = static_cast<PacketType>(i.ReadNtohU16());
108
109 return GetSerializedSize();
110}
111
112} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
void WriteHtonU64(uint64_t data)
Definition buffer.cc:923
uint64_t ReadNtohU64()
Definition buffer.cc:1030
void WriteHtonU16(uint16_t data)
Definition buffer.h:904
uint16_t ReadNtohU16()
Definition buffer.h:943
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
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
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.