|
@ -41,7 +41,7 @@ static void check_peer_registration_needed (n2n_edge_t *eee, |
|
|
const n2n_sock_t *peer); |
|
|
const n2n_sock_t *peer); |
|
|
|
|
|
|
|
|
static int edge_init_sockets (n2n_edge_t *eee); |
|
|
static int edge_init_sockets (n2n_edge_t *eee); |
|
|
static int edge_init_routes (n2n_edge_t *eee, n2n_route_t *routes, uint16_t num_routes); |
|
|
int edge_init_routes (n2n_edge_t *eee, n2n_route_t *routes, uint16_t num_routes); |
|
|
static void edge_cleanup_routes (n2n_edge_t *eee); |
|
|
static void edge_cleanup_routes (n2n_edge_t *eee); |
|
|
|
|
|
|
|
|
static void check_known_peer_sock_change (n2n_edge_t *eee, |
|
|
static void check_known_peer_sock_change (n2n_edge_t *eee, |
|
@ -417,11 +417,6 @@ n2n_edge_t* edge_init (const n2n_edge_conf_t *conf, int *rv) { |
|
|
goto edge_init_error; |
|
|
goto edge_init_error; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(edge_init_routes(eee, eee->conf.routes, eee->conf.num_routes) < 0) { |
|
|
|
|
|
traceEvent(TRACE_ERROR, "routes setup failed"); |
|
|
|
|
|
goto edge_init_error; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
eee->network_traffic_filter = create_network_traffic_filter(); |
|
|
eee->network_traffic_filter = create_network_traffic_filter(); |
|
|
network_traffic_filter_add_rule(eee->network_traffic_filter, eee->conf.network_traffic_filter_rules); |
|
|
network_traffic_filter_add_rule(eee->network_traffic_filter, eee->conf.network_traffic_filter_rules); |
|
|
|
|
|
|
|
@ -3385,12 +3380,14 @@ static int edge_init_routes_linux (n2n_edge_t *eee, n2n_route_t *routes, uint16_ |
|
|
|
|
|
|
|
|
/* ************************************** */ |
|
|
/* ************************************** */ |
|
|
|
|
|
|
|
|
static int edge_init_routes_win (n2n_edge_t *eee, n2n_route_t *routes, uint16_t num_routes) { |
|
|
static int edge_init_routes_win (n2n_edge_t *eee, n2n_route_t *routes, uint16_t num_routes, uint8_t verb /* 0 = add, 1 = delete */) { |
|
|
#ifdef WIN32 |
|
|
#ifdef WIN32 |
|
|
int i; |
|
|
int i; |
|
|
struct in_addr net_addr, gateway; |
|
|
struct in_addr net_addr, gateway; |
|
|
char c_net_addr[32]; |
|
|
char c_net_addr[32]; |
|
|
char c_gateway[32]; |
|
|
char c_gateway[32]; |
|
|
|
|
|
char c_interface[32]; |
|
|
|
|
|
char c_verb[32]; |
|
|
char cmd[256]; |
|
|
char cmd[256]; |
|
|
|
|
|
|
|
|
for(i = 0; i < num_routes; i++) { |
|
|
for(i = 0; i < num_routes; i++) { |
|
@ -3404,12 +3401,13 @@ static int edge_init_routes_win (n2n_edge_t *eee, n2n_route_t *routes, uint16_t |
|
|
memcpy(&gateway, &(route->gateway), sizeof(gateway)); |
|
|
memcpy(&gateway, &(route->gateway), sizeof(gateway)); |
|
|
_snprintf(c_net_addr, sizeof(c_net_addr), inet_ntoa(net_addr)); |
|
|
_snprintf(c_net_addr, sizeof(c_net_addr), inet_ntoa(net_addr)); |
|
|
_snprintf(c_gateway, sizeof(c_gateway), inet_ntoa(gateway)); |
|
|
_snprintf(c_gateway, sizeof(c_gateway), inet_ntoa(gateway)); |
|
|
_snprintf(cmd, sizeof(cmd), "route add %s/%d %s > nul", c_net_addr, route->net_bitlen, c_gateway); |
|
|
_snprintf(c_interface, sizeof(c_interface), "if %u", eee->device.if_idx); |
|
|
|
|
|
_snprintf(c_verb, sizeof(c_verb), verb ? "delete" : "add"); |
|
|
|
|
|
_snprintf(cmd, sizeof(cmd), "route %s %s/%d %s %s > nul", c_verb, c_net_addr, route->net_bitlen, c_gateway, c_interface); |
|
|
traceEvent(TRACE_NORMAL, "ROUTE CMD = '%s'\n", cmd); |
|
|
traceEvent(TRACE_NORMAL, "ROUTE CMD = '%s'\n", cmd); |
|
|
system(cmd); |
|
|
system(cmd); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#endif // WIN32
|
|
|
#endif // WIN32
|
|
|
|
|
|
|
|
|
return (0); |
|
|
return (0); |
|
@ -3420,13 +3418,13 @@ static int edge_init_routes_win (n2n_edge_t *eee, n2n_route_t *routes, uint16_t |
|
|
/* Add the user-provided routes to the linux routing table. Network routes
|
|
|
/* Add the user-provided routes to the linux routing table. Network routes
|
|
|
* are bound to the n2n TAP device, so they are automatically removed when |
|
|
* are bound to the n2n TAP device, so they are automatically removed when |
|
|
* the TAP device is destroyed. */ |
|
|
* the TAP device is destroyed. */ |
|
|
static int edge_init_routes (n2n_edge_t *eee, n2n_route_t *routes, uint16_t num_routes) { |
|
|
int edge_init_routes (n2n_edge_t *eee, n2n_route_t *routes, uint16_t num_routes) { |
|
|
#ifdef __linux__ |
|
|
#ifdef __linux__ |
|
|
return edge_init_routes_linux(eee, routes, num_routes); |
|
|
return edge_init_routes_linux(eee, routes, num_routes); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifdef WIN32 |
|
|
#ifdef WIN32 |
|
|
return edge_init_routes_win(eee, routes, num_routes); |
|
|
return edge_init_routes_win(eee, routes, num_routes, 0 /* add */); |
|
|
#endif |
|
|
#endif |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
@ -3441,6 +3439,11 @@ static void edge_cleanup_routes (n2n_edge_t *eee) { |
|
|
free(eee->sn_route_to_clean); |
|
|
free(eee->sn_route_to_clean); |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef WIN32 |
|
|
|
|
|
edge_init_routes_win(eee, eee->conf.routes, eee->conf.num_routes, 1 /* del */); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* ************************************** */ |
|
|
/* ************************************** */ |
|
|