Commit 9b4eed3d authored by Dominik Charousset's avatar Dominik Charousset

fixed #95

this patch fixes some minor errors in the Linux implementation of
`get_mac_addresses` and `get_root_uuid`
parent bdf0784a
......@@ -117,7 +117,7 @@ std::vector<std::string> get_mac_addresses() {
// query available interfaces
char buf[1024] = {0};
ifconf ifc = {0};
ifconf ifc;
ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;
if (ioctl(sck, SIOCGIFCONF, &ifc) < 0) {
......@@ -132,12 +132,12 @@ std::vector<std::string> get_mac_addresses() {
// iterate through interfaces
auto ifr = ifc.ifc_req;
auto num_ifaces = ifc.ifc_len / sizeof(struct ifreq);
for (int i = 0; i < num_ifaces; i++) {
struct ifreq *item = &ifr[i];
for (size_t i = 0; i < num_ifaces; ++i) {
auto item = &ifr[i];
// get mac address
if (ioctl(sck, SIOCGIFHWADDR, item) < 0) {
perror("ioctl(SIOCGIFHWADDR)");
return 1;
return {};
}
std::ostringstream oss;
oss << hex;
......
......@@ -82,6 +82,8 @@ std::string get_root_uuid() {
#include <unistd.h>
#include <iostream>
#include "cppa/util/algorithm.hpp"
using namespace std;
struct columns_iterator : iterator<forward_iterator_tag, vector<string>> {
......@@ -93,7 +95,7 @@ struct columns_iterator : iterator<forward_iterator_tag, vector<string>> {
columns_iterator& operator++() {
string line;
if (!getline(*fs, line)) fs = nullptr;
else cols = split(line);
else cols = cppa::util::split(line);
return *this;
}
......@@ -123,7 +125,7 @@ std::string get_root_uuid() {
sck = socket(AF_INET, SOCK_DGRAM, 0);
if(sck < 0) {
perror("socket");
return 1;
return "";
}
// Query available interfaces.
......@@ -131,7 +133,7 @@ std::string get_root_uuid() {
ifc.ifc_buf = buf;
if(ioctl(sck, SIOCGIFCONF, &ifc) < 0) {
perror("ioctl(SIOCGIFCONF)");
return 1;
return "";
}
vector<string> hw_addresses;
......@@ -146,7 +148,7 @@ std::string get_root_uuid() {
// Get the MAC address
if(ioctl(sck, SIOCGIFHWADDR, item) < 0) {
perror("ioctl(SIOCGIFHWADDR)");
return 1;
return "";
}
std::ostringstream oss;
oss << hex;
......@@ -180,11 +182,7 @@ std::string get_root_uuid() {
// discard invalid UUID
if (cpy != "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF") uuid.clear();
}
for (auto& addr : hw_addresses) {
cout << addr << endl;
}
cout << uuid << endl;
return uuid;
}
} } // namespace cppa::util
......
......@@ -147,16 +147,12 @@ struct raw_struct_type_info : util::abstract_uniform_type_info<raw_struct> {
int main() {
CPPA_TEST(test_serialization);
auto addresses = util::get_mac_addresses();
for (auto& addr : addresses) {
cout << addr << endl;
}
return 0;
announce(typeid(raw_struct), new raw_struct_type_info);
network::default_actor_addressing addressing;
cout << "process id: " << to_string(process_information::get()) << endl;
auto oarr = new detail::object_array;
oarr->push_back(object::from(static_cast<uint32_t>(42)));
oarr->push_back(object::from("foo" ));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment