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
af91262d
Commit
af91262d
authored
Sep 05, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return interface names from get_mac_addresses
parent
4d17b790
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
13 deletions
+24
-13
libcaf_core/caf/detail/get_mac_addresses.hpp
libcaf_core/caf/detail/get_mac_addresses.hpp
+7
-1
libcaf_core/src/get_mac_addresses.cpp
libcaf_core/src/get_mac_addresses.cpp
+11
-11
libcaf_core/src/node_id.cpp
libcaf_core/src/node_id.cpp
+6
-1
No files found.
libcaf_core/caf/detail/get_mac_addresses.hpp
View file @
af91262d
...
@@ -22,11 +22,17 @@
...
@@ -22,11 +22,17 @@
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <utility>
namespace
caf
{
namespace
caf
{
namespace
detail
{
namespace
detail
{
std
::
vector
<
std
::
string
>
get_mac_addresses
();
struct
iface_info
{
std
::
string
interface_name
;
std
::
string
ethernet_address
;
};
std
::
vector
<
iface_info
>
get_mac_addresses
();
}
// namespace detail
}
// namespace detail
}
// namespace caf
}
// namespace caf
...
...
libcaf_core/src/get_mac_addresses.cpp
View file @
af91262d
...
@@ -22,9 +22,9 @@
...
@@ -22,9 +22,9 @@
namespace
caf
{
namespace
caf
{
namespace
detail
{
namespace
detail
{
std
::
vector
<
std
::
string
>
get_mac_addresses
()
{
std
::
vector
<
iface_info
>
get_mac_addresses
()
{
int
mib
[
6
];
int
mib
[
6
];
std
::
vector
<
std
::
string
>
result
;
std
::
vector
<
iface_info
>
result
;
mib
[
0
]
=
CTL_NET
;
mib
[
0
]
=
CTL_NET
;
mib
[
1
]
=
AF_ROUTE
;
mib
[
1
]
=
AF_ROUTE
;
mib
[
2
]
=
0
;
mib
[
2
]
=
0
;
...
@@ -66,7 +66,7 @@ std::vector<std::string> get_mac_addresses() {
...
@@ -66,7 +66,7 @@ std::vector<std::string> get_mac_addresses() {
}
}
auto
addr
=
oss
.
str
();
auto
addr
=
oss
.
str
();
if
(
addr
!=
"00:00:00:00:00:00"
)
{
if
(
addr
!=
"00:00:00:00:00:00"
)
{
result
.
push_back
(
std
::
move
(
addr
)
);
result
.
push_back
(
{
i
->
if_name
,
std
::
move
(
addr
)}
);
}
}
}
}
if_freenameindex
(
indices
);
if_freenameindex
(
indices
);
...
@@ -100,7 +100,7 @@ using namespace std;
...
@@ -100,7 +100,7 @@ using namespace std;
namespace
caf
{
namespace
caf
{
namespace
detail
{
namespace
detail
{
std
::
vector
<
std
::
string
>
get_mac_addresses
()
{
std
::
vector
<
iface_info
>
get_mac_addresses
()
{
// get a socket handle
// get a socket handle
int
sck
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
int
sck
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
if
(
sck
<
0
)
{
if
(
sck
<
0
)
{
...
@@ -116,7 +116,7 @@ std::vector<std::string> get_mac_addresses() {
...
@@ -116,7 +116,7 @@ std::vector<std::string> get_mac_addresses() {
perror
(
"ioctl(SIOCGIFCONF)"
);
perror
(
"ioctl(SIOCGIFCONF)"
);
return
{};
return
{};
}
}
vector
<
string
>
hw_addresses
;
vector
<
iface_info
>
result
;
auto
ctoi
=
[](
char
c
)
->
unsigned
{
auto
ctoi
=
[](
char
c
)
->
unsigned
{
return
static_cast
<
unsigned
char
>
(
c
);
return
static_cast
<
unsigned
char
>
(
c
);
};
};
...
@@ -141,10 +141,10 @@ std::vector<std::string> get_mac_addresses() {
...
@@ -141,10 +141,10 @@ std::vector<std::string> get_mac_addresses() {
}
}
auto
addr
=
oss
.
str
();
auto
addr
=
oss
.
str
();
if
(
addr
!=
"00:00:00:00:00:00"
)
{
if
(
addr
!=
"00:00:00:00:00:00"
)
{
hw_addresses
.
push_back
(
std
::
move
(
addr
)
);
result
.
push_back
({
item
->
ifr_name
,
std
::
move
(
addr
)}
);
}
}
}
}
return
hw_addresses
;
return
result
;
}
}
}
// namespace detail
}
// namespace detail
...
@@ -193,9 +193,9 @@ using namespace std;
...
@@ -193,9 +193,9 @@ using namespace std;
namespace
caf
{
namespace
caf
{
namespace
detail
{
namespace
detail
{
std
::
vector
<
std
::
string
>
get_mac_addresses
()
{
std
::
vector
<
iface_info
>
get_mac_addresses
()
{
// result vector
// result vector
vector
<
string
>
hw_addresses
;
vector
<
iface_info
>
result
;
// flags to pass to GetAdaptersAddresses
// flags to pass to GetAdaptersAddresses
ULONG
flags
=
GAA_FLAG_INCLUDE_PREFIX
;
ULONG
flags
=
GAA_FLAG_INCLUDE_PREFIX
;
// default to unspecified address family (both)
// default to unspecified address family (both)
...
@@ -232,7 +232,7 @@ std::vector<std::string> get_mac_addresses() {
...
@@ -232,7 +232,7 @@ std::vector<std::string> get_mac_addresses() {
}
}
auto
hw_addr
=
oss
.
str
();
auto
hw_addr
=
oss
.
str
();
if
(
hw_addr
!=
"00:00:00:00:00:00"
)
{
if
(
hw_addr
!=
"00:00:00:00:00:00"
)
{
hw_addresses
.
push_back
(
std
::
move
(
hw_addr
)
);
result
.
push_back
({
addr
->
AdapterName
,
std
::
move
(
hw_addr
)}
);
}
}
}
}
}
}
...
@@ -243,7 +243,7 @@ std::vector<std::string> get_mac_addresses() {
...
@@ -243,7 +243,7 @@ std::vector<std::string> get_mac_addresses() {
perror
(
"Call to GetAdaptersAddresses failed with error"
);
perror
(
"Call to GetAdaptersAddresses failed with error"
);
}
}
}
}
return
hw_addresses
;
return
result
;
}
}
}
// namespace detail
}
// namespace detail
...
...
libcaf_core/src/node_id.cpp
View file @
af91262d
...
@@ -179,7 +179,12 @@ node_id::data::~data() {
...
@@ -179,7 +179,12 @@ node_id::data::~data() {
// initializes singleton
// initializes singleton
node_id
::
data
*
node_id
::
data
::
create_singleton
()
{
node_id
::
data
*
node_id
::
data
::
create_singleton
()
{
auto
macs
=
detail
::
get_mac_addresses
();
auto
ifs
=
detail
::
get_mac_addresses
();
std
::
vector
<
std
::
string
>
macs
;
macs
.
reserve
(
ifs
.
size
());
for
(
auto
&
i
:
ifs
)
{
macs
.
emplace_back
(
std
::
move
(
i
.
ethernet_address
));
}
auto
hd_serial_and_mac_addr
=
join
(
macs
,
""
)
+
detail
::
get_root_uuid
();
auto
hd_serial_and_mac_addr
=
join
(
macs
,
""
)
+
detail
::
get_root_uuid
();
node_id
::
host_id_type
nid
;
node_id
::
host_id_type
nid
;
detail
::
ripemd_160
(
nid
,
hd_serial_and_mac_addr
);
detail
::
ripemd_160
(
nid
,
hd_serial_and_mac_addr
);
...
...
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