Merge with code.nsnam.org

This commit is contained in:
Kirill Andreev
2009-07-16 14:57:43 +04:00
67 changed files with 1381 additions and 457 deletions

View File

@@ -81,12 +81,15 @@ ArpL3Protocol::SetNode (Ptr<Node> node)
void
ArpL3Protocol::NotifyNewAggregate ()
{
Ptr<Node>node = this->GetObject<Node> ();
//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);
Ptr<Node>node = this->GetObject<Node> ();
//verify that it's a valid node and that
//the node was not set before
if (node != 0)
{
this->SetNode (node);
}
}
Object::NotifyNewAggregate ();
}

View File

@@ -50,15 +50,20 @@ Icmpv4L4Protocol::SetNode (Ptr<Node> node)
void
Icmpv4L4Protocol::NotifyNewAggregate ()
{
bool is_not_initialized = (m_node == 0);
Ptr<Node>node = this->GetObject<Node> ();
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
if (is_not_initialized && node!= 0 && ipv4 != 0)
if (m_node == 0)
{
this->SetNode (node);
ipv4->Insert (this);
Ptr<Ipv4RawSocketFactoryImpl> rawFactory = CreateObject<Ipv4RawSocketFactoryImpl> ();
ipv4->AggregateObject (rawFactory);
Ptr<Node> node = this->GetObject<Node> ();
if (node != 0)
{
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
if (ipv4 != 0)
{
this->SetNode (node);
ipv4->Insert (this);
Ptr<Ipv4RawSocketFactoryImpl> rawFactory = CreateObject<Ipv4RawSocketFactoryImpl> ();
ipv4->AggregateObject (rawFactory);
}
}
}
Object::NotifyNewAggregate ();
}

View File

@@ -1,52 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2005,2006,2007 INRIA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "ipv4-checksum.h"
namespace ns3 {
uint16_t
Ipv4ChecksumCalculate (uint16_t checksum, uint8_t *buffer, uint16_t size)
{
/* see RFC 1071 to understand this code. */
uint32_t sum = checksum;
uint16_t *data = (uint16_t *) buffer;
for (uint16_t i = 0; i < (size/2); i++) {
sum += data[i];
}
if ((size % 2) != 0) {
uint8_t tmpBuf[2];
tmpBuf[0] = buffer[size-1];
tmpBuf[1] = 0;
data = (uint16_t *)tmpBuf;
sum += *data;
}
while (sum >> 16) {
sum = (sum & 0xffff) + (sum >> 16);
}
return sum;
}
uint16_t
Ipv4ChecksumComplete (uint16_t checksum)
{
return ~checksum;
}
}; //namespace ns3

View File

@@ -1,33 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2005,2006,2007 INRIA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#ifndef IPV4_CHECKSUM_H
#define IPV4_CHECKSUM_H
#include <stdint.h>
namespace ns3 {
uint16_t Ipv4ChecksumCalculate (uint16_t checksum, uint8_t *buffer, uint16_t size);
uint16_t Ipv4ChecksumComplete (uint16_t checksum);
}; //namespace ns3
#endif /* IPV4_CHECKSUM_H */

View File

@@ -178,7 +178,7 @@ Ipv4Interface::SetForwarding (bool val)
void
Ipv4Interface::Send (Ptr<Packet> p, Ipv4Address dest)
{
NS_LOG_FUNCTION_NOARGS ();
NS_LOG_FUNCTION (dest << *p);
if (!IsUp())
{
return;
@@ -199,7 +199,7 @@ Ipv4Interface::Send (Ptr<Packet> p, Ipv4Address dest)
{
Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> ();
ipv4->Receive (0, p, Ipv4L3Protocol::PROT_NUMBER,
ipv4->Receive (m_device, p, Ipv4L3Protocol::PROT_NUMBER,
m_device->GetBroadcast (),
m_device->GetBroadcast (),
NetDevice::PACKET_HOST // note: linux uses PACKET_LOOPBACK here

View File

@@ -146,12 +146,15 @@ Ipv4L3Protocol::DeleteRawSocket (Ptr<Socket> socket)
void
Ipv4L3Protocol::NotifyNewAggregate ()
{
Ptr<Node>node = this->GetObject<Node>();
// 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);
Ptr<Node>node = this->GetObject<Node>();
// verify that it's a valid node and that
// the node has not been set before
if (node != 0)
{
this->SetNode (node);
}
}
Object::NotifyNewAggregate ();
}

View File

@@ -164,16 +164,21 @@ NscTcpL4Protocol::SetNode (Ptr<Node> node)
void
NscTcpL4Protocol::NotifyNewAggregate ()
{
bool is_not_initialized = (m_node == 0);
Ptr<Node>node = this->GetObject<Node> ();
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
if (is_not_initialized && node!= 0 && ipv4 != 0)
if (m_node == 0)
{
this->SetNode (node);
ipv4->Insert (this);
Ptr<NscTcpSocketFactoryImpl> tcpFactory = CreateObject<NscTcpSocketFactoryImpl> ();
tcpFactory->SetTcp (this);
node->AggregateObject (tcpFactory);
Ptr<Node>node = this->GetObject<Node> ();
if (node != 0)
{
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
if (ipv4 != 0)
{
this->SetNode (node);
ipv4->Insert (this);
Ptr<NscTcpSocketFactoryImpl> tcpFactory = CreateObject<NscTcpSocketFactoryImpl> ();
tcpFactory->SetTcp (this);
node->AggregateObject (tcpFactory);
}
}
}
Object::NotifyNewAggregate ();
}

View File

@@ -366,16 +366,21 @@ TcpL4Protocol::SetNode (Ptr<Node> node)
void
TcpL4Protocol::NotifyNewAggregate ()
{
bool is_not_initialized = (m_node == 0);
Ptr<Node>node = this->GetObject<Node> ();
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
if (is_not_initialized && node!= 0 && ipv4 != 0)
if (m_node == 0)
{
this->SetNode (node);
ipv4->Insert (this);
Ptr<TcpSocketFactoryImpl> tcpFactory = CreateObject<TcpSocketFactoryImpl> ();
tcpFactory->SetTcp (this);
node->AggregateObject (tcpFactory);
Ptr<Node> node = this->GetObject<Node> ();
if (node != 0)
{
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
if (ipv4 != 0)
{
this->SetNode (node);
ipv4->Insert (this);
Ptr<TcpSocketFactoryImpl> tcpFactory = CreateObject<TcpSocketFactoryImpl> ();
tcpFactory->SetTcp (this);
node->AggregateObject (tcpFactory);
}
}
}
Object::NotifyNewAggregate ();
}

View File

@@ -77,16 +77,21 @@ UdpL4Protocol::SetNode (Ptr<Node> node)
void
UdpL4Protocol::NotifyNewAggregate ()
{
bool is_not_initialized = (m_node == 0);
Ptr<Node>node = this->GetObject<Node> ();
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
if (is_not_initialized && node!= 0 && ipv4 != 0)
if (m_node == 0)
{
this->SetNode (node);
ipv4->Insert (this);
Ptr<UdpSocketFactoryImpl> udpFactory = CreateObject<UdpSocketFactoryImpl> ();
udpFactory->SetUdp (this);
node->AggregateObject (udpFactory);
Ptr<Node> node = this->GetObject<Node> ();
if (node != 0)
{
Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
if (ipv4 != 0)
{
this->SetNode (node);
ipv4->Insert (this);
Ptr<UdpSocketFactoryImpl> udpFactory = CreateObject<UdpSocketFactoryImpl> ();
udpFactory->SetUdp (this);
node->AggregateObject (udpFactory);
}
}
}
Object::NotifyNewAggregate ();
}

View File

@@ -78,7 +78,6 @@ def build(bld):
'ipv4-l4-protocol.cc',
'udp-header.cc',
'tcp-header.cc',
'ipv4-checksum.cc',
'ipv4-interface.cc',
'ipv4-l3-protocol.cc',
'ipv4-end-point.cc',