1
0
mirror of https://github.com/solemnwarning/ipxwrapper synced 2024-12-30 16:45:37 +01:00

Moved address cache and interface TTL values into main_config.

This commit is contained in:
Daniel Collins 2012-10-21 10:33:20 +00:00
parent ebcf1673e2
commit e96c9db3e2
5 changed files with 13 additions and 12 deletions

View File

@ -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;

View File

@ -24,8 +24,6 @@
#include "common.h"
extern unsigned int addr_cache_ttl;
void addr_cache_init(void);
void addr_cache_cleanup(void);

View File

@ -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);

View File

@ -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 {

View File

@ -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);