"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/example_edge_embed.c" between
n2n-2.8.tar.gz and n2n-3.0.tar.gz

About: n2n is a layer-two peer-to-peer virtual private network (VPN) which allows bypassing intermediate firewalls.

example_edge_embed.c  (n2n-2.8):example_edge_embed.c  (n2n-3.0)
/** /**
* (C) 2007-20 - ntop.org and contributors * (C) 2007-21 - 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
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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 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"
static int keep_running; static int keep_running;
int main() int main() {
{
n2n_edge_conf_t conf; n2n_edge_conf_t conf;
tuntap_dev tuntap; tuntap_dev tuntap;
n2n_edge_t *eee; n2n_edge_t *eee;
int rc; int rc;
edge_init_conf_defaults(&conf); edge_init_conf_defaults(&conf);
conf.allow_p2p = 1; // Whether to allow peer-to-peer communication conf.allow_p2p = 1; // Whether to allow peer-to-peer communication
conf.allow_routing = 1; // Whether to allow the edge to route packets to other edges conf.allow_routing = 1; // Whether to allow the edge to route packets to other edges
snprintf((char *)conf.community_name, sizeof(conf.community_name), "%s", "my community"); // Community to connect to snprintf((char *)conf.community_name, sizeof(conf.community_name), "%s", "my community"); // Community to connect to
conf.disable_pmtu_discovery = 1; // Whether to disable the path MTU discovery conf.disable_pmtu_discovery = 1; // Whether to disable the path MTU discovery
conf.drop_multicast = 0; // Whether to disable multicast conf.drop_multicast = 0; // Whether to disable multicast
conf.dyn_ip_mode = 0; // Whether the IP address is set dynamically (see IP mode; 0 if sta tic, 1 if dynamic) conf.tuntap_ip_mode = TUNTAP_IP_MODE_SN_ASSIGN; // How to set the IP address
conf.encrypt_key = "mysecret"; // Secret to decrypt & encrypt with conf.encrypt_key = "mysecret"; // Secret to decrypt & encrypt with
conf.local_port = 0; // What port to use (0 = any port) conf.local_port = 0; // What port to use (0 = any port)
conf.mgmt_port = N2N_EDGE_MGMT_PORT; // Edge management port (5644 by default) conf.mgmt_port = N2N_EDGE_MGMT_PORT; // Edge management port (5644 by default)
conf.register_interval = 1; // Interval for both UDP NAT hole punching and supernode registrati on conf.register_interval = 1; // Interval for both UDP NAT hole punching and supernode registrati on
conf.register_ttl = 1; // Interval for UDP NAT hole punching through supernode conf.register_ttl = 1; // Interval for UDP NAT hole punching through supernode
edge_conf_add_supernode(&conf, "localhost:1234"); // Supernode to connect to edge_conf_add_supernode(&conf, "localhost:1234"); // Supernode to connect to
conf.tos = 16; // Type of service for sent packets conf.tos = 16; // Type of service for sent packets
conf.transop_id = N2N_TRANSFORM_ID_TWOFISH; // Use the twofish encryption conf.transop_id = N2N_TRANSFORM_ID_TWOFISH; // Use the twofish encryption
if (edge_verify_conf(&conf) != 0) if(edge_verify_conf(&conf) != 0) {
{
return -1; return -1;
} }
if (tuntap_open(&tuntap, if(tuntap_open(&tuntap,
"edge0", // Name of the device to create "edge0", // Name of the device to create
"static", // IP mode; static|dhcp "static", // IP mode; static|dhcp
"10.0.0.1", // Set ip address "10.0.0.1", // Set ip address
"255.255.255.0", // Netmask to use "255.255.255.0", // Netmask to use
"DE:AD:BE:EF:01:10", // Set mac address "DE:AD:BE:EF:01:10", // Set mac address
DEFAULT_MTU) < 0) // MTU to use DEFAULT_MTU // MTU to use
{ #ifdef WIN32
return -1; , 0
} #endif
) < 0)
{
return -1;
}
eee = edge_init(&tuntap, &conf, &rc); eee = edge_init(&conf, &rc);
if (eee == NULL) if(eee == NULL) {
{
exit(1); exit(1);
} }
keep_running = 1; keep_running = 1;
rc = run_edge_loop(eee, &keep_running); eee->keep_running = &keep_running;
rc = run_edge_loop(eee);
edge_term(eee); edge_term(eee);
tuntap_close(&tuntap); tuntap_close(&tuntap);
return rc; return rc;
} }
 End of changes. 8 change blocks. 
21 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)