aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorler <ler@FreeBSD.org>2018-01-22 09:54:25 +0800
committerler <ler@FreeBSD.org>2018-01-22 09:54:25 +0800
commit373ad21a2167767308e94e9297544f49459e568b (patch)
tree2a5a46b716f0a2bb35d69581a74a292956cfdbdf /net
parentb5d3c4d83203c4e1ce7c97d90f89468fb21658c8 (diff)
downloadfreebsd-ports-gnome-373ad21a2167767308e94e9297544f49459e568b.tar.gz
freebsd-ports-gnome-373ad21a2167767308e94e9297544f49459e568b.tar.zst
freebsd-ports-gnome-373ad21a2167767308e94e9297544f49459e568b.zip
net/boinc-client: actually get the real MAC address
Diffstat (limited to 'net')
-rw-r--r--net/boinc-client/files/patch-client_mac__address.cpp40
1 files changed, 37 insertions, 3 deletions
diff --git a/net/boinc-client/files/patch-client_mac__address.cpp b/net/boinc-client/files/patch-client_mac__address.cpp
index 5e2a774906f9..d87206a48bb5 100644
--- a/net/boinc-client/files/patch-client_mac__address.cpp
+++ b/net/boinc-client/files/patch-client_mac__address.cpp
@@ -1,12 +1,46 @@
---- client/mac_address.cpp.orig 2018-01-21 22:41:16 UTC
+--- client/mac_address.cpp.orig 2018-01-14 10:07:52 UTC
+++ client/mac_address.cpp
-@@ -262,6 +262,9 @@ int get_mac_address(char* address) {
+@@ -67,6 +67,10 @@
+ #ifdef HAVE_NETINET_ETHER_H
+ #include <netinet/ether.h>
+ #endif
++#if defined(__FreeBSD__)
++#include <ifaddrs.h>
++#include <net/if_dl.h>
++#endif
+
+ #include "mac_address.h"
+
+@@ -262,10 +266,32 @@ int get_mac_address(char* address) {
return -1;
}
hw_addr = (struct ether_addr *)&(item->lifr_lifru.lifru_enaddr);
++#elif defined(__FreeBSD__)
++ struct ifaddrs *ifap, *ifaptr;
++ unsigned char *ptr;
++
++ if (getifaddrs(&ifap) == 0) {
++ for(ifaptr = ifap; ifaptr != NULL; ifaptr = (ifaptr)->ifa_next) {
++ if (!strcmp((ifaptr)->ifa_name, item->ifr_name) && (((ifaptr)->ifa_addr)->sa_family == AF_LINK)) {
++ ptr = (unsigned char *)LLADDR((struct sockaddr_dl *)(ifaptr)->ifa_addr);
++ hw_addr = (struct ether_addr *)ptr;
++ break;
++ }
++ }
++ } else {
++ return -1;
++ }
+#else
-+ /* Need to teach this how on FreeBSD, but for now don't crash */
+ return -1;
#endif
strcpy(address, ether_ntoa(hw_addr));
++#if defined(__FreeBSD__)
++ freeifaddrs(ifap);
++#endif
#ifdef HAVE_STRUCT_LIFCONF
+ if (strstr(item->lifr_name, "eth")) break;
++#elif defined(__FreeBSD__)
++ break;
+ #else
+ if (strstr(item->ifr_name, "eth")) break;
+ #endif