A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
bridge-channel.cc
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0-only
3 *
4 * Author: Gustavo Carneiro <gjc@inescporto.pt>
5 */
6
7#include "bridge-channel.h"
8
9#include "ns3/log.h"
10
11/**
12 * \file
13 * \ingroup bridge
14 * ns3::BridgeChannel implementation.
15 */
16
17namespace ns3
18{
19
20NS_LOG_COMPONENT_DEFINE("BridgeChannel");
21
22NS_OBJECT_ENSURE_REGISTERED(BridgeChannel);
23
24TypeId
26{
27 static TypeId tid = TypeId("ns3::BridgeChannel")
29 .SetGroupName("Bridge")
30 .AddConstructor<BridgeChannel>();
31 return tid;
32}
33
39
41{
43
44 for (auto iter = m_bridgedChannels.begin(); iter != m_bridgedChannels.end(); iter++)
45 {
46 *iter = nullptr;
47 }
48 m_bridgedChannels.clear();
49}
50
51void
53{
54 m_bridgedChannels.push_back(bridgedChannel);
55}
56
57std::size_t
59{
60 uint32_t ndevices = 0;
61 for (auto iter = m_bridgedChannels.begin(); iter != m_bridgedChannels.end(); iter++)
62 {
63 ndevices += (*iter)->GetNDevices();
64 }
65 return ndevices;
66}
67
69BridgeChannel::GetDevice(std::size_t i) const
70{
71 std::size_t ndevices = 0;
72 for (auto iter = m_bridgedChannels.begin(); iter != m_bridgedChannels.end(); iter++)
73 {
74 if ((i - ndevices) < (*iter)->GetNDevices())
75 {
76 return (*iter)->GetDevice(i - ndevices);
77 }
78 ndevices += (*iter)->GetNDevices();
79 }
80 return nullptr;
81}
82
83} // namespace ns3
ns3::BridgeChannel declaration.
Virtual channel implementation for bridges (BridgeNetDevice).
~BridgeChannel() override
void AddChannel(Ptr< Channel > bridgedChannel)
Adds a channel to the bridged pool.
static TypeId GetTypeId()
Get the type ID.
std::vector< Ptr< Channel > > m_bridgedChannels
pool of bridged channels
std::size_t GetNDevices() const override
Ptr< NetDevice > GetDevice(std::size_t i) const override
Abstract Channel Base Class.
Definition channel.h:34
Smart pointer class similar to boost::intrusive_ptr.
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_NOARGS()
Output the name of the function.
#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.