diff --git a/src/addrcache.c b/src/addrcache.c index 9d9fbaf..edeed9d 100644 --- a/src/addrcache.c +++ b/src/addrcache.c @@ -24,6 +24,7 @@ #include "addrcache.h" #include "common.h" +#include "ipxwrapper.h" struct host_table_key { addr32_t netnum; @@ -43,8 +44,6 @@ struct host_table { typedef struct host_table host_table_t; typedef struct host_table_key host_table_key_t; -unsigned int addr_cache_ttl = 30; - static host_table_t *host_table = NULL; static CRITICAL_SECTION host_table_cs; @@ -124,7 +123,7 @@ int addr_cache_get(SOCKADDR_STORAGE *addr, size_t *addrlen, addr32_t net, addr48 host_table_t *host = host_table_find(net, node); - if(host && time(NULL) < host->time + addr_cache_ttl) + if(host && time(NULL) < host->time + main_config.addr_cache_ttl) { memcpy(addr, &(host->addr), host->addrlen); *addrlen = host->addrlen; diff --git a/src/addrcache.h b/src/addrcache.h index eb6da99..3462d1c 100644 --- a/src/addrcache.h +++ b/src/addrcache.h @@ -24,8 +24,6 @@ #include "common.h" -extern unsigned int addr_cache_ttl; - void addr_cache_init(void); void addr_cache_cleanup(void); diff --git a/src/config.c b/src/config.c index 89b9e5f..b4e149a 100644 --- a/src/config.c +++ b/src/config.c @@ -26,11 +26,13 @@ main_config_t get_main_config(void) main_config_t config; - config.udp_port = DEFAULT_PORT; - config.router_port = DEFAULT_ROUTER_PORT; - config.w95_bug = true; - config.bcast_all = false; - config.src_filter = true; + config.udp_port = DEFAULT_PORT; + config.router_port = DEFAULT_ROUTER_PORT; + config.w95_bug = true; + config.bcast_all = false; + config.src_filter = true; + config.addr_cache_ttl = 30; + config.iface_ttl = 5; HKEY reg = reg_open_main(false); DWORD version = reg_get_dword(reg, "config_version", 1); diff --git a/src/config.h b/src/config.h index 7479c8d..6fc0f51 100644 --- a/src/config.h +++ b/src/config.h @@ -20,7 +20,6 @@ #define DEFAULT_PORT 54792 #define DEFAULT_ROUTER_PORT 54793 -#define IFACE_TTL 10 #include "common.h" @@ -31,6 +30,9 @@ typedef struct main_config { bool w95_bug; bool bcast_all; bool src_filter; + + unsigned int addr_cache_ttl; + unsigned int iface_ttl; } main_config_t; struct v1_global_config { diff --git a/src/ipxwrapper.c b/src/ipxwrapper.c index 505b60b..45aa2ec 100644 --- a/src/ipxwrapper.c +++ b/src/ipxwrapper.c @@ -188,7 +188,7 @@ void unlock_sockets(void) { BOOL ip_is_local(uint32_t ipaddr) { EnterCriticalSection(&addrs_cs); - if(local_updated + IFACE_TTL < time(NULL)) { + if(local_updated + main_config.iface_ttl < time(NULL)) { /* TODO: Use all local IPs rather than just the ones with associated IPX addresses? */ struct ipx_interface *ifaces = get_interfaces(-1);