mirror of
https://github.com/ntop/n2n.git
synced 2024-09-19 16:41:11 +02:00
commit
0f5faada07
|
@ -10,9 +10,10 @@ 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(-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)
|
||||||
|
find_package(OpenSSL REQUIRED)
|
||||||
add_definitions(-DN2N_HAVE_AES)
|
add_definitions(-DN2N_HAVE_AES)
|
||||||
endif(N2N_OPTION_AES)
|
endif(N2N_OPTION_AES)
|
||||||
|
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -45,8 +45,10 @@ MAN8DIR=$(MANDIR)/man8
|
||||||
|
|
||||||
N2N_LIB=n2n.a
|
N2N_LIB=n2n.a
|
||||||
N2N_OBJS=n2n.o n2n_keyfile.o wire.o minilzo.o twofish.o \
|
N2N_OBJS=n2n.o n2n_keyfile.o wire.o minilzo.o twofish.o \
|
||||||
|
egde_utils.o \
|
||||||
transform_null.o transform_tf.o transform_aes.o \
|
transform_null.o transform_tf.o transform_aes.o \
|
||||||
tuntap_freebsd.o tuntap_netbsd.o tuntap_linux.o tuntap_osx.o version.o
|
tuntap_freebsd.o tuntap_netbsd.o tuntap_linux.o \
|
||||||
|
tuntap_osx.o version.o
|
||||||
LIBS_EDGE+=$(LIBS_EDGE_OPT)
|
LIBS_EDGE+=$(LIBS_EDGE_OPT)
|
||||||
LIBS_SN=
|
LIBS_SN=
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,6 @@ AES (-O3) 12532
|
||||||
TF (-O3) 14046
|
TF (-O3) 14046
|
||||||
NULL (-O3) 10659
|
NULL (-O3) 10659
|
||||||
|
|
||||||
(C) 2007-2010 - Luca Deri <deri@ntop.org> and Richard Andrews <andrews@ntop.org>
|
-----------------
|
||||||
|
|
||||||
(C) 2016 - ntop
|
(C) 2007-18 - ntop.org and contributors
|
||||||
|
|
18
benchmark.c
18
benchmark.c
|
@ -1,3 +1,21 @@
|
||||||
|
/*
|
||||||
|
* (C) 2007-18 - 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "n2n_wire.h"
|
#include "n2n_wire.h"
|
||||||
#include "n2n_transforms.h"
|
#include "n2n_transforms.h"
|
||||||
#include "n2n.h"
|
#include "n2n.h"
|
||||||
|
|
8
contributors.txt
Normal file
8
contributors.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Code contributions courtesy of:
|
||||||
|
* Richard Andrews <andrews@ntop.org>
|
||||||
|
* Don Bindner <don.bindner@gmail.com>
|
||||||
|
* Sylwester Sosnowski <syso-n2n@no-route.org>
|
||||||
|
* Wilfried "Wonka" Klaebe
|
||||||
|
* Lukasz Taczuk
|
||||||
|
* Alaric Snell-Pym <alaric@kitten-technologies.co.uk>
|
||||||
|
* Babak Farrokhi <babak@farrokhi.net> [FreeBSD port]
|
19
doc/n2n_on_MacOS.txt
Normal file
19
doc/n2n_on_MacOS.txt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
Using n2n on MacOS
|
||||||
|
------------------
|
||||||
|
|
||||||
|
In order to use n2n on MacOS you need to first install support for the tap interface.
|
||||||
|
if you are a brew (https://brew.sh) user you can do it in a couple of steps
|
||||||
|
|
||||||
|
- brew tap homebrew/cask
|
||||||
|
- brew cask install tuntap
|
||||||
|
|
||||||
|
Note that in the latest OS versions (for instance MacOS High Sierra), you may need to
|
||||||
|
need to enable their kernel extension in
|
||||||
|
|
||||||
|
System Preferences → Security & Privacy → General
|
||||||
|
|
||||||
|
For more information refer to vendor documentation or the Apple Technical Note:
|
||||||
|
|
||||||
|
https://developer.apple.com/library/content/technotes/tn2459/_index.html
|
||||||
|
|
1563
egde_utils.c
Normal file
1563
egde_utils.c
Normal file
File diff suppressed because it is too large
Load Diff
196
n2n.c
196
n2n.c
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/**
|
||||||
* (C) 2007-09 - Luca Deri <deri@ntop.org>
|
* (C) 2007-18 - ntop.org and contributors
|
||||||
* Richard Andrews <andrews@ntop.org>
|
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -13,11 +12,7 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
*
|
|
||||||
* Code contributions courtesy of:
|
|
||||||
* Massimo Torquati <torquati@ntop.org>
|
|
||||||
* Matt Gilg
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -32,7 +27,7 @@
|
||||||
# define REGISTRATION_TIMEOUT 120
|
# define REGISTRATION_TIMEOUT 120
|
||||||
#else /* #if defined(DEBUG) */
|
#else /* #if defined(DEBUG) */
|
||||||
# define PURGE_REGISTRATION_FREQUENCY 60
|
# define PURGE_REGISTRATION_FREQUENCY 60
|
||||||
# define REGISTRATION_TIMEOUT (60*20)
|
# define REGISTRATION_TIMEOUT (60*20)
|
||||||
#endif /* #if defined(DEBUG) */
|
#endif /* #if defined(DEBUG) */
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,13 +52,13 @@ SOCKET open_socket(int local_port, int bind_any) {
|
||||||
/* fcntl(sock_fd, F_SETFL, O_NONBLOCK); */
|
/* fcntl(sock_fd, F_SETFL, O_NONBLOCK); */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, (char *)&sockopt, sizeof(sockopt));
|
setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR,(char *)&sockopt, sizeof(sockopt));
|
||||||
|
|
||||||
memset(&local_address, 0, sizeof(local_address));
|
memset(&local_address, 0, sizeof(local_address));
|
||||||
local_address.sin_family = AF_INET;
|
local_address.sin_family = AF_INET;
|
||||||
local_address.sin_port = htons(local_port);
|
local_address.sin_port = htons(local_port);
|
||||||
local_address.sin_addr.s_addr = htonl(bind_any?INADDR_ANY:INADDR_LOOPBACK);
|
local_address.sin_addr.s_addr = htonl(bind_any?INADDR_ANY:INADDR_LOOPBACK);
|
||||||
if(bind(sock_fd, (struct sockaddr*) &local_address, sizeof(local_address)) == -1) {
|
if(bind(sock_fd,(struct sockaddr*) &local_address, sizeof(local_address)) == -1) {
|
||||||
traceEvent(TRACE_ERROR, "Bind error [%s]\n", strerror(errno));
|
traceEvent(TRACE_ERROR, "Bind error [%s]\n", strerror(errno));
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
@ -89,11 +84,11 @@ void traceEvent(int eventTraceLevel, char* file, int line, char * format, ...) {
|
||||||
char *extra_msg = "";
|
char *extra_msg = "";
|
||||||
time_t theTime = time(NULL);
|
time_t theTime = time(NULL);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
int i;
|
int i;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* We have two paths - one if we're logging, one if we aren't
|
/* We have two paths - one if we're logging, one if we aren't
|
||||||
* Note that the no-log case is those systems which don't support it (WIN32),
|
* Note that the no-log case is those systems which don't support it(WIN32),
|
||||||
* those without the headers !defined(USE_SYSLOG)
|
* those without the headers !defined(USE_SYSLOG)
|
||||||
* those where it's parametrically off...
|
* those where it's parametrically off...
|
||||||
*/
|
*/
|
||||||
|
@ -101,7 +96,7 @@ void traceEvent(int eventTraceLevel, char* file, int line, char * format, ...) {
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
strftime(theDate, N2N_TRACE_DATESIZE, "%d/%b/%Y %H:%M:%S", localtime(&theTime));
|
strftime(theDate, N2N_TRACE_DATESIZE, "%d/%b/%Y %H:%M:%S", localtime(&theTime));
|
||||||
|
|
||||||
va_start (va_ap, format);
|
va_start(va_ap, format);
|
||||||
vsnprintf(buf, sizeof(buf)-1, format, va_ap);
|
vsnprintf(buf, sizeof(buf)-1, format, va_ap);
|
||||||
va_end(va_ap);
|
va_end(va_ap);
|
||||||
|
|
||||||
|
@ -128,7 +123,7 @@ void traceEvent(int eventTraceLevel, char* file, int line, char * format, ...) {
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* this is the WIN32 code */
|
/* this is the WIN32 code */
|
||||||
for(i=strlen(file)-1; i>0; i--) if(file[i] == '\\') { i++; break; };
|
for(i=strlen(file)-1; i>0; i--) if(file[i] == '\\') { i++; break; };
|
||||||
snprintf(out_buf, sizeof(out_buf), "%s [%11s:%4d] %s%s", theDate, &file[i], line, extra_msg, buf);
|
snprintf(out_buf, sizeof(out_buf), "%s [%11s:%4d] %s%s", theDate, &file[i], line, extra_msg, buf);
|
||||||
printf("%s\n", out_buf);
|
printf("%s\n", out_buf);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -153,42 +148,42 @@ char* intoa(uint32_t /* host order */ addr, char* buf, uint16_t buf_len) {
|
||||||
byteval = addr & 0xff;
|
byteval = addr & 0xff;
|
||||||
*--cp = byteval % 10 + '0';
|
*--cp = byteval % 10 + '0';
|
||||||
byteval /= 10;
|
byteval /= 10;
|
||||||
if (byteval > 0) {
|
if(byteval > 0) {
|
||||||
*--cp = byteval % 10 + '0';
|
*--cp = byteval % 10 + '0';
|
||||||
byteval /= 10;
|
byteval /= 10;
|
||||||
if (byteval > 0)
|
if(byteval > 0)
|
||||||
*--cp = byteval + '0';
|
*--cp = byteval + '0';
|
||||||
}
|
}
|
||||||
*--cp = '.';
|
*--cp = '.';
|
||||||
addr >>= 8;
|
addr >>= 8;
|
||||||
} while (--n > 0);
|
} while(--n > 0);
|
||||||
|
|
||||||
/* Convert the string to lowercase */
|
/* Convert the string to lowercase */
|
||||||
retStr = (char*)(cp+1);
|
retStr =(char*)(cp+1);
|
||||||
|
|
||||||
return(retStr);
|
return(retStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *********************************************** */
|
/* *********************************************** */
|
||||||
|
|
||||||
char * macaddr_str( macstr_t buf,
|
char * macaddr_str(macstr_t buf,
|
||||||
const n2n_mac_t mac )
|
const n2n_mac_t mac)
|
||||||
{
|
{
|
||||||
snprintf(buf, N2N_MACSTR_SIZE, "%02X:%02X:%02X:%02X:%02X:%02X",
|
snprintf(buf, N2N_MACSTR_SIZE, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||||
mac[0] & 0xFF, mac[1] & 0xFF, mac[2] & 0xFF,
|
mac[0] & 0xFF, mac[1] & 0xFF, mac[2] & 0xFF,
|
||||||
mac[3] & 0xFF, mac[4] & 0xFF, mac[5] & 0xFF);
|
mac[3] & 0xFF, mac[4] & 0xFF, mac[5] & 0xFF);
|
||||||
return(buf);
|
return(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *********************************************** */
|
/* *********************************************** */
|
||||||
|
|
||||||
uint8_t is_multi_broadcast(const uint8_t * dest_mac) {
|
uint8_t is_multi_broadcast(const uint8_t * dest_mac) {
|
||||||
|
|
||||||
int is_broadcast = ( memcmp(broadcast_addr, dest_mac, 6) == 0 );
|
int is_broadcast =(memcmp(broadcast_addr, dest_mac, 6) == 0);
|
||||||
int is_multicast = ( memcmp(multicast_addr, dest_mac, 3) == 0 );
|
int is_multicast =(memcmp(multicast_addr, dest_mac, 3) == 0);
|
||||||
int is_ipv6_multicast = ( memcmp(ipv6_multicast_addr, dest_mac, 2) == 0 );
|
int is_ipv6_multicast =(memcmp(ipv6_multicast_addr, dest_mac, 2) == 0);
|
||||||
|
|
||||||
return is_broadcast || is_multicast || is_ipv6_multicast;
|
return is_broadcast || is_multicast || is_ipv6_multicast;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,17 +212,17 @@ char* msg_type2str(uint16_t msg_type) {
|
||||||
|
|
||||||
void hexdump(const uint8_t * buf, size_t len)
|
void hexdump(const uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if ( 0 == len ) { return; }
|
if(0 == len) { return; }
|
||||||
|
|
||||||
for(i=0; i<len; i++)
|
for(i=0; i<len; i++)
|
||||||
{
|
{
|
||||||
if((i > 0) && ((i % 16) == 0)) { printf("\n"); }
|
if((i > 0) &&((i % 16) == 0)) { printf("\n"); }
|
||||||
printf("%02X ", buf[i] & 0xFF);
|
printf("%02X ", buf[i] & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *********************************************** */
|
/* *********************************************** */
|
||||||
|
@ -235,12 +230,11 @@ void hexdump(const uint8_t * buf, size_t len)
|
||||||
void print_n2n_version() {
|
void print_n2n_version() {
|
||||||
printf("Welcome to n2n v.%s for %s\n"
|
printf("Welcome to n2n v.%s for %s\n"
|
||||||
"Built on %s\n"
|
"Built on %s\n"
|
||||||
"Copyright 2007-09 - http://www.ntop.org\n\n",
|
"Copyright 2007-18 - ntop.org and contributors\n\n",
|
||||||
n2n_sw_version, n2n_sw_osName, n2n_sw_buildDate);
|
n2n_sw_version, n2n_sw_osName, n2n_sw_buildDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* *********************************************** */
|
||||||
|
|
||||||
|
|
||||||
/** Find the peer entry in list with mac_addr equal to mac.
|
/** Find the peer entry in list with mac_addr equal to mac.
|
||||||
*
|
*
|
||||||
|
@ -248,11 +242,11 @@ void print_n2n_version() {
|
||||||
*
|
*
|
||||||
* @return NULL if not found; otherwise pointer to peer entry.
|
* @return NULL if not found; otherwise pointer to peer entry.
|
||||||
*/
|
*/
|
||||||
struct peer_info * find_peer_by_mac( struct peer_info * list, const n2n_mac_t mac )
|
struct peer_info * find_peer_by_mac(struct peer_info * list, const n2n_mac_t mac)
|
||||||
{
|
{
|
||||||
while(list != NULL)
|
while(list != NULL)
|
||||||
{
|
{
|
||||||
if( 0 == memcmp(mac, list->mac_addr, 6) )
|
if(0 == memcmp(mac, list->mac_addr, 6))
|
||||||
{
|
{
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -266,11 +260,11 @@ struct peer_info * find_peer_by_mac( struct peer_info * list, const n2n_mac_t ma
|
||||||
/** Return the number of elements in the list.
|
/** Return the number of elements in the list.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
size_t peer_list_size( const struct peer_info * list )
|
size_t peer_list_size(const struct peer_info * list)
|
||||||
{
|
{
|
||||||
size_t retval=0;
|
size_t retval=0;
|
||||||
|
|
||||||
while ( list )
|
while(list)
|
||||||
{
|
{
|
||||||
++retval;
|
++retval;
|
||||||
list = list->next;
|
list = list->next;
|
||||||
|
@ -284,8 +278,8 @@ size_t peer_list_size( const struct peer_info * list )
|
||||||
* The item new is added to the head of the list. New is modified during
|
* The item new is added to the head of the list. New is modified during
|
||||||
* insertion. list takes ownership of new.
|
* insertion. list takes ownership of new.
|
||||||
*/
|
*/
|
||||||
void peer_list_add( struct peer_info * * list,
|
void peer_list_add(struct peer_info * * list,
|
||||||
struct peer_info * new )
|
struct peer_info * new)
|
||||||
{
|
{
|
||||||
new->next = *list;
|
new->next = *list;
|
||||||
new->last_seen = time(NULL);
|
new->last_seen = time(NULL);
|
||||||
|
@ -293,7 +287,7 @@ void peer_list_add( struct peer_info * * list,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t purge_expired_registrations( struct peer_info ** peer_list ) {
|
size_t purge_expired_registrations(struct peer_info ** peer_list) {
|
||||||
static time_t last_purge = 0;
|
static time_t last_purge = 0;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
size_t num_reg = 0;
|
size_t num_reg = 0;
|
||||||
|
@ -302,7 +296,7 @@ size_t purge_expired_registrations( struct peer_info ** peer_list ) {
|
||||||
|
|
||||||
traceEvent(TRACE_INFO, "Purging old registrations");
|
traceEvent(TRACE_INFO, "Purging old registrations");
|
||||||
|
|
||||||
num_reg = purge_peer_list( peer_list, now-REGISTRATION_TIMEOUT );
|
num_reg = purge_peer_list(peer_list, now-REGISTRATION_TIMEOUT);
|
||||||
|
|
||||||
last_purge = now;
|
last_purge = now;
|
||||||
traceEvent(TRACE_INFO, "Remove %ld registrations", num_reg);
|
traceEvent(TRACE_INFO, "Remove %ld registrations", num_reg);
|
||||||
|
@ -311,8 +305,8 @@ size_t purge_expired_registrations( struct peer_info ** peer_list ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Purge old items from the peer_list and return the number of items that were removed. */
|
/** Purge old items from the peer_list and return the number of items that were removed. */
|
||||||
size_t purge_peer_list( struct peer_info ** peer_list,
|
size_t purge_peer_list(struct peer_info ** peer_list,
|
||||||
time_t purge_before )
|
time_t purge_before)
|
||||||
{
|
{
|
||||||
struct peer_info *scan;
|
struct peer_info *scan;
|
||||||
struct peer_info *prev;
|
struct peer_info *prev;
|
||||||
|
@ -350,46 +344,46 @@ size_t purge_peer_list( struct peer_info ** peer_list,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Purge all items from the peer_list and return the number of items that were removed. */
|
/** Purge all items from the peer_list and return the number of items that were removed. */
|
||||||
size_t clear_peer_list( struct peer_info ** peer_list )
|
size_t clear_peer_list(struct peer_info ** peer_list)
|
||||||
{
|
{
|
||||||
struct peer_info *scan;
|
struct peer_info *scan;
|
||||||
struct peer_info *prev;
|
struct peer_info *prev;
|
||||||
size_t retval=0;
|
size_t retval=0;
|
||||||
|
|
||||||
scan = *peer_list;
|
scan = *peer_list;
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
while(scan != NULL)
|
while(scan != NULL)
|
||||||
{
|
{
|
||||||
struct peer_info *next = scan->next;
|
struct peer_info *next = scan->next;
|
||||||
|
|
||||||
if(prev == NULL)
|
if(prev == NULL)
|
||||||
{
|
{
|
||||||
*peer_list = next;
|
*peer_list = next;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prev->next = next;
|
prev->next = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
++retval;
|
++retval;
|
||||||
free(scan);
|
free(scan);
|
||||||
scan = next;
|
scan = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t hex2byte( const char * s )
|
static uint8_t hex2byte(const char * s)
|
||||||
{
|
{
|
||||||
char tmp[3];
|
char tmp[3];
|
||||||
tmp[0]=s[0];
|
tmp[0]=s[0];
|
||||||
tmp[1]=s[1];
|
tmp[1]=s[1];
|
||||||
tmp[2]=0; /* NULL term */
|
tmp[2]=0; /* NULL term */
|
||||||
|
|
||||||
return((uint8_t)strtol( tmp, NULL, 16 ));
|
return((uint8_t)strtol(tmp, NULL, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int str2mac( uint8_t * outmac /* 6 bytes */, const char * s )
|
extern int str2mac(uint8_t * outmac /* 6 bytes */, const char * s)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
@ -400,7 +394,7 @@ extern int str2mac( uint8_t * outmac /* 6 bytes */, const char * s )
|
||||||
++outmac;
|
++outmac;
|
||||||
s+=2; /* don't skip colon yet - helps generalise loop. */
|
s+=2; /* don't skip colon yet - helps generalise loop. */
|
||||||
|
|
||||||
for (i=1; i<6; ++i )
|
for(i=1; i<6; ++i)
|
||||||
{
|
{
|
||||||
s+=1;
|
s+=1;
|
||||||
*outmac=hex2byte(s);
|
*outmac=hex2byte(s);
|
||||||
|
@ -411,45 +405,49 @@ extern int str2mac( uint8_t * outmac /* 6 bytes */, const char * s )
|
||||||
return 0; /* ok */
|
return 0; /* ok */
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char * sock_to_cstr( n2n_sock_str_t out,
|
extern char * sock_to_cstr(n2n_sock_str_t out,
|
||||||
const n2n_sock_t * sock )
|
const n2n_sock_t * sock) {
|
||||||
{
|
if(NULL == out) { return NULL; }
|
||||||
int r;
|
memset(out, 0, N2N_SOCKBUF_SIZE);
|
||||||
|
|
||||||
if ( NULL == out ) { return NULL; }
|
if(AF_INET6 == sock->family) {
|
||||||
memset(out, 0, N2N_SOCKBUF_SIZE);
|
/* INET6 not written yet */
|
||||||
|
snprintf(out, N2N_SOCKBUF_SIZE, "XXXX:%hu", sock->port);
|
||||||
|
return out;
|
||||||
|
} else {
|
||||||
|
const uint8_t * a = sock->addr.v4;
|
||||||
|
|
||||||
if ( AF_INET6 == sock->family )
|
snprintf(out, N2N_SOCKBUF_SIZE, "%hu.%hu.%hu.%hu:%hu",
|
||||||
{
|
(unsigned short)(a[0] & 0xff),
|
||||||
/* INET6 not written yet */
|
(unsigned short)(a[1] & 0xff),
|
||||||
r = snprintf( out, N2N_SOCKBUF_SIZE, "XXXX:%hu", sock->port );
|
(unsigned short)(a[2] & 0xff),
|
||||||
return out;
|
(unsigned short)(a[3] & 0xff),
|
||||||
}
|
(unsigned short)sock->port);
|
||||||
else
|
return out;
|
||||||
{
|
}
|
||||||
const uint8_t * a = sock->addr.v4;
|
|
||||||
r = snprintf( out, N2N_SOCKBUF_SIZE, "%hu.%hu.%hu.%hu:%hu",
|
|
||||||
(a[0] & 0xff), (a[1] & 0xff), (a[2] & 0xff), (a[3] & 0xff), sock->port );
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @return zero if the two sockets are equivalent. */
|
/* @return zero if the two sockets are equivalent. */
|
||||||
int sock_equal( const n2n_sock_t * a,
|
int sock_equal(const n2n_sock_t * a,
|
||||||
const n2n_sock_t * b )
|
const n2n_sock_t * b) {
|
||||||
{
|
if(a->port != b->port) { return 1; }
|
||||||
if ( a->port != b->port ) { return 1; }
|
if(a->family != b->family) { return 1; }
|
||||||
if ( a->family != b->family ) { return 1; }
|
|
||||||
switch (a->family) /* they are the same */
|
switch(a->family) {
|
||||||
{
|
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
if ( 0 != memcmp( a->addr.v4, b->addr.v4, IPV4_SIZE ) ) { return 1;};
|
if(0 != memcmp(a->addr.v4, b->addr.v4, IPV4_SIZE)) {
|
||||||
break;
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if ( 0 != memcmp( a->addr.v6, b->addr.v6, IPV6_SIZE ) ) { return 1;};
|
if(0 != memcmp(a->addr.v6, b->addr.v6, IPV6_SIZE)) {
|
||||||
break;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
153
n2n.h
153
n2n.h
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/**
|
||||||
* (C) 2007-09 - Luca Deri <deri@ntop.org>
|
* (C) 2007-18 - ntop.org and contributors
|
||||||
* Richard Andrews <andrews@ntop.org>
|
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -13,11 +12,7 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
*
|
|
||||||
* Code contributions courtesy of:
|
|
||||||
* Babak Farrokhi <babak@farrokhi.net> [FreeBSD port]
|
|
||||||
* Lukasz Taczuk
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -25,25 +20,18 @@
|
||||||
#define _N2N_H_
|
#define _N2N_H_
|
||||||
|
|
||||||
/*
|
/*
|
||||||
tunctl -t tun0
|
tunctl -t tun0
|
||||||
tunctl -t tun1
|
tunctl -t tun1
|
||||||
ifconfig tun0 1.2.3.4 up
|
ifconfig tun0 1.2.3.4 up
|
||||||
ifconfig tun1 1.2.3.5 up
|
ifconfig tun1 1.2.3.5 up
|
||||||
./edge -d tun0 -l 2000 -r 127.0.0.1:3000 -c hello
|
./edge -d tun0 -l 2000 -r 127.0.0.1:3000 -c hello
|
||||||
./edge -d tun1 -l 3000 -r 127.0.0.1:2000 -c hello
|
./edge -d tun1 -l 3000 -r 127.0.0.1:2000 -c hello
|
||||||
|
|
||||||
|
|
||||||
tunctl -u UID -t tunX
|
tunctl -u UID -t tunX
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(__APPLE__) && defined(__MACH__)
|
|
||||||
#define _DARWIN_
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Some capability defaults which can be reset for particular platforms. */
|
|
||||||
#define N2N_HAVE_DAEMON 1
|
|
||||||
#define N2N_HAVE_SETUID 1
|
|
||||||
/* #define N2N_CAN_NAME_IFACE */
|
/* #define N2N_CAN_NAME_IFACE */
|
||||||
|
|
||||||
/* Moved here to define _CRT_SECURE_NO_WARNINGS before all the including takes place */
|
/* Moved here to define _CRT_SECURE_NO_WARNINGS before all the including takes place */
|
||||||
|
@ -92,18 +80,13 @@
|
||||||
#define ETH_ADDR_LEN 6
|
#define ETH_ADDR_LEN 6
|
||||||
struct ether_hdr
|
struct ether_hdr
|
||||||
{
|
{
|
||||||
uint8_t dhost[ETH_ADDR_LEN];
|
uint8_t dhost[ETH_ADDR_LEN];
|
||||||
uint8_t shost[ETH_ADDR_LEN];
|
uint8_t shost[ETH_ADDR_LEN];
|
||||||
uint16_t type; /* higher layer protocol encapsulated */
|
uint16_t type; /* higher layer protocol encapsulated */
|
||||||
} __attribute__ ((__packed__));
|
} __attribute__ ((__packed__));
|
||||||
|
|
||||||
typedef struct ether_hdr ether_hdr_t;
|
typedef struct ether_hdr ether_hdr_t;
|
||||||
|
|
||||||
#ifdef __sun__
|
|
||||||
#include <sys/sysmacros.h> /* MIN() and MAX() declared here */
|
|
||||||
#undef N2N_HAVE_DAEMON
|
|
||||||
#endif /* #ifdef __sun__ */
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netinet/ip.h>
|
#include <netinet/ip.h>
|
||||||
#include <netinet/udp.h>
|
#include <netinet/udp.h>
|
||||||
|
@ -111,6 +94,9 @@ typedef struct ether_hdr ether_hdr_t;
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include "minilzo.h"
|
||||||
|
|
||||||
#define closesocket(a) close(a)
|
#define closesocket(a) close(a)
|
||||||
#endif /* #ifndef WIN32 */
|
#endif /* #ifndef WIN32 */
|
||||||
|
@ -124,6 +110,7 @@ typedef struct ether_hdr ether_hdr_t;
|
||||||
#endif /* #ifdef WIN32 */
|
#endif /* #ifdef WIN32 */
|
||||||
|
|
||||||
#include "n2n_wire.h"
|
#include "n2n_wire.h"
|
||||||
|
#include "n2n_transforms.h"
|
||||||
|
|
||||||
/* N2N_IFNAMSIZ is needed on win32 even if dev_name is not used after declaration */
|
/* N2N_IFNAMSIZ is needed on win32 even if dev_name is not used after declaration */
|
||||||
#define N2N_IFNAMSIZ 16 /* 15 chars * NULL */
|
#define N2N_IFNAMSIZ 16 /* 15 chars * NULL */
|
||||||
|
@ -167,16 +154,69 @@ typedef char ipstr_t[32];
|
||||||
typedef char macstr_t[N2N_MACSTR_SIZE];
|
typedef char macstr_t[N2N_MACSTR_SIZE];
|
||||||
|
|
||||||
struct peer_info {
|
struct peer_info {
|
||||||
struct peer_info * next;
|
struct peer_info * next;
|
||||||
n2n_community_t community_name;
|
n2n_community_t community_name;
|
||||||
n2n_mac_t mac_addr;
|
n2n_mac_t mac_addr;
|
||||||
n2n_sock_t sock;
|
n2n_sock_t sock;
|
||||||
time_t last_seen;
|
time_t last_seen;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct n2n_edge; /* defined in edge.c */
|
struct n2n_edge; /* defined in edge.c */
|
||||||
typedef struct n2n_edge n2n_edge_t;
|
typedef struct n2n_edge n2n_edge_t;
|
||||||
|
|
||||||
|
#define N2N_EDGE_SN_HOST_SIZE 48
|
||||||
|
#define N2N_EDGE_NUM_SUPERNODES 2
|
||||||
|
#define N2N_EDGE_SUP_ATTEMPTS 3 /* Number of failed attmpts before moving on to next supernode. */
|
||||||
|
#define N2N_PATHNAME_MAXLEN 256
|
||||||
|
#define N2N_MAX_TRANSFORMS 16
|
||||||
|
#define N2N_EDGE_MGMT_PORT 5644
|
||||||
|
|
||||||
|
|
||||||
|
typedef char n2n_sn_name_t[N2N_EDGE_SN_HOST_SIZE];
|
||||||
|
|
||||||
|
struct n2n_edge {
|
||||||
|
int daemon; /**< Non-zero if edge should detach and run in the background. */
|
||||||
|
uint8_t re_resolve_supernode_ip;
|
||||||
|
|
||||||
|
n2n_sock_t supernode;
|
||||||
|
|
||||||
|
size_t sn_idx; /**< Currently active supernode. */
|
||||||
|
size_t sn_num; /**< Number of supernode addresses defined. */
|
||||||
|
n2n_sn_name_t sn_ip_array[N2N_EDGE_NUM_SUPERNODES];
|
||||||
|
int sn_wait; /**< Whether we are waiting for a supernode response. */
|
||||||
|
|
||||||
|
n2n_community_t community_name; /**< The community. 16 full octets. */
|
||||||
|
char keyschedule[N2N_PATHNAME_MAXLEN];
|
||||||
|
int null_transop; /**< Only allowed if no key sources defined. */
|
||||||
|
|
||||||
|
int udp_sock;
|
||||||
|
int udp_mgmt_sock; /**< socket for status info. */
|
||||||
|
|
||||||
|
tuntap_dev device; /**< All about the TUNTAP device */
|
||||||
|
int dyn_ip_mode; /**< Interface IP address is dynamically allocated, eg. DHCP. */
|
||||||
|
int allow_routing; /**< Accept packet no to interface address. */
|
||||||
|
int drop_multicast; /**< Multicast ethernet addresses. */
|
||||||
|
|
||||||
|
n2n_trans_op_t transop[N2N_MAX_TRANSFORMS]; /* one for each transform at fixed positions */
|
||||||
|
size_t tx_transop_idx; /**< The transop to use when encoding. */
|
||||||
|
|
||||||
|
struct peer_info * known_peers; /**< Edges we are connected to. */
|
||||||
|
struct peer_info * pending_peers; /**< Edges we have tried to register with. */
|
||||||
|
time_t last_register_req; /**< Check if time to re-register with super*/
|
||||||
|
size_t register_lifetime; /**< Time distance after last_register_req at which to re-register. */
|
||||||
|
time_t last_p2p; /**< Last time p2p traffic was received. */
|
||||||
|
time_t last_sup; /**< Last time a packet arrived from supernode. */
|
||||||
|
size_t sup_attempts; /**< Number of remaining attempts to this supernode. */
|
||||||
|
n2n_cookie_t last_cookie; /**< Cookie sent in last REGISTER_SUPER. */
|
||||||
|
|
||||||
|
time_t start_time; /**< For calculating uptime */
|
||||||
|
|
||||||
|
/* Statistics */
|
||||||
|
size_t tx_p2p;
|
||||||
|
size_t rx_p2p;
|
||||||
|
size_t tx_sup;
|
||||||
|
size_t rx_sup;
|
||||||
|
};
|
||||||
|
|
||||||
/* ************************************** */
|
/* ************************************** */
|
||||||
|
|
||||||
|
@ -251,4 +291,47 @@ size_t purge_expired_registrations( struct peer_info ** peer_list );
|
||||||
/* version.c */
|
/* version.c */
|
||||||
extern char *n2n_sw_version, *n2n_sw_osName, *n2n_sw_buildDate;
|
extern char *n2n_sw_version, *n2n_sw_osName, *n2n_sw_buildDate;
|
||||||
|
|
||||||
|
/* egde_utils.c */
|
||||||
|
int edge_init(n2n_edge_t * eee);
|
||||||
|
void supernode2addr(n2n_sock_t * sn, const n2n_sn_name_t addrIn);
|
||||||
|
void update_supernode_reg(n2n_edge_t * eee, time_t nowTime);
|
||||||
|
int is_empty_ip_address(const n2n_sock_t * sock);
|
||||||
|
void update_peer_address(n2n_edge_t * eee,
|
||||||
|
uint8_t from_supernode,
|
||||||
|
const n2n_mac_t mac,
|
||||||
|
const n2n_sock_t * peer,
|
||||||
|
time_t when);
|
||||||
|
int transop_enum_to_index(n2n_transform_t id);
|
||||||
|
int edge_init_keyschedule(n2n_edge_t * eee);
|
||||||
|
void update_peer_address(n2n_edge_t * eee,
|
||||||
|
uint8_t from_supernode,
|
||||||
|
const n2n_mac_t mac,
|
||||||
|
const n2n_sock_t * peer,
|
||||||
|
time_t when);
|
||||||
|
int is_empty_ip_address(const n2n_sock_t * sock);
|
||||||
|
void send_register(n2n_edge_t * eee,
|
||||||
|
const n2n_sock_t * remote_peer);
|
||||||
|
void send_packet2net(n2n_edge_t * eee,
|
||||||
|
uint8_t *tap_pkt, size_t len);
|
||||||
|
void check_peer(n2n_edge_t * eee,
|
||||||
|
uint8_t from_supernode,
|
||||||
|
const n2n_mac_t mac,
|
||||||
|
const n2n_sock_t * peer);
|
||||||
|
void try_send_register(n2n_edge_t * eee,
|
||||||
|
uint8_t from_supernode,
|
||||||
|
const n2n_mac_t mac,
|
||||||
|
const n2n_sock_t * peer);
|
||||||
|
void set_peer_operational(n2n_edge_t * eee,
|
||||||
|
const n2n_mac_t mac,
|
||||||
|
const n2n_sock_t * peer);
|
||||||
|
const char * supernode_ip(const n2n_edge_t * eee);
|
||||||
|
int edge_init_twofish(n2n_edge_t * eee, uint8_t *encrypt_pwd,
|
||||||
|
uint32_t encrypt_pwd_len);
|
||||||
|
int run_edge_loop(n2n_edge_t * eee);
|
||||||
|
void edge_term(n2n_edge_t * eee);
|
||||||
|
int quick_edge_init(char *device_name, char *community_name,
|
||||||
|
char *encrypt_key, char *device_mac,
|
||||||
|
char *local_ip_address,
|
||||||
|
char *supernode_ip_address_port);
|
||||||
|
|
||||||
#endif /* _N2N_H_ */
|
#endif /* _N2N_H_ */
|
||||||
|
|
|
@ -1,6 +1,19 @@
|
||||||
/* (c) 2009 Richard Andrews <andrews@ntop.org> */
|
/**
|
||||||
/* Contributions from:
|
* (C) 2007-18 - ntop.org and contributors
|
||||||
* - Jozef Kralik
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "n2n.h"
|
#include "n2n.h"
|
||||||
|
|
|
@ -1,4 +1,20 @@
|
||||||
/* (c) 2009 Richard Andrews <andrews@ntop.org> */
|
/**
|
||||||
|
* (C) 2007-18 - 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/** Key files
|
/** Key files
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,4 +1,20 @@
|
||||||
/* (c) 2009 Richard Andrews <andrews@ntop.org> */
|
/**
|
||||||
|
* (C) 2007-18 - 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#if !defined(N2N_TRANSFORMS_H_)
|
#if !defined(N2N_TRANSFORMS_H_)
|
||||||
#define N2N_TRANSFORMS_H_
|
#define N2N_TRANSFORMS_H_
|
||||||
|
@ -21,10 +37,9 @@
|
||||||
struct n2n_trans_op;
|
struct n2n_trans_op;
|
||||||
typedef struct n2n_trans_op n2n_trans_op_t;
|
typedef struct n2n_trans_op n2n_trans_op_t;
|
||||||
|
|
||||||
struct n2n_tostat
|
struct n2n_tostat {
|
||||||
{
|
uint8_t can_tx; /* Does this transop have a valid SA for encoding. */
|
||||||
uint8_t can_tx; /* Does this transop have a valid SA for encoding. */
|
n2n_cipherspec_t tx_spec; /* If can_tx, the spec used to encode. */
|
||||||
n2n_cipherspec_t tx_spec; /* If can_tx, the spec used to encode. */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct n2n_tostat n2n_tostat_t;
|
typedef struct n2n_tostat n2n_tostat_t;
|
||||||
|
@ -48,19 +63,18 @@ typedef int (*n2n_transform_f)( n2n_trans_op_t * arg,
|
||||||
* to use to decode the packet content. The transform code then decodes the
|
* to use to decode the packet content. The transform code then decodes the
|
||||||
* packet and consults its internal key lookup.
|
* packet and consults its internal key lookup.
|
||||||
*/
|
*/
|
||||||
struct n2n_trans_op
|
struct n2n_trans_op {
|
||||||
{
|
void * priv; /* opaque data. Key schedule goes here. */
|
||||||
void * priv; /* opaque data. Key schedule goes here. */
|
|
||||||
|
|
||||||
n2n_transform_t transform_id; /* link header enum to a transform */
|
n2n_transform_t transform_id; /* link header enum to a transform */
|
||||||
size_t tx_cnt;
|
size_t tx_cnt;
|
||||||
size_t rx_cnt;
|
size_t rx_cnt;
|
||||||
|
|
||||||
n2n_transdeinit_f deinit; /* destructor function */
|
n2n_transdeinit_f deinit; /* destructor function */
|
||||||
n2n_transaddspec_f addspec; /* parse opaque data from a key schedule file. */
|
n2n_transaddspec_f addspec; /* parse opaque data from a key schedule file. */
|
||||||
n2n_transtick_f tick; /* periodic maintenance */
|
n2n_transtick_f tick; /* periodic maintenance */
|
||||||
n2n_transform_f fwd; /* encode a payload */
|
n2n_transform_f fwd; /* encode a payload */
|
||||||
n2n_transform_f rev; /* decode a payload */
|
n2n_transform_f rev; /* decode a payload */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Setup a single twofish SA for single-key operation. */
|
/* Setup a single twofish SA for single-key operation. */
|
||||||
|
|
19
n2n_wire.h
19
n2n_wire.h
|
@ -1,8 +1,19 @@
|
||||||
/* (c) 2009 Richard Andrews <andrews@ntop.org>
|
/**
|
||||||
|
* (C) 2007-18 - 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* Contributions by:
|
|
||||||
* Luca Deri
|
|
||||||
* Lukasz Taczuk
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined( N2N_WIRE_H_ )
|
#if !defined( N2N_WIRE_H_ )
|
||||||
|
|
|
@ -28,7 +28,7 @@ PKG_AND_VERSION="${PACKAGE}-${PKG_VERSION}"
|
||||||
TEMPDIR="tmp"
|
TEMPDIR="tmp"
|
||||||
|
|
||||||
SOURCE_MANIFEST="
|
SOURCE_MANIFEST="
|
||||||
README
|
README.md
|
||||||
edge.c
|
edge.c
|
||||||
lzoconf.h
|
lzoconf.h
|
||||||
lzodefs.h
|
lzodefs.h
|
||||||
|
|
22
sn.c
22
sn.c
|
@ -1,12 +1,22 @@
|
||||||
/* Supernode for n2n-2.x */
|
/**
|
||||||
|
* (C) 2007-18 - ntop.org and contributors
|
||||||
/* (c) 2009 Richard Andrews <andrews@ntop.org>
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* Contributions by:
|
|
||||||
* Lukasz Taczuk
|
|
||||||
* Struan Bartlett
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Supernode for n2n-2.x */
|
||||||
|
|
||||||
#include "n2n.h"
|
#include "n2n.h"
|
||||||
|
|
||||||
|
|
18
test.c
18
test.c
|
@ -1,3 +1,21 @@
|
||||||
|
/**
|
||||||
|
* (C) 2007-18 - 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "n2n.h"
|
#include "n2n.h"
|
||||||
#include "n2n_keyfile.h"
|
#include "n2n_keyfile.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
|
@ -1,6 +1,19 @@
|
||||||
/* (c) 2009 Richard Andrews <andrews@ntop.org> */
|
/**
|
||||||
/* Contributions from:
|
* (C) 2007-18 - ntop.org and contributors
|
||||||
* - Jozef Kralik
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "n2n.h"
|
#include "n2n.h"
|
||||||
|
|
|
@ -1,4 +1,20 @@
|
||||||
/* (c) 2009 Richard Andrews <andrews@ntop.org> */
|
/**
|
||||||
|
* (C) 2007-18 - 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "n2n.h"
|
#include "n2n.h"
|
||||||
#include "n2n_transforms.h"
|
#include "n2n_transforms.h"
|
||||||
|
|
|
@ -1,4 +1,20 @@
|
||||||
/* (c) 2009 Richard Andrews <andrews@ntop.org> */
|
/**
|
||||||
|
* (C) 2007-18 - 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "n2n.h"
|
#include "n2n.h"
|
||||||
#include "n2n_transforms.h"
|
#include "n2n_transforms.h"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/**
|
||||||
* (C) 2007-09 - Luca Deri <deri@ntop.org>
|
* (C) 2007-18 - ntop.org and contributors
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -13,6 +13,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "n2n.h"
|
#include "n2n.h"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/**
|
||||||
* (C) 2007-09 - Luca Deri <deri@ntop.org>
|
* (C) 2007-18 - ntop.org and contributors
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -12,13 +12,16 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "n2n.h"
|
#include "n2n.h"
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|
||||||
|
/* *************************************************** */
|
||||||
|
|
||||||
static void read_mac(char *ifname, n2n_mac_t mac_addr) {
|
static void read_mac(char *ifname, n2n_mac_t mac_addr) {
|
||||||
int _sock, res;
|
int _sock, res;
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
|
@ -30,8 +33,10 @@ static void read_mac(char *ifname, n2n_mac_t mac_addr) {
|
||||||
_sock=socket(PF_INET, SOCK_DGRAM, 0);
|
_sock=socket(PF_INET, SOCK_DGRAM, 0);
|
||||||
strcpy(ifr.ifr_name, ifname);
|
strcpy(ifr.ifr_name, ifname);
|
||||||
res = ioctl(_sock,SIOCGIFHWADDR,&ifr);
|
res = ioctl(_sock,SIOCGIFHWADDR,&ifr);
|
||||||
if (res<0) {
|
|
||||||
|
if(res < 0) {
|
||||||
perror ("Get hw addr");
|
perror ("Get hw addr");
|
||||||
|
traceEvent(TRACE_ERROR, "Unable to read interfce %s MAC", ifname);
|
||||||
} else
|
} else
|
||||||
memcpy(mac_addr, ifr.ifr_ifru.ifru_hwaddr.sa_data, 6);
|
memcpy(mac_addr, ifr.ifr_ifru.ifru_hwaddr.sa_data, 6);
|
||||||
|
|
||||||
|
@ -92,24 +97,24 @@ int tuntap_open(tuntap_dev *device,
|
||||||
strncpy(device->dev_name, ifr.ifr_name, MIN(IFNAMSIZ, N2N_IFNAMSIZ) );
|
strncpy(device->dev_name, ifr.ifr_name, MIN(IFNAMSIZ, N2N_IFNAMSIZ) );
|
||||||
|
|
||||||
if ( device_mac && device_mac[0] != '\0' )
|
if ( device_mac && device_mac[0] != '\0' )
|
||||||
{
|
{
|
||||||
/* Set the hw address before bringing the if up. */
|
/* Set the hw address before bringing the if up. */
|
||||||
snprintf(buf, sizeof(buf), "/sbin/ifconfig %s hw ether %s",
|
snprintf(buf, sizeof(buf), "/sbin/ifconfig %s hw ether %s",
|
||||||
ifr.ifr_name, device_mac );
|
ifr.ifr_name, device_mac );
|
||||||
system(buf);
|
system(buf);
|
||||||
traceEvent(TRACE_INFO, "Setting MAC: %s", buf);
|
traceEvent(TRACE_INFO, "Setting MAC: %s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 == strncmp( "dhcp", address_mode, 5 ) )
|
if ( 0 == strncmp( "dhcp", address_mode, 5 ) )
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "/sbin/ifconfig %s %s mtu %d up",
|
snprintf(buf, sizeof(buf), "/sbin/ifconfig %s %s mtu %d up",
|
||||||
ifr.ifr_name, device_ip, mtu);
|
ifr.ifr_name, device_ip, mtu);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "/sbin/ifconfig %s %s netmask %s mtu %d up",
|
snprintf(buf, sizeof(buf), "/sbin/ifconfig %s %s netmask %s mtu %d up",
|
||||||
ifr.ifr_name, device_ip, device_mask, mtu);
|
ifr.ifr_name, device_ip, device_mask, mtu);
|
||||||
}
|
}
|
||||||
|
|
||||||
system(buf);
|
system(buf);
|
||||||
traceEvent(TRACE_INFO, "Bringing up: %s", buf);
|
traceEvent(TRACE_INFO, "Bringing up: %s", buf);
|
||||||
|
@ -120,45 +125,56 @@ int tuntap_open(tuntap_dev *device,
|
||||||
return(device->fd);
|
return(device->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* *************************************************** */
|
||||||
|
|
||||||
int tuntap_read(struct tuntap_dev *tuntap, unsigned char *buf, int len) {
|
int tuntap_read(struct tuntap_dev *tuntap, unsigned char *buf, int len) {
|
||||||
return(read(tuntap->fd, buf, len));
|
return(read(tuntap->fd, buf, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* *************************************************** */
|
||||||
|
|
||||||
int tuntap_write(struct tuntap_dev *tuntap, unsigned char *buf, int len) {
|
int tuntap_write(struct tuntap_dev *tuntap, unsigned char *buf, int len) {
|
||||||
return(write(tuntap->fd, buf, len));
|
return(write(tuntap->fd, buf, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* *************************************************** */
|
||||||
|
|
||||||
void tuntap_close(struct tuntap_dev *tuntap) {
|
void tuntap_close(struct tuntap_dev *tuntap) {
|
||||||
close(tuntap->fd);
|
close(tuntap->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* *************************************************** */
|
||||||
|
|
||||||
/* Fill out the ip_addr value from the interface. Called to pick up dynamic
|
/* Fill out the ip_addr value from the interface. Called to pick up dynamic
|
||||||
* address changes. */
|
* address changes. */
|
||||||
void tuntap_get_address(struct tuntap_dev *tuntap)
|
void tuntap_get_address(struct tuntap_dev *tuntap) {
|
||||||
{
|
FILE * fp=NULL;
|
||||||
FILE * fp=NULL;
|
ssize_t nread=0;
|
||||||
ssize_t nread=0;
|
char buf[N2N_LINUX_SYSTEMCMD_SIZE];
|
||||||
char buf[N2N_LINUX_SYSTEMCMD_SIZE];
|
|
||||||
|
|
||||||
/* Would rather have a more direct way to get the inet address but a netlink
|
/* Would rather have a more direct way to get the inet address but a netlink
|
||||||
* socket is overkill and probably less portable than ifconfig and sed. */
|
* socket is overkill and probably less portable than ifconfig and sed. */
|
||||||
|
|
||||||
/* If the interface has no address (0.0.0.0) there will be no inet addr
|
/* If the interface has no address (0.0.0.0) there will be no inet addr
|
||||||
* line and the returned string will be empty. */
|
* line and the returned string will be empty. */
|
||||||
snprintf( buf, sizeof(buf), "/sbin/ifconfig %s | /bin/sed -e '/inet addr:/!d' -e 's/^.*inet addr://' -e 's/ .*$//'",
|
snprintf( buf, sizeof(buf),
|
||||||
tuntap->dev_name );
|
"/sbin/ifconfig %s | /bin/sed -e '/inet addr:/!d' -e 's/^.*inet addr://' -e 's/ .*$//'",
|
||||||
fp=popen(buf, "r");
|
tuntap->dev_name);
|
||||||
if (fp )
|
fp = popen(buf, "r");
|
||||||
{
|
|
||||||
memset(buf,0,N2N_LINUX_SYSTEMCMD_SIZE); /* make sure buf is NULL terminated. */
|
|
||||||
nread=fread(buf, 1, 15, fp);
|
|
||||||
fclose(fp);
|
|
||||||
fp=NULL;
|
|
||||||
|
|
||||||
traceEvent(TRACE_INFO, "ifconfig address = %s", buf);
|
if (fp) {
|
||||||
|
memset(buf, 0, N2N_LINUX_SYSTEMCMD_SIZE); /* make sure buf is NULL terminated. */
|
||||||
|
nread = fread(buf, N2N_LINUX_SYSTEMCMD_SIZE-1, 1, fp);
|
||||||
|
fclose(fp);
|
||||||
|
fp = NULL;
|
||||||
|
|
||||||
tuntap->ip_addr = inet_addr(buf);
|
traceEvent(TRACE_INFO, "ifconfig address = %s", buf);
|
||||||
|
|
||||||
|
if(nread > 0) {
|
||||||
|
buf[nread] = '\0';
|
||||||
|
tuntap->ip_addr = inet_addr(buf);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/**
|
||||||
* (C) 2007-09 - Luca Deri <deri@ntop.org>
|
* (C) 2007-18 - ntop.org and contributors
|
||||||
* (C) 2009 - Alaric Snell-Pym <alaric@kitten-technologies.co.uk>
|
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -14,6 +13,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "n2n.h"
|
#include "n2n.h"
|
||||||
|
@ -39,7 +39,7 @@ int tuntap_open(tuntap_dev *device /* ignored */,
|
||||||
char tap_device[N2N_NETBSD_TAPDEVICE_SIZE];
|
char tap_device[N2N_NETBSD_TAPDEVICE_SIZE];
|
||||||
struct ifreq req;
|
struct ifreq req;
|
||||||
|
|
||||||
if (dev) {
|
if(dev) {
|
||||||
snprintf(tap_device, sizeof(tap_device), "/dev/%s", dev);
|
snprintf(tap_device, sizeof(tap_device), "/dev/%s", dev);
|
||||||
device->fd = open(tap_device, O_RDWR);
|
device->fd = open(tap_device, O_RDWR);
|
||||||
snprintf(tap_device, sizeof(tap_device), "%s", dev);
|
snprintf(tap_device, sizeof(tap_device), "%s", dev);
|
||||||
|
@ -47,7 +47,7 @@ int tuntap_open(tuntap_dev *device /* ignored */,
|
||||||
else {
|
else {
|
||||||
device->fd = open("/dev/tap", O_RDWR);
|
device->fd = open("/dev/tap", O_RDWR);
|
||||||
if(device->fd >= 0) {
|
if(device->fd >= 0) {
|
||||||
if (ioctl(device->fd, TAPGIFNAME, &req) == -1) {
|
if(ioctl(device->fd, TAPGIFNAME, &req) == -1) {
|
||||||
traceEvent(TRACE_ERROR, "Unable to obtain name of tap device (%s)", strerror(errno));
|
traceEvent(TRACE_ERROR, "Unable to obtain name of tap device (%s)", strerror(errno));
|
||||||
close(device->fd);
|
close(device->fd);
|
||||||
return(-1);
|
return(-1);
|
||||||
|
@ -62,46 +62,45 @@ int tuntap_open(tuntap_dev *device /* ignored */,
|
||||||
traceEvent(TRACE_ERROR, "Unable to open tap device (%s)", strerror(errno));
|
traceEvent(TRACE_ERROR, "Unable to open tap device (%s)", strerror(errno));
|
||||||
return(-1);
|
return(-1);
|
||||||
} else {
|
} else {
|
||||||
char buf[256];
|
char cmd[256];
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
|
|
||||||
traceEvent(TRACE_NORMAL, "Succesfully open %s", tap_device);
|
traceEvent(TRACE_NORMAL, "Succesfully open %s", tap_device);
|
||||||
|
|
||||||
device->ip_addr = inet_addr(device_ip);
|
device->ip_addr = inet_addr(device_ip);
|
||||||
|
|
||||||
if ( device_mac && device_mac[0] != '\0' )
|
if( device_mac && device_mac[0] != '\0') {
|
||||||
{
|
|
||||||
/* Set the hw address before bringing the if up. */
|
/* Set the hw address before bringing the if up. */
|
||||||
snprintf(buf, sizeof(buf), "ifconfig %s link %s active",
|
snprintf(cmd, sizeof(cmd), "ifconfig %s link %s active",
|
||||||
tap_device, device_mac);
|
tap_device, device_mac);
|
||||||
system(buf);
|
system(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "ifconfig %s %s netmask %s mtu %d up",
|
snprintf(cmd, sizeof(cmd), "ifconfig %s %s netmask %s mtu %d up",
|
||||||
tap_device, device_ip, device_mask, mtu);
|
tap_device, device_ip, device_mask, mtu);
|
||||||
system(buf);
|
system(cmd);
|
||||||
|
|
||||||
traceEvent(TRACE_NORMAL, "Interface %s up and running (%s/%s)",
|
traceEvent(TRACE_NORMAL, "Interface %s up and running (%s/%s)",
|
||||||
tap_device, device_ip, device_mask);
|
tap_device, device_ip, device_mask);
|
||||||
|
|
||||||
/* Read MAC address */
|
/* Read MAC address */
|
||||||
|
snprintf(cmd, sizeof(cmd), "ifconfig %s |grep address|cut -c 11-28", tap_device);
|
||||||
|
/* traceEvent(TRACE_INFO, "%s", cmd); */
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "ifconfig %s |grep address|cut -c 11-28", tap_device);
|
fd = popen(cmd, "r");
|
||||||
/* traceEvent(TRACE_INFO, "%s", buf); */
|
|
||||||
|
|
||||||
fd = popen(buf, "r");
|
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
tun_close(device);
|
tun_close(device);
|
||||||
return(-1);
|
return(-1);
|
||||||
} else {
|
} else {
|
||||||
int a, b, c, d, e, f;
|
int a, b, c, d, e, f;
|
||||||
|
char buf[256];
|
||||||
|
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
fgets(buf, sizeof(buf), fd);
|
fgets(buf, sizeof(buf), fd);
|
||||||
pclose(fd);
|
pclose(fd);
|
||||||
|
|
||||||
if(buf[0] == '\0') {
|
if(buf[0] == '\0') {
|
||||||
traceEvent(TRACE_ERROR, "Unable to read %s interface MAC address", tap_device);
|
traceEvent(TRACE_ERROR, "Unable to read %s interface MAC address [%s]", tap_device, cmd);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
tuntap_osx.c
11
tuntap_osx.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/**
|
||||||
* (C) 2007-09 - Luca Deri <deri@ntop.org>
|
* (C) 2007-18 - ntop.org and contributors
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -13,11 +13,12 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "n2n.h"
|
#include "n2n.h"
|
||||||
|
|
||||||
#ifdef _DARWIN_
|
#ifdef __APPLE__
|
||||||
|
|
||||||
void tun_close(tuntap_dev *device);
|
void tun_close(tuntap_dev *device);
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ int tuntap_open(tuntap_dev *device /* ignored */,
|
||||||
|
|
||||||
fd = popen(buf, "r");
|
fd = popen(buf, "r");
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
tun_close(device);
|
tuntap_close(device);
|
||||||
return(-1);
|
return(-1);
|
||||||
} else {
|
} else {
|
||||||
int a, b, c, d, e, f;
|
int a, b, c, d, e, f;
|
||||||
|
@ -129,4 +130,4 @@ void tuntap_get_address(struct tuntap_dev *tuntap)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _DARWIN_ */
|
#endif /* __APPLE__ */
|
||||||
|
|
18
wire.c
18
wire.c
|
@ -1,4 +1,20 @@
|
||||||
/* (c) 2009 Richard Andrews <andrews@ntop.org> */
|
/**
|
||||||
|
* (C) 2007-18 - 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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not see see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/** Routines for encoding and decoding n2n packets on the wire.
|
/** Routines for encoding and decoding n2n packets on the wire.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user