diff --git a/src/applications/udp-echo/udp-echo-server.cc b/src/applications/udp-echo/udp-echo-server.cc index badd4ec92..ea305616c 100644 --- a/src/applications/udp-echo/udp-echo-server.cc +++ b/src/applications/udp-echo/udp-echo-server.cc @@ -109,7 +109,7 @@ UdpEchoServer::HandleRead (Ptr socket) address.GetIpv4()); NS_LOG_LOGIC ("Echoing packet"); - socket->SendTo (from, packet); + socket->SendTo (packet, from); } } } diff --git a/src/internet-node/tcp-socket.cc b/src/internet-node/tcp-socket.cc index e73e36c05..a350476e0 100644 --- a/src/internet-node/tcp-socket.cc +++ b/src/internet-node/tcp-socket.cc @@ -441,7 +441,7 @@ int TcpSocket::DoSendTo (Ptr p, Ipv4Address ipv4, uint16_t port) } int -TcpSocket::SendTo (const Address &address, Ptr p) +TcpSocket::SendTo (Ptr p, const Address &address) { NS_LOG_FUNCTION (this << address << p); if (!m_connected) diff --git a/src/internet-node/tcp-socket.h b/src/internet-node/tcp-socket.h index 6e4d3c4a4..023d3029d 100644 --- a/src/internet-node/tcp-socket.h +++ b/src/internet-node/tcp-socket.h @@ -67,7 +67,7 @@ public: virtual int Connect(const Address &address); virtual int Send (Ptr p); virtual int Send (const uint8_t* buf, uint32_t size); - virtual int SendTo(const Address &address, Ptr p); + virtual int SendTo(Ptr p, const Address &address); virtual uint32_t GetTxAvailable (void) const; virtual int Listen(uint32_t queueLimit); diff --git a/src/internet-node/udp-socket.cc b/src/internet-node/udp-socket.cc index 9f1764b1c..5670aa8fc 100644 --- a/src/internet-node/udp-socket.cc +++ b/src/internet-node/udp-socket.cc @@ -353,7 +353,7 @@ UdpSocket::GetTxAvailable (void) const } int -UdpSocket::SendTo (const Address &address, Ptr p) +UdpSocket::SendTo (Ptr p, const Address &address) { NS_LOG_FUNCTION (this << address << p); InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); @@ -604,8 +604,8 @@ UdpSocketTest::RunTests (void) // Unicast test m_receivedPacket = Create (); m_receivedPacket2 = Create (); - NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("10.0.0.1"), 1234), - Create (123)), 123); + NS_TEST_ASSERT_EQUAL (txSocket->SendTo ( Create (123), + InetSocketAddress (Ipv4Address("10.0.0.1"), 1234)), 123); Simulator::Run (); NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123); NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 0); // second interface should receive it @@ -617,8 +617,8 @@ UdpSocketTest::RunTests (void) m_receivedPacket = Create (); m_receivedPacket2 = Create (); - NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("255.255.255.255"), 1234), - Create (123)), 123); + NS_TEST_ASSERT_EQUAL (txSocket->SendTo ( Create (123), + InetSocketAddress (Ipv4Address("255.255.255.255"), 1234)), 123); Simulator::Run (); NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123); // second socket should not receive it (it is bound specifically to the second interface's address @@ -639,8 +639,8 @@ UdpSocketTest::RunTests (void) m_receivedPacket = Create (); m_receivedPacket2 = Create (); - NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("255.255.255.255"), 1234), - Create (123)), 123); + NS_TEST_ASSERT_EQUAL (txSocket->SendTo (Create (123), +InetSocketAddress (Ipv4Address("255.255.255.255"), 1234)), 123); Simulator::Run (); NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123); NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 123); diff --git a/src/internet-node/udp-socket.h b/src/internet-node/udp-socket.h index aa21a8e7f..71e55f232 100644 --- a/src/internet-node/udp-socket.h +++ b/src/internet-node/udp-socket.h @@ -57,7 +57,7 @@ public: virtual int ShutdownRecv (void); virtual int Connect(const Address &address); virtual int Send (Ptr p); - virtual int SendTo(const Address &address,Ptr p); + virtual int SendTo (Ptr p, const Address &address); virtual uint32_t GetTxAvailable (void) const; virtual Ptr Recv (uint32_t maxSize, uint32_t flags); diff --git a/src/node/packet-socket.cc b/src/node/packet-socket.cc index 4067410c1..09f7ce099 100644 --- a/src/node/packet-socket.cc +++ b/src/node/packet-socket.cc @@ -237,7 +237,7 @@ PacketSocket::Send (Ptr p) m_errno = ERROR_NOTCONN; return -1; } - return SendTo (m_destAddr, p); + return SendTo (p, m_destAddr); } uint32_t @@ -248,7 +248,7 @@ PacketSocket::GetTxAvailable (void) const } int -PacketSocket::SendTo(const Address &address, Ptr p) +PacketSocket::SendTo(Ptr p, const Address &address) { NS_LOG_FUNCTION_NOARGS (); PacketSocketAddress ad; diff --git a/src/node/packet-socket.h b/src/node/packet-socket.h index 2e70a67fa..f34c90051 100644 --- a/src/node/packet-socket.h +++ b/src/node/packet-socket.h @@ -91,7 +91,7 @@ public: virtual int Send (Ptr p); virtual uint32_t GetTxAvailable (void) const; - virtual int SendTo(const Address &address,Ptr p); + virtual int SendTo(Ptr p, const Address &address); virtual Ptr Recv (uint32_t maxSize, uint32_t flags); virtual uint32_t GetRxAvailable (void) const; diff --git a/src/node/socket.cc b/src/node/socket.cc index 69a6d4d98..9fe458e08 100644 --- a/src/node/socket.cc +++ b/src/node/socket.cc @@ -185,7 +185,7 @@ Socket::Recv (void) return Recv (std::numeric_limits::max(), 0); } -int Socket::SendTo (const Address &address, const uint8_t* buf, uint32_t size) +int Socket::SendTo (const uint8_t* buf, uint32_t size, const Address &address) { NS_LOG_FUNCTION_NOARGS (); Ptr p; @@ -197,7 +197,7 @@ int Socket::SendTo (const Address &address, const uint8_t* buf, uint32_t size) { p = Create (size); } - return SendTo (address,p); + return SendTo (p, address); } void diff --git a/src/node/socket.h b/src/node/socket.h index 9f106dc75..0d879e74d 100644 --- a/src/node/socket.h +++ b/src/node/socket.h @@ -282,26 +282,26 @@ public: /** * \brief Send data to a specified peer. - * \param address IP Address of remote host * \param p packet to send + * \param address IP Address of remote host * \returns -1 in case of error or the number of bytes copied in the * internal buffer and accepted for transmission. */ - virtual int SendTo (const Address &address,Ptr p) = 0; + virtual int SendTo (Ptr p, const Address &address) = 0; /** * \brief Send data to a specified peer. - * \param address IP Address of remote host * \param buf A pointer to a raw byte buffer of some data to send. If this * is 0, we send dummy data whose size is specified by the third parameter * \param size the number of bytes to copy from the buffer + * \param address IP Address of remote host * \returns -1 in case of error or the number of bytes copied in the * internal buffer and accepted for transmission. * * This is provided so as to have an API which is closer in appearance * to that of real network or BSD sockets. */ - int SendTo (const Address &address, const uint8_t* buf, uint32_t size); + int SendTo (const uint8_t* buf, uint32_t size, const Address &address); /** * \brief Read a single packet from the socket