mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-11 13:53:37 +00:00
Initial modifications to support FreeBSD
This commit is contained in:
17
makefile
17
makefile
@@ -52,7 +52,7 @@
|
||||
# ARCHID=2 # Windows Console x86 64 bit
|
||||
# ARCHID=3 # Windows Service x86 32 bit
|
||||
# ARCHID=4 # Windows Service x86 64 bit
|
||||
# make macos ARCHID=16 # Mac OS x86 64 bit
|
||||
# make macos ARCHID=16 # Mac OS x86 64 bit
|
||||
# make linux ARCHID=5 # Linux x86 32 bit
|
||||
# make linux ARCHID=6 # Linux x86 64 bit
|
||||
# make linux ARCHID=7 # Linux MIPS
|
||||
@@ -66,7 +66,7 @@
|
||||
# make linux ARCHID=25 # Linux ARM 32 bit HardFloat (Raspberry Pi, etc)
|
||||
# make linux ARCHID=26 # Linux ARM 64 bit
|
||||
# make pi KVM=1 ARCHID=25 # Linux ARM 32 bit HardFloat, compiled on the Pi.
|
||||
#
|
||||
# gmake freebsd ARCHID=30 # FreeBSD x86 64 bit
|
||||
|
||||
# Microstack & Microscript
|
||||
SOURCES = microstack/ILibAsyncServerSocket.c microstack/ILibAsyncSocket.c microstack/ILibAsyncUDPSocket.c microstack/ILibParsers.c microstack/ILibMulticastSocket.c
|
||||
@@ -257,6 +257,15 @@ CFLAGS += -D_NOFSWATCHER
|
||||
CEXTRA = -fno-strict-aliasing
|
||||
endif
|
||||
|
||||
# Official FreeBSD x86-64
|
||||
ifeq ($(ARCHID),30)
|
||||
ARCHNAME = freebsd_x86-64
|
||||
CC = clang
|
||||
KVM = 0
|
||||
LMS = 0
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(WEBLOG),1)
|
||||
CFLAGS += -D_REMOTELOGGINGSERVER -D_REMOTELOGGING
|
||||
endif
|
||||
@@ -293,9 +302,11 @@ SOURCES += microstack/nossl/sha384-512.c microstack/nossl/sha224-256.c microstac
|
||||
CFLAGS += -DMICROSTACK_NOTLS
|
||||
LINUXSSL =
|
||||
MACSSL =
|
||||
BSDSSL =
|
||||
else
|
||||
LINUXSSL = -Lopenssl/libstatic/linux/$(ARCHNAME)
|
||||
MACSSL = -Lopenssl/libstatic/macos/$(ARCHNAME)
|
||||
BSDSSL = -Lopenssl/libstatic/bsd/$(ARCHNAME)
|
||||
CFLAGS += -DMICROSTACK_TLS_DETECT
|
||||
LDEXTRA += -lssl -lcrypto
|
||||
endif
|
||||
@@ -412,4 +423,6 @@ macos:
|
||||
$(MAKE) $(MAKEFILE) EXENAME="$(EXENAME)_$(ARCHNAME)" ADDITIONALSOURCES="$(MACOSKVMSOURCES)" CFLAGS="-arch x86_64 -mmacosx-version-min=10.5 -std=gnu99 -Wall -DMESH_AGENTID=$(ARCHID) -D_POSIX -D_NOILIBSTACKDEBUG -D_NOHECI -DMICROSTACK_PROXY -D__APPLE__ $(CWEBLOG) -fno-strict-aliasing $(INCDIRS) $(CFLAGS) $(CEXTRA)" LDFLAGS="$(MACSSL) $(MACOSFLAGS) -L. -lpthread -ldl -lz -lutil -framework IOKit -framework ApplicationServices -framework SystemConfiguration -framework CoreFoundation -fconstant-cfstrings $(LDFLAGS) $(LDEXTRA)"
|
||||
$(STRIP)
|
||||
|
||||
freebsd:
|
||||
$(MAKE) EXENAME="$(EXENAME)_$(ARCHNAME)$(EXENAME2)" AID="$(ARCHID)" CFLAGS="-std=gnu99 -Wall -DMESH_AGENTID=$(ARCHID) -D_POSIX -D_FREEBSD -D_NOHECI -D_NOILIBSTACKDEBUG -DMICROSTACK_PROXY -fno-strict-aliasing $(INCDIRS) $(CFLAGS) $(CEXTRA)" LDFLAGS="$(BSDSSL) -L. -lpthread -ldl -lz -lutil $(LDFLAGS) $(LDEXTRA)"
|
||||
|
||||
|
||||
@@ -4488,7 +4488,11 @@ int MeshAgent_Start(MeshAgentHostContainer *agentHost, int paramLen, char **para
|
||||
agentHost->exePath = exePath;
|
||||
#elif defined(NACL)
|
||||
#else
|
||||
#ifdef _FREEBSD
|
||||
x = readlink("/proc/curproc/file", exePath, 1024);
|
||||
#else
|
||||
x = readlink("/proc/self/exe", exePath, 1024);
|
||||
#endif
|
||||
if (x < 0 || x >= 1024) ILIBCRITICALEXIT(246);
|
||||
exePath[x] = 0;
|
||||
#endif
|
||||
|
||||
@@ -42,8 +42,9 @@ limitations under the License.
|
||||
#include <net/if_arp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <linux/reboot.h>
|
||||
|
||||
#ifndef _FREEBSD
|
||||
#include <linux/reboot.h>
|
||||
#endif
|
||||
|
||||
#define inaddrr(x) (*(struct in_addr *) &ifr->x[sizeof sa.sin_port])
|
||||
#define IFRSIZE ((int)(size * sizeof (struct ifreq)))
|
||||
@@ -333,7 +334,7 @@ int info_GetDefaultGateway(char* ifname, char** gateway)
|
||||
// This is the POSIX implementation of a method that gets information about local interfaces
|
||||
int info_GetLocalInterfaces(char* data, int maxdata)
|
||||
{
|
||||
#ifdef NACL
|
||||
#if defined NACL || defined(_FREEBSD)
|
||||
return 0;
|
||||
#else
|
||||
|
||||
@@ -510,7 +511,7 @@ int MeshInfo_PowerState(enum AgentPowerStateActions flg, int force)
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif _VX_CPU // If VxWorks, we still need to implement this.
|
||||
#elif defined(_VX_CPU) || defined(_FREEBSD) // If VxWorks, we still need to implement this.
|
||||
|
||||
int MeshInfo_PowerState(enum AgentPowerStateActions flg, int force)
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ limitations under the License.
|
||||
#include "../microstack/ILibProcessPipe.h"
|
||||
#include "../microstack/ILibRemoteLogging.h"
|
||||
|
||||
#ifndef _NOHECI
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
@@ -1143,3 +1144,6 @@ void ILibDuktape_HECI_Init(duk_context *ctx)
|
||||
{
|
||||
ILibDuktape_ModSearch_AddHandler(ctx, "heci", ILibDuktape_HECI_Push);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ limitations under the License.
|
||||
#ifndef NO_IFADDR
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
#ifndef __APPLE__
|
||||
#include <netpacket/packet.h>
|
||||
#else
|
||||
#include <mach-o/dyld.h>
|
||||
#ifdef __APPLE__
|
||||
#include <mach-o/dyld.h>
|
||||
#elif !defined(_FREEBSD)
|
||||
#include <netpacket/packet.h>
|
||||
#endif
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
@@ -467,7 +467,11 @@ void ILibDuktape_ScriptContainer_CheckEmbedded(char **script, int *scriptLen)
|
||||
if (_NSGetExecutablePath(exePath, &len) != 0) ILIBCRITICALEXIT(247);
|
||||
exePath[len] = 0;
|
||||
#elif defined(NACL)
|
||||
#else
|
||||
#elif defined(_FREEBSD)
|
||||
int x = readlink("/proc/curproc/file", exePath, sizeof(exePath));
|
||||
if (x < 0 || x >= sizeof(exePath)) ILIBCRITICALEXIT(246);
|
||||
exePath[x] = 0;
|
||||
#elif
|
||||
int x = readlink("/proc/self/exe", exePath, sizeof(exePath));
|
||||
if (x < 0 || x >= sizeof(exePath)) ILIBCRITICALEXIT(246);
|
||||
exePath[x] = 0;
|
||||
@@ -1015,6 +1019,8 @@ void ILibDuktape_ScriptContainer_Process_Init(duk_context *ctx, char **argList)
|
||||
duk_push_string(ctx, "win32");
|
||||
#elif defined(__APPLE__)
|
||||
duk_push_string(ctx, "darwin");
|
||||
#elif defined(_FREEBSD)
|
||||
duk_push_string(ctx, "freebsd");
|
||||
#else
|
||||
duk_push_string(ctx, "linux");
|
||||
#endif
|
||||
@@ -1346,7 +1352,7 @@ int ILibDuktape_ScriptContainer_os_isWirelessInterface(char *interfaceName)
|
||||
return(retVal);
|
||||
}
|
||||
#endif
|
||||
#ifndef __APPLE__
|
||||
#if !defined(__APPLE__) && !defined(_FREEBSD)
|
||||
duk_ret_t ILibDuktape_ScriptContainer_OS_networkInterfaces(duk_context *ctx)
|
||||
{
|
||||
#if !defined(WIN32)
|
||||
@@ -1607,7 +1613,7 @@ void ILibDuktape_ScriptContainer_OS_Push(duk_context *ctx, void *chain)
|
||||
|
||||
ILibDuktape_CreateInstanceMethod(ctx, "arch", ILibDuktape_ScriptContainer_OS_arch, 0);
|
||||
ILibDuktape_CreateInstanceMethod(ctx, "platform", ILibDuktape_ScriptContainer_OS_platform, 0);
|
||||
#ifndef __APPLE__
|
||||
#if !defined(__APPLE__) && !defined(_FREEBSD)
|
||||
ILibDuktape_CreateInstanceMethod(ctx, "networkInterfaces", ILibDuktape_ScriptContainer_OS_networkInterfaces, 0);
|
||||
#endif
|
||||
ILibDuktape_CreateInstanceMethod(ctx, "hostname", ILibDuktape_ScriptContainer_OS_hostname, 0);
|
||||
|
||||
@@ -39,8 +39,8 @@ limitations under the License.
|
||||
|
||||
#ifdef _POSIX
|
||||
#include <sys/stat.h>
|
||||
#if !defined(_NOFSWATCHER) && !defined(__APPLE__)
|
||||
#include <sys/inotify.h>
|
||||
#if !defined(_NOFSWATCHER) && !defined(__APPLE__) && !defined(_FREEBSD)
|
||||
#include <sys/inotify.h>
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
@@ -905,7 +905,7 @@ duk_ret_t ILibDuktape_fs_watcher_close(duk_context *ctx)
|
||||
ILibProcessPipe_WaitHandle_Remove(data->pipeManager, data->overlapped.hEvent);
|
||||
CloseHandle(data->h);
|
||||
data->h = NULL;
|
||||
#elif defined(_POSIX) && !defined(__APPLE__)
|
||||
#elif defined(_POSIX) && !defined(__APPLE__) && !defined(_FREEBSD)
|
||||
ILibHashtable_Remove(data->linuxWatcher->watchTable, data->wd.p, NULL, 0);
|
||||
if (inotify_rm_watch(data->linuxWatcher->fd, data->wd.i) != 0) { ILibRemoteLogging_printf(ILibChainGetLogger(Duktape_GetChain(ctx)), ILibRemoteLogging_Modules_Agent_GuardPost | ILibRemoteLogging_Modules_ConsolePrint, ILibRemoteLogging_Flags_VerbosityLevel_1, "FSWatcher.close(): Error removing wd[%d] from fd[%d]", data->wd.i, data->linuxWatcher->fd); }
|
||||
else
|
||||
@@ -1046,7 +1046,7 @@ duk_ret_t ILibDuktape_fs_watcher_finalizer(duk_context *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_POSIX) && !defined(__APPLE__)
|
||||
#if defined(_POSIX) && !defined(__APPLE__) && !defined(_FREEBSD)
|
||||
void ILibDuktape_fs_notifyDispatcher_PreSelect(void* object, fd_set *readset, fd_set *writeset, fd_set *errorset, int* blocktime)
|
||||
{
|
||||
ILibDuktape_fs_linuxWatcher *data = (ILibDuktape_fs_linuxWatcher*)object;
|
||||
@@ -1296,7 +1296,7 @@ duk_ret_t ILibDuktape_fs_watch(duk_context *ctx)
|
||||
duk_pop(ctx); // ...
|
||||
}
|
||||
#elif defined(_POSIX)
|
||||
#ifndef __APPLE__
|
||||
#if !defined(__APPLE__) && !defined(_FREEBSD)
|
||||
// Linux
|
||||
ILibDuktape_fs_linuxWatcher *notifyDispatcher = NULL;
|
||||
duk_push_this(ctx); // [fs]
|
||||
@@ -1320,7 +1320,7 @@ duk_ret_t ILibDuktape_fs_watch(duk_context *ctx)
|
||||
duk_put_prop_string(ctx, -2, FS_NOTIFY_DISPATCH_PTR); // [fs]
|
||||
duk_pop(ctx); // ...
|
||||
}
|
||||
#else
|
||||
#elif defined(__APPLE__)
|
||||
// MacOS
|
||||
ILibDuktape_fs_appleWatcher *watcher = NULL;
|
||||
duk_push_this(ctx); // [fs]
|
||||
@@ -1363,7 +1363,7 @@ duk_ret_t ILibDuktape_fs_watch(duk_context *ctx)
|
||||
data->chain = chain;
|
||||
data->pipeManager = pipeMgr;
|
||||
data->recursive = recursive;
|
||||
#elif defined(_POSIX) && !defined(__APPLE__)
|
||||
#elif defined(_POSIX) && !defined(__APPLE__) && !defined(_FREEBSD)
|
||||
data->linuxWatcher = notifyDispatcher;
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
@@ -1396,7 +1396,7 @@ duk_ret_t ILibDuktape_fs_watch(duk_context *ctx)
|
||||
return(ILibDuktape_Error(ctx, "fs.watch(): Error creating watcher"));
|
||||
}
|
||||
ILibProcessPipe_WaitHandle_Add(pipeMgr, data->overlapped.hEvent, data, ILibDuktape_fs_watch_iocompletion);
|
||||
#elif defined(_POSIX) && !defined(__APPLE__)
|
||||
#elif defined(_POSIX) && !defined(__APPLE__) && !defined(_FREEBSD)
|
||||
data->wd.i = inotify_add_watch(data->linuxWatcher->fd, path, IN_CREATE | IN_DELETE | IN_MODIFY | IN_MOVED_FROM | IN_MOVED_TO);
|
||||
if (data->wd.i < 0)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ limitations under the License.
|
||||
#if defined(WIN32) || defined(_WIN32_WCE)
|
||||
#include <STDDEF.H>
|
||||
#elif defined(_POSIX)
|
||||
#if !defined(__APPLE__) && !defined(_VX_CPU)
|
||||
#if !defined(__APPLE__) && !defined(_VX_CPU) && !defined(_FREEBSD)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,7 @@ limitations under the License.
|
||||
#if defined(WIN32) || defined(_WIN32_WCE)
|
||||
#include <STDDEF.H>
|
||||
#elif defined(_POSIX)
|
||||
#if !defined(__APPLE__) && !defined(_VX_CPU)
|
||||
#if !defined(__APPLE__) && !defined(_VX_CPU) && !defined(_FREEBSD)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,7 @@ limitations under the License.
|
||||
#if defined(WIN32) || defined(_WIN32_WCE)
|
||||
#include <STDDEF.H>
|
||||
#elif defined(_POSIX)
|
||||
#if !defined(__APPLE__) && !defined(_VX_CPU)
|
||||
#if !defined(__APPLE__) && !defined(_VX_CPU) && !defined(_FREEBSD)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,7 @@ limitations under the License.
|
||||
|
||||
#include "ILibParsers.h"
|
||||
|
||||
#if defined(_POSIX) && !defined(__APPLE__) && !defined(NO_IPADDR_MONITOR)
|
||||
#if defined(_POSIX) && !defined(__APPLE__) && !defined(NO_IPADDR_MONITOR) && !defined(_FREEBSD)
|
||||
#include <netinet/in.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
@@ -47,7 +47,7 @@ typedef struct _ILibIPAddressMonitor
|
||||
SOCKET mSocket;
|
||||
DWORD bytesReturned;
|
||||
OVERLAPPED *reserved;
|
||||
#elif defined (_POSIX) && !defined(__APPLE__)
|
||||
#elif defined (_POSIX) && !defined(__APPLE__) && !defined(_FREEBSD)
|
||||
int mSocket;
|
||||
struct sockaddr_nl addr;
|
||||
#endif
|
||||
@@ -96,13 +96,13 @@ void ILibIPAddressMonitor_Destroy(void *object)
|
||||
obj->reserved->hEvent = NULL;
|
||||
closesocket(obj->mSocket);
|
||||
obj->mSocket = INVALID_SOCKET;
|
||||
#elif defined(_POSIX) && !defined(__APPLE__)
|
||||
#elif defined(_POSIX) && !defined(__APPLE__) && !defined(_FREEBSD)
|
||||
close(obj->mSocket);
|
||||
obj->mSocket = -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(_POSIX) && !defined(__APPLE__)
|
||||
#if defined(_POSIX) && !defined(__APPLE__) && !defined(_FREEBSD)
|
||||
void ILibIPAddressMonitor_PreSelect(void* object, fd_set *readset, fd_set *writeset, fd_set *errorset, int* blocktime)
|
||||
{
|
||||
_ILibIPAddressMonitor *obj = (_ILibIPAddressMonitor*)object;
|
||||
@@ -148,7 +148,7 @@ ILibIPAddressMonitor ILibIPAddressMonitor_Create(void *chain, ILibIPAddressMonit
|
||||
obj->reserved->hEvent = (HANDLE)obj;
|
||||
obj->mSocket = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
WSAIoctl(obj->mSocket, SIO_ADDRESS_LIST_CHANGE, NULL, 0, NULL, 0, &(obj->bytesReturned), obj->reserved, ILibIPAddressMonitor_dispatch);
|
||||
#elif defined (_POSIX) && !defined(__APPLE__)
|
||||
#elif defined (_POSIX) && !defined(__APPLE__) && !defined(_FREEBSD)
|
||||
obj->mSocket = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
|
||||
int flags = fcntl(obj->mSocket, F_GETFL, 0);
|
||||
fcntl(obj->mSocket, F_SETFL, O_NONBLOCK | flags);
|
||||
|
||||
@@ -25,8 +25,12 @@ limitations under the License.
|
||||
#include "chrome/nacl.h"
|
||||
#endif
|
||||
#if defined(_POSIX)
|
||||
#ifndef _VX_CPU
|
||||
#include <sys/statfs.h>
|
||||
#if !defined(_VX_CPU) && !defined(_FREEBSD)
|
||||
#include <sys/statfs.h>
|
||||
#endif
|
||||
#ifdef _FREEBSD
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#ifndef _NOILIBSTACKDEBUG
|
||||
@@ -8117,7 +8121,7 @@ int ILibGetCurrentTimezoneOffset_Minutes()
|
||||
{
|
||||
return(-1*(int)((u.QuadPart - l.QuadPart ) / 10000000 / 60));
|
||||
}
|
||||
#elif defined(_ANDROID)
|
||||
#elif defined(_ANDROID) || defined(_FREEBSD)
|
||||
return 0; // TODO
|
||||
#else
|
||||
int offset;
|
||||
@@ -8144,8 +8148,12 @@ int ILibIsDaylightSavingsTime()
|
||||
#elif defined(_ANDROID)
|
||||
return 0; // TODO
|
||||
#else
|
||||
tzset();
|
||||
return daylight;
|
||||
#ifdef _FREEBSD
|
||||
return(0);
|
||||
#else
|
||||
tzset();
|
||||
return daylight;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ struct sockaddr_in6;
|
||||
#ifndef __APPLE__
|
||||
#include <semaphore.h>
|
||||
#endif
|
||||
#if !defined(__APPLE__) && !defined(_VX_CPU)
|
||||
#if !defined(__APPLE__) && !defined(_VX_CPU) && !defined(_FREEBSD)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
@@ -95,7 +95,7 @@ struct sockaddr_in6;
|
||||
#define UNREFERENCED_PARAMETER(P)
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX) && !defined(__APPLE__)
|
||||
#if defined(_POSIX) && !defined(__APPLE__) && !defined(_FREEBSD)
|
||||
#include <linux/limits.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ limitations under the License.
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#ifndef __APPLE__
|
||||
#if !defined( __APPLE__) && !defined(_FREEBSD)
|
||||
#include <pty.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -47,7 +47,7 @@ extern "C" {
|
||||
#if defined(WIN32) || defined(_WIN32_WCE)
|
||||
#include <STDDEF.h>
|
||||
#elif defined(_POSIX)
|
||||
#if !defined(__APPLE__) && !defined(_VX_CPU)
|
||||
#if !defined(__APPLE__) && !defined(_VX_CPU) && !defined(_FREEBSD)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
BIN
openssl/libstatic/bsd/freebsd_x86-64/libcrypto.a
Normal file
BIN
openssl/libstatic/bsd/freebsd_x86-64/libcrypto.a
Normal file
Binary file not shown.
BIN
openssl/libstatic/bsd/freebsd_x86-64/libssl.a
Normal file
BIN
openssl/libstatic/bsd/freebsd_x86-64/libssl.a
Normal file
Binary file not shown.
Reference in New Issue
Block a user