use Ptr<> everywhere Object or NsUnknown are used
This commit is contained in:
1 parent
7102517ca9
commit
e70e445975
53 files changed
+379
-518
No files matched your search
@@ -41,35 +41,22 @@ namespace ns3 {
|
||||
|
||||
InternetNode::InternetNode()
|
||||
{
|
||||
Ipv4 *ipv4 = new Ipv4 (this);
|
||||
Arp *arp = new Arp (this);
|
||||
Udp *udp = new Udp (this);
|
||||
Ptr<Ipv4> ipv4 = new Ipv4 (this);
|
||||
Ptr<Arp> arp = new Arp (this);
|
||||
Ptr<Udp> udp = new Udp (this);
|
||||
|
||||
ipv4->Ref ();
|
||||
arp->Ref ();
|
||||
udp->Ref ();
|
||||
|
||||
ApplicationList *applicationList = new ApplicationList(this);
|
||||
L3Demux *l3Demux = new L3Demux(this);
|
||||
Ipv4L4Demux *ipv4L4Demux = new Ipv4L4Demux(this);
|
||||
|
||||
applicationList->Ref ();
|
||||
l3Demux->Ref ();
|
||||
ipv4L4Demux->Ref ();
|
||||
Ptr<ApplicationList> applicationList = new ApplicationList(this);
|
||||
Ptr<L3Demux> l3Demux = new L3Demux(this);
|
||||
Ptr<Ipv4L4Demux> ipv4L4Demux = new Ipv4L4Demux(this);
|
||||
|
||||
l3Demux->Insert (ipv4);
|
||||
l3Demux->Insert (arp);
|
||||
ipv4L4Demux->Insert (udp);
|
||||
|
||||
IUdpImpl *udpImpl = new IUdpImpl (udp);
|
||||
IArpPrivate *arpPrivate = new IArpPrivate (arp);
|
||||
IIpv4Impl *ipv4Impl = new IIpv4Impl (ipv4);
|
||||
IIpv4Private *ipv4Private = new IIpv4Private (ipv4);
|
||||
|
||||
udpImpl->Ref ();
|
||||
arpPrivate->Ref ();
|
||||
ipv4Impl->Ref ();
|
||||
ipv4Private->Ref ();
|
||||
Ptr<IUdpImpl> udpImpl = new IUdpImpl (udp);
|
||||
Ptr<IArpPrivate> arpPrivate = new IArpPrivate (arp);
|
||||
Ptr<IIpv4Impl> ipv4Impl = new IIpv4Impl (ipv4);
|
||||
Ptr<IIpv4Private> ipv4Private = new IIpv4Private (ipv4);
|
||||
|
||||
NsUnknown::AddInterface (ipv4Private);
|
||||
NsUnknown::AddInterface (ipv4Impl);
|
||||
@@ -78,18 +65,6 @@ InternetNode::InternetNode()
|
||||
NsUnknown::AddInterface (applicationList);
|
||||
NsUnknown::AddInterface (l3Demux);
|
||||
NsUnknown::AddInterface (ipv4L4Demux);
|
||||
|
||||
|
||||
applicationList->Unref ();
|
||||
l3Demux->Unref ();
|
||||
ipv4L4Demux->Unref ();
|
||||
arp->Unref ();
|
||||
ipv4->Unref ();
|
||||
udp->Unref ();
|
||||
udpImpl->Unref ();
|
||||
arpPrivate->Unref ();
|
||||
ipv4Impl->Unref ();
|
||||
ipv4Private->Unref ();
|
||||
}
|
||||
|
||||
InternetNode::~InternetNode ()
|
||||
@@ -105,11 +80,10 @@ TraceResolver *
|
||||
InternetNode::CreateTraceResolver (TraceContext const &context)
|
||||
{
|
||||
CompositeTraceResolver *resolver = new CompositeTraceResolver (context);
|
||||
IIpv4Private *ipv4 = QueryInterface<IIpv4Private> (IIpv4Private::iid);
|
||||
Ptr<IIpv4Private> ipv4 = QueryInterface<IIpv4Private> (IIpv4Private::iid);
|
||||
resolver->Add ("ipv4",
|
||||
MakeCallback (&IIpv4Private::CreateTraceResolver, ipv4),
|
||||
MakeCallback (&IIpv4Private::CreateTraceResolver, ipv4.Peek ()),
|
||||
InternetNode::IPV4);
|
||||
ipv4->Unref ();
|
||||
|
||||
return resolver;
|
||||
}
|
||||
@@ -121,17 +95,16 @@ InternetNode::DoDispose()
|
||||
}
|
||||
|
||||
void
|
||||
InternetNode::DoAddDevice (NetDevice *device) const
|
||||
InternetNode::DoAddDevice (Ptr<NetDevice> device) const
|
||||
{
|
||||
device->SetReceiveCallback (MakeCallback (&InternetNode::ReceiveFromDevice, this));
|
||||
}
|
||||
|
||||
bool
|
||||
InternetNode::ReceiveFromDevice (NetDevice *device, const Packet &p, uint16_t protocolNumber) const
|
||||
InternetNode::ReceiveFromDevice (Ptr<NetDevice> device, const Packet &p, uint16_t protocolNumber) const
|
||||
{
|
||||
L3Demux *demux = QueryInterface<L3Demux> (L3Demux::iid);
|
||||
L3Protocol *target = demux->PeekProtocol (protocolNumber);
|
||||
demux->Unref ();
|
||||
Ptr<L3Demux> demux = QueryInterface<L3Demux> (L3Demux::iid);
|
||||
Ptr<L3Protocol> target = demux->GetProtocol (protocolNumber);
|
||||
if (target != 0)
|
||||
{
|
||||
Packet packet = p;
|
||||
|
||||
Reference in new issue
Block a user