A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
llc-snap-header.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
9#include "llc-snap-header.h"
10
11#include "ns3/assert.h"
12#include "ns3/log.h"
13
14#include <string>
15
16namespace ns3
17{
18
19NS_LOG_COMPONENT_DEFINE("LlcSnalHeader");
20
21NS_OBJECT_ENSURE_REGISTERED(LlcSnapHeader);
22
27
28void
30{
31 NS_LOG_FUNCTION(this);
32 m_etherType = type;
33}
34
35uint16_t
37{
38 NS_LOG_FUNCTION(this);
39 return m_etherType;
40}
41
48
51{
52 static TypeId tid = TypeId("ns3::LlcSnapHeader")
54 .SetGroupName("Network")
55 .AddConstructor<LlcSnapHeader>();
56 return tid;
57}
58
61{
62 return GetTypeId();
63}
64
65void
66LlcSnapHeader::Print(std::ostream& os) const
67{
68 NS_LOG_FUNCTION(this << &os);
69 os << "type 0x";
70 os.setf(std::ios::hex, std::ios::basefield);
71 os << m_etherType;
72 os.setf(std::ios::dec, std::ios::basefield);
73}
74
75void
77{
78 NS_LOG_FUNCTION(this << &start);
79 Buffer::Iterator i = start;
80 uint8_t buf[] = {0xaa, 0xaa, 0x03, 0, 0, 0};
81 i.Write(buf, 6);
83}
84
87{
88 NS_LOG_FUNCTION(this << &start);
89 Buffer::Iterator i = start;
90 i.Next(5 + 1);
92 return GetSerializedSize();
93}
94
95} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
void Write(const uint8_t *buffer, uint32_t size)
Definition buffer.cc:937
void WriteHtonU16(uint16_t data)
Definition buffer.h:904
uint16_t ReadNtohU16()
Definition buffer.h:943
void Next()
go forward by one byte
Definition buffer.h:842
Protocol header serialization and deserialization.
Definition header.h:33
Header for the LLC/SNAP encapsulation.
uint32_t Deserialize(Buffer::Iterator start) override
uint16_t m_etherType
the Ethertype
void Print(std::ostream &os) const override
static TypeId GetTypeId()
Get the type ID.
uint16_t GetType()
Return the Ethertype.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint32_t GetSerializedSize() const override
void Serialize(Buffer::Iterator start) const override
void SetType(uint16_t type)
Set the Ethertype.
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.
static const uint16_t LLC_SNAP_HEADER_LENGTH
The length in octets of the LLC/SNAP header.