diff options
author | Michael Brown | 2005-05-01 13:30:26 +0200 |
---|---|---|
committer | Michael Brown | 2005-05-01 13:30:26 +0200 |
commit | bcedad47088a004ea860f7f0edfd21cea91a0914 (patch) | |
tree | bee1208ee262ce88ee4c0ef6c3a23d67eba58178 /src/proto | |
parent | NMB packets are so similar to DNS packets; we may as well add NMB as a (diff) | |
download | ipxe-bcedad47088a004ea860f7f0edfd21cea91a0914.tar.gz ipxe-bcedad47088a004ea860f7f0edfd21cea91a0914.tar.xz ipxe-bcedad47088a004ea860f7f0edfd21cea91a0914.zip |
Add debugging for CNAME records.
Allow routines to be called by nmb.c
Diffstat (limited to 'src/proto')
-rw-r--r-- | src/proto/dns.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/proto/dns.c b/src/proto/dns.c index 347df9cc..b2f258bf 100644 --- a/src/proto/dns.c +++ b/src/proto/dns.c @@ -145,8 +145,8 @@ static inline const char * dns_skip_name ( const char *name ) { * query. Returns a pointer to the RR, or NULL if no answer found. * */ -static struct dns_rr_info * dns_find_rr ( struct dns_query *query, - struct dns_header *reply ) { +struct dns_rr_info * dns_find_rr ( struct dns_query *query, + struct dns_header *reply ) { int i, cmp; const char *p = ( ( char * ) reply ) + sizeof ( struct dns_header ); @@ -193,6 +193,23 @@ static inline char * dns_make_name ( char *dest, const char *name ) { } /* + * Produce a printable version of a DNS name. Used only for debugging. + * + */ +static inline char * dns_unmake_name ( char *name ) { + char *p; + unsigned int len; + + p = name; + while ( ( len = *p ) ) { + *(p++) = '.'; + p += len; + } + + return name + 1; +} + +/* * Decompress a DNS name. * * Returns a pointer to the character following the decompressed DNS @@ -281,10 +298,15 @@ static int dns_resolv ( struct in_addr *addr, const char *name ) { ( struct dns_rr_info_cname * ) rr_info; char *cname = rr_info_cname->cname; - DBG ( "DNS found CNAME\n" ); query_info = ( void * ) dns_decompress_name ( query.payload, cname, reply ); + DBG ( "DNS found CNAME %s\n", + dns_unmake_name ( query.payload ) ); + DBG ( "", /* Reconstruct name */ + dns_make_name ( query.payload, + query.payload + 1 ) ); + query_info->qtype = htons ( DNS_TYPE_A ); query_info->qclass = htons ( DNS_CLASS_IN ); |