Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
fbaad96
introduce new crypto layer; depend on gcrypt and gnutls
Aug 5, 2011
db03ad1
starting symmetric encryption, KEYS CONSTANT ZERO
Aug 6, 2011
50aa934
fix free() of encryption handles using dealloc_peer
Aug 6, 2011
4664b16
fix segfault in session destruction
Aug 6, 2011
6da92f5
Merge branch 'master' into gnutls-new
Aug 6, 2011
76cf6cc
fix merge problems
Aug 6, 2011
ec3562a
merge problems solved: linker and vcs tags
Aug 6, 2011
d80bbe9
gitignore vim swp files
Aug 6, 2011
8176ae7
reintroduce CRYPTO file with protocol discussion
Aug 6, 2011
1b54163
changed traffic enc algo to 128bit GCM
Aug 6, 2011
c3e4a32
lukas227: fix peer lookup, packet send in encryption
Aug 7, 2011
61927a0
fix returned size of crypttext + auth tag
Aug 7, 2011
43b9b55
lukas227: fixed packed transmission sizes
Aug 7, 2011
77a3133
IV design considerations and minor crypto hints
Aug 7, 2011
161920c
gitignore cscope, ctags and gprof files
Aug 7, 2011
ae54afd
Merge branch 'gnutls' of git://git.stusta.mhn.de/n2n into p2p_crypto
meyerd Aug 8, 2011
1add3de
- find libgcrypt script for cmake system
meyerd Aug 8, 2011
d4affc0
started working on specification for protocol
lukas227 Aug 8, 2011
1754cee
specified derivation of session keys from DH secret
Aug 8, 2011
455f501
added session key derivation
Aug 8, 2011
b12a459
updated crypto lib evaluation
Aug 8, 2011
4032272
Merge branch 'gnutls-github' into gnutls
Aug 8, 2011
ed38653
Merge branch 'gnutls' of git://git.stusta.mhn.de/n2n into p2p_crypto
meyerd Aug 9, 2011
ed6fcc7
some new ideas into specification
lukas227 Aug 9, 2011
98d6f14
Merge branch 'gnutls-github' into gnutls
Aug 9, 2011
3bfc224
minor corrections + some additions for Procedure
lukas227 Aug 9, 2011
1d62e96
Merge branch 'gnutls-github' into gnutls
Aug 9, 2011
d552b5d
removed redundant or old documentation, minor notes
Aug 10, 2011
a8ea347
state dependencies for installation
Aug 10, 2011
caee4a7
remove obsolete benchmarks
Aug 10, 2011
f0142ff
moved internal/protocol documentation to ./doc/
Aug 10, 2011
ada8201
Revert "moved internal/protocol documentation to ./doc/"
Aug 10, 2011
9982ea0
updated crypto primitives in protocol spec
Aug 10, 2011
f8418f1
original SA has to be sent back at the handshake
lukas227 Aug 10, 2011
2c43695
added arp-requests and rekeying
lukas227 Aug 10, 2011
c3f6eaa
one timeout too many in exchange sequences
lukas227 Aug 10, 2011
490e22b
started specification of crypto packets
Aug 10, 2011
0470785
Merge branch 'gnutls-github' into gnutls
Aug 10, 2011
b14fc36
started specification of crypto packets
Aug 10, 2011
a5a6c45
Merge branch 'gnutls-github' into gnutls
Aug 10, 2011
1a9bb83
used packets from SPEC.CRYPTO in SPECIFICATION
lukas227 Aug 10, 2011
747a351
increased readability of specification
lukas227 Aug 10, 2011
790c7d7
change packet -> payload packet
lukas227 Aug 10, 2011
8f93774
Merge branch 'gnutls-github' into gnutls
Aug 10, 2011
c5436fa
revisited protocol details, more details
Aug 10, 2011
ba321cc
discard packets when spi not found
Aug 10, 2011
4c50a1a
some work on decoding
lukas227 Aug 10, 2011
0eae4b3
Merge branch 'gnutls-github' into gnutls
Aug 10, 2011
123fa71
- move manpages from doc/ to man/
meyerd Aug 11, 2011
300bdbb
- typo forgot to replace one doc
meyerd Aug 11, 2011
841dd17
- drop old n2n_v1
meyerd Aug 11, 2011
32eb4ad
Merge branch 'p2p_crypto' of github.com:meyerd/n2n into p2p_crypto
meyerd Aug 11, 2011
a4cefb1
Merge branch 'gnutls-github' into gnutls
Aug 11, 2011
f23bda1
- win32/ whitespace fix
meyerd Aug 11, 2011
aa2ab96
prototype for hole punch packet, community name discussion
Aug 11, 2011
c0a78a9
- whitespace fix up to edge.c
meyerd Aug 11, 2011
4e30637
- whitespace cleanup up to n2n.c
meyerd Aug 11, 2011
1b46e59
- whitespace fix up to sn.c
meyerd Aug 11, 2011
345ed41
- whitespace cleanup up to transform_null.c
meyerd Aug 11, 2011
35f2acf
- whitespace cleanup up to tuntap_osx.c
meyerd Aug 11, 2011
114df39
- final whitespace cleanup (twofish.c, twofish.h left out!)
meyerd Aug 11, 2011
5c8febb
Merge branch 'p2p_crypto' of github.com:meyerd/n2n into p2p_crypto
meyerd Aug 11, 2011
6056ba2
NIST concat KDF, SPI random number generator
Aug 11, 2011
625e21e
removed superfluous initialization
Aug 11, 2011
c974975
fix stupid bug in hash function
lukas227 Aug 12, 2011
1f3772c
cleanup unused list iteration function
lukas227 Aug 12, 2011
7455876
remove functions in header file too...
lukas227 Aug 12, 2011
2b081e2
specified new pre-handshake packet
lukas227 Aug 12, 2011
e769afc
updated HMAC and KDF specification
Aug 12, 2011
450076d
started working on initial supernode handshake
lukas227 Aug 12, 2011
5a223d7
more work on initial_supernode_registration
lukas227 Aug 12, 2011
89f9e3c
KDF prepared for more general use
Aug 12, 2011
eb758bd
elliptic curve Diffie-Hellman key exchange
Aug 14, 2011
df5565f
updated dependencies to include libgcrypt >=1.5
Aug 14, 2011
9e30945
fix includes for new structure of files
Aug 14, 2011
1e45a71
include libgcrypt and new crypto files for cmake
Aug 14, 2011
1cabb1a
error control, moved functions
Aug 14, 2011
2cf7fb5
reflect function move in header file
Aug 14, 2011
e90594a
new error macros
Aug 14, 2011
e12894d
information about master keys
Aug 14, 2011
5e8084a
the new files for AES/sessions/SAs
Aug 14, 2011
6204fda
functions to import the master keys into the backend
Aug 14, 2011
0a0a4f6
make set_key fcts available
Aug 14, 2011
48dd4f8
introduce HMAC functionality
Aug 15, 2011
5babf0f
secure memory allocation wrapper, wiping improved
Aug 17, 2011
7051308
ecdh: fixes, restructuring
Aug 17, 2011
8c598f2
bring hmac up to date with new memory management
Aug 17, 2011
bced25b
minor documentation updates
Aug 17, 2011
0f2e6f6
Merge branch 'p2p_crypto' into new_protocol
meyerd Aug 19, 2011
36f7d34
renamed specification, prepare to split in multiple files
lukas227 Aug 21, 2011
86fb25e
complete splitup
lukas227 Aug 21, 2011
57f17fa
work on SPEC.DECODING
lukas227 Aug 21, 2011
9d8820a
removed unnecessary part of SPEC.FORMATS
lukas227 Aug 21, 2011
3703687
add some thoughts on MTU
lukas227 Aug 21, 2011
6a3bb49
new pre-handshake packet format
Aug 22, 2011
77dfe79
Merge remote-tracking branch 'benni/gnutls' into p2p_crypto
lukas227 Aug 22, 2011
9ead7fe
small additions to SPEC.CRYPTO
lukas227 Aug 22, 2011
492a625
Merge branch 'p2p_crypto' into new_protocol
meyerd Aug 22, 2011
e9abc7c
- common packet header parsing (initial version), won't compile!!!
meyerd Sep 14, 2011
bb083d2
reworked packed codes, some cleanup
lukas227 Oct 14, 2011
0ab6ac1
removed old definiton of n2n_flags_t
lukas227 Oct 14, 2011
1729958
adjusted msg_type2str function
lukas227 Oct 14, 2011
6738e64
removed n2n_common_t
lukas227 Oct 14, 2011
b02d27b
remove encode_common and decode_common
lukas227 Oct 14, 2011
dcb8ef3
reworked decode_* functions, added supernode_reg
lukas227 Oct 14, 2011
53f87f2
removed some decode function, minor bugfixes
lukas227 Oct 14, 2011
44b4a0b
updated transforms to new decode parameters
lukas227 Oct 14, 2011
c618f65
uncommenting conflicting parts of benchmark
lukas227 Oct 14, 2011
a61cb20
remove version information from HEADER struct
lukas227 Oct 15, 2011
38b13b3
introduce hash function for community name
Oct 15, 2011
c8f9773
reduce N2N_COMMUNITY_SIZE
lukas227 Oct 15, 2011
159e2c4
work on initial supernode registration
lukas227 Oct 15, 2011
9a8cab4
security associations modified
Oct 15, 2011
ee40f15
remove unnecessary wiping
Oct 15, 2011
db50dc5
Merge branch 'p2p_crypto' into new_protocol
lukas227 Oct 15, 2011
d9e1a9e
added encode & decode ip functions
lukas227 Oct 15, 2011
df9dd28
adjusted datatype n2n_ip_addr
lukas227 Oct 15, 2011
1047076
destroy functions have changed, uncomment for now
lukas227 Oct 15, 2011
1b84934
further work on initial supernode handshake
lukas227 Oct 15, 2011
a482c68
- updated wiki
meyerd Jan 5, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CMakeFiles/
cmake_install.cmake
benchmark
benchmark_hashtable
doc/
man/
edge
gnutls/
libn2n.a
Expand All @@ -15,3 +15,8 @@ test
*.vcxproj.filters
*.vcxproj.user
~$
*.swp
*.swo
cscope.out
gmon.out
tags
55 changes: 36 additions & 19 deletions n2n_v2/CMakeLists.txt → CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
project(n2n)
cmake_minimum_required(VERSION 2.6)

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/FindLibGcrypt.cmake)

# N2n information
set(N2N_VERSION 2.1.0)
set(N2N_OSNAME ${CMAKE_SYSTEM})
Expand Down Expand Up @@ -40,7 +42,7 @@ if(NOT WIN32)
set(CMAKE_C_FLAGS "-Wall -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs -fPIC")
set(CMAKE_CXX_FLAGS "-Wall -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs")
# Debug
set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_DEBUG "-g -Wno-deprecated-declarations")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
# Release
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
Expand All @@ -54,9 +56,22 @@ endif(NOT WIN32)
#message(${N2N_OPTION_AES})
## DEBUG FOR CMAKE

# install gnutls >= 2.99.0 in your system path or here
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/gnutls/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libgcrypt/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/gnutls/lib)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/libgcrypt/lib)

# libgcrypt
gcr_check(GCRYPT REQUIRED gcrypt)

add_library(n2n n2n.c
n2n_keyfile.c
wire.c
crypto/crypto.c
crypto/aes.c
crypto/ecdh.c
crypto/hmac.c
minilzo.c
twofish.c
transform_null.c
Expand All @@ -74,6 +89,8 @@ add_subdirectory(win32)
target_link_libraries(n2n n2n_win32)
endif(DEFINED WIN32)

target_link_libraries(n2n gnutls gcrypt)

if(N2N_OPTION_AES)
target_link_libraries(n2n crypto)
endif(N2N_OPTION_AES)
Expand All @@ -82,7 +99,7 @@ endif(N2N_OPTION_AES)
#target_link_libraries(n2n socket nsl)

add_executable(edge edge.c)
target_link_libraries(edge n2n)
target_link_libraries(edge n2n gcrypt gnutls)

add_executable(supernode sn.c)
target_link_libraries(supernode n2n)
Expand All @@ -104,37 +121,37 @@ install(TARGETS edge supernode

# Documentation
if(DEFINED UNIX)
add_dependencies(n2n doc)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/doc)
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/doc/edge.8.gz
COMMAND gzip -c ${PROJECT_SOURCE_DIR}/edge.8 > ${PROJECT_BINARY_DIR}/doc/edge.8.gz
add_dependencies(n2n man)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/man)
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/man/edge.8.gz
COMMAND gzip -c ${PROJECT_SOURCE_DIR}/edge.8 > ${PROJECT_BINARY_DIR}/man/edge.8.gz
DEPENDS ${PROJECT_SOURCE_DIR}/edge.8
)

add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/doc/supernode.1.gz
COMMAND gzip -c ${PROJECT_SOURCE_DIR}/supernode.1 > ${PROJECT_BINARY_DIR}/doc/supernode.1.gz
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/man/supernode.1.gz
COMMAND gzip -c ${PROJECT_SOURCE_DIR}/supernode.1 > ${PROJECT_BINARY_DIR}/man/supernode.1.gz
DEPENDS ${PROJECT_SOURCE_DIR}/supernode.1
)

add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/doc/n2n_v2.7.gz
COMMAND gzip -c ${PROJECT_SOURCE_DIR}/n2n_v2.7 > ${PROJECT_BINARY_DIR}/doc/n2n_v2.7.gz
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/man/n2n_v2.7.gz
COMMAND gzip -c ${PROJECT_SOURCE_DIR}/n2n_v2.7 > ${PROJECT_BINARY_DIR}/man/n2n_v2.7.gz
DEPENDS ${PROJECT_SOURCE_DIR}/n2n_v2.7
)

add_custom_target(doc DEPENDS ${PROJECT_BINARY_DIR}/doc/edge.8.gz
${PROJECT_BINARY_DIR}/doc/supernode.1.gz
${PROJECT_BINARY_DIR}/doc/n2n_v2.7.gz
add_custom_target(man DEPENDS ${PROJECT_BINARY_DIR}/man/edge.8.gz
${PROJECT_BINARY_DIR}/man/supernode.1.gz
${PROJECT_BINARY_DIR}/man/n2n_v2.7.gz
)

set_source_files_properties(${PROJECT_BINARY_DIR}/doc/edge.8.gz
${PROJECT_BINARY_DIR}/doc/supernode.1.gz
${PROJECT_BINARY_DIR}/doc/n2n_v2.7.gz
set_source_files_properties(${PROJECT_BINARY_DIR}/man/edge.8.gz
${PROJECT_BINARY_DIR}/man/supernode.1.gz
${PROJECT_BINARY_DIR}/man/n2n_v2.7.gz
PROPERTIES GENERATED 1)

install(FILES ${PROJECT_BINARY_DIR}/doc/edge.8.gz
install(FILES ${PROJECT_BINARY_DIR}/man/edge.8.gz
DESTINATION /usr/share/man8)
install(FILES ${PROJECT_BINARY_DIR}/doc/supernode.1.gz
install(FILES ${PROJECT_BINARY_DIR}/man/supernode.1.gz
DESTINATION /usr/share/man1)
install(FILES ${PROJECT_BINARY_DIR}/doc/n2n_v2.7.gz
install(FILES ${PROJECT_BINARY_DIR}/man/n2n_v2.7.gz
DESTINATION /usr/share/man7)
endif(DEFINED UNIX)
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions n2n_v2/INSTALL → INSTALL
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Dependencies:
- libgcrypt >= 1.5
- GnuTLS >= 3.0.1 (depends itself on nettle 2.2 at the time of writing)

New install procedure, using cmake.

Customize CMakeLists.txt
Expand Down
File renamed without changes.
10 changes: 9 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
This is a fork of the n2n p2p vpn software. http://www.ntop.org/n2n.
This is the current development branch of the n2n p2p vpn software.

http://www.ntop.org/products/n2n/

It contains some modifications of the v2 version of n2n, which is the latest stable version
and should be used for productive environments.
All the current development happens in this repository in the new_protocol branch, which is
intended to be come version v3 of n2n and then merged back into the original svn repository
on ntop.org.

Uses sglib http://sglib.sourceforge.net.

Expand Down
9 changes: 4 additions & 5 deletions n2n_v1/README → README.n2n.orig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Edge node
---------

You need to start an egde node on each host you want to connect with the *same*
You need to start an edge node on each host you want to connect with the *same*
community.

0. become root
Expand Down Expand Up @@ -53,7 +53,7 @@ safe if your host has only one login user.
Running As a Daemon (UNIX)
-------------------

When given "-f" as a command line option, edge will call daemon(3) after
Unless given "-f" as a command line option, edge will call daemon(3) after
successful setup. This causes the process to fork a child which closes stdin,
stdout and stderr then sets itself as process group leader. When this is done,
the edge command returns immediately and you will only see the edge process in
Expand All @@ -64,7 +64,7 @@ returns non-zero then edge failed to start up for some reason. When edge starts
running as a daemon, all logging goes to syslog daemon.info facility.


IPv6 Support (added r3650)
IPv6 Support
------------

n2n supports the carriage of IPv6 packets within the n2n tunnel. N2n does not
Expand All @@ -91,5 +91,4 @@ Once the IPv6 addresses are configured and edge started, IPv6 neighbor discovery
packets flow (get broadcast) and IPv6 entities self arrange. Test your IPv6
setup with ping6 - the IPv6 ping command.


(C) 2007,2008 - Luca Deri <deri@ntop.org>, Richard Andrews <andrews@ntop.org>
(C) 2007-2010 - Luca Deri <deri@ntop.org>, Richard Andrews <andrews@ntop.org>
117 changes: 117 additions & 0 deletions benchmark.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#include "n2n_wire.h"
#include "n2n_transforms.h"
#include "n2n.h"

#ifndef WIN32
#include <sys/time.h>
#endif
#include <time.h>
#include <string.h>
#include <stdio.h>

uint8_t PKT_CONTENT[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15 };

/* Prototypes */
static ssize_t do_encode_packet(uint8_t * pktbuf, size_t bufsize,
const n2n_community_t c);

int main(int argc, char * argv[])
{
uint8_t pktbuf[N2N_PKT_BUF_SIZE];
n2n_trans_op_t transop_null;

/* n2n_common_t cmn; */
/* n2n_PACKET_t pkt; */
n2n_community_t c;

struct timeval t1;
struct timeval t2;

unsigned long int i;
size_t n;
/* size_t idx; */
/* size_t rem; */
ssize_t nw;
unsigned long int tdiff;

transop_null_init(&transop_null);
memset(c, 0, sizeof(N2N_COMMUNITY_SIZE));

n = 10000;
memcpy(c, "abc123def456", 12);

gettimeofday(&t1, NULL);
for (i = 0; i < n; ++i) {
nw = do_encode_packet(pktbuf, N2N_PKT_BUF_SIZE, c);

nw += transop_null.fwd(&transop_null, pktbuf + nw,
N2N_PKT_BUF_SIZE - nw, PKT_CONTENT, sizeof(PKT_CONTENT));

/* idx = 0; */
/* rem = nw; */

/* decode_common(&cmn, pktbuf, &rem, &idx); */
/* decode_PACKET(&pkt, &cmn, pktbuf, &rem, &idx); */

if (0 == (i % 1000)) {
fprintf(stderr, ".");
}
}
gettimeofday(&t2, NULL);

tdiff = ((t2.tv_sec - t1.tv_sec) * 1000000) + (t2.tv_usec - t1.tv_usec);

fprintf(stderr,
"\nrun %lu times. (%lu -> %lu nsec each) %u.%06u -> %u.%06u.\n", i,
tdiff, (tdiff * 1000) / i, (uint32_t) t1.tv_sec,
(uint32_t) t1.tv_usec, (uint32_t) t2.tv_sec, (uint32_t) t2.tv_usec);

return 0;
}

static ssize_t do_encode_packet(uint8_t * pktbuf, size_t bufsize,
const n2n_community_t c)
{
/* n2n_mac_t destMac={0,1,2,3,4,5}; */
/* n2n_common_t cmn; */
n2n_PACKET_t pkt;
size_t idx;

/* memset(&cmn, 0, sizeof(cmn)); */
/*cmn.ttl = N2N_DEFAULT_TTL;
cmn.pc = n2n_packet;
cmn.flags = 0; // no options, not from supernode, no socket
memcpy(cmn.community, c, N2N_COMMUNITY_SIZE); */

memset(&pkt, 0, sizeof(pkt));

idx = 0;
/* encode_PACKET(pktbuf, &idx, &cmn, &pkt); */
traceEvent(TRACE_DEBUG, "encoded PACKET header of size=%u", (unsigned int)idx);

return idx;
}
25 changes: 25 additions & 0 deletions benchmark_hashtable.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "n2n_wire.h"
#include "n2n_transforms.h"
#include "n2n.h"

#ifndef WIN32
#include <sys/time.h>
#endif
#include <time.h>
#include <string.h>
#include <stdio.h>

int main(int argc, char** argv) {
peer_info_t* testpeers[PEER_HASH_TAB_SIZE];
struct sglib_hashed_peer_info_t_iterator it;
peer_info_t *ll;

sglib_hashed_peer_info_t_init(testpeers);

for (ll = sglib_hashed_peer_info_t_it_init(&it, testpeers); ll != NULL; ll =
sglib_hashed_peer_info_t_it_next(&it)) {
sglib_hashed_peer_info_t_delete(testpeers, ll);
free(ll);
}
return 0;
}
Loading