diff --git a/CMakeLists.txt b/CMakeLists.txt index 435be93..6afd63e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,8 @@ project (ndhcp) cmake_minimum_required (VERSION 2.6) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s -std=gnu99 -pedantic -Wall -lcap -D_GNU_SOURCE -DHAVE_CLEARENV -DLINUX") -set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -s -std=gnu99 -pedantic -Wall -lcap -D_GNU_SOURCE -DHAVE_CLEARENV -DLINUX") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s -std=gnu99 -pedantic -Wall -lrt -lcap -D_GNU_SOURCE -DHAVE_CLEARENV -DLINUX") +set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -s -std=gnu99 -pedantic -Wall -lrt -lcap -D_GNU_SOURCE -DHAVE_CLEARENV -DLINUX") include_directories( "${PROJECT_SOURCE_DIR}/ncmlib" diff --git a/Makefile b/Makefile index 65aad04..da96f30 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ makedir: mkdir -p $(BUILD_DIR) $(OBJ_DIR)/ndhc $(OBJ_DIR)/ifchd $(OBJ_DIR)/ncmlib %.o: %.c - $(CC) $(CFLAGS) $(NCM_INC) -c -o $(OBJ_DIR)/$@ $< + $(CC) $(CFLAGS) $(IFCH_INC) $(NCM_INC) -c -o $(OBJ_DIR)/$@ $< ncmlib.a: $(NCM_OBJS) $(AR) rc $(BUILD_DIR)/$@ $(subst ncmlib/,$(OBJ_DIR)/ncmlib/,$(NCM_OBJS)) @@ -37,7 +37,7 @@ ifchd: $(IFCHD_OBJS) $(CC) $(CFLAGS) $(NCM_INC) -o $(BUILD_DIR)/$@ $(subst ifchd/,$(OBJ_DIR)/ifchd/,$(IFCHD_OBJS)) $(BUILD_DIR)/ncmlib.a -lcap ndhc: $(NDHC_OBJS) - $(CC) $(CFLAGS) $(IFCH_INC) $(NCM_INC) -o $(BUILD_DIR)/$@ $(subst ndhc/,$(OBJ_DIR)/ndhc/,$(NDHC_OBJS)) $(BUILD_DIR)/ncmlib.a -lcap + $(CC) $(CFLAGS) $(IFCH_INC) $(NCM_INC) -o $(BUILD_DIR)/$@ $(subst ndhc/,$(OBJ_DIR)/ndhc/,$(NDHC_OBJS)) $(BUILD_DIR)/ncmlib.a -lcap -lrt .PHONY: all clean diff --git a/ndhc/sys.h b/ndhc/sys.h index 0c43701..e056153 100644 --- a/ndhc/sys.h +++ b/ndhc/sys.h @@ -28,15 +28,15 @@ #ifndef SYS_H_ #define SYS_H_ -#include +#include #include "ndhc-defines.h" #include "config.h" static inline unsigned long long curms() { - struct timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_sec * 1000ULL + tv.tv_usec / 1000ULL; + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return ts.tv_sec * 1000ULL + ts.tv_nsec / 1000000ULL; } extern char pidfile[MAX_PATH_LENGTH];