Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Common++/header/IpAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,19 @@ namespace pcpp
std::unique_ptr<IPv6Network> m_IPv6Network;
};

namespace literals
{
inline IPv4Address operator""_ipv4(const char* addrString, std::size_t size)
{
return IPv4Address(std::string(addrString, size));
}

inline IPv6Address operator""_ipv6(const char* addrString, std::size_t size)
{
return IPv6Address(std::string(addrString, size));
}
} // namespace literals

inline std::ostream& operator<<(std::ostream& oss, const pcpp::IPv4Address& ipv4Address)
{
oss << ipv4Address.toString();
Expand Down
12 changes: 10 additions & 2 deletions Common++/header/MacAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,22 @@ namespace pcpp
bool copyToNewBuffer(uint8_t** buffer, size_t& size) const;

/// A static value representing a zero value of MAC address, meaning address of value "00:00:00:00:00:00"
static MacAddress Zero;
static const MacAddress Zero;
/// A static value representing a broadcast MAC address, meaning address of value "ff:ff:ff:ff:ff:ff"
static MacAddress Broadcast;
static const MacAddress Broadcast;

private:
std::array<uint8_t, 6> m_Address{};
};

namespace literals
{
inline MacAddress operator""_mac(const char* addrString, size_t size)
{
return MacAddress(std::string(addrString, size));
}
} // namespace literals

inline std::ostream& operator<<(std::ostream& oss, const pcpp::MacAddress& macAddress)
{
oss << macAddress.toString();
Expand Down
4 changes: 2 additions & 2 deletions Common++/src/MacAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace pcpp
{

MacAddress MacAddress::Zero(0, 0, 0, 0, 0, 0);
const MacAddress MacAddress::Zero(0, 0, 0, 0, 0, 0);

MacAddress MacAddress::Broadcast(0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
const MacAddress MacAddress::Broadcast(0xff, 0xff, 0xff, 0xff, 0xff, 0xff);

std::string MacAddress::toString() const
{
Expand Down
Loading