diff options
author | Laurent Deniel <laurent.deniel@free.fr> | 2000-08-10 22:35:30 +0000 |
---|---|---|
committer | Laurent Deniel <laurent.deniel@free.fr> | 2000-08-10 22:35:30 +0000 |
commit | 54ddb5b1d3a4d4b05dced5c1cb9bb0a4e62217bb (patch) | |
tree | 33c03d3ed4ef2bdea44b7cb590ac314bd2fadc86 | |
parent | 6f5b18e7cc33565935dbea9e6c66700424f990e4 (diff) |
- remove debugging #ifdef
- protect expensive calls (getXXXbyYYY) with g_resolving_actif check,
that solves a problem with add_ether_byip which was too expensive
due to IP address resolution even when g_resolving_actif was disabled.
I need to clean further.
Do you think that having inexpensive name resolution (i.e. from
hash table only which can be filled by dissectors or file reading)
even if name resolution is disabled (g_resolving_actif = FALSE) is
preferable than having no name resolution at all (which is currently
the case). I may change to the first solution in the future if there
is no objection.
svn path=/trunk/; revision=2249
-rw-r--r-- | resolv.c | 72 |
1 files changed, 35 insertions, 37 deletions
@@ -1,7 +1,7 @@ /* resolv.c * Routines for network object lookup * - * $Id: resolv.c,v 1.26 2000/08/10 20:09:28 deniel Exp $ + * $Id: resolv.c,v 1.27 2000/08/10 22:35:30 deniel Exp $ * * Laurent Deniel <deniel@worldnet.fr> * @@ -211,7 +211,8 @@ static u_char *serv_name_lookup(u_int port, u_int proto) tp->addr = port; tp->next = NULL; - if ((servp = getservbyport(htons(port), serv_proto)) == NULL) { + if (!g_resolving_actif || + (servp = getservbyport(htons(port), serv_proto)) == NULL) { /* unknown port */ sprintf(tp->name, "%d", port); } else { @@ -269,27 +270,29 @@ static u_char *host_name_lookup(u_int addr, gboolean *found) tp->addr = addr; tp->next = NULL; + if (g_resolving_actif) { #ifdef AVOID_DNS_TIMEOUT - /* Quick hack to avoid DNS/YP timeout */ + /* Quick hack to avoid DNS/YP timeout */ - if (!setjmp(hostname_env)) { - signal(SIGALRM, abort_network_query); - alarm(DNS_TIMEOUT); + if (!setjmp(hostname_env)) { + signal(SIGALRM, abort_network_query); + alarm(DNS_TIMEOUT); #endif - hostp = gethostbyaddr((char *)&addr, 4, AF_INET); + hostp = gethostbyaddr((char *)&addr, 4, AF_INET); #ifdef AVOID_DNS_TIMEOUT - alarm(0); + alarm(0); #endif - if (hostp != NULL) { - strncpy(tp->name, hostp->h_name, MAXNAMELEN); - tp->name[MAXNAMELEN-1] = '\0'; - tp->is_dummy_entry = FALSE; - return tp->name; - } + if (hostp != NULL) { + strncpy(tp->name, hostp->h_name, MAXNAMELEN); + tp->name[MAXNAMELEN-1] = '\0'; + tp->is_dummy_entry = FALSE; + return tp->name; + } #ifdef AVOID_DNS_TIMEOUT - } + } #endif + } /* unknown host or DNS timeout */ @@ -306,27 +309,30 @@ static u_char *host_name_lookup6(struct e_in6_addr *addr, gboolean *found) static u_char name[MAXNAMELEN]; #ifdef INET6 struct hostent *hostp; + + if (g_resolving_actif) { #ifdef AVOID_DNS_TIMEOUT - /* Quick hack to avoid DNS/YP timeout */ - - if (!setjmp(hostname_env)) { - signal(SIGALRM, abort_network_query); - alarm(DNS_TIMEOUT); + /* Quick hack to avoid DNS/YP timeout */ + + if (!setjmp(hostname_env)) { + signal(SIGALRM, abort_network_query); + alarm(DNS_TIMEOUT); #endif /* AVOID_DNS_TIMEOUT */ - hostp = gethostbyaddr((char *)addr, sizeof(*addr), AF_INET6); + hostp = gethostbyaddr((char *)addr, sizeof(*addr), AF_INET6); #ifdef AVOID_DNS_TIMEOUT - alarm(0); + alarm(0); #endif - if (hostp != NULL) { - strncpy(name, hostp->h_name, MAXNAMELEN); - name[MAXNAMELEN-1] = '\0'; - *found = TRUE; - return name; - } + if (hostp != NULL) { + strncpy(name, hostp->h_name, MAXNAMELEN); + name[MAXNAMELEN-1] = '\0'; + *found = TRUE; + return name; + } #ifdef AVOID_DNS_TIMEOUT - } + } #endif + } /* unknown host or DNS timeout */ #endif /* INET6 */ @@ -598,10 +604,6 @@ static void initialize_ethers(void) { ether_t *eth; -#ifdef DEBUG_RESOLV - signal(SIGSEGV, SIG_IGN); -#endif - /* Set g_pethers_path here, but don't actually do anything * with it. It's used in get_ethbyname() and get_ethbyaddr() */ @@ -896,10 +898,6 @@ static ipxnet_t *get_ipxnetbyaddr(guint32 addr) static void initialize_ipxnets(void) { -#ifdef DEBUG_RESOLV - signal(SIGSEGV, SIG_IGN); -#endif - /* Set g_pipxnets_path here, but don't actually do anything * with it. It's used in get_ipxnetbyname() and get_ipxnetbyaddr() */ |