--- a/misc/util.cpp +++ b/misc/util.cpp @@ -12,6 +12,14 @@ #include #include #include +#ifdef __FreeBSD__ +#include +#include +#include +#include +#include +#include +#endif #include #include #include @@ -74,6 +82,7 @@ char* substr(const char* str, unsigned i } const char* getMACFromInterface(const char* Interface) { +#ifndef __FreeBSD__ int fd; struct ifreq ifr; @@ -95,6 +104,31 @@ const char* getMACFromInterface(const ch (unsigned char)ifr.ifr_hwaddr.sa_data[3], (unsigned char)ifr.ifr_hwaddr.sa_data[4], (unsigned char)ifr.ifr_hwaddr.sa_data[5]); +#else + struct ifaddrs *ifa, *ifp = NULL; + char *ret = new char[18]; + strcpy(ret, "00:00:00:00:00:00"); + + if (!Interface || getifaddrs(&ifp) < 0) + return ret; + + for (ifa = ifp; ifa != NULL; ifa = ifa->ifa_next) { + if (strcmp(ifa->ifa_name, Interface)) + continue; + + if (ifa->ifa_addr->sa_family == AF_LINK) { + struct sockaddr_dl *sdl = + (struct sockaddr_dl *)ifa->ifa_addr; + + if (sdl->sdl_type == IFT_ETHER && + sdl->sdl_alen == ETHER_ADDR_LEN) + snprintf(ret, 18, "%s", + ether_ntoa((struct ether_addr *)LLADDR(sdl))); + break; + } + } + freeifaddrs(ifp); +#endif return ret; } --- a/server/server.cpp +++ b/server/server.cpp @@ -8,6 +8,9 @@ #include #include #include +#ifdef __FreeBSD__ +#include +#endif #include #include #include "server.h" --- a/database/database.cpp +++ b/database/database.cpp @@ -161,7 +161,11 @@ bool cRow::fetchColumn(char** Column, ch int cSQLiteDatabase::initialize(){ int ret; +#ifdef __FreeBSD__ + const char* dbdir = (cUPnPConfig::get()->mDatabaseFolder) ? cUPnPConfig::get()->mDatabaseFolder : "/var/cache/vdr/upnp"; +#else const char* dbdir = (cUPnPConfig::get()->mDatabaseFolder) ? cUPnPConfig::get()->mDatabaseFolder : cPluginUpnp::getConfigDirectory(); +#endif cString File = cString::sprintf("%s/%s", dbdir, SQLITE_DB_FILE); if((ret = sqlite3_open(File, &this->mDatabase))){ ERROR("Unable to open database file %s (Error code: %d)!", *File, ret);