Last active
August 20, 2018 08:58
-
-
Save basilfx/0e09c77b837e8aba3253754213094e72 to your computer and use it in GitHub Desktop.
Homebrew Formula for knxd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Knxd < Formula | |
desc "knxd is an advanced router/gateway; it can talk to all known KNX interfaces" | |
homepage "https://github.com/knxd/knxd" | |
head "https://github.com/knxd/knxd.git" | |
url "https://github.com/knxd/knxd/archive/v0.14.17.tar.gz" | |
sha256 "f1e64fd09a0bfa789e75311d4ac11353ebe83cca49929159f02b9bc41960afdd" | |
depends_on "argp-standalone" => :build | |
depends_on "autoconf" => :build | |
depends_on "automake" => :build | |
depends_on "cmake" => :build | |
depends_on "libev" => :build | |
depends_on "libtool" => :build | |
depends_on "pkg-config" => :build | |
def patches | |
DATA | |
end | |
def install | |
system "./bootstrap.sh" | |
system "./configure", "--disable-systemd", | |
"--disable-usb", | |
"--prefix=#{prefix}" | |
system "make", "install" | |
end | |
test do | |
system "#{bin}/knxd", "--version" | |
end | |
end | |
__END__ | |
diff --git a/bootstrap.sh b/bootstrap.sh | |
index 4f42d0e..34c8aa6 100755 | |
--- a/bootstrap.sh | |
+++ b/bootstrap.sh | |
@@ -4,7 +4,7 @@ if test -f /usr/local/lib/libeibclient.so.0 ; then | |
echo "*** Remove them before building or installing knxd." >&2 | |
exit 1 | |
fi | |
-libtoolize --copy --force --install && \ | |
+glibtoolize --copy --force --install && \ | |
aclocal -I m4 --force && \ | |
autoheader && \ | |
automake --add-missing --copy --force-missing && \ | |
diff --git a/configure.ac b/configure.ac | |
index f7025e3..df340da 100644 | |
--- a/configure.ac | |
+++ b/configure.ac | |
@@ -25,7 +25,7 @@ dnl ## SUCH DAMAGE. | |
AC_PREREQ(2.59) | |
-AC_INIT(knxd, m4_esyscmd(sh ./tools/version.sh)) | |
+AC_INIT(knxd, m4_esyscmd(sh -c "./tools/version.sh | tr -d '\n'")) | |
AM_INIT_AUTOMAKE([foreign]) | |
AC_CANONICAL_HOST | |
diff --git a/src/common/iobuf.cpp b/src/common/iobuf.cpp | |
index 475525c..4b38ed7 100644 | |
--- a/src/common/iobuf.cpp | |
+++ b/src/common/iobuf.cpp | |
@@ -18,6 +18,7 @@ | |
*/ | |
#include <assert.h> | |
+#include <errno.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
diff --git a/src/libserver/eibnetserver.cpp b/src/libserver/eibnetserver.cpp | |
index ae82867..40c28f7 100644 | |
--- a/src/libserver/eibnetserver.cpp | |
+++ b/src/libserver/eibnetserver.cpp | |
@@ -22,8 +22,12 @@ | |
#include "config.h" | |
#include <stdlib.h> | |
#include <sys/ioctl.h> | |
+#include <sys/socket.h> | |
+#include <sys/types.h> | |
#include <net/if.h> | |
#include <net/if_arp.h> | |
+#include <net/if_dl.h> | |
+#include <ifaddrs.h> | |
#include <unistd.h> | |
#include <netinet/in.h> | |
#include <string.h> | |
@@ -457,38 +461,28 @@ void | |
EIBnetServer::handle_packet (EIBNetIPPacket *p1, EIBNetIPSocket *isock) | |
{ | |
/* Get MAC Address */ | |
- /* TODO: cache all of this, and ask at most once per seoncd */ | |
- | |
- struct ifreq ifr; | |
- struct ifconf ifc; | |
- char buf[1024]; | |
- unsigned char mac_address[IFHWADDRLEN]= {0,0,0,0,0,0}; | |
+ unsigned char mac_address[] = {0,0,0,0,0,0}; | |
if (sock_mac != -1 && discover && | |
- (p1->service == DESCRIPTION_REQUEST || p1->service == SEARCH_REQUEST)) | |
+ (p1->service == DESCRIPTION_REQUEST || p1->service == SEARCH_REQUEST)) | |
{ | |
- ifc.ifc_len = sizeof(buf); | |
- ifc.ifc_buf = buf; | |
- if (ioctl(sock_mac, SIOCGIFCONF, &ifc) != -1) | |
- { | |
- struct ifreq* it = ifc.ifc_req; | |
- const struct ifreq* const end = it + (ifc.ifc_len / sizeof(struct ifreq)); | |
+ struct ifaddrs *ifap, *ifaptr; | |
+ unsigned char *ptr; | |
- for (; it != end; ++it) | |
- { | |
- strcpy(ifr.ifr_name, it->ifr_name); | |
- if (ioctl(sock_mac, SIOCGIFFLAGS, &ifr)) | |
- continue; | |
- if (ifr.ifr_flags & IFF_LOOPBACK) // don't count loopback | |
- continue; | |
- if (ioctl(sock_mac, SIOCGIFHWADDR, &ifr)) | |
- continue; | |
- if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) | |
- continue; | |
- memcpy(mac_address, ifr.ifr_hwaddr.sa_data, sizeof(mac_address)); | |
- break; | |
- } | |
- } | |
+ if (getifaddrs(&ifap) != 0) { | |
+ return; | |
+ } | |
+ | |
+ for (ifaptr = ifap; ifaptr != NULL; ifaptr = (ifaptr)->ifa_next) { | |
+ if ((ifaptr->ifa_addr)->sa_family == AF_LINK && (ifaptr->ifa_flags & IFF_RUNNING) && !(ifaptr->ifa_flags & IFF_LOOPBACK)) { | |
+ ptr = (unsigned char *)LLADDR((struct sockaddr_dl *)(ifaptr)->ifa_addr); | |
+ memcpy(mac_address, ptr, 6); | |
+ | |
+ break; | |
+ } | |
+ } | |
+ | |
+ freeifaddrs(ifap); | |
} | |
/* End MAC Address */ | |
diff --git a/src/server/Makefile.am b/src/server/Makefile.am | |
index c51f98e..5fbf3de 100644 | |
--- a/src/server/Makefile.am | |
+++ b/src/server/Makefile.am | |
@@ -3,7 +3,7 @@ libexec_PROGRAMS = knxd_args | |
AM_CPPFLAGS=-I$(top_srcdir)/src/libserver -I$(top_srcdir)/src/backend -I$(top_srcdir)/src/common -I$(top_srcdir)/src/usb $(LIBUSB_CFLAGS) $(SYSTEMD_CFLAGS) -Wno-missing-field-initializers | |
knxd_CPPFLAGS=$(AM_CPPFLAGS) -DLIBEXECDIR="\"$(libexecdir)\"" | |
-knxd_LDFLAGS=-Wl,--whole-archive,../backend/libbackend.a,../libserver/libserver.a,--no-whole-archive | |
+knxd_LDFLAGS=-Wl,../backend/libbackend.a,../libserver/libserver.a | |
knxd_LDADD=../libserver/libeibstack.a ../common/libcommon.a ../usb/libusb.a $(LIBUSB_LIBS) $(SYSTEMD_LIBS) $(EV_LIBS) | |
knxd_DEPENDENCIES=../libserver/libserver.a ../backend/libbackend.a ../libserver/libeibstack.a ../common/libcommon.a ../usb/libusb.a | |
knxd_args_DEPENDENCIES=../common/libcommon.a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, thx for ur work. But unfortunately its not working for me on mac os sierra:
Error: uninitialized constant Formulary::FormulaNamespacefe986eb8b510a1e605dee8a873536ba6::Knxd::DATA
Did you mean? Data
Date
Please report this bug:
https://docs.brew.sh/Troubleshooting
I had to change :
def patches
DATA
end
to:
patch :DATA
Greetings Matthias