20 #include "pedigree/kernel/network/IpAddress.h" 21 #include "pedigree/kernel/utilities/StaticString.h" 26 return (m_Ipv4 & 0xFFFF) == 0xA9FE;
28 return (m_Ipv6[0] == 0xFE) && (m_Ipv6[1] == 0x80);
41 size_t prefix =
override <= 128 ?
override : m_Ipv6Prefix;
43 for (
size_t i = 0; i < prefix / 8; i++)
45 if (i && ((i % 2) == 0))
49 if (i && m_Ipv6[i - 1])
51 str.append(m_Ipv6[i], 16, pad);
54 return String(static_cast<const char *>(str));
58 String IpAddress::toString()
const 64 str.append(m_Ipv4 & 0xff);
66 str.append((m_Ipv4 >> 8) & 0xff);
68 str.append((m_Ipv4 >> 16) & 0xff);
70 str.append((m_Ipv4 >> 24) & 0xff);
71 return String(static_cast<const char *>(str));
77 bool bZeroComp =
false;
78 bool alreadyZeroComp =
false;
81 for (
size_t i = 0; i < 16; i++)
83 if (i && ((i % 2) == 0))
91 str.append(m_Ipv6[i], 16);
96 if (!m_Ipv6[i] && !m_Ipv6[i + 1])
106 alreadyZeroComp =
true;
110 if (m_Ipv6[i] || (i && m_Ipv6[i - 1]))
115 str.append(m_Ipv6[i], 16, pad);
121 str.append(m_Ipv6Prefix, 10);
123 return String(static_cast<const char *>(str));
133 if (((m_Ipv4 & 0xFF) & 0xE0) == 0xE0)
136 else if (m_Type == IPv6)
139 if (m_Ipv6[0] == 0xFF)
bool isLinkLocal() const
Whether the IP address is considered "link-local" or not.
String prefixString(size_t override=256) const
Prefix string. Not zero-compressed. For routing.
bool isMulticast() const
Whether the IP address is a valid multicast address.