diff --git a/include/n2n.h b/include/n2n.h index 99644dc..e5b0bfd 100644 --- a/include/n2n.h +++ b/include/n2n.h @@ -50,6 +50,7 @@ #endif /* WIN32 */ +#include #include // for size_t, FILE #include "n2n_define.h" #include "n2n_typedefs.h" @@ -207,7 +208,7 @@ 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, - int *keep_on_running); + bool *keep_on_running); int comm_init (struct sn_community *comm, char *cmn); int sn_init_defaults (n2n_sn_t *sss); void sn_init (n2n_sn_t *sss); diff --git a/include/n2n_define.h b/include/n2n_define.h index 230df6f..27113b9 100644 --- a/include/n2n_define.h +++ b/include/n2n_define.h @@ -99,9 +99,6 @@ #define FEDERATION_NAME "*Federation" enum federation {IS_NO_FEDERATION = 0,IS_FEDERATION = 1}; -/* (un)purgeable indicator for supernodes, communities, routes, ... */ -enum sn_purge {UNPURGEABLE = 0, PURGEABLE = 1}; - /* Header encryption indicators */ #define HEADER_ENCRYPTION_UNKNOWN 0 #define HEADER_ENCRYPTION_NONE 1 diff --git a/include/n2n_typedefs.h b/include/n2n_typedefs.h index ad76fd6..582b590 100644 --- a/include/n2n_typedefs.h +++ b/include/n2n_typedefs.h @@ -19,6 +19,7 @@ #ifndef _N2N_TYPEDEFS_H_ #define _N2N_TYPEDEFS_H_ +#include #include // for uint8_t and friends #ifndef WIN32 #include // for in_addr_t @@ -455,7 +456,7 @@ struct peer_info { n2n_cookie_t last_cookie; n2n_auth_t auth; int timeout; - uint8_t purgeable; + bool purgeable; time_t last_seen; time_t last_p2p; time_t last_sent_query; @@ -703,7 +704,7 @@ struct n2n_edge { n2n_edge_conf_t conf; /* Status */ - int *keep_running; /**< Pointer to edge loop stop/go flag */ + bool *keep_running; /**< Pointer to edge loop stop/go flag */ struct peer_info *curr_sn; /**< Currently active supernode. */ uint8_t sn_wait; /**< Whether we are waiting for a supernode response. */ uint8_t sn_pong; /**< Whether we have seen a PONG since last time reset. */ @@ -733,7 +734,7 @@ struct n2n_edge { /* Peers */ struct peer_info * known_peers; /**< Edges we are connected to. */ struct peer_info * pending_peers; /**< Edges we have tried to register with. */ -#ifdef HAVE_BRIDGING_SUPPORT +#ifdef HAVE_BRIDGING_SUPPORT struct host_info * known_hosts; /**< hosts we know. */ #endif /* Timers */ @@ -789,7 +790,7 @@ typedef struct sn_user { struct sn_community { char community[N2N_COMMUNITY_SIZE]; uint8_t is_federation; /* if not-zero, then the current community is the federation of supernodes */ - uint8_t purgeable; /* indicates purgeable community (fixed-name, predetermined (-c parameter) communties usually are unpurgeable) */ + bool purgeable; /* indicates purgeable community (fixed-name, predetermined (-c parameter) communties usually are unpurgeable) */ uint8_t header_encryption; /* Header encryption indicator. */ he_context_t *header_encryption_ctx_static; /* Header encryption cipher context. */ he_context_t *header_encryption_ctx_dynamic; /* Header encryption cipher context. */ @@ -832,7 +833,7 @@ typedef struct n2n_tcp_connection { typedef struct n2n_sn { - int *keep_running; /* Pointer to sn loop stop/go flag */ + bool *keep_running; /* Pointer to sn loop stop/go flag */ time_t start_time; /* Used to measure uptime. */ n2n_version_t version; /* version string sent to edges along with PEER_INFO a.k.a. PONG */ sn_stats_t stats; diff --git a/src/edge.c b/src/edge.c index 9e6b501..d2c0288 100644 --- a/src/edge.c +++ b/src/edge.c @@ -21,6 +21,7 @@ #include // for errno #include // for required_argument, no_argument #include // for signal, SIG_IGN, SIGPIPE, SIGCHLD +#include #include // for uint8_t, uint16_t #include // for printf, NULL, fclose, snprintf #include // for atoi, exit, calloc, free, malloc @@ -958,7 +959,7 @@ static void daemonize () { /* *************************************************** */ -static int keep_on_running; +static bool keep_on_running = true; #if defined(__linux__) || defined(WIN32) #ifdef WIN32 @@ -977,8 +978,15 @@ BOOL WINAPI term_handler(DWORD sig) called = 1; } - keep_on_running = 0; + keep_on_running = false; #ifdef WIN32 + switch (sig) { + case CTRL_CLOSE_EVENT: + case CTRL_LOGOFF_EVENT: + case CTRL_SHUTDOWN_EVENT: + // Will terminate us after we return, blocking it to cleanup + Sleep(INFINITE); + } return(TRUE); #endif } @@ -1336,7 +1344,6 @@ int main (int argc, char* argv[]) { SetConsoleCtrlHandler(term_handler, TRUE); #endif - keep_on_running = 1; eee->keep_running = &keep_on_running; traceEvent(TRACE_NORMAL, "edge started"); rc = run_edge_loop(eee); diff --git a/src/edge_management.c b/src/edge_management.c index 3741b04..53e0b6f 100644 --- a/src/edge_management.c +++ b/src/edge_management.c @@ -21,6 +21,7 @@ // fails with what looks like a struct rearrangement involving eee->stats #include // for errno +#include #include // for uint32_t #include // for snprintf, size_t, NULL #include // for memcmp, memcpy, strerror, strncpy @@ -494,7 +495,7 @@ void readFromMgmtSocket (n2n_edge_t *eee) { if(0 == memcmp(udp_buf, "stop", 4)) { traceEvent(TRACE_NORMAL, "stop command received"); - *eee->keep_running = 0; + *eee->keep_running = false; return; } @@ -608,7 +609,7 @@ void readFromMgmtSocket (n2n_edge_t *eee) { msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len), "%-19s %1s%1s | %-17s | %-21s | %-15s | %9s | %10s\n", peer->version, - (peer->purgeable == UNPURGEABLE) ? "l" : "", + (peer->purgeable == false) ? "l" : "", (peer == eee->curr_sn) ? (eee->sn_wait ? "." : "*" ) : "", is_null_mac(peer->mac_addr) ? "" : macaddr_str(mac_buf, peer->mac_addr), sock_to_cstr(sockbuf, &(peer->sock)), diff --git a/src/edge_utils.c b/src/edge_utils.c index 9474377..8d6568a 100644 --- a/src/edge_utils.c +++ b/src/edge_utils.c @@ -19,6 +19,7 @@ #include // for errno, EAFNOSUPPORT, EINPROGRESS #include // for fcntl, F_SETFL, O_NONBLOCK +#include #include // for uint8_t, uint16_t, uint32_t, uin... #include // for snprintf, sprintf #include // for free, calloc, getenv @@ -2894,7 +2895,7 @@ int run_edge_loop (n2n_edge_t *eee) { HANDLE tun_read_thread = startTunReadThread(&arg); #endif - *eee->keep_running = 1; + *eee->keep_running = true; update_supernode_reg(eee, time(NULL)); /* Main loop @@ -2953,7 +2954,7 @@ int run_edge_loop (n2n_edge_t *eee) { if(0 != fetch_and_eventually_process_data(eee, eee->sock, pktbuf, &expected, &position, now)) { - *eee->keep_running = 0; + *eee->keep_running = false; break; } if(eee->conf.connect_tcp) { @@ -2974,7 +2975,7 @@ int run_edge_loop (n2n_edge_t *eee) { if(0 != fetch_and_eventually_process_data(eee, eee->udp_multicast_sock, pktbuf, &expected, &position, now)) { - *eee->keep_running = 0; + *eee->keep_running = false; break; } } @@ -3022,7 +3023,7 @@ int run_edge_loop (n2n_edge_t *eee) { if((eee->conf.allow_routing) && (now > last_purge_host + SWEEP_TIME)) { struct host_info *host, *host_tmp; HASH_ITER(hh, eee->known_hosts, host, host_tmp) { - if(now > host->last_seen + HOSTINFO_TIMEOUT) { + if(now > host->last_seen + HOSTINFO_TIMEOUT) { HASH_DEL(eee->known_hosts, host); free(host); } @@ -3088,12 +3089,12 @@ void edge_term (n2n_edge_t * eee) { #ifdef HAVE_BRIDGING_SUPPORT if(eee->conf.allow_routing) { struct host_info *host, *host_tmp; - HASH_ITER(hh, eee->known_hosts, host, host_tmp) { + HASH_ITER(hh, eee->known_hosts, host, host_tmp) { HASH_DEL(eee->known_hosts, host); free(host); } } -#endif +#endif eee->transop.deinit(&eee->transop); eee->transop_lzo.deinit(&eee->transop_lzo); @@ -3254,7 +3255,7 @@ int edge_conf_add_supernode (n2n_edge_conf_t *conf, const char *ip_and_port) { strncpy(sn->ip_addr, ip_and_port, N2N_EDGE_SN_HOST_SIZE - 1); memcpy(&(sn->sock), sock, sizeof(n2n_sock_t)); memcpy(sn->mac_addr, null_mac, sizeof(n2n_mac_t)); - sn->purgeable = UNPURGEABLE; + sn->purgeable = false; } } @@ -3272,7 +3273,7 @@ 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, - int *keep_on_running) { + bool *keep_on_running) { tuntap_dev tuntap; n2n_edge_t *eee; diff --git a/src/example_edge_embed.c b/src/example_edge_embed.c index b8b8180..2b32269 100644 --- a/src/example_edge_embed.c +++ b/src/example_edge_embed.c @@ -17,12 +17,13 @@ */ +#include #include // for snprintf, NULL #include // for exit #include "n2n.h" // for n2n_edge_conf_t, edge_conf_add_supernode, edge_init -static int keep_running; +static bool keep_running = true; int main() { @@ -60,8 +61,8 @@ int main() { DEFAULT_MTU // MTU to use #ifdef WIN32 , 0 -#endif - ) < 0) +#endif + ) < 0) { return -1; } @@ -71,7 +72,6 @@ int main() { exit(1); } - keep_running = 1; eee->keep_running = &keep_running; rc = run_edge_loop(eee); diff --git a/src/example_edge_embed_quick_edge_init.c b/src/example_edge_embed_quick_edge_init.c index 72a8ae6..525795c 100644 --- a/src/example_edge_embed_quick_edge_init.c +++ b/src/example_edge_embed_quick_edge_init.c @@ -17,6 +17,7 @@ */ +#include #include "n2n.h" // for quick_edge_init, setTraceLevel #include "random_numbers.h" // for n2n_seed, n2n_srand @@ -34,7 +35,7 @@ int main (int argc, char* argv[]) { char *my_mac_address = (char*)"DE:AD:BE:EF:01:10"; char *my_ipv4_addr = (char*)"1.2.3.4"; char *supernode = (char*)"7.8.9.10:1234"; - int keep_on_running = 1; + bool keep_on_running = true; /* Increase tracelevel to see what's happening */ setTraceLevel(10); diff --git a/src/example_sn_embed.c b/src/example_sn_embed.c index 77dca85..713d068 100644 --- a/src/example_sn_embed.c +++ b/src/example_sn_embed.c @@ -17,6 +17,7 @@ */ +#include #include // for exit #include "n2n.h" // for n2n_sn_t, open_socket, run_sn_loop, sn_init @@ -27,7 +28,7 @@ #endif -static int keep_running; +static bool keep_running = true; int main () { @@ -50,7 +51,6 @@ int main () { sn_init(&sss_node); - keep_running = 1; sss_node.keep_running = &keep_running; rc = run_sn_loop(&sss_node); diff --git a/src/management.c b/src/management.c index 7a7b7cc..70a3b4f 100644 --- a/src/management.c +++ b/src/management.c @@ -5,6 +5,7 @@ #include // for pearson_hash_64 +#include #include // for snprintf, NULL, size_t #include // for strtoul #include // for strtok, strlen, strncpy @@ -68,7 +69,7 @@ void mgmt_error (mgmt_req_t *req, strbuf_t *buf, char *msg) { void mgmt_stop (mgmt_req_t *req, strbuf_t *buf) { if(req->type==N2N_MGMT_WRITE) { - *req->keep_running = 0; + *req->keep_running = false; } send_json_1uint(req, buf, "row", "keep_running", *req->keep_running); diff --git a/src/management.h b/src/management.h index 59cbce4..3e95458 100644 --- a/src/management.h +++ b/src/management.h @@ -9,6 +9,7 @@ #define MANAGEMENT_H 1 #include // For the n2n_edge_t and n2n_sn_t defs +#include #include // for size_t #include // for uint64_t #include // for ssize_t @@ -42,7 +43,7 @@ typedef struct mgmt_req { n2n_sn_t *sss; n2n_edge_t *eee; int mgmt_sock; // socket replies come from - int *keep_running; + bool *keep_running; uint64_t mgmt_password_hash; enum n2n_mgmt_type type; char *argv0; diff --git a/src/n2n.c b/src/n2n.c index 0675dec..c5a65ad 100644 --- a/src/n2n.c +++ b/src/n2n.c @@ -19,6 +19,7 @@ #include // for errno #include // for va_end, va_list, va_start +#include #include // for free, atoi, calloc, strtol #include // for memcmp, memcpy, memset, strlen, strerror #include // for gettimeofday, timeval @@ -440,13 +441,13 @@ uint8_t resolve_check (n2n_resolve_parameter_t *param, uint8_t requires_resoluti uint8_t ret = requires_resolution; /* if trylock fails, it still requires resolution */ -#ifdef HAVE_PTHREAD +#ifdef HAVE_PTHREAD n2n_resolve_ip_sock_t *entry, *tmp_entry; n2n_sock_str_t sock_buf; if(NULL == param) return ret; - + // check_interval and last_check do not need to be guarded by the mutex because // their values get changed and evaluated only here @@ -650,7 +651,7 @@ size_t purge_peer_list (struct peer_info **peer_list, size_t retval = 0; HASH_ITER(hh, *peer_list, scan, tmp) { - if((scan->purgeable == PURGEABLE) && (scan->last_seen < purge_before)) { + if(scan->purgeable && scan->last_seen < purge_before) { if((scan->socket_fd >=0) && (scan->socket_fd != socket_not_to_close)) { if(tcp_connections) { HASH_FIND_INT(*tcp_connections, &scan->socket_fd, conn); @@ -680,7 +681,7 @@ size_t clear_peer_list (struct peer_info ** peer_list) { size_t retval = 0; HASH_ITER(hh, *peer_list, scan, tmp) { - if (scan->purgeable == UNPURGEABLE && scan->ip_addr) { + if (scan->purgeable == false && scan->ip_addr) { free(scan->ip_addr); } HASH_DEL(*peer_list, scan); diff --git a/src/sn_management.c b/src/sn_management.c index 9b422fa..3dae672 100644 --- a/src/sn_management.c +++ b/src/sn_management.c @@ -23,6 +23,7 @@ #include // for errno +#include #include // for uint8_t, uint32_t #include // for snprintf, size_t, sprintf, NULL #include // for memcmp, memcpy, strerror, strncpy @@ -371,7 +372,7 @@ int process_mgmt (n2n_sn_t *sss, ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize, "%s '%s'\n", - (community->is_federation) ? "FEDERATION" : ((community->purgeable == UNPURGEABLE) ? "FIXED NAME COMMUNITY" : "COMMUNITY"), + (community->is_federation) ? "FEDERATION" : ((community->purgeable == false) ? "FIXED NAME COMMUNITY" : "COMMUNITY"), (community->is_federation) ? "-/-" : community->community); sendto_mgmt(sss, sender_sock, sock_size, (const uint8_t *) resbuf, ressize); ressize = 0; @@ -382,7 +383,7 @@ int process_mgmt (n2n_sn_t *sss, ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize, "%4u | %-19s | %-17s | %-21s %-3s | %-15s | %9s\n", ++num, - (peer->dev_addr.net_addr == 0) ? ((peer->purgeable == UNPURGEABLE) ? "-l" : "") : ip_subnet_to_str(ip_bit_str, &peer->dev_addr), + (peer->dev_addr.net_addr == 0) ? ((peer->purgeable == false) ? "-l" : "") : ip_subnet_to_str(ip_bit_str, &peer->dev_addr), (is_null_mac(peer->mac_addr)) ? "" : macaddr_str(mac_buf, peer->mac_addr), sock_to_cstr(sockbuf, &(peer->sock)), ((peer->socket_fd >= 0) && (peer->socket_fd != sss->sock)) ? "TCP" : "", diff --git a/src/sn_utils.c b/src/sn_utils.c index a1c3117..9b57f58 100644 --- a/src/sn_utils.c +++ b/src/sn_utils.c @@ -18,6 +18,7 @@ #include // for errno, EAFNOSUPPORT +#include #include // for uint8_t, uint32_t, uint16_t, uint64_t #include // for sscanf, snprintf, fclose, fgets, fopen #include // for free, calloc, getenv @@ -412,7 +413,7 @@ int load_allowed_sn_community (n2n_sn_t *sss) { if(comm != NULL) { comm_init(comm, cmn_str); /* loaded from file, this community is unpurgeable */ - comm->purgeable = UNPURGEABLE; + comm->purgeable = false; /* we do not know if header encryption is used in this community, * first packet will show. just in case, setup the key. */ comm->header_encryption = HEADER_ENCRYPTION_UNKNOWN; @@ -800,7 +801,7 @@ int sn_init_defaults (n2n_sn_t *sss) { sss->federation->community[N2N_COMMUNITY_SIZE - 1] = '\0'; /* enable the flag for federation */ sss->federation->is_federation = IS_FEDERATION; - sss->federation->purgeable = UNPURGEABLE; + sss->federation->purgeable = false; /* header encryption enabled by default */ sss->federation->header_encryption = HEADER_ENCRYPTION_ENABLED; /*setup the encryption key */ @@ -1108,6 +1109,7 @@ static int update_edge (n2n_sn_t *sss, if(handle_remote_auth(sss, &(reg->auth), answer_auth, comm) == 0) { if(skip_add == SN_ADD) { scan = (struct peer_info *) calloc(1, sizeof(struct peer_info)); /* deallocated in purge_expired_nodes */ + scan->purgeable = true; memcpy(&(scan->mac_addr), reg->edgeMac, sizeof(n2n_mac_t)); scan->dev_addr.net_addr = reg->dev_addr.net_addr; scan->dev_addr.net_bitlen = reg->dev_addr.net_bitlen; @@ -1479,7 +1481,7 @@ static int purge_expired_communities (n2n_sn_t *sss, } } - if((comm->edges == NULL) && (comm->purgeable == PURGEABLE)) { + if((comm->edges == NULL) && (comm->purgeable == true)) { traceEvent(TRACE_INFO, "purging idle community %s", comm->community); if(NULL != comm->header_encryption_ctx_static) { /* this should not happen as 'purgeable' and thus only communities w/o encrypted header here */ @@ -1937,7 +1939,7 @@ static int process_udp (n2n_sn_t * sss, comm->header_encryption_ctx_static = NULL; comm->header_encryption_ctx_dynamic = NULL; /* ... and also are purgeable during periodic purge */ - comm->purgeable = PURGEABLE; + comm->purgeable = true; comm->number_enc_packets = 0; HASH_ADD_STR(sss->communities, community, comm); @@ -2650,7 +2652,7 @@ int run_sn_loop (n2n_sn_t *sss) { #ifdef WIN32 traceEvent(TRACE_ERROR, "WSAGetLastError(): %u", WSAGetLastError()); #endif - *sss->keep_running = 0; + *sss->keep_running = false; break; } @@ -2768,7 +2770,7 @@ int run_sn_loop (n2n_sn_t *sss) { // REVISIT: should we error out if ss_size returns bigger than before? can this ever happen? if(bread <= 0) { traceEvent(TRACE_ERROR, "recvfrom() failed %d errno %d (%s)", bread, errno, strerror(errno)); - *sss->keep_running = 0; + *sss->keep_running = false; break; } diff --git a/src/supernode.c b/src/supernode.c index 3155d86..1c640f1 100644 --- a/src/supernode.c +++ b/src/supernode.c @@ -23,6 +23,7 @@ #include // for errno #include // for required_argument, getopt_long, no_arg... #include // for signal, SIGHUP, SIGINT, SIGPIPE, SIGTERM +#include #include // for uint8_t, uint32_t #include // for printf, NULL, fclose, fgets, fopen #include // for exit, atoi, calloc, free @@ -272,7 +273,7 @@ static int setOption (int optkey, char *_optarg, n2n_sn_t *sss) { strncpy(anchor_sn->ip_addr, _optarg, N2N_EDGE_SN_HOST_SIZE - 1); memcpy(&(anchor_sn->sock), socket, sizeof(n2n_sock_t)); memcpy(anchor_sn->mac_addr, null_mac, sizeof(n2n_mac_t)); - anchor_sn->purgeable = UNPURGEABLE; + anchor_sn->purgeable = false; anchor_sn->last_valid_time_stamp = initial_time_stamp(); } } @@ -335,7 +336,7 @@ static int setOption (int optkey, char *_optarg, n2n_sn_t *sss) { case 'F': { /* federation name */ snprintf(sss->federation->community, N2N_COMMUNITY_SIZE - 1 ,"*%s", _optarg); sss->federation->community[N2N_COMMUNITY_SIZE - 1] = '\0'; - sss->federation->purgeable = UNPURGEABLE; + sss->federation->purgeable = false; break; } #ifdef SN_MANUAL_MAC @@ -564,7 +565,7 @@ static void dump_registrations (int signo) { /* *************************************************** */ -static int keep_running; +static bool keep_running = true; #if defined(__linux__) || defined(WIN32) #ifdef WIN32 @@ -583,7 +584,7 @@ BOOL WINAPI term_handler (DWORD sig) called = 1; } - keep_running = 0; + keep_running = false; #ifdef WIN32 return(TRUE); #endif @@ -737,7 +738,6 @@ int main (int argc, char * const argv[]) { SetConsoleCtrlHandler(term_handler, TRUE); #endif - keep_running = 1; sss_node.keep_running = &keep_running; return run_sn_loop(&sss_node); } diff --git a/tools/n2n-portfwd.c b/tools/n2n-portfwd.c index 0e1bdd4..89dabcc 100644 --- a/tools/n2n-portfwd.c +++ b/tools/n2n-portfwd.c @@ -20,6 +20,7 @@ #include // for getopt_long #include // for optarg #include // for signal, SIGINT, SIGPIPE, SIGTERM, SIG_IGN +#include #include // for uint16_t, uint32_t, uint8_t #include // for printf, snprintf #include // for NULL, atoi, exit, size_t @@ -58,7 +59,7 @@ typedef struct n2n_portfwd_conf { } n2n_portfwd_conf_t; -static int keep_running = 1; /* for main loop, handled by signals */ +static bool keep_running = true; /* for main loop, handled by signals */ // ------------------------------------------------------------------------------------------------------- @@ -94,7 +95,7 @@ static void term_handler (int sig) { called = 1; } - keep_running = 0; + keep_running = false; #ifdef WIN32 return TRUE; #endif diff --git a/tools/n2n-route.c b/tools/n2n-route.c index d19f329..a7d3cdd 100644 --- a/tools/n2n-route.c +++ b/tools/n2n-route.c @@ -20,6 +20,7 @@ #include // for errno #include // for getopt_long, optind, optarg #include // for signal, SIGINT, SIGPIPE, SIGTERM, SIG_IGN +#include #include // for uint8_t, uint16_t, uint32_t #include // for snprintf, printf, sscanf #include // for calloc, free, atoi, EXIT_FAILURE, exit @@ -99,7 +100,7 @@ typedef struct n2n_route_conf { } n2n_route_conf_t; -static int keep_running = 1; /* for main loop, handled by signals */ +static bool keep_running = true; /* for main loop, handled by signals */ // ------------------------------------------------------------------------------------------------------- @@ -167,7 +168,7 @@ BOOL WINAPI term_handler (DWORD sig) { called = 1; } - keep_running = 0; + keep_running = false; #if defined(WIN32) return TRUE; #endif @@ -857,7 +858,7 @@ int main (int argc, char* argv[]) { if(!inet_address_valid(route->gateway)) { route->gateway = rrr.gateway_vpn; } - route->purgeable = UNPURGEABLE; + route->purgeable = false; handle_route(route, ROUTE_ADD); } @@ -906,7 +907,7 @@ reset_main_loop: rrr.gateway_org = addr_tmp; // delete all purgeable routes as they are still relying on old original default gateway HASH_ITER(hh, rrr.routes, route, tmp_route) { - if((route->purgeable == PURGEABLE)) { + if((route->purgeable == true)) { handle_route(route, ROUTE_DEL); HASH_DEL(rrr.routes, route); free(route); @@ -967,7 +968,7 @@ reset_main_loop: if(now > last_purge + PURGE_INTERVAL) { last_purge = now; HASH_ITER(hh, rrr.routes, route, tmp_route) { - if((route->purgeable == PURGEABLE) && (now > route->last_seen + REMOVE_ROUTE_AGE)) { + if((route->purgeable == true) && (now > route->last_seen + REMOVE_ROUTE_AGE)) { handle_route(route, ROUTE_DEL); HASH_DEL(rrr.routes, route); free(route); @@ -1037,7 +1038,7 @@ reset_main_loop: HASH_DEL(rrr.routes, route); if(route) { fill_route(route, addr, inet_address(HOST_MASK), rrr.gateway_org); - route->purgeable = PURGEABLE; + route->purgeable = true; if(!(route->last_seen)) { handle_route(route, ROUTE_ADD); }