mirror of
https://github.com/ntop/n2n.git
synced 2024-09-19 16:41:11 +02:00
Minor code claanup
This commit is contained in:
parent
de86a22705
commit
0bf7ae0a01
|
@ -129,6 +129,7 @@ typedef struct ether_hdr ether_hdr_t;
|
|||
#include <signal.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
|
|
@ -43,10 +43,11 @@
|
|||
#define IP4_MIN_SIZE 20
|
||||
#define UDP_SIZE 8
|
||||
|
||||
#if 0
|
||||
/* heap allocation for compression as per lzo example doc */
|
||||
#define HEAP_ALLOC(var,size) lzo_align_t __LZO_MMODEL var [ ((size) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t) ]
|
||||
static HEAP_ALLOC(wrkmem, LZO1X_1_MEM_COMPRESS);
|
||||
|
||||
#endif
|
||||
|
||||
/* N2N compression indicators. */
|
||||
/* Compression is disabled by default for outgoing packets if no cli
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
|
||||
#include "n2n.h"
|
||||
|
||||
/* heap allocation for compression as per lzo example doc */
|
||||
#define HEAP_ALLOC(var,size) lzo_align_t __LZO_MMODEL var [ ((size) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t) ]
|
||||
static HEAP_ALLOC(wrkmem, LZO1X_1_MEM_COMPRESS);
|
||||
|
||||
/* ************************************** */
|
||||
|
||||
static const char * supernode_ip(const n2n_edge_t * eee);
|
||||
|
|
|
@ -40,7 +40,7 @@ n2n-decode: n2n_decode.c $(N2N_LIB) $(HEADERS)
|
|||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -rf $(TOOLS) $(N2N_LIB) *.o *.dSYM *~
|
||||
rm -rf $(TOOLS) *.o *.dSYM *~
|
||||
|
||||
install: $(TOOLS)
|
||||
$(INSTALL_PROG) $(TOOLS) $(SBINDIR)/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* (C) 2007-18 - ntop.org and contributors
|
||||
* (C) 2007-20 - ntop.org and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,37 +16,26 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "n2n_wire.h"
|
||||
#include "n2n_transforms.h"
|
||||
#include "n2n.h"
|
||||
#ifdef __GNUC__
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#if defined(WIN32) && !defined(__GNUC__)
|
||||
#include <windows.h>
|
||||
|
||||
static int gettimeofday(struct timeval *tp, void *tzp)
|
||||
{
|
||||
time_t clock;
|
||||
struct tm tm;
|
||||
SYSTEMTIME wtm;
|
||||
GetLocalTime(&wtm);
|
||||
tm.tm_year = wtm.wYear - 1900;
|
||||
tm.tm_mon = wtm.wMonth - 1;
|
||||
tm.tm_mday = wtm.wDay;
|
||||
tm.tm_hour = wtm.wHour;
|
||||
tm.tm_min = wtm.wMinute;
|
||||
tm.tm_sec = wtm.wSecond;
|
||||
tm.tm_isdst = -1;
|
||||
clock = mktime(&tm);
|
||||
tp->tv_sec = clock;
|
||||
tp->tv_usec = wtm.wMilliseconds * 1000;
|
||||
return (0);
|
||||
time_t clock;
|
||||
struct tm tm;
|
||||
SYSTEMTIME wtm;
|
||||
GetLocalTime(&wtm);
|
||||
tm.tm_year = wtm.wYear - 1900;
|
||||
tm.tm_mon = wtm.wMonth - 1;
|
||||
tm.tm_mday = wtm.wDay;
|
||||
tm.tm_hour = wtm.wHour;
|
||||
tm.tm_min = wtm.wMinute;
|
||||
tm.tm_sec = wtm.wSecond;
|
||||
tm.tm_isdst = -1;
|
||||
clock = mktime(&tm);
|
||||
tp->tv_sec = clock;
|
||||
tp->tv_usec = wtm.wMilliseconds * 1000;
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -75,7 +64,7 @@ static int perform_decryption = 0;
|
|||
|
||||
static void usage() {
|
||||
fprintf(stderr, "Usage: benchmark [-d]\n"
|
||||
" -d\t\tEnable decryption. Default: only encryption is performed\n");
|
||||
" -d\t\tEnable decryption. Default: only encryption is performed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -162,7 +151,7 @@ static void run_transop_benchmark(const char *op_name, n2n_trans_op_t *op_fn, n2
|
|||
size_t num_packets = 0;
|
||||
|
||||
printf("Run %s[%s] for %us (%u bytes): ", perform_decryption ? "enc/dec" : "enc",
|
||||
op_name, target_sec, (unsigned int)sizeof(PKT_CONTENT));
|
||||
op_name, target_sec, (unsigned int)sizeof(PKT_CONTENT));
|
||||
fflush(stdout);
|
||||
|
||||
memset(mac_buf, 0, sizeof(mac_buf));
|
||||
|
@ -172,8 +161,8 @@ static void run_transop_benchmark(const char *op_name, n2n_trans_op_t *op_fn, n2
|
|||
nw = do_encode_packet( pktbuf, N2N_PKT_BUF_SIZE, conf->community_name);
|
||||
|
||||
nw += op_fn->fwd(op_fn,
|
||||
pktbuf+nw, N2N_PKT_BUF_SIZE-nw,
|
||||
PKT_CONTENT, sizeof(PKT_CONTENT), mac_buf);
|
||||
pktbuf+nw, N2N_PKT_BUF_SIZE-nw,
|
||||
PKT_CONTENT, sizeof(PKT_CONTENT), mac_buf);
|
||||
|
||||
idx=0;
|
||||
rem=nw;
|
||||
|
@ -198,7 +187,7 @@ static void run_transop_benchmark(const char *op_name, n2n_trans_op_t *op_fn, n2
|
|||
float mpps = num_packets / (tdiff / 1e6) / 1e6;
|
||||
|
||||
printf("\t%12u packets\t%8.1f Kpps\t%8.1f MB/s\n",
|
||||
(unsigned int)num_packets, mpps * 1e3, mpps * sizeof(PKT_CONTENT));
|
||||
(unsigned int)num_packets, mpps * 1e3, mpps * sizeof(PKT_CONTENT));
|
||||
}
|
||||
|
||||
static ssize_t do_encode_packet( uint8_t * pktbuf, size_t bufsize, const n2n_community_t c )
|
||||
|
|
Loading…
Reference in New Issue
Block a user