MCPcopy Create free account
hub / github.com/ValveSoftware/GameNetworkingSockets / IsBroadcast

Method IsBroadcast

src/tier1/netadr.cpp:284–311  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Purpose: Is this IP address a broadcast address? -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

282// Purpose: Is this IP address a broadcast address?
283//-----------------------------------------------------------------------------
284bool CIPAddress::IsBroadcast() const
285{
286 // The code below will be incorrect if we are a ipv4-mapped-to-ipv6 address
287 // So - unmap ourselves to a temp CIPAddress and return it
288 if ( IsMappedIPv4() )
289 {
290 CIPAddress ipTemp = *this;
291 ipTemp.BConvertMappedToIPv4();
292 return ipTemp.IsBroadcast();
293 }
294
295 switch ( m_usType )
296 {
297 case k_EIPTypeInvalid:
298 case k_EIPTypeLoopbackDeprecated:
299 return false;
300 case k_EIPTypeBroadcastDeprecated:
301 return true;
302 case k_EIPTypeV4:
303 return m_unIPv4 == 0xffffffff; // 255.255.255.255
304 case k_EIPTypeV6:
305 // There might other IPs than could be construed as "broadcast",
306 // but just check for the one used by SetIPV6Broadcast()
307 return memcmp( m_rgubIPv6, k_ipv6Bytes_LinkLocalAllNodes, 16 ) == 0;
308 }
309 Assert( false );
310 return false;
311}
312
313//-----------------------------------------------------------------------------
314// Purpose: Get the ipv6 bytes (network byte order) of this address. Works even

Callers

nothing calls this directly

Calls 1

BConvertMappedToIPv4Method · 0.80

Tested by

no test coverage detected