MCPcopy Create free account
hub / github.com/NazaraEngine/NazaraEngine / BuildFromAddress

Method BuildFromAddress

src/Nazara/Network/IpAddress.cpp:37–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 */
36
37 bool IpAddress::BuildFromAddress(const char* address)
38 {
39 m_isValid = false;
40
41 bool isIPv6;
42 UInt8 result[16];
43 if (!ParseIPAddress(address, result, &m_port, &isIPv6, nullptr))
44 return false;
45
46 m_isValid = true;
47 if (isIPv6)
48 {
49 m_protocol = NetProtocol_IPv6;
50
51 for (unsigned int i = 0; i < 8; ++i)
52 m_ipv6[i] = UInt32(result[i*2]) << 8 | result[i*2 + 1];
53 }
54 else
55 {
56 m_protocol = NetProtocol_IPv4;
57
58 for (unsigned int i = 0; i < 4; ++i)
59 m_ipv4[i] = result[i];
60 }
61
62 return true;
63 }
64
65 /*!
66 * \brief Checks whether the IP address is loopback

Callers 1

IpAddress.cppFile · 0.80

Calls 1

ParseIPAddressFunction · 0.85

Tested by

no test coverage detected