pollita Fri Apr 4 21:42:12 2003 EDT Modified files: /php4/main/streams xp_socket.c Log: Add IPv6 support to stream_socket_client/server() Index: php4/main/streams/xp_socket.c diff -u php4/main/streams/xp_socket.c:1.9 php4/main/streams/xp_socket.c:1.10 --- php4/main/streams/xp_socket.c:1.9 Tue Mar 18 10:15:10 2003 +++ php4/main/streams/xp_socket.c Fri Apr 4 21:42:12 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xp_socket.c,v 1.9 2003/03/18 15:15:10 wez Exp $ */ +/* $Id: xp_socket.c,v 1.10 2003/04/05 02:42:12 pollita Exp $ */ #include "php.h" #include "ext/standard/file.h" @@ -380,9 +380,24 @@ static inline char *parse_ip_address(php_stream_xport_param *xparam, int *portno TSRMLS_DC) { char *colon; - char *host = NULL; + char *p, *host = NULL; - colon = memchr(xparam->inputs.name, ':', xparam->inputs.namelen); +#ifdef HAVE_IPV6 + if (*(xparam->inputs.name) == '[') { + /* IPV6 notation to specify raw address with port (i.e. [fe80::1]:80) */ + p = memchr(xparam->inputs.name + 1, ']', xparam->inputs.namelen - 2); + if (!p || *(p + 1) != ':') { + if (xparam->want_errortext) { + spprintf(&xparam->outputs.error_text, 0, "Failed to parse IPv6 address \"%s\"", xparam->inputs.name); + } + return NULL; + } + *portno = atoi(p + 2); + return estrndup(xparam->inputs.name + 1, p - xparam->inputs.name - 1); + } +#endif + + colon = memchr(xparam->inputs.name, ':', xparam->inputs.namelen - 1); if (colon) { *portno = atoi(colon + 1); host = estrndup(xparam->inputs.name, colon - xparam->inputs.name);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php