diff --git a/src/internet-stack/arp-l3-protocol.cc b/src/internet-stack/arp-l3-protocol.cc index c2f7ac5ea..f98f9f2ad 100644 --- a/src/internet-stack/arp-l3-protocol.cc +++ b/src/internet-stack/arp-l3-protocol.cc @@ -81,12 +81,15 @@ ArpL3Protocol::SetNode (Ptr node) void ArpL3Protocol::NotifyNewAggregate () { - Ptrnode = this->GetObject (); - //verify that it's a valid node and that - //the node was not set before - if (node!= 0 && m_node == 0) + if (m_node == 0) { - this->SetNode (node); + Ptrnode = this->GetObject (); + //verify that it's a valid node and that + //the node was not set before + if (node != 0) + { + this->SetNode (node); + } } Object::NotifyNewAggregate (); } diff --git a/src/internet-stack/icmpv4-l4-protocol.cc b/src/internet-stack/icmpv4-l4-protocol.cc index 231a58607..93bd54467 100644 --- a/src/internet-stack/icmpv4-l4-protocol.cc +++ b/src/internet-stack/icmpv4-l4-protocol.cc @@ -50,15 +50,20 @@ Icmpv4L4Protocol::SetNode (Ptr node) void Icmpv4L4Protocol::NotifyNewAggregate () { - bool is_not_initialized = (m_node == 0); - Ptrnode = this->GetObject (); - Ptr ipv4 = this->GetObject (); - if (is_not_initialized && node!= 0 && ipv4 != 0) + if (m_node == 0) { - this->SetNode (node); - ipv4->Insert (this); - Ptr rawFactory = CreateObject (); - ipv4->AggregateObject (rawFactory); + Ptr node = this->GetObject (); + if (node != 0) + { + Ptr ipv4 = this->GetObject (); + if (ipv4 != 0) + { + this->SetNode (node); + ipv4->Insert (this); + Ptr rawFactory = CreateObject (); + ipv4->AggregateObject (rawFactory); + } + } } Object::NotifyNewAggregate (); } diff --git a/src/internet-stack/ipv4-l3-protocol.cc b/src/internet-stack/ipv4-l3-protocol.cc index c3bbbf982..793b8bb43 100644 --- a/src/internet-stack/ipv4-l3-protocol.cc +++ b/src/internet-stack/ipv4-l3-protocol.cc @@ -146,12 +146,15 @@ Ipv4L3Protocol::DeleteRawSocket (Ptr socket) void Ipv4L3Protocol::NotifyNewAggregate () { - Ptrnode = this->GetObject(); - // verify that it's a valid node and that - // the node has not been set before - if (node!= 0 && m_node == 0) + if (m_node == 0) { - this->SetNode (node); + Ptrnode = this->GetObject(); + // verify that it's a valid node and that + // the node has not been set before + if (node != 0) + { + this->SetNode (node); + } } Object::NotifyNewAggregate (); } diff --git a/src/internet-stack/nsc-tcp-l4-protocol.cc b/src/internet-stack/nsc-tcp-l4-protocol.cc index 514d4c245..f8af6ec79 100644 --- a/src/internet-stack/nsc-tcp-l4-protocol.cc +++ b/src/internet-stack/nsc-tcp-l4-protocol.cc @@ -164,16 +164,21 @@ NscTcpL4Protocol::SetNode (Ptr node) void NscTcpL4Protocol::NotifyNewAggregate () { - bool is_not_initialized = (m_node == 0); - Ptrnode = this->GetObject (); - Ptr ipv4 = this->GetObject (); - if (is_not_initialized && node!= 0 && ipv4 != 0) + if (m_node == 0) { - this->SetNode (node); - ipv4->Insert (this); - Ptr tcpFactory = CreateObject (); - tcpFactory->SetTcp (this); - node->AggregateObject (tcpFactory); + Ptrnode = this->GetObject (); + if (node != 0) + { + Ptr ipv4 = this->GetObject (); + if (ipv4 != 0) + { + this->SetNode (node); + ipv4->Insert (this); + Ptr tcpFactory = CreateObject (); + tcpFactory->SetTcp (this); + node->AggregateObject (tcpFactory); + } + } } Object::NotifyNewAggregate (); } diff --git a/src/internet-stack/tcp-l4-protocol.cc b/src/internet-stack/tcp-l4-protocol.cc index 93fc216b2..433ea7dbd 100644 --- a/src/internet-stack/tcp-l4-protocol.cc +++ b/src/internet-stack/tcp-l4-protocol.cc @@ -366,16 +366,21 @@ TcpL4Protocol::SetNode (Ptr node) void TcpL4Protocol::NotifyNewAggregate () { - bool is_not_initialized = (m_node == 0); - Ptrnode = this->GetObject (); - Ptr ipv4 = this->GetObject (); - if (is_not_initialized && node!= 0 && ipv4 != 0) + if (m_node == 0) { - this->SetNode (node); - ipv4->Insert (this); - Ptr tcpFactory = CreateObject (); - tcpFactory->SetTcp (this); - node->AggregateObject (tcpFactory); + Ptr node = this->GetObject (); + if (node != 0) + { + Ptr ipv4 = this->GetObject (); + if (ipv4 != 0) + { + this->SetNode (node); + ipv4->Insert (this); + Ptr tcpFactory = CreateObject (); + tcpFactory->SetTcp (this); + node->AggregateObject (tcpFactory); + } + } } Object::NotifyNewAggregate (); } diff --git a/src/internet-stack/udp-l4-protocol.cc b/src/internet-stack/udp-l4-protocol.cc index 2f3bf9fc3..972e3c9bf 100644 --- a/src/internet-stack/udp-l4-protocol.cc +++ b/src/internet-stack/udp-l4-protocol.cc @@ -77,16 +77,21 @@ UdpL4Protocol::SetNode (Ptr node) void UdpL4Protocol::NotifyNewAggregate () { - bool is_not_initialized = (m_node == 0); - Ptrnode = this->GetObject (); - Ptr ipv4 = this->GetObject (); - if (is_not_initialized && node!= 0 && ipv4 != 0) + if (m_node == 0) { - this->SetNode (node); - ipv4->Insert (this); - Ptr udpFactory = CreateObject (); - udpFactory->SetUdp (this); - node->AggregateObject (udpFactory); + Ptr node = this->GetObject (); + if (node != 0) + { + Ptr ipv4 = this->GetObject (); + if (ipv4 != 0) + { + this->SetNode (node); + ipv4->Insert (this); + Ptr udpFactory = CreateObject (); + udpFactory->SetUdp (this); + node->AggregateObject (udpFactory); + } + } } Object::NotifyNewAggregate (); }