--- a/SConstruct Mon Jun 04 17:14:59 2007 +0200
+++ b/SConstruct Mon Jun 04 17:18:02 2007 +0200
@@ -265,7 +265,7 @@
'ipv4-interface.cc',
'ipv4-l3-protocol.cc',
'ipv4-end-point.cc',
- 'udp.cc',
+ 'udp-l4-protocol.cc',
'arp-header.cc',
'arp-cache.cc',
'arp-ipv4-interface.cc',
@@ -293,7 +293,7 @@
'header-utils.h',
'arp-ipv4-interface.h',
'udp-socket.h',
- 'udp.h',
+ 'udp-l4-protocol.h',
'arp-private.h',
'ipv4-impl.h',
'ipv4-private.h',
--- a/src/internet-node/internet-node.cc Mon Jun 04 17:14:59 2007 +0200
+++ b/src/internet-node/internet-node.cc Mon Jun 04 17:18:02 2007 +0200
@@ -27,7 +27,7 @@
#include "l3-demux.h"
#include "ipv4-l4-demux.h"
#include "internet-node.h"
-#include "udp.h"
+#include "udp-l4-protocol.h"
#include "ipv4-l3-protocol.h"
#include "arp-l3-protocol.h"
#include "udp-impl.h"
--- a/src/internet-node/udp-impl.cc Mon Jun 04 17:14:59 2007 +0200
+++ b/src/internet-node/udp-impl.cc Mon Jun 04 17:18:02 2007 +0200
@@ -19,7 +19,7 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "udp-impl.h"
-#include "udp.h"
+#include "udp-l4-protocol.h"
#include "ns3/socket.h"
#include "ns3/assert.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/internet-node/udp-l4-protocol.cc Mon Jun 04 17:18:02 2007 +0200
@@ -0,0 +1,149 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005 INRIA
+ * 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+
+#include "ns3/assert.h"
+#include "ns3/packet.h"
+#include "ns3/empty-trace-resolver.h"
+#include "ns3/node.h"
+
+#include "udp-l4-protocol.h"
+#include "udp-header.h"
+#include "ipv4-end-point-demux.h"
+#include "ipv4-end-point.h"
+#include "ipv4-l3-protocol.h"
+#include "ipv4-private.h"
+#include "l3-demux.h"
+#include "udp-socket.h"
+
+namespace ns3 {
+
+/* see http://www.iana.org/assignments/protocol-numbers */
+const uint8_t Udp::PROT_NUMBER = 17;
+
+Udp::Udp (Ptr<Node> node)
+ : Ipv4L4Protocol (PROT_NUMBER, 2),
+ m_node (node),
+ m_endPoints (new Ipv4EndPointDemux ())
+{}
+
+Udp::~Udp ()
+{}
+
+TraceResolver *
+Udp::CreateTraceResolver (TraceContext const &context)
+{
+ return new EmptyTraceResolver (context);
+}
+
+void
+Udp::DoDispose (void)
+{
+ if (m_endPoints != 0)
+ {
+ delete m_endPoints;
+ m_endPoints = 0;
+ }
+ m_node = 0;
+ Ipv4L4Protocol::DoDispose ();
+}
+
+Ptr<Socket>
+Udp::CreateSocket (void)
+{
+ Ptr<Socket> socket = Create<UdpSocket> (m_node, this);
+ return socket;
+}
+
+Ipv4EndPoint *
+Udp::Allocate (void)
+{
+ return m_endPoints->Allocate ();
+}
+Ipv4EndPoint *
+Udp::Allocate (Ipv4Address address)
+{
+ return m_endPoints->Allocate (address);
+}
+Ipv4EndPoint *
+Udp::Allocate (uint16_t port)
+{
+ return m_endPoints->Allocate (port);
+}
+Ipv4EndPoint *
+Udp::Allocate (Ipv4Address address, uint16_t port)
+{
+ return m_endPoints->Allocate (address, port);
+}
+Ipv4EndPoint *
+Udp::Allocate (Ipv4Address localAddress, uint16_t localPort,
+ Ipv4Address peerAddress, uint16_t peerPort)
+{
+ return m_endPoints->Allocate (localAddress, localPort,
+ peerAddress, peerPort);
+}
+
+void
+Udp::DeAllocate (Ipv4EndPoint *endPoint)
+{
+ m_endPoints->DeAllocate (endPoint);
+}
+
+void
+Udp::Receive(Packet& packet,
+ Ipv4Address const &source,
+ Ipv4Address const &destination)
+{
+ UdpHeader udpHeader;
+ packet.RemoveHeader (udpHeader);
+ Ipv4EndPoint *endPoint = m_endPoints->Lookup (destination, udpHeader.GetDestination (),
+ source, udpHeader.GetSource ());
+ if (endPoint == 0)
+ {
+ return;
+ }
+ endPoint->ForwardUp (packet, source, udpHeader.GetSource ());
+}
+
+void
+Udp::Send (Packet packet,
+ Ipv4Address saddr, Ipv4Address daddr,
+ uint16_t sport, uint16_t dport)
+{
+ UdpHeader udpHeader;
+ udpHeader.SetDestination (dport);
+ udpHeader.SetSource (sport);
+ udpHeader.SetPayloadSize (packet.GetSize ());
+ udpHeader.InitializeChecksum (saddr,
+ daddr,
+ PROT_NUMBER);
+
+ packet.AddHeader (udpHeader);
+
+ Ptr<IIpv4Private> ipv4 = m_node->QueryInterface<IIpv4Private> (IIpv4Private::iid);
+ if (ipv4 != 0)
+ {
+ ipv4->Send (packet, saddr, daddr, PROT_NUMBER);
+ }
+}
+
+
+}; // namespace ns3
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/internet-node/udp-l4-protocol.h Mon Jun 04 17:18:02 2007 +0200
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005,2006,2007 INRIA
+ * 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+
+#ifndef UDP_H
+#define UDP_H
+
+#include <stdint.h>
+
+#include "ns3/packet.h"
+#include "ns3/ipv4-address.h"
+#include "ns3/ptr.h"
+#include "ipv4-end-point-demux.h"
+#include "ipv4-l4-protocol.h"
+
+namespace ns3 {
+
+class Node;
+class TraceResolver;
+class TraceContext;
+class Socket;
+/**
+ * \brief Implementation of the UDP protocol
+ */
+class Udp : public Ipv4L4Protocol {
+public:
+ static const uint8_t PROT_NUMBER;
+ /**
+ * \brief Constructor
+ * \param node The node this protocol is associated with
+ */
+ Udp (Ptr<Node> node);
+ virtual ~Udp ();
+
+ virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
+ /**
+ * \return A smart Socket pointer to a UdpSocket, allocated by this instance
+ * of the UDP protocol
+ */
+ Ptr<Socket> CreateSocket (void);
+
+ Ipv4EndPoint *Allocate (void);
+ Ipv4EndPoint *Allocate (Ipv4Address address);
+ Ipv4EndPoint *Allocate (uint16_t port);
+ Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
+ Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
+ Ipv4Address peerAddress, uint16_t peerPort);
+
+ void DeAllocate (Ipv4EndPoint *endPoint);
+
+ // called by UdpSocket.
+ /**
+ * \brief Send a packet via UDP
+ * \param packet The packet to send
+ * \param saddr The source Ipv4Address
+ * \param daddr The destination Ipv4Address
+ * \param sport The source port number
+ * \param dport The destination port number
+ */
+ void Send (Packet packet,
+ Ipv4Address saddr, Ipv4Address daddr,
+ uint16_t sport, uint16_t dport);
+ /**
+ * \brief Recieve a packet up the protocol stack
+ * \param p The Packet to dump the contents into
+ * \param source The source's Ipv4Address
+ * \param destination The destinations Ipv4Address
+ */
+ // inherited from Ipv4L4Protocol
+ virtual void Receive(Packet& p,
+ Ipv4Address const &source,
+ Ipv4Address const &destination);
+protected:
+ virtual void DoDispose (void);
+private:
+ Ptr<Node> m_node;
+ Ipv4EndPointDemux *m_endPoints;
+};
+
+}; // namespace ns3
+
+#endif /* UDP_H */
--- a/src/internet-node/udp-socket.cc Mon Jun 04 17:14:59 2007 +0200
+++ b/src/internet-node/udp-socket.cc Mon Jun 04 17:18:02 2007 +0200
@@ -20,7 +20,7 @@
*/
#include "ns3/node.h"
#include "udp-socket.h"
-#include "udp.h"
+#include "udp-l4-protocol.h"
#include "ipv4-end-point.h"
#include "ipv4-l4-demux.h"
--- a/src/internet-node/udp.cc Mon Jun 04 17:14:59 2007 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005 INRIA
- * 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-
-#include "ns3/assert.h"
-#include "ns3/packet.h"
-#include "ns3/empty-trace-resolver.h"
-#include "ns3/node.h"
-
-#include "udp.h"
-#include "udp-header.h"
-#include "ipv4-end-point-demux.h"
-#include "ipv4-end-point.h"
-#include "ipv4-l3-protocol.h"
-#include "ipv4-private.h"
-#include "l3-demux.h"
-#include "udp-socket.h"
-
-namespace ns3 {
-
-/* see http://www.iana.org/assignments/protocol-numbers */
-const uint8_t Udp::PROT_NUMBER = 17;
-
-Udp::Udp (Ptr<Node> node)
- : Ipv4L4Protocol (PROT_NUMBER, 2),
- m_node (node),
- m_endPoints (new Ipv4EndPointDemux ())
-{}
-
-Udp::~Udp ()
-{}
-
-TraceResolver *
-Udp::CreateTraceResolver (TraceContext const &context)
-{
- return new EmptyTraceResolver (context);
-}
-
-void
-Udp::DoDispose (void)
-{
- if (m_endPoints != 0)
- {
- delete m_endPoints;
- m_endPoints = 0;
- }
- m_node = 0;
- Ipv4L4Protocol::DoDispose ();
-}
-
-Ptr<Socket>
-Udp::CreateSocket (void)
-{
- Ptr<Socket> socket = Create<UdpSocket> (m_node, this);
- return socket;
-}
-
-Ipv4EndPoint *
-Udp::Allocate (void)
-{
- return m_endPoints->Allocate ();
-}
-Ipv4EndPoint *
-Udp::Allocate (Ipv4Address address)
-{
- return m_endPoints->Allocate (address);
-}
-Ipv4EndPoint *
-Udp::Allocate (uint16_t port)
-{
- return m_endPoints->Allocate (port);
-}
-Ipv4EndPoint *
-Udp::Allocate (Ipv4Address address, uint16_t port)
-{
- return m_endPoints->Allocate (address, port);
-}
-Ipv4EndPoint *
-Udp::Allocate (Ipv4Address localAddress, uint16_t localPort,
- Ipv4Address peerAddress, uint16_t peerPort)
-{
- return m_endPoints->Allocate (localAddress, localPort,
- peerAddress, peerPort);
-}
-
-void
-Udp::DeAllocate (Ipv4EndPoint *endPoint)
-{
- m_endPoints->DeAllocate (endPoint);
-}
-
-void
-Udp::Receive(Packet& packet,
- Ipv4Address const &source,
- Ipv4Address const &destination)
-{
- UdpHeader udpHeader;
- packet.RemoveHeader (udpHeader);
- Ipv4EndPoint *endPoint = m_endPoints->Lookup (destination, udpHeader.GetDestination (),
- source, udpHeader.GetSource ());
- if (endPoint == 0)
- {
- return;
- }
- endPoint->ForwardUp (packet, source, udpHeader.GetSource ());
-}
-
-void
-Udp::Send (Packet packet,
- Ipv4Address saddr, Ipv4Address daddr,
- uint16_t sport, uint16_t dport)
-{
- UdpHeader udpHeader;
- udpHeader.SetDestination (dport);
- udpHeader.SetSource (sport);
- udpHeader.SetPayloadSize (packet.GetSize ());
- udpHeader.InitializeChecksum (saddr,
- daddr,
- PROT_NUMBER);
-
- packet.AddHeader (udpHeader);
-
- Ptr<IIpv4Private> ipv4 = m_node->QueryInterface<IIpv4Private> (IIpv4Private::iid);
- if (ipv4 != 0)
- {
- ipv4->Send (packet, saddr, daddr, PROT_NUMBER);
- }
-}
-
-
-}; // namespace ns3
-
--- a/src/internet-node/udp.h Mon Jun 04 17:14:59 2007 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006,2007 INRIA
- * 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-
-#ifndef UDP_H
-#define UDP_H
-
-#include <stdint.h>
-
-#include "ns3/packet.h"
-#include "ns3/ipv4-address.h"
-#include "ns3/ptr.h"
-#include "ipv4-end-point-demux.h"
-#include "ipv4-l4-protocol.h"
-
-namespace ns3 {
-
-class Node;
-class TraceResolver;
-class TraceContext;
-class Socket;
-/**
- * \brief Implementation of the UDP protocol
- */
-class Udp : public Ipv4L4Protocol {
-public:
- static const uint8_t PROT_NUMBER;
- /**
- * \brief Constructor
- * \param node The node this protocol is associated with
- */
- Udp (Ptr<Node> node);
- virtual ~Udp ();
-
- virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
- /**
- * \return A smart Socket pointer to a UdpSocket, allocated by this instance
- * of the UDP protocol
- */
- Ptr<Socket> CreateSocket (void);
-
- Ipv4EndPoint *Allocate (void);
- Ipv4EndPoint *Allocate (Ipv4Address address);
- Ipv4EndPoint *Allocate (uint16_t port);
- Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
- Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
- Ipv4Address peerAddress, uint16_t peerPort);
-
- void DeAllocate (Ipv4EndPoint *endPoint);
-
- // called by UdpSocket.
- /**
- * \brief Send a packet via UDP
- * \param packet The packet to send
- * \param saddr The source Ipv4Address
- * \param daddr The destination Ipv4Address
- * \param sport The source port number
- * \param dport The destination port number
- */
- void Send (Packet packet,
- Ipv4Address saddr, Ipv4Address daddr,
- uint16_t sport, uint16_t dport);
- /**
- * \brief Recieve a packet up the protocol stack
- * \param p The Packet to dump the contents into
- * \param source The source's Ipv4Address
- * \param destination The destinations Ipv4Address
- */
- // inherited from Ipv4L4Protocol
- virtual void Receive(Packet& p,
- Ipv4Address const &source,
- Ipv4Address const &destination);
-protected:
- virtual void DoDispose (void);
-private:
- Ptr<Node> m_node;
- Ipv4EndPointDemux *m_endPoints;
-};
-
-}; // namespace ns3
-
-#endif /* UDP_H */