Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
78681359
Commit
78681359
authored
Aug 14, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add convenience functions for IP classes
parent
18ba5447
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
0 deletions
+39
-0
libcaf_core/caf/ipv4_address.hpp
libcaf_core/caf/ipv4_address.hpp
+6
-0
libcaf_core/caf/ipv4_subnet.hpp
libcaf_core/caf/ipv4_subnet.hpp
+5
-0
libcaf_core/caf/ipv6_subnet.hpp
libcaf_core/caf/ipv6_subnet.hpp
+12
-0
libcaf_core/src/ipv4_subnet.cpp
libcaf_core/src/ipv4_subnet.cpp
+7
-0
libcaf_core/src/ipv6_subnet.cpp
libcaf_core/src/ipv6_subnet.cpp
+7
-0
libcaf_core/test/ipv6_address.cpp
libcaf_core/test/ipv6_address.cpp
+2
-0
No files found.
libcaf_core/caf/ipv4_address.hpp
View file @
78681359
...
@@ -46,6 +46,12 @@ public:
...
@@ -46,6 +46,12 @@ public:
explicit
ipv4_address
(
array_type
bytes
);
explicit
ipv4_address
(
array_type
bytes
);
static
ipv4_address
from_bits
(
uint32_t
bits
)
{
ipv4_address
result
;
result
.
bits
(
bits
);
return
result
;
}
// -- properties -------------------------------------------------------------
// -- properties -------------------------------------------------------------
/// Returns whether this is a loopback address.
/// Returns whether this is a loopback address.
...
...
libcaf_core/caf/ipv4_subnet.hpp
View file @
78681359
...
@@ -62,4 +62,9 @@ private:
...
@@ -62,4 +62,9 @@ private:
uint8_t
prefix_length_
;
uint8_t
prefix_length_
;
};
};
// -- related free functions ---------------------------------------------------
/// @relates ipv4_subnet
std
::
string
to_string
(
ipv4_subnet
x
);
}
// namespace caf
}
// namespace caf
libcaf_core/caf/ipv6_subnet.hpp
View file @
78681359
...
@@ -81,6 +81,13 @@ public:
...
@@ -81,6 +81,13 @@ public:
int
compare
(
const
ipv6_subnet
&
other
)
const
noexcept
;
int
compare
(
const
ipv6_subnet
&
other
)
const
noexcept
;
// -- inspection -------------------------------------------------------------
template
<
class
Inspector
>
friend
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
ipv6_subnet
&
x
)
{
return
f
(
x
.
address_
,
x
.
prefix_length_
);
}
private:
private:
// -- member variables -------------------------------------------------------
// -- member variables -------------------------------------------------------
...
@@ -88,5 +95,10 @@ private:
...
@@ -88,5 +95,10 @@ private:
uint8_t
prefix_length_
;
uint8_t
prefix_length_
;
};
};
// -- related free functions ---------------------------------------------------
/// @relates ipv6_subnet
std
::
string
to_string
(
ipv6_subnet
x
);
}
// namespace caf
}
// namespace caf
libcaf_core/src/ipv4_subnet.cpp
View file @
78681359
...
@@ -55,4 +55,11 @@ int ipv4_subnet::compare(const ipv4_subnet& other) const noexcept {
...
@@ -55,4 +55,11 @@ int ipv4_subnet::compare(const ipv4_subnet& other) const noexcept {
:
static_cast
<
int
>
(
prefix_length_
)
-
other
.
prefix_length_
;
:
static_cast
<
int
>
(
prefix_length_
)
-
other
.
prefix_length_
;
}
}
std
::
string
to_string
(
ipv4_subnet
x
)
{
auto
result
=
to_string
(
x
.
network_address
());
result
+=
'/'
;
result
+=
std
::
to_string
(
x
.
prefix_length
());
return
result
;
}
}
// namespace caf
}
// namespace caf
libcaf_core/src/ipv6_subnet.cpp
View file @
78681359
...
@@ -84,5 +84,12 @@ int ipv6_subnet::compare(const ipv6_subnet& other) const noexcept {
...
@@ -84,5 +84,12 @@ int ipv6_subnet::compare(const ipv6_subnet& other) const noexcept {
:
static_cast
<
int
>
(
prefix_length_
)
-
other
.
prefix_length_
;
:
static_cast
<
int
>
(
prefix_length_
)
-
other
.
prefix_length_
;
}
}
std
::
string
to_string
(
ipv6_subnet
x
)
{
auto
result
=
to_string
(
x
.
network_address
());
result
+=
'/'
;
result
+=
std
::
to_string
(
x
.
prefix_length
());
return
result
;
}
}
// namespace caf
}
// namespace caf
libcaf_core/test/ipv6_address.cpp
View file @
78681359
...
@@ -69,6 +69,8 @@ CAF_TEST(from string) {
...
@@ -69,6 +69,8 @@ CAF_TEST(from string) {
CAF_CHECK_EQUAL
(
from_string
(
"::1:2"
),
addr
({},
{
0x01
,
0x02
}));
CAF_CHECK_EQUAL
(
from_string
(
"::1:2"
),
addr
({},
{
0x01
,
0x02
}));
CAF_CHECK_EQUAL
(
from_string
(
"::1:2"
),
addr
({},
{
0x01
,
0x02
}));
CAF_CHECK_EQUAL
(
from_string
(
"::1:2"
),
addr
({},
{
0x01
,
0x02
}));
CAF_CHECK_EQUAL
(
from_string
(
"1::1"
),
addr
({
0x01
},
{
0x01
}));
CAF_CHECK_EQUAL
(
from_string
(
"1::1"
),
addr
({
0x01
},
{
0x01
}));
CAF_CHECK_EQUAL
(
from_string
(
"2a00:bdc0:e003::"
),
addr
({
0x2a00
,
0xbdc0
,
0xe003
},
{}));
CAF_CHECK_EQUAL
(
from_string
(
"1::"
),
addr
({
0x01
},
{}));
CAF_CHECK_EQUAL
(
from_string
(
"1::"
),
addr
({
0x01
},
{}));
CAF_CHECK_EQUAL
(
from_string
(
"0.1.0.1"
),
addr
({},
{
0xFFFF
,
0x01
,
0x01
}));
CAF_CHECK_EQUAL
(
from_string
(
"0.1.0.1"
),
addr
({},
{
0xFFFF
,
0x01
,
0x01
}));
CAF_CHECK_EQUAL
(
from_string
(
"::ffff:127.0.0.1"
),
CAF_CHECK_EQUAL
(
from_string
(
"::ffff:127.0.0.1"
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment