UniRec
3.3.2
Loading...
Searching...
No Matches
include
unirec++
ipAddress.hpp
Go to the documentation of this file.
1
9
#pragma once
10
11
#include <ostream>
12
#include <string>
13
14
#include <
unirec/ipaddr.h
>
15
16
namespace
Nemea
{
17
22
// C++ designated initializers is available with -std=c++2a
23
static
const
ip_addr_t
EMPTY_IP_ADDRESS
24
= { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff } };
25
29
struct
IpAddress
{
30
ip_addr_t
ip
;
31
36
IpAddress
(
ip_addr_t
ip
=
EMPTY_IP_ADDRESS
);
37
43
IpAddress
(
const
std::string& ipAddressAsString);
44
49
bool
isIpv4
()
const
;
50
55
bool
isIpv6
()
const
;
56
62
bool
operator==
(
const
IpAddress
& other)
const
;
63
69
IpAddress
operator&
(
const
IpAddress
& other)
const
;
70
76
std::ostream&
operator<<
(std::ostream& os);
77
};
78
79
static_assert
(
sizeof
(
IpAddress
) ==
sizeof
(
ip_addr_t
),
"Invalid header definition"
);
80
81
}
// namespace Nemea
ip_addr_t
Definition
ipaddr.h:101
ipaddr.h
Structure to store both IPv4 and IPv6 addresses and associated functions.
Nemea
Definition
bidirectionalInterface.cpp:14
Nemea::EMPTY_IP_ADDRESS
static const ip_addr_t EMPTY_IP_ADDRESS
Define a constant for an empty IP address 0.0.0.0 for IPv4, :: for IPv6.
Definition
ipAddress.hpp:24
Nemea::IpAddress
A struct representing an IP address with associated operations.
Definition
ipAddress.hpp:29
Nemea::IpAddress::operator==
bool operator==(const IpAddress &other) const
Equality operator to compare two IpAddress objects.
Definition
ipAddress.cpp:32
Nemea::IpAddress::ip
ip_addr_t ip
Definition
ipAddress.hpp:30
Nemea::IpAddress::isIpv6
bool isIpv6() const
Check if the stored IP address is an IPv6 address.
Definition
ipAddress.cpp:30
Nemea::IpAddress::operator&
IpAddress operator&(const IpAddress &other) const
Bitwise AND operator to perform a bitwise AND operation on two IpAddress objects.
Definition
ipAddress.cpp:37
Nemea::IpAddress::operator<<
std::ostream & operator<<(std::ostream &os)
Output stream operator to stream an IpAddress object to an output stream.
Definition
ipAddress.cpp:45
Nemea::IpAddress::isIpv4
bool isIpv4() const
Check if the stored IP address is an IPv4 address.
Definition
ipAddress.cpp:28
Nemea::IpAddress::IpAddress
IpAddress(ip_addr_t ip=EMPTY_IP_ADDRESS)
Constructor to initialize IpAddress with an ip_addr_t value.
Definition
ipAddress.cpp:15
Generated by
1.12.0