Index: src/network/utils/inet-socket-address.cc |
diff --git a/src/network/utils/inet-socket-address.cc b/src/network/utils/inet-socket-address.cc |
index f678c455a378283e6431358d38191a3779571169..2139eca75155fa9aa3f9b2fb1a967cc7ccabb797 100644 |
--- a/src/network/utils/inet-socket-address.cc |
+++ b/src/network/utils/inet-socket-address.cc |
@@ -28,31 +28,36 @@ NS_LOG_COMPONENT_DEFINE ("InetSocketAddress"); |
InetSocketAddress::InetSocketAddress (Ipv4Address ipv4, uint16_t port) |
: m_ipv4 (ipv4), |
- m_port (port) |
+ m_port (port), |
+ m_tos (0) |
{ |
NS_LOG_FUNCTION (this << ipv4 << port); |
} |
InetSocketAddress::InetSocketAddress (Ipv4Address ipv4) |
: m_ipv4 (ipv4), |
- m_port (0) |
+ m_port (0), |
+ m_tos (0) |
{ |
NS_LOG_FUNCTION (this << ipv4); |
} |
InetSocketAddress::InetSocketAddress (const char *ipv4, uint16_t port) |
: m_ipv4 (Ipv4Address (ipv4)), |
- m_port (port) |
+ m_port (port), |
+ m_tos (0) |
{ |
NS_LOG_FUNCTION (this << ipv4 << port); |
} |
InetSocketAddress::InetSocketAddress (const char * ipv4) |
: m_ipv4 (Ipv4Address (ipv4)), |
- m_port (0) |
+ m_port (0), |
+ m_tos (0) |
{ |
NS_LOG_FUNCTION (this << ipv4); |
} |
InetSocketAddress::InetSocketAddress (uint16_t port) |
: m_ipv4 (Ipv4Address::GetAny ()), |
- m_port (port) |
+ m_port (port), |
+ m_tos (0) |
{ |
NS_LOG_FUNCTION (this << port); |
} |
@@ -68,6 +73,12 @@ InetSocketAddress::GetIpv4 (void) const |
NS_LOG_FUNCTION (this); |
return m_ipv4; |
} |
+uint8_t |
+InetSocketAddress::GetTos (void) const |
+{ |
+ NS_LOG_FUNCTION (this); |
+ return m_tos; |
+} |
void |
InetSocketAddress::SetPort (uint16_t port) |
@@ -81,12 +92,18 @@ InetSocketAddress::SetIpv4 (Ipv4Address address) |
NS_LOG_FUNCTION (this << address); |
m_ipv4 = address; |
} |
+void |
+InetSocketAddress::SetTos (uint8_t tos) |
+{ |
+ NS_LOG_FUNCTION (this << tos); |
+ m_tos = tos; |
+} |
bool |
InetSocketAddress::IsMatchingType (const Address &address) |
{ |
NS_LOG_FUNCTION (&address); |
- return address.CheckCompatible (GetType (), 6); |
+ return address.CheckCompatible (GetType (), 7); |
} |
InetSocketAddress::operator Address () const |
@@ -98,22 +115,26 @@ Address |
InetSocketAddress::ConvertTo (void) const |
{ |
NS_LOG_FUNCTION (this); |
- uint8_t buf[6]; |
+ uint8_t buf[7]; |
m_ipv4.Serialize (buf); |
buf[4] = m_port & 0xff; |
buf[5] = (m_port >> 8) & 0xff; |
- return Address (GetType (), buf, 6); |
+ buf[6] = m_tos; |
+ return Address (GetType (), buf, 7); |
} |
InetSocketAddress |
InetSocketAddress::ConvertFrom (const Address &address) |
{ |
NS_LOG_FUNCTION (&address); |
- NS_ASSERT (address.CheckCompatible (GetType (), 6)); |
- uint8_t buf[6]; |
+ NS_ASSERT (address.CheckCompatible (GetType (), 7)); |
+ uint8_t buf[7]; |
address.CopyTo (buf); |
Ipv4Address ipv4 = Ipv4Address::Deserialize (buf); |
uint16_t port = buf[4] | (buf[5] << 8); |
- return InetSocketAddress (ipv4, port); |
+ uint8_t tos = buf[6]; |
+ InetSocketAddress inet (ipv4, port); |
+ inet.SetTos (tos); |
+ return inet; |
} |
uint8_t |
InetSocketAddress::GetType (void) |