mirror of
https://github.com/ipxe/ipxe
synced 2025-12-26 01:22:37 +03:00
Add debugging for CNAME records.
Allow routines to be called by nmb.c
This commit is contained in:
@@ -2,8 +2,9 @@
|
|||||||
#define DNS_RESOLVER_H
|
#define DNS_RESOLVER_H
|
||||||
|
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include "nic.h"
|
|
||||||
#include "in.h"
|
#include "in.h"
|
||||||
|
#include "ip.h"
|
||||||
|
#include "udp.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
@@ -76,6 +77,16 @@ struct dns_rr_info_a {
|
|||||||
struct dns_rr_info_cname {
|
struct dns_rr_info_cname {
|
||||||
struct dns_rr_info;
|
struct dns_rr_info;
|
||||||
char cname[0];
|
char cname[0];
|
||||||
};
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Functions in dns.c (used by nmb.c)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
extern struct dns_header * dns_query ( struct dns_query *query,
|
||||||
|
unsigned int query_len,
|
||||||
|
struct sockaddr_in *nameserver );
|
||||||
|
extern struct dns_rr_info * dns_find_rr ( struct dns_query *query,
|
||||||
|
struct dns_header *reply );
|
||||||
|
|
||||||
#endif /* DNS_RESOLVER_H */
|
#endif /* DNS_RESOLVER_H */
|
||||||
|
|||||||
@@ -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.
|
* 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_rr_info * dns_find_rr ( struct dns_query *query,
|
||||||
struct dns_header *reply ) {
|
struct dns_header *reply ) {
|
||||||
int i, cmp;
|
int i, cmp;
|
||||||
const char *p = ( ( char * ) reply ) + sizeof ( struct dns_header );
|
const char *p = ( ( char * ) reply ) + sizeof ( struct dns_header );
|
||||||
|
|
||||||
@@ -192,6 +192,23 @@ static inline char * dns_make_name ( char *dest, const char *name ) {
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
* Decompress a DNS name.
|
||||||
*
|
*
|
||||||
@@ -281,10 +298,15 @@ static int dns_resolv ( struct in_addr *addr, const char *name ) {
|
|||||||
( struct dns_rr_info_cname * ) rr_info;
|
( struct dns_rr_info_cname * ) rr_info;
|
||||||
char *cname = rr_info_cname->cname;
|
char *cname = rr_info_cname->cname;
|
||||||
|
|
||||||
DBG ( "DNS found CNAME\n" );
|
|
||||||
query_info = ( void * )
|
query_info = ( void * )
|
||||||
dns_decompress_name ( query.payload,
|
dns_decompress_name ( query.payload,
|
||||||
cname, reply );
|
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->qtype = htons ( DNS_TYPE_A );
|
||||||
query_info->qclass = htons ( DNS_CLASS_IN );
|
query_info->qclass = htons ( DNS_CLASS_IN );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user