From ee4d2739f11465ba6a7d817f9b988da5bfe86e2c Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Wed, 1 Dec 2010 17:22:56 +0100 Subject: Make the IPA installer IPv6 friendly Notable changes include: * parse AAAA records in dnsclient * also ask for AAAA records when verifying FQDN * do not use functions that are not IPv6 aware - notably socket.gethostbyname() The complete list of functions was taken from http://www.akkadia.org/drepper/userapi-ipv6.html section "Interface Checklist" --- ipapython/dnsclient.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'ipapython') diff --git a/ipapython/dnsclient.py b/ipapython/dnsclient.py index 58d93d85..6b02a5e3 100644 --- a/ipapython/dnsclient.py +++ b/ipapython/dnsclient.py @@ -37,6 +37,7 @@ DNS_T_PTR = 12 DNS_T_HINFO = 13 DNS_T_MX = 15 DNS_T_TXT = 16 +DNS_T_AAAA = 28 DNS_T_SRV = 33 DNS_T_ANY = 255 @@ -127,6 +128,10 @@ class DNSRData: # u_int32_t address; #} dns_rr_a_t; # +#typedef struct dns_rr_aaaa { +# unsigned char address[16]; +#} dns_rr_aaaa_t; +# #typedef struct dns_rr_cname { # const char *cname; #} dns_rr_cname_t; @@ -239,6 +244,18 @@ def dnsParseA(data, base): print "A = %d.%d.%d.%d." % (ord(data[0]), ord(data[1]), ord(data[2]), ord(data[3])) return rdata +def dnsParseAAAA(data, base): + rdata = DNSRData() + if len(data) < 16: + rdata.address = 0 + return None + + rdata.address = list(struct.unpack('!16B', data)) + if DEBUG_DNSCLIENT: + print socket.inet_ntop(socket.AF_INET6, + struct.pack('!16B', *rdata.address)) + return rdata + def dnsParseText(data): if len(data) < 1: return ("", None) @@ -413,7 +430,7 @@ def dnsParseResults(results): DNS_T_NULL: dnsParseNULL, DNS_T_WKS: dnsParseWKS, DNS_T_PTR: dnsParsePTR, DNS_T_HINFO: dnsParseHINFO, DNS_T_MX: dnsParseMX, DNS_T_TXT: dnsParseTXT, - DNS_T_SRV: dnsParseSRV} + DNS_T_AAAA : dnsParseAAAA, DNS_T_SRV: dnsParseSRV} if not rr.dns_type in fmap: if DEBUG_DNSCLIENT: -- cgit