pajoye Mon, 10 Aug 2009 08:05:11 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=286990
Log: - fix and improve dns' AAAA support on windows Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/standard/dns_win32.c U php/php-src/trunk/ext/standard/dns_win32.c Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2009-08-10 07:23:14 UTC (rev 286989) +++ php/php-src/branches/PHP_5_3/NEWS 2009-08-10 08:05:11 UTC (rev 286990) @@ -1,6 +1,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2009, PHP 5.3.1 +- Improve dns_get_record AAAA support on windows. Always available when IPv6 is + support is installed, format is now the same than on unix. (Pierre) + - Fixed spl_autoload_unregister/spl_autoload_functions wrt. Closures and Functors. (Christian Seiler) - Fixed open_basedir circumvention for mail.log. (Maksymilian Arciemowicz, Modified: php/php-src/branches/PHP_5_3/ext/standard/dns_win32.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/dns_win32.c 2009-08-10 07:23:14 UTC (rev 286989) +++ php/php-src/branches/PHP_5_3/ext/standard/dns_win32.c 2009-08-10 08:05:11 UTC (rev 286990) @@ -132,7 +132,6 @@ } /* }}} */ -#if 1 /* {{{ php_parserr */ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, zval **subarray) { @@ -237,20 +236,51 @@ } break; - case DNS_TYPE_AAAA: -#if _WIN32_WINNT >= 0x0600 { - LPSTR str[MAXHOSTNAMELEN]; DNS_AAAA_DATA *data_aaaa = &pRec->Data.AAAA; + char buf[sizeof("AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA")]; + char *tp = buf; + int i; + unsigned short out[8]; + int have_v6_break = 0, in_v6_break = 0; + + for (i = 0; i < 4; ++i) { + DWORD chunk = data_aaaa->Ip6Address.IP6Dword[i]; + out[i * 2] = htons(LOWORD(chunk)); + out[i * 2 + 1] = htons(HIWORD(chunk)); + } + + for(i=0; i < 8; i++) { + if (out[i] != 0) { + if (tp > (u_char *)buf) { + in_v6_break = 0; + tp[0] = ':'; + tp++; + } + tp += sprintf((char*)tp,"%x", out[i]); + } else { + if (!have_v6_break) { + have_v6_break = 1; + in_v6_break = 1; + tp[0] = ':'; + tp++; + } else if (!in_v6_break) { + tp[0] = ':'; + tp++; + tp[0] = '0'; + tp++; + } + } + } + add_assoc_string(*subarray, "type", "AAAA", 1); - add_assoc_string(*subarray, "ipv6", RtlIpv6AddressToString(data_aaaa->Ip6Address, str), 1); + add_assoc_string(*subarray, "ipv6", buf, 1); } -#endif break; #if 0 - /* Not supported yet */ + /* Won't be implemented. A6 is deprecated. (Pierre) */ case DNS_TYPE_A6: break; #endif @@ -291,7 +321,6 @@ add_assoc_long(*subarray, "ttl", ttl); } /* }}} */ -#endif /* {{{ proto array|false dns_get_record(string hostname [, int type[, array authns, array addtl]]) Get any Resource Record corresponding to a given Internet host name */ Modified: php/php-src/trunk/ext/standard/dns_win32.c =================================================================== --- php/php-src/trunk/ext/standard/dns_win32.c 2009-08-10 07:23:14 UTC (rev 286989) +++ php/php-src/trunk/ext/standard/dns_win32.c 2009-08-10 08:05:11 UTC (rev 286990) @@ -132,7 +132,6 @@ } /* }}} */ -#if 1 /* {{{ php_parserr */ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, zval **subarray TSRMLS_DC) { @@ -237,20 +236,51 @@ } break; - case DNS_TYPE_AAAA: -#if _WIN32_WINNT >= 0x0600 { - LPSTR str[MAXHOSTNAMELEN]; DNS_AAAA_DATA *data_aaaa = &pRec->Data.AAAA; - add_ascii_assoc_rt_string(*subarray, "type", "AAAA", ZSTR_DUPLICATE); - add_ascii_assoc_rt_string(*subarray, "ipv6", RtlIpv6AddressToString(data_aaaa->Ip6Address, str), ZSTR_DUPLICATE); + char buf[sizeof("AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA")]; + char *tp = buf; + int i; + unsigned short out[8]; + int have_v6_break = 0, in_v6_break = 0; + + for (i = 0; i < 4; ++i) { + DWORD chunk = data_aaaa->Ip6Address.IP6Dword[i]; + out[i * 2] = htons(LOWORD(chunk)); + out[i * 2 + 1] = htons(HIWORD(chunk)); + } + + for(i=0; i < 8; i++) { + if (out[i] != 0) { + if (tp > (u_char *)buf) { + in_v6_break = 0; + tp[0] = ':'; + tp++; + } + tp += sprintf((char*)tp,"%x", out[i]); + } else { + if (!have_v6_break) { + have_v6_break = 1; + in_v6_break = 1; + tp[0] = ':'; + tp++; + } else if (!in_v6_break) { + tp[0] = ':'; + tp++; + tp[0] = '0'; + tp++; + } + } + } + + add_assoc_string(*subarray, "type", "AAAA", 1); + add_assoc_string(*subarray, "ipv6", buf, 1); } -#endif break; #if 0 - /* Not supported yet */ + /* Won't be implemented. A6 is deprecated. (Pierre) */ case DNS_TYPE_A6: break; #endif @@ -291,7 +321,6 @@ add_ascii_assoc_long(*subarray, "ttl", ttl); } /* }}} */ -#endif /* {{{ proto array|false dns_get_record(string hostname [, int type[, array authns, array addtl]]) Get any Resource Record corresponding to a given Internet host name */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php