A Discrete-Event Network Simulator
API
ipv6-extension-demux.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007-2009 Strasbourg University
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: David Gross <gdavid.devel@gmail.com>
18  */
19 
20 #include "ipv6-extension-demux.h"
21 
22 #include "ipv6-extension.h"
23 
24 #include "ns3/node.h"
25 #include "ns3/object-vector.h"
26 #include "ns3/ptr.h"
27 
28 #include <sstream>
29 
30 namespace ns3
31 {
32 
33 NS_OBJECT_ENSURE_REGISTERED(Ipv6ExtensionDemux);
34 
35 TypeId
37 {
38  static TypeId tid =
39  TypeId("ns3::Ipv6ExtensionDemux")
40  .SetParent<Object>()
41  .SetGroupName("Internet")
42  .AddAttribute("Extensions",
43  "The set of IPv6 extensions registered with this demux.",
46  MakeObjectVectorChecker<Ipv6Extension>());
47  return tid;
48 }
49 
51 {
52 }
53 
55 {
56 }
57 
58 void
60 {
61  for (auto it = m_extensions.begin(); it != m_extensions.end(); it++)
62  {
63  (*it)->Dispose();
64  *it = nullptr;
65  }
66  m_extensions.clear();
67  m_node = nullptr;
69 }
70 
71 void
73 {
74  m_node = node;
75 }
76 
77 void
79 {
80  m_extensions.push_back(extension);
81 }
82 
84 Ipv6ExtensionDemux::GetExtension(uint8_t extensionNumber)
85 {
86  for (auto i = m_extensions.begin(); i != m_extensions.end(); ++i)
87  {
88  if ((*i)->GetExtensionNumber() == extensionNumber)
89  {
90  return *i;
91  }
92  }
93  return nullptr;
94 }
95 
96 void
98 {
99  m_extensions.remove(extension);
100 }
101 
102 } /* namespace ns3 */
Ipv6ExtensionList_t m_extensions
List of IPv6 Extensions supported.
void SetNode(Ptr< Node > node)
Set the node.
void DoDispose() override
Dispose object.
static TypeId GetTypeId()
The interface ID.
~Ipv6ExtensionDemux() override
Destructor.
Ptr< Node > m_node
The node.
void Remove(Ptr< Ipv6Extension > extension)
Remove an extension from this demux.
Ptr< Ipv6Extension > GetExtension(uint8_t extensionNumber)
Get the extension corresponding to extensionNumber.
void Insert(Ptr< Ipv6Extension > extension)
Insert a new IPv6 Extension.
A base class which provides memory management and object aggregation.
Definition: object.h:89
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:352
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
#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.
ObjectPtrContainerValue ObjectVectorValue
ObjectVectorValue is an alias for ObjectPtrContainerValue.
Definition: object-vector.h:40
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition: object-vector.h:76