Skip to content

Commit

Permalink
Add tools subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuele-f committed Sep 21, 2019
1 parent 1ba5fa3 commit 60a4ba9
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ configure.ac
config.*
Makefile
autom4te.cache
benchmark
edge
n2n-decode
example_edge_embed
supernode
tools/n2n-benchmark
tools/n2n-decode
build
packages/debian/debian/changelog
packages/debian/debian/control
Expand Down
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ if(NOT DEFINED N2N_OPTION_AES)
set(N2N_OPTION_AES ON)
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}")

if(N2N_OPTION_AES)
Expand Down Expand Up @@ -79,8 +81,17 @@ target_link_libraries(edge n2n)
add_executable(supernode sn.c)
target_link_libraries(supernode n2n)

add_executable(benchmark benchmark.c)
target_link_libraries(benchmark n2n)
# Tools
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
RUNTIME DESTINATION sbin
Expand Down
26 changes: 12 additions & 14 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GIT_COMMITS=@GIT_COMMITS@
CC?=gcc
DEBUG?=-g3
#OPTIMIZATION?=-O2
WARN?=-Wall -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs
WARN?=-Wall

#Ultrasparc64 users experiencing SIGBUS should try the following gcc options
#(thanks to Robert Gibbon)
Expand Down Expand Up @@ -63,29 +63,26 @@ endif
APPS=edge
APPS+=supernode
APPS+=example_edge_embed
APPS+=benchmark

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
$(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
$(CC) $(CFLAGS) sn.c $(N2N_LIB) $(LIBS_SN) -o supernode

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
$(CC) $(CFLAGS) $< $(N2N_LIB) $(LIBS_SN) -o $@

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
$(CC) $(CFLAGS) -c $<
$(CC) $(CFLAGS) -c $< -o $@

%.gz : %
gzip -c $< > $@
Expand All @@ -96,6 +93,7 @@ $(N2N_LIB): $(N2N_OBJS)

clean:
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
echo "MANDIR=$(MANDIR)"
Expand All @@ -105,6 +103,7 @@ install: edge supernode edge.8.gz supernode.1.gz n2n.7.gz
$(INSTALL_DOC) edge.8.gz $(MAN8DIR)/
$(INSTALL_DOC) supernode.1.gz $(MAN1DIR)/
$(INSTALL_DOC) n2n.7.gz $(MAN7DIR)/
$(MAKE) -C tools install

# Docker builder section
DOCKER_IMAGE_NAME=ntop/supernode
Expand Down Expand Up @@ -140,5 +139,4 @@ push:
echo "Please pass TARGET_ARCHITECTURE, see README.md."; \
fi

.PHONY: steps build push
# End Docker builder section
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
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
------------
Expand Down
9 changes: 9 additions & 0 deletions configure.seed
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ else
N2N_LIBS=-lcrypto
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`
SYSTEM=`uname -s`

Expand Down Expand Up @@ -60,8 +67,10 @@ AC_SUBST(GIT_REVISION)
AC_SUBST(GIT_RELEASE)
AC_SUBST(N2N_DEFINES)
AC_SUBST(N2N_LIBS)
AC_SUBST(ADDITIONAL_TOOLS)
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_FILES(Makefile)
AC_CONFIG_FILES(tools/Makefile)

AC_OUTPUT

2 changes: 2 additions & 0 deletions n2n.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
#undef N2N_HAVE_DAEMON
#undef N2N_HAVE_SETUID
#else
#ifndef CMAKE_BUILD
#include "config.h"
#endif
#endif

#define PACKAGE_BUILDDATE (__DATE__ " " __TIME__)

Expand Down
38 changes: 38 additions & 0 deletions tools/Makefile.in
Original file line number Diff line number Diff line change
@@ -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)/
File renamed without changes.
File renamed without changes.

0 comments on commit 60a4ba9

Please sign in to comment.