InetAddress -> InetSocketAddress
This commit is contained in:
1 parent
41074331ed
commit
df7f115415
8 files changed
+44
-44
No files matched your search
@@ -1,52 +1,52 @@
|
||||
#include "inet-address.h"
|
||||
#include "inet-socket-address.h"
|
||||
#include "ns3/assert.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
InetAddress::InetAddress (Ipv4Address ipv4, uint16_t port)
|
||||
InetSocketAddress::InetSocketAddress (Ipv4Address ipv4, uint16_t port)
|
||||
: m_ipv4 (ipv4),
|
||||
m_port (port)
|
||||
{}
|
||||
InetAddress::InetAddress (Ipv4Address ipv4)
|
||||
InetSocketAddress::InetSocketAddress (Ipv4Address ipv4)
|
||||
: m_ipv4 (ipv4),
|
||||
m_port (0)
|
||||
{}
|
||||
InetAddress::InetAddress (const char *ipv4, uint16_t port)
|
||||
InetSocketAddress::InetSocketAddress (const char *ipv4, uint16_t port)
|
||||
: m_ipv4 (Ipv4Address (ipv4)),
|
||||
m_port (port)
|
||||
{}
|
||||
InetAddress::InetAddress (const char * ipv4)
|
||||
InetSocketAddress::InetSocketAddress (const char * ipv4)
|
||||
: m_ipv4 (Ipv4Address (ipv4)),
|
||||
m_port (0)
|
||||
{}
|
||||
InetAddress::InetAddress (uint16_t port)
|
||||
InetSocketAddress::InetSocketAddress (uint16_t port)
|
||||
: m_ipv4 (Ipv4Address::GetAny ()),
|
||||
m_port (port)
|
||||
{}
|
||||
uint16_t
|
||||
InetAddress::GetPort (void) const
|
||||
InetSocketAddress::GetPort (void) const
|
||||
{
|
||||
return m_port;
|
||||
}
|
||||
Ipv4Address
|
||||
InetAddress::GetIpv4 (void) const
|
||||
InetSocketAddress::GetIpv4 (void) const
|
||||
{
|
||||
return m_ipv4;
|
||||
}
|
||||
|
||||
void
|
||||
InetAddress::SetPort (uint16_t port)
|
||||
InetSocketAddress::SetPort (uint16_t port)
|
||||
{
|
||||
m_port = port;
|
||||
}
|
||||
void
|
||||
InetAddress::SetIpv4 (Ipv4Address address)
|
||||
InetSocketAddress::SetIpv4 (Ipv4Address address)
|
||||
{
|
||||
m_ipv4 = address;
|
||||
}
|
||||
|
||||
Address
|
||||
InetAddress::ConvertTo (void) const
|
||||
InetSocketAddress::ConvertTo (void) const
|
||||
{
|
||||
uint8_t buf[6];
|
||||
m_ipv4.Serialize (buf);
|
||||
@@ -54,18 +54,18 @@ InetAddress::ConvertTo (void) const
|
||||
buf[5] = (m_port >> 8) & 0xff;
|
||||
return Address (GetType (), buf, 6);
|
||||
}
|
||||
InetAddress
|
||||
InetAddress::ConvertFrom (const Address &address)
|
||||
InetSocketAddress
|
||||
InetSocketAddress::ConvertFrom (const Address &address)
|
||||
{
|
||||
NS_ASSERT (address.CheckCompatible (GetType (), 6));
|
||||
uint8_t buf[6];
|
||||
address.CopyTo (buf);
|
||||
Ipv4Address ipv4 = Ipv4Address::Deserialize (buf);
|
||||
uint16_t port = buf[0] | (buf[1] << 8);
|
||||
return InetAddress (ipv4, port);
|
||||
return InetSocketAddress (ipv4, port);
|
||||
}
|
||||
uint8_t
|
||||
InetAddress::GetType (void)
|
||||
InetSocketAddress::GetType (void)
|
||||
{
|
||||
static uint8_t type = Address::Register ();
|
||||
return type;
|
||||
@@ -15,37 +15,37 @@ namespace ns3 {
|
||||
* API. i.e., this class holds an Ipv4Address and a port number
|
||||
* to form an ipv4 transport endpoint.
|
||||
*/
|
||||
class InetAddress
|
||||
class InetSocketAddress
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \param ipv4 the ipv4 address
|
||||
* \param port the port number
|
||||
*/
|
||||
InetAddress (Ipv4Address ipv4, uint16_t port);
|
||||
InetSocketAddress (Ipv4Address ipv4, uint16_t port);
|
||||
/**
|
||||
* \param ipv4 the ipv4 address
|
||||
*
|
||||
* The port number is set to zero by default.
|
||||
*/
|
||||
InetAddress (Ipv4Address ipv4);
|
||||
InetSocketAddress (Ipv4Address ipv4);
|
||||
/**
|
||||
* \param port the port number
|
||||
*
|
||||
* The ipv4 address is set to the "Any" address by default.
|
||||
*/
|
||||
InetAddress (uint16_t port);
|
||||
InetSocketAddress (uint16_t port);
|
||||
/**
|
||||
* \param ipv4 string which represents an ipv4 address
|
||||
* \param port the port number
|
||||
*/
|
||||
InetAddress (const char *ipv4, uint16_t port);
|
||||
InetSocketAddress (const char *ipv4, uint16_t port);
|
||||
/**
|
||||
* \param ipv4 string which represents an ipv4 address
|
||||
*
|
||||
* The port number is set to zero.
|
||||
*/
|
||||
InetAddress (const char *ipv4);
|
||||
InetSocketAddress (const char *ipv4);
|
||||
/**
|
||||
* \returns the port number
|
||||
*/
|
||||
@@ -66,15 +66,15 @@ public:
|
||||
|
||||
/**
|
||||
* \returns an Address instance which represents this
|
||||
* InetAddress instance.
|
||||
* InetSocketAddress instance.
|
||||
*/
|
||||
Address ConvertTo (void) const;
|
||||
/**
|
||||
* \param address the Address instance to convert from.
|
||||
* \returns an InetAddress which corresponds to the input
|
||||
* \returns an InetSocketAddress which corresponds to the input
|
||||
* Address
|
||||
*/
|
||||
static InetAddress ConvertFrom (const Address &address);
|
||||
static InetSocketAddress ConvertFrom (const Address &address);
|
||||
private:
|
||||
static uint8_t GetType (void);
|
||||
Ipv4Address m_ipv4;
|
||||
+2
-2
@@ -8,7 +8,7 @@ def build(bld):
|
||||
node.source = [
|
||||
'address.cc',
|
||||
'eui48-address.cc',
|
||||
'inet-address.cc',
|
||||
'inet-socket-address.cc',
|
||||
'node.cc',
|
||||
'ipv4-address.cc',
|
||||
'net-device.cc',
|
||||
@@ -32,7 +32,7 @@ def build(bld):
|
||||
headers.source = [
|
||||
'address.h',
|
||||
'eui48-address.h',
|
||||
'inet-address.h',
|
||||
'inet-socket-address.h',
|
||||
'node.h',
|
||||
'ipv4-address.h',
|
||||
'net-device.h',
|
||||
|
||||
Reference in new issue
Block a user