- improve/fix add_host_name

- add hostname/IP in host hashtable from DNS answers
  (currently only type A RR).

svn path=/trunk/; revision=2228
This commit is contained in:
Laurent Deniel 2000-08-08 16:21:24 +00:00
parent cedac6e3f1
commit 58bdaa850e
2 changed files with 11 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/* packet-dns.c
* Routines for DNS packet disassembly
*
* $Id: packet-dns.c,v 1.49 2000/08/07 03:20:28 guy Exp $
* $Id: packet-dns.c,v 1.50 2000/08/08 16:21:23 deniel Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -737,6 +737,11 @@ dissect_dns_answer(const u_char *pd, int offset, int dns_data_offset,
proto_tree_add_text(rr_tree, NullTVB, cur_offset, 4, "Addr: %s",
ip_to_str((guint8 *)dptr));
}
if (class == 1) {
guint32 addr;
memcpy(&addr, dptr, sizeof(addr));
add_host_name(addr, name);
}
break;
case T_NS:

View File

@ -1,7 +1,7 @@
/* resolv.c
* Routines for network object lookup
*
* $Id: resolv.c,v 1.24 2000/07/14 07:11:53 guy Exp $
* $Id: resolv.c,v 1.25 2000/08/08 16:21:24 deniel Exp $
*
* Laurent Deniel <deniel@worldnet.fr>
*
@ -1038,6 +1038,10 @@ extern void add_host_name(u_int addr, u_char *name)
(hashname_t *)g_malloc(sizeof(hashname_t));
} else {
while(1) {
if (tp->addr == addr && strcmp(tp->name, name) == 0) {
/* address already known */
return;
}
if (tp->next == NULL) {
tp->next = (hashname_t *)g_malloc(sizeof(hashname_t));
tp = tp->next;