mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
Kernel/AK: Add is_zero helpers for IP and MAC addresses
This commit is contained in:
parent
fac1148679
commit
4a4e66b2d0
Notes:
sideshowbarker
2024-07-19 12:28:31 +09:00
Author: https://github.com/deoxxa Commit: https://github.com/SerenityOS/serenity/commit/4a4e66b2d0f Pull-request: https://github.com/SerenityOS/serenity/pull/499 Reviewed-by: https://github.com/awesomekling
2 changed files with 10 additions and 0 deletions
|
@ -72,6 +72,11 @@ public:
|
|||
bool operator==(const IPv4Address& other) const { return m_data_as_u32 == other.m_data_as_u32; }
|
||||
bool operator!=(const IPv4Address& other) const { return m_data_as_u32 != other.m_data_as_u32; }
|
||||
|
||||
bool is_zero() const
|
||||
{
|
||||
return m_data_as_u32 == 0;
|
||||
}
|
||||
|
||||
private:
|
||||
union {
|
||||
u8 m_data[4];
|
||||
|
|
|
@ -40,6 +40,11 @@ public:
|
|||
return String::format("%02x:%02x:%02x:%02x:%02x:%02x", m_data[0], m_data[1], m_data[2], m_data[3], m_data[4], m_data[5]);
|
||||
}
|
||||
|
||||
bool is_zero() const
|
||||
{
|
||||
return m_data[0] == 0 && m_data[1] == 0 && m_data[2] == 0 && m_data[3] == 0 && m_data[4] == 0 && m_data[5] == 0;
|
||||
}
|
||||
|
||||
private:
|
||||
u8 m_data[6];
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue