diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..18097b95 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ + +depdirs = \ + libcallbackstreamdll \ + libdparserdll \ + libreqlistdll \ + libsymbolsdll \ + irpmondll \ + libserver + +maindirs = irpmonc irpmon-server + +otherdirs = device-connector shared + +.PHONY: all clean $(depdirs) $(maindirs) $(otherdirs) + +all: $(otherdirs) $(maindirs) + +$(maindirs): $(depdirs) + $(MAKE) -C $@ + +$(depdirs) $(otherdirs): + $(MAKE) -C $@ + +libserver: device-connector + +clean: + $(foreach dir,$(depdirs) $(maindirs) $(otherdirs),$(MAKE) -C $(dir) $@ &&) : diff --git a/common.mk b/common.mk new file mode 100644 index 00000000..fe80ce84 --- /dev/null +++ b/common.mk @@ -0,0 +1,20 @@ + +# for cross-building with MinGW +CROSS = x86_64-w64-mingw32- +INCLUDES = -I/usr/share/mingw-w64/include + +INCLUDES += -I../include -I../shared +CPPFLAGS += $(INCLUDES) -O2 +CFLAGS += $(INCLUDES) -O2 + +CC = $(CROSS)gcc +LD = $(CROSS)ld +CXX = $(CROSS)g++ + +all: $(EXE) + +$(EXE): $(OBJS) + $(CXX) -o $@ $(LDFLAGS) $^ $(LDLIBS) + +clean: + rm -f $(EXE) $(OBJS) $(DELOBJS) diff --git a/device-connector/Makefile b/device-connector/Makefile new file mode 100644 index 00000000..57b17ee4 --- /dev/null +++ b/device-connector/Makefile @@ -0,0 +1,7 @@ + +LDFLAGS += -shared + +EXE = device-connector.dll +OBJS = device-connector.o + +include ../common.mk diff --git a/irpmon-server/Makefile b/irpmon-server/Makefile new file mode 100644 index 00000000..89b04d71 --- /dev/null +++ b/irpmon-server/Makefile @@ -0,0 +1,9 @@ + +LDFLAGS += -L../libserver -mconsole +LDLIBS += -lserver + +EXE = server +OBJS = server.o +DELOBJS = $(EXE).exe + +include ../common.mk diff --git a/irpmonc/Makefile b/irpmonc/Makefile new file mode 100644 index 00000000..5687908e --- /dev/null +++ b/irpmonc/Makefile @@ -0,0 +1,16 @@ + +CPPFLAGS += -DNOVSOCKETS + +LDFLAGS += -municode \ + -L../irpmondll -L../libdparserdll -L../libreqlistdll \ + -L../libsymbolsdll -L../libcallbackstreamdll + +LDLIBS += \ + -lirpmondll -llibdparser -llibreqlist \ + -llibsymbols -lcallbackstream + +EXE = irpmonc +OBJS = driver-settings.o irpmonc.o guid-api.o stop-event.o +DELOBJS = $(EXE).exe + +include ../common.mk diff --git a/irpmondll/Makefile b/irpmondll/Makefile new file mode 100644 index 00000000..72fe1672 --- /dev/null +++ b/irpmondll/Makefile @@ -0,0 +1,7 @@ + +LDFLAGS += -shared + +EXE = irpmondll.dll +OBJS = driver-com.o main.o + +include ../common.mk diff --git a/libcallbackstreamdll/Makefile b/libcallbackstreamdll/Makefile new file mode 100644 index 00000000..68f2d7e7 --- /dev/null +++ b/libcallbackstreamdll/Makefile @@ -0,0 +1,7 @@ + +LDFLAGS += -shared + +EXE = libcallbackstream.dll +OBJS = callback-stream.o + +include ../common.mk diff --git a/libdparserdll/Makefile b/libdparserdll/Makefile new file mode 100644 index 00000000..046693ed --- /dev/null +++ b/libdparserdll/Makefile @@ -0,0 +1,7 @@ + +LDFLAGS += -shared + +EXE = libdparser.dll +OBJS = dparser.o + +include ../common.mk diff --git a/libreqlistdll/Makefile b/libreqlistdll/Makefile new file mode 100644 index 00000000..4932ef41 --- /dev/null +++ b/libreqlistdll/Makefile @@ -0,0 +1,7 @@ + +LDFLAGS += -shared + +EXE = libreqlist.dll +OBJS = reqlist.o + +include ../common.mk diff --git a/libserver/Makefile b/libserver/Makefile new file mode 100644 index 00000000..d58f6e5c --- /dev/null +++ b/libserver/Makefile @@ -0,0 +1,9 @@ + +CFLAGS += -DNOVSOCKETS -D_WIN32_WINNT=0x0600 +LDFLAGS += -shared -L../device-connector +LDLIBS += -ldevice-connector -lws2_32 + +EXE = libserver.dll +OBJS = libserver.o + +include ../common.mk diff --git a/libserver/libserver.c b/libserver/libserver.c index 1db8721d..c9f034d9 100644 --- a/libserver/libserver.c +++ b/libserver/libserver.c @@ -1,11 +1,15 @@ #include #include +#include #include +#include #include #include #include +#ifndef NOVSOCKETS #include "libvsock.h" +#endif #include "irpmondll-types.h" #include "network-connector.h" #include "device-connector.h" @@ -258,8 +262,11 @@ DWORD IRPMonServerStart(const char *Address, const char *Port, HANDLE ExitEvent) goto Exit; } +#ifndef NOVSOCKETS useVSockets = strcmp(Address, "vsock") == 0; +#endif if (useVSockets) { +#ifndef NOVSOCKETS ADDRINFOA localAddrs; struct sockaddr *a = NULL; int aLen = 0; @@ -282,6 +289,7 @@ DWORD IRPMonServerStart(const char *Address, const char *Port, HANDLE ExitEvent) addrs->ai_addrlen = aLen; addrs->ai_family = LibVSockGetAddressFamily(); addrs->ai_socktype = SOCK_STREAM; +#endif } else { memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; @@ -295,9 +303,13 @@ DWORD IRPMonServerStart(const char *Address, const char *Port, HANDLE ExitEvent) } ret = _Listener(addrs, ExitEvent); +#ifndef NOVSOCKETS if (useVSockets) LibVSockAddressFree(addrs->ai_addr); else freeaddrinfo(addrs); +#else + freeaddrinfo(addrs); +#endif Cleanup: WSACleanup(); Exit: diff --git a/libsymbolsdll/Makefile b/libsymbolsdll/Makefile new file mode 100644 index 00000000..9de6709b --- /dev/null +++ b/libsymbolsdll/Makefile @@ -0,0 +1,7 @@ + +LDFLAGS += -shared + +EXE = libsymbols.dll +OBJS = symbols.o + +include ../common.mk diff --git a/libvsock/Makefile b/libvsock/Makefile new file mode 100644 index 00000000..5003ac2d --- /dev/null +++ b/libvsock/Makefile @@ -0,0 +1,7 @@ + +LDFLAGS += -shared + +EXE = libvsock.dll +OBJS = libvsock.o + +include ../common.mk diff --git a/shared/Makefile b/shared/Makefile new file mode 100644 index 00000000..a02b8ff9 --- /dev/null +++ b/shared/Makefile @@ -0,0 +1,7 @@ + +LDFLAGS += -shared + +EXE = request.dll +OBJS = request.o + +include ../common.mk