----------------------------------------------------------------------------- Purpose: Is this IP address a "loopback" special address, such as 127.0.0.1? -----------------------------------------------------------------------------
| 247 | // Purpose: Is this IP address a "loopback" special address, such as 127.0.0.1? |
| 248 | //----------------------------------------------------------------------------- |
| 249 | bool CIPAddress::IsLoopback() const |
| 250 | { |
| 251 | // The code below will be incorrect if we are a ipv4-mapped-to-ipv6 address |
| 252 | // So - unmap ourselves to a temp CIPAddress and ask it |
| 253 | if ( IsMappedIPv4() ) |
| 254 | { |
| 255 | CIPAddress ipTemp = *this; |
| 256 | ipTemp.BConvertMappedToIPv4(); |
| 257 | return ipTemp.IsLoopback(); |
| 258 | } |
| 259 | |
| 260 | switch ( m_usType ) |
| 261 | { |
| 262 | case k_EIPTypeInvalid: |
| 263 | case k_EIPTypeBroadcastDeprecated: |
| 264 | return false; |
| 265 | case k_EIPTypeLoopbackDeprecated: |
| 266 | return true; |
| 267 | case k_EIPTypeV4: |
| 268 | return ( m_unIPv4 & 0xff000000 ) == 0x7f000000; // 127.x.x.x |
| 269 | case k_EIPTypeV6: |
| 270 | return m_ipv6Qword[0] == 0 && |
| 271 | #ifdef VALVE_BIG_ENDIAN |
| 272 | m_ipv6Qword[1] == 1; |
| 273 | #else |
| 274 | m_ipv6Qword[1] == 0x0100000000000000ull; |
| 275 | #endif |
| 276 | } |
| 277 | Assert( false ); |
| 278 | return false; |
| 279 | } |
| 280 | |
| 281 | //----------------------------------------------------------------------------- |
| 282 | // Purpose: Is this IP address a broadcast address? |
no test coverage detected