Skip to content

Commit

Permalink
add routines for checking broadcast and multicast
Browse files Browse the repository at this point in the history
  • Loading branch information
gyf304 committed Nov 25, 2023
1 parent 9e61643 commit a251874
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ namespace lpvpn::ip {
}
return ret;
}
bool Address4::isBroadcast() const {
return toUint32() == 0xFFFFFFFF;
}
bool Address4::isMulticast() const {
return (addr[0] & 0xF0) == 0xE0;
}
bool Address4::operator==(const Address4& other) const {
return addr == other.addr;
}
Expand Down
2 changes: 2 additions & 0 deletions src/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace lpvpn::ip {
Address4(uint32_t addr);
~Address4();
uint32_t toUint32() const;
bool isBroadcast() const;
bool isMulticast() const;
bool operator==(const Address4& other) const;
Address4 operator+(uint32_t other) const;
Address4 operator-(uint32_t other) const;
Expand Down

0 comments on commit a251874

Please sign in to comment.