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
a434453d
Commit
a434453d
authored
Jun 18, 2013
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup and coding style
parent
3ce5f985
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
22 deletions
+17
-22
src/get_root_uuid.cpp
src/get_root_uuid.cpp
+17
-22
No files found.
src/get_root_uuid.cpp
View file @
a434453d
...
@@ -115,49 +115,43 @@ bool operator!=(const columns_iterator& lhs, const columns_iterator& rhs) {
...
@@ -115,49 +115,43 @@ bool operator!=(const columns_iterator& lhs, const columns_iterator& rhs) {
namespace
cppa
{
namespace
util
{
namespace
cppa
{
namespace
util
{
std
::
string
get_root_uuid
()
{
std
::
string
get_root_uuid
()
{
char
buf
[
1024
]
=
{
0
};
int
sck
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
struct
ifconf
ifc
=
{
0
};
if
(
sck
<
0
)
{
struct
ifreq
*
ifr
=
NULL
;
int
sck
=
0
;
int
nInterfaces
=
0
;
// Get a socket handle.
sck
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
if
(
sck
<
0
)
{
perror
(
"socket"
);
perror
(
"socket"
);
return
""
;
return
""
;
}
}
// query available interfaces
// Query available interfaces.
char
buf
[
1024
];
ifconf
ifc
;
ifc
.
ifc_len
=
sizeof
(
buf
);
ifc
.
ifc_len
=
sizeof
(
buf
);
ifc
.
ifc_buf
=
buf
;
ifc
.
ifc_buf
=
buf
;
if
(
ioctl
(
sck
,
SIOCGIFCONF
,
&
ifc
)
<
0
)
{
if
(
ioctl
(
sck
,
SIOCGIFCONF
,
&
ifc
)
<
0
)
{
perror
(
"ioctl(SIOCGIFCONF)"
);
perror
(
"ioctl(SIOCGIFCONF)"
);
return
""
;
return
""
;
}
}
vector
<
string
>
hw_addresses
;
vector
<
string
>
hw_addresses
;
auto
ctoi
=
[](
char
c
)
->
unsigned
{
auto
ctoi
=
[](
char
c
)
->
unsigned
{
return
static_cast
<
unsigned
char
>
(
c
);
return
static_cast
<
unsigned
char
>
(
c
);
};
};
//
Iterate through the list of
interfaces.
//
iterate through
interfaces.
ifr
=
ifc
.
ifc_req
;
auto
ifr
=
ifc
.
ifc_req
;
nInterfaces
=
ifc
.
ifc_len
/
sizeof
(
struct
ifreq
);
size_t
num_interfaces
=
ifc
.
ifc_len
/
sizeof
(
ifreq
);
for
(
int
i
=
0
;
i
<
nI
nterfaces
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
num_i
nterfaces
;
i
++
)
{
struct
ifreq
*
item
=
&
ifr
[
i
];
auto
&
item
=
ifr
[
i
];
//
Get the
MAC address
//
get
MAC address
if
(
ioctl
(
sck
,
SIOCGIFHWADDR
,
item
)
<
0
)
{
if
(
ioctl
(
sck
,
SIOCGIFHWADDR
,
&
item
)
<
0
)
{
perror
(
"ioctl(SIOCGIFHWADDR)"
);
perror
(
"ioctl(SIOCGIFHWADDR)"
);
return
""
;
return
""
;
}
}
// convert MAC address to standard string representation
std
::
ostringstream
oss
;
std
::
ostringstream
oss
;
oss
<<
hex
;
oss
<<
hex
;
oss
.
width
(
2
);
oss
.
width
(
2
);
oss
<<
ctoi
(
item
->
ifr_hwaddr
.
sa_data
[
0
]);
oss
<<
ctoi
(
item
.
ifr_hwaddr
.
sa_data
[
0
]);
for
(
size_t
i
=
1
;
i
<
6
;
++
i
)
{
for
(
size_t
i
=
1
;
i
<
6
;
++
i
)
{
oss
<<
":"
;
oss
<<
":"
;
oss
.
width
(
2
);
oss
.
width
(
2
);
oss
<<
ctoi
(
item
->
ifr_hwaddr
.
sa_data
[
i
]);
oss
<<
ctoi
(
item
.
ifr_hwaddr
.
sa_data
[
i
]);
}
}
auto
addr
=
oss
.
str
();
auto
addr
=
oss
.
str
();
if
(
addr
!=
"00:00:00:00:00:00"
)
{
if
(
addr
!=
"00:00:00:00:00:00"
)
{
...
@@ -188,3 +182,4 @@ std::string get_root_uuid() {
...
@@ -188,3 +182,4 @@ std::string get_root_uuid() {
}
}
// namespace cppa::util
}
}
// namespace cppa::util
#endif // CPPA_LINUX
#endif // CPPA_LINUX
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