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 * 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
20#include "llc-snap-header.h"
21
22#include "ns3/assert.h"
23#include "ns3/log.h"
24
25#include <string>
26
27namespace ns3
28{
29
30NS_LOG_COMPONENT_DEFINE("LlcSnalHeader");
31
32NS_OBJECT_ENSURE_REGISTERED(LlcSnapHeader);
33
35{
36 NS_LOG_FUNCTION(this);
37}
38
39void
41{
42 NS_LOG_FUNCTION(this);
43 m_etherType = type;
44}
45
46uint16_t
48{
49 NS_LOG_FUNCTION(this);
50 return m_etherType;
51}
52
55{
56 NS_LOG_FUNCTION(this);
58}
59
62{
63 static TypeId tid = TypeId("ns3::LlcSnapHeader")
65 .SetGroupName("Network")
66 .AddConstructor<LlcSnapHeader>();
67 return tid;
68}
69
72{
73 return GetTypeId();
74}
75
76void
77LlcSnapHeader::Print(std::ostream& os) const
78{
79 NS_LOG_FUNCTION(this << &os);
80 os << "type 0x";
81 os.setf(std::ios::hex, std::ios::basefield);
82 os << m_etherType;
83 os.setf(std::ios::dec, std::ios::basefield);
84}
85
86void
88{
89 NS_LOG_FUNCTION(this << &start);
90 Buffer::Iterator i = start;
91 uint8_t buf[] = {0xaa, 0xaa, 0x03, 0, 0, 0};
92 i.Write(buf, 6);
94}
95
98{
99 NS_LOG_FUNCTION(this << &start);
100 Buffer::Iterator i = start;
101 i.Next(5 + 1);
103 return GetSerializedSize();
104}
105
106} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
void Write(const uint8_t *buffer, uint32_t size)
Definition: buffer.cc:948
void WriteHtonU16(uint16_t data)
Definition: buffer.h:915
uint16_t ReadNtohU16()
Definition: buffer.h:954
void Next()
go forward by one byte
Definition: buffer.h:853
Protocol header serialization and deserialization.
Definition: header.h:44
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:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:46
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.