remove UdpIpv4L4Protocol class

This commit is contained in:
Mathieu Lacage
2007-02-17 09:42:30 +01:00
parent d7a398bc11
commit c2e3d19e06
7 changed files with 15 additions and 136 deletions

View File

@@ -171,7 +171,6 @@ node.add_sources ([
'l3-protocol.cc',
'ipv4-l4-demux.cc',
'ipv4-l4-protocol.cc',
'udp-ipv4-l4-protocol.cc',
'ipv4-address.cc',
'internet-node.cc',
'net-device.cc',
@@ -203,7 +202,6 @@ node.add_headers ([
'ipv4-checksum.h',
'udp.h',
'ipv4-l4-protocol.h',
'udp-ipv4-l4-protocol.h',
'arp-header.h',
'arp-cache-cache.h',
'arp.h',

View File

@@ -28,7 +28,6 @@
#include "udp.h"
#include "ipv4.h"
#include "arp.h"
#include "udp-ipv4-l4-protocol.h"
#include "ipv4-loopback-interface.h"
namespace ns3 {
@@ -39,10 +38,9 @@ InternetNode::InternetNode()
m_netDevices = new NetDeviceList();
m_l3Demux = new L3Demux(this);
m_ipv4L4Demux = new Ipv4L4Demux(this);
m_udp = new Udp (this);
m_l3Demux->Insert (Ipv4 (this));
m_l3Demux->Insert (Arp (this));
m_ipv4L4Demux->Insert (UdpIpv4L4Protocol (this));
m_ipv4L4Demux->Insert (Udp (this));
SetupLoopback ();
}
@@ -51,7 +49,6 @@ InternetNode::InternetNode (InternetNode const &o)
m_netDevices = new NetDeviceList ();
m_l3Demux = o.m_l3Demux->Copy (this);
m_ipv4L4Demux = o.m_ipv4L4Demux->Copy (this);
m_udp = o.m_udp->Copy (this);
SetupLoopback ();
}
@@ -60,7 +57,6 @@ InternetNode::~InternetNode ()
delete m_netDevices;
delete m_l3Demux;
delete m_ipv4L4Demux;
delete m_udp;
}
void
@@ -109,7 +105,7 @@ InternetNode::GetIpv4 (void) const
Udp *
InternetNode::GetUdp (void) const
{
return m_udp;
return static_cast<Udp*> (m_ipv4L4Demux->Lookup (Udp::PROT_NUMBER));
}
Arp *

View File

@@ -52,8 +52,6 @@ private:
NetDeviceList* m_netDevices;
L3Demux* m_l3Demux;
Ipv4L4Demux* m_ipv4L4Demux;
Udp * m_udp;
Arp * m_arp;
};
}//namespace ns3

View File

@@ -1,58 +0,0 @@
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
//
// Copyright (c) 2006 Georgia Tech Research Corporation
// All rights reserved.
//
// 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: George F. Riley<riley@ece.gatech.edu>
//
// NS3 - Layer 4 Protocol base class
// George F. Riley, Georgia Tech, Spring 2007
#include "udp-ipv4-l4-protocol.h"
#include "node.h"
#include "udp.h"
namespace ns3 {
/* see http://www.iana.org/assignments/protocol-numbers */
const uint8_t UdpIpv4L4Protocol::UDP_PROTOCOL = 17;
UdpIpv4L4Protocol::UdpIpv4L4Protocol(Node *node)
: Ipv4L4Protocol (UDP_PROTOCOL, 2),
m_node (node)
{}
UdpIpv4L4Protocol::~UdpIpv4L4Protocol ()
{}
UdpIpv4L4Protocol*
UdpIpv4L4Protocol::Copy(Node *node) const
{
return new UdpIpv4L4Protocol (node);
}
void
UdpIpv4L4Protocol::Receive(Packet& p,
Ipv4Address const &source,
Ipv4Address const &destination)
{
if (m_node->GetUdp () != 0)
{
m_node->GetUdp ()->Receive (p, source, destination);
}
}
}//namespace ns3

View File

@@ -1,58 +0,0 @@
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
//
// Copyright (c) 2006 Georgia Tech Research Corporation
// All rights reserved.
//
// 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: George F. Riley<riley@ece.gatech.edu>
//
// NS3 - Layer 4 Protocol base class
// George F. Riley, Georgia Tech, Spring 2007
#ifndef UDP_IPV4_L4_PROTOCOL_H
#define UDP_IPV4_L4_PROTOCOL_H
#include <stdint.h>
#include "ipv4-l4-protocol.h"
namespace ns3 {
class Node;
class Packet;
class Ipv4Address;
class UdpIpv4L4Protocol : public Ipv4L4Protocol {
public:
UdpIpv4L4Protocol(Node *node);
virtual ~UdpIpv4L4Protocol ();
virtual UdpIpv4L4Protocol* Copy(Node *node) const;
/**
* Called from lower-level layers to send the packet up
* in the stack.
*/
virtual void Receive(Packet& p,
Ipv4Address const &source,
Ipv4Address const &destination);
private:
Node *m_node;
static const uint8_t UDP_PROTOCOL;
};
} // Namespace ns3
#endif /* UDP_IPV4_L4_PROTOCOL */

View File

@@ -33,10 +33,11 @@
namespace ns3 {
/* see http://www.iana.org/assignments/protocol-numbers */
const uint8_t Udp::UDP_PROTOCOL = 17;
const uint8_t Udp::PROT_NUMBER = 17;
Udp::Udp (Node *node)
: m_node (node),
: Ipv4L4Protocol (PROT_NUMBER, 2),
m_node (node),
m_endPoints (new Ipv4EndPointDemux<UdpEndPoint> ())
{}
@@ -109,14 +110,14 @@ Udp::Send (Packet packet,
udpHeader.SetPayloadSize (packet.GetSize ());
udpHeader.InitializeChecksum (saddr,
daddr,
UDP_PROTOCOL);
PROT_NUMBER);
packet.Add (udpHeader);
Ipv4 *ipv4 = m_node->GetIpv4 ();
if (ipv4 != 0)
{
ipv4->Send (packet, saddr, daddr, UDP_PROTOCOL);
ipv4->Send (packet, saddr, daddr, PROT_NUMBER);
}
}

View File

@@ -28,13 +28,16 @@
#include "ipv4-address.h"
#include "ipv4-end-point-demux.h"
#include "udp-end-point.h"
#include "ipv4-l4-protocol.h"
namespace ns3 {
class Node;
class Udp {
class Udp : public Ipv4L4Protocol {
public:
static const uint8_t PROT_NUMBER;
Udp (Node *node);
virtual ~Udp ();
@@ -50,12 +53,11 @@ public:
Ipv4Address saddr, Ipv4Address daddr,
uint16_t sport, uint16_t dport);
// inherited from Ipv4L4Protocol
Udp* Copy(Node *node) const;
void Receive(Packet& p,
Ipv4Address const &source,
Ipv4Address const &destination);
virtual Udp* Copy(Node *node) const;
virtual void Receive(Packet& p,
Ipv4Address const &source,
Ipv4Address const &destination);
private:
static const uint8_t UDP_PROTOCOL;
Node *m_node;
Ipv4EndPointDemux<UdpEndPoint> *m_endPoints;
};