Browse Source

Add tools subdirectory

pull/115/head
emanuele-f 5 years ago
parent
commit
60a4ba90ce
  1. 4
      .gitignore
  2. 15
      CMakeLists.txt
  3. 26
      Makefile.in
  4. 2
      README.md
  5. 9
      configure.seed
  6. 2
      n2n.h
  7. 38
      tools/Makefile.in
  8. 0
      tools/benchmark.c
  9. 0
      tools/n2n_decode.c

4
.gitignore

@ -6,11 +6,11 @@ configure.ac
config.* config.*
Makefile Makefile
autom4te.cache autom4te.cache
benchmark
edge edge
n2n-decode
example_edge_embed example_edge_embed
supernode supernode
tools/n2n-benchmark
tools/n2n-decode
build build
packages/debian/debian/changelog packages/debian/debian/changelog
packages/debian/debian/control packages/debian/debian/control

15
CMakeLists.txt

@ -16,6 +16,8 @@ if(NOT DEFINED N2N_OPTION_AES)
set(N2N_OPTION_AES ON) set(N2N_OPTION_AES ON)
endif(NOT DEFINED N2N_OPTION_AES) endif(NOT DEFINED N2N_OPTION_AES)
add_definitions(-DCMAKE_BUILD)
add_definitions(-DGIT_RELEASE="" -DPACKAGE_VERSION="${N2N_VERSION}" -DPACKAGE_OSNAME="${CMAKE_SYSTEM}")
add_definitions(-DN2N_VERSION="${N2N_VERSION}" -DN2N_OSNAME="${N2N_OSNAME}") add_definitions(-DN2N_VERSION="${N2N_VERSION}" -DN2N_OSNAME="${N2N_OSNAME}")
if(N2N_OPTION_AES) if(N2N_OPTION_AES)
@ -79,8 +81,17 @@ target_link_libraries(edge n2n)
add_executable(supernode sn.c) add_executable(supernode sn.c)
target_link_libraries(supernode n2n) target_link_libraries(supernode n2n)
add_executable(benchmark benchmark.c) # Tools
target_link_libraries(benchmark n2n) include_directories(.)
add_executable(n2n-benchmark tools/benchmark.c)
target_link_libraries(n2n-benchmark n2n)
find_library(PCAP_LIB pcap)
if(PCAP_LIB)
add_executable(n2n-decode tools/n2n_decode.c)
target_link_libraries(n2n-decode n2n pcap)
endif()
install(TARGETS edge supernode install(TARGETS edge supernode
RUNTIME DESTINATION sbin RUNTIME DESTINATION sbin

26
Makefile.in

@ -8,7 +8,7 @@ GIT_COMMITS=@GIT_COMMITS@
CC?=gcc CC?=gcc
DEBUG?=-g3 DEBUG?=-g3
#OPTIMIZATION?=-O2 #OPTIMIZATION?=-O2
WARN?=-Wall -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs WARN?=-Wall
#Ultrasparc64 users experiencing SIGBUS should try the following gcc options #Ultrasparc64 users experiencing SIGBUS should try the following gcc options
#(thanks to Robert Gibbon) #(thanks to Robert Gibbon)
@ -63,29 +63,26 @@ endif
APPS=edge APPS=edge
APPS+=supernode APPS+=supernode
APPS+=example_edge_embed APPS+=example_edge_embed
APPS+=benchmark
DOCS=edge.8.gz supernode.1.gz n2n.7.gz DOCS=edge.8.gz supernode.1.gz n2n.7.gz
all: $(APPS) $(DOCS) .PHONY: steps build push all clean install tools
all: $(APPS) $(DOCS) tools
tools: $(N2N_LIB)
$(MAKE) -C $@
edge: edge.c $(N2N_LIB) n2n_wire.h n2n.h Makefile edge: edge.c $(N2N_LIB) n2n_wire.h n2n.h Makefile
$(CC) $(CFLAGS) edge.c $(N2N_LIB) $(LIBS_EDGE) -o edge $(CC) $(CFLAGS) $< $(N2N_LIB) $(LIBS_EDGE) -o $@
supernode: sn.c $(N2N_LIB) n2n.h Makefile supernode: sn.c $(N2N_LIB) n2n.h Makefile
$(CC) $(CFLAGS) sn.c $(N2N_LIB) $(LIBS_SN) -o supernode $(CC) $(CFLAGS) $< $(N2N_LIB) $(LIBS_SN) -o $@
benchmark: benchmark.c $(N2N_LIB) n2n_wire.h n2n.h Makefile
$(CC) $(CFLAGS) benchmark.c $(N2N_LIB) $(LIBS_EDGE) -o benchmark
n2n-decode: n2n_decode.c $(N2N_LIB) n2n_wire.h n2n.h Makefile
$(CC) $(CFLAGS) n2n_decode.c $(N2N_LIB) $(LIBS_EDGE) -lpcap -o n2n-decode
example_edge_embed: example_edge_embed.c $(N2N_LIB) n2n.h example_edge_embed: example_edge_embed.c $(N2N_LIB) n2n.h
$(CC) $(CFLAGS) example_edge_embed.c $(N2N_LIB) $(LIBS_EDGE) -o example_edge_embed $(CC) $(CFLAGS) $< $(N2N_LIB) $(LIBS_EDGE) -o $@
.c.o: n2n.h n2n_transforms.h n2n_wire.h twofish.h Makefile .c.o: n2n.h n2n_transforms.h n2n_wire.h twofish.h Makefile
$(CC) $(CFLAGS) -c $< $(CC) $(CFLAGS) -c $< -o $@
%.gz : % %.gz : %
gzip -c $< > $@ gzip -c $< > $@
@ -96,6 +93,7 @@ $(N2N_LIB): $(N2N_OBJS)
clean: clean:
rm -rf $(N2N_OBJS) $(N2N_LIB) $(APPS) $(DOCS) test n2n-decode *.dSYM *~ rm -rf $(N2N_OBJS) $(N2N_LIB) $(APPS) $(DOCS) test n2n-decode *.dSYM *~
$(MAKE) -C tools clean
install: edge supernode edge.8.gz supernode.1.gz n2n.7.gz install: edge supernode edge.8.gz supernode.1.gz n2n.7.gz
echo "MANDIR=$(MANDIR)" echo "MANDIR=$(MANDIR)"
@ -105,6 +103,7 @@ install: edge supernode edge.8.gz supernode.1.gz n2n.7.gz
$(INSTALL_DOC) edge.8.gz $(MAN8DIR)/ $(INSTALL_DOC) edge.8.gz $(MAN8DIR)/
$(INSTALL_DOC) supernode.1.gz $(MAN1DIR)/ $(INSTALL_DOC) supernode.1.gz $(MAN1DIR)/
$(INSTALL_DOC) n2n.7.gz $(MAN7DIR)/ $(INSTALL_DOC) n2n.7.gz $(MAN7DIR)/
$(MAKE) -C tools install
# Docker builder section # Docker builder section
DOCKER_IMAGE_NAME=ntop/supernode DOCKER_IMAGE_NAME=ntop/supernode
@ -140,5 +139,4 @@ push:
echo "Please pass TARGET_ARCHITECTURE, see README.md."; \ echo "Please pass TARGET_ARCHITECTURE, see README.md."; \
fi fi
.PHONY: steps build push
# End Docker builder section # End Docker builder section

2
README.md

@ -133,7 +133,7 @@ two edge nodes, but it will now that edge A is talking with edge B.
Recently AES encryption support has been implemented, which increases both security and performance, Recently AES encryption support has been implemented, which increases both security and performance,
so it is recommended to enable it on all the edge nodes by specifying the `-A` option. so it is recommended to enable it on all the edge nodes by specifying the `-A` option.
A benchmark of the encryption methods is available when compiled from source with `./benchmark`. A benchmark of the encryption methods is available when compiled from source with `tools/n2n-benchmark`.
Contribution Contribution
------------ ------------

9
configure.seed

@ -24,6 +24,13 @@ else
N2N_LIBS=-lcrypto N2N_LIBS=-lcrypto
fi fi
AC_CHECK_LIB([pcap], [pcap_open_live], pcap=true)
if test x$pcap != x; then
AC_DEFINE([N2N_HAVE_PCAP], [], [Have PCAP library])
ADDITIONAL_TOOLS="$ADDITIONAL_TOOLS n2n-decode"
fi
MACHINE=`uname -m` MACHINE=`uname -m`
SYSTEM=`uname -s` SYSTEM=`uname -s`
@ -60,8 +67,10 @@ AC_SUBST(GIT_REVISION)
AC_SUBST(GIT_RELEASE) AC_SUBST(GIT_RELEASE)
AC_SUBST(N2N_DEFINES) AC_SUBST(N2N_DEFINES)
AC_SUBST(N2N_LIBS) AC_SUBST(N2N_LIBS)
AC_SUBST(ADDITIONAL_TOOLS)
AC_CONFIG_HEADERS(config.h) AC_CONFIG_HEADERS(config.h)
AC_CONFIG_FILES(Makefile) AC_CONFIG_FILES(Makefile)
AC_CONFIG_FILES(tools/Makefile)
AC_OUTPUT AC_OUTPUT

2
n2n.h

@ -42,8 +42,10 @@
#undef N2N_HAVE_DAEMON #undef N2N_HAVE_DAEMON
#undef N2N_HAVE_SETUID #undef N2N_HAVE_SETUID
#else #else
#ifndef CMAKE_BUILD
#include "config.h" #include "config.h"
#endif #endif
#endif
#define PACKAGE_BUILDDATE (__DATE__ " " __TIME__) #define PACKAGE_BUILDDATE (__DATE__ " " __TIME__)

38
tools/Makefile.in

@ -0,0 +1,38 @@
CC?=gcc
DEBUG?=-g3
#OPTIMIZATION?=-O2
WARN?=-Wall
INSTALL=install
INSTALL_PROG=$(INSTALL) -m755
MKDIR=mkdir -p
LIBS_EDGE_OPT=@N2N_LIBS@
LIBS_EDGE+=$(LIBS_EDGE_OPT)
HEADERS=../n2n_wire.h ../n2n.h ../twofish.h ../n2n_transforms.h
CFLAGS+=-I..
LDFLAGS+=-L..
CFLAGS+=$(DEBUG) $(OPTIMIZATION) $(WARN)
N2N_LIB=../libn2n.a
TOOLS=n2n-benchmark
TOOLS+=@ADDITIONAL_TOOLS@
.PHONY: all clean install
all: $(TOOLS)
n2n-benchmark: benchmark.c $(N2N_LIB) $(HEADERS)
$(CC) $(CFLAGS) $< $(N2N_LIB) $(LIBS_EDGE) -o $@
n2n-decode: n2n_decode.c $(N2N_LIB) $(HEADERS)
$(CC) $(CFLAGS) $< $(N2N_LIB) $(LIBS_EDGE) -lpcap -o $@
.c.o: $(HEADERS) ../Makefile Makefile
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf $(TOOLS) $(N2N_LIB) *.o *.dSYM *~
install: $(TOOLS)
$(INSTALL_PROG) $(TOOLS) $(SBINDIR)/

0
benchmark.c → tools/benchmark.c

0
n2n_decode.c → tools/n2n_decode.c

Loading…
Cancel
Save