[PHP-CVS] com php-src: Merge branch 'PHP-5.4' into PHP-5.5: ext/sockets/multicast.c ext/sockets/multicast.h ext/sockets/sockaddr_conv.c

2013-10-02 Thread Michael Wallner
Commit:2ba39268151549f03140ec3d260cf9489336ec93
Author:Michael Wallner m...@php.net Wed, 2 Oct 2013 15:55:38 +0200
Parents:   60e38b3243577abc80ce6bbcfb0b4125b08acb85 
9209c19f8f7eef807cb457b32d3ab517ff8dc178
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=2ba39268151549f03140ec3d260cf9489336ec93

Log:
Merge branch 'PHP-5.4' into PHP-5.5

* PHP-5.4:
  fix bug #65808the socket_connect() won't work with IPv6 address
  5.4.22-dev now

Conflicts:
configure.in
ext/sockets/sockets.c
main/php_version.h

Bugs:
https://bugs.php.net/65808

Changed paths:
  MM  ext/sockets/multicast.c
  MM  ext/sockets/multicast.h
  MA  ext/sockets/sockaddr_conv.c

diff --cc ext/sockets/multicast.c
index 7466c62,43b6f7d..ecf3a65
--- a/ext/sockets/multicast.c
+++ b/ext/sockets/multicast.c
@@@ -63,309 -73,6 +63,317 @@@ static const char *_php_source_op_to_st
  static int _php_source_op_to_ipv4_op(enum source_op sop);
  #endif
  
++int php_string_to_if_index(const char *val, unsigned *out TSRMLS_DC)
++{
++#if HAVE_IF_NAMETOINDEX
++  unsigned int ind;
++
++  ind = if_nametoindex(val);
++  if (ind == 0) {
++  php_error_docref(NULL TSRMLS_CC, E_WARNING,
++  no interface with name \%s\ could be found, val);
++  return FAILURE;
++  } else {
++  *out = ind;
++  return SUCCESS;
++  }
++#else
++  php_error_docref(NULL TSRMLS_CC, E_WARNING,
++  this platform does not support looking up an interface 
by 
++  name, an integer interface index must be supplied 
instead);
++  return FAILURE;
++#endif
++}
++
 +static int php_get_if_index_from_zval(zval *val, unsigned *out TSRMLS_DC)
 +{
 +  int ret;
 +
 +  if (Z_TYPE_P(val) == IS_LONG) {
 +  if (Z_LVAL_P(val)  0 || Z_LVAL_P(val)  UINT_MAX) {
 +  php_error_docref(NULL TSRMLS_CC, E_WARNING,
 +  the interface index cannot be negative or 
larger than %u;
 +   given %ld, UINT_MAX, Z_LVAL_P(val));
 +  ret = FAILURE;
 +  } else {
 +  *out = Z_LVAL_P(val);
 +  ret = SUCCESS;
 +  }
 +  } else {
- #if HAVE_IF_NAMETOINDEX
-   unsigned int ind;
 +  zval_add_ref(val);
 +  convert_to_string_ex(val);
-   ind = if_nametoindex(Z_STRVAL_P(val));
-   if (ind == 0) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING,
-   no interface with name \%s\ could be found, 
Z_STRVAL_P(val));
-   ret = FAILURE;
-   } else {
-   *out = ind;
-   ret = SUCCESS;
-   }
++  ret = php_string_to_if_index(Z_STRVAL_P(val), out TSRMLS_CC);
 +  zval_ptr_dtor(val);
- #else
-   php_error_docref(NULL TSRMLS_CC, E_WARNING,
-   this platform does not support looking up an 
interface by 
-   name, an integer interface index must be 
supplied instead);
-   ret = FAILURE;
- #endif
 +  }
 +
 +  return ret;
 +}
 +
++
++
 +static int php_get_if_index_from_array(const HashTable *ht, const char *key,
 +  php_socket *sock, unsigned int *if_index TSRMLS_DC)
 +{
 +  zval **val;
 +
 +  if (zend_hash_find(ht, key, strlen(key) + 1, (void **)val) == FAILURE) 
{
 +  *if_index = 0; /* default: 0 */
 +  return SUCCESS;
 +  }
 +
 +  return php_get_if_index_from_zval(*val, if_index TSRMLS_CC);
 +}
 +
 +static int php_get_address_from_array(const HashTable *ht, const char *key,
 +  php_socket *sock, php_sockaddr_storage *ss, socklen_t *ss_len TSRMLS_DC)
 +{
 +  zval **val,
 +   *valcp;
 +
 +  if (zend_hash_find(ht, key, strlen(key) + 1, (void **)val) == FAILURE) 
{
 +  php_error_docref(NULL TSRMLS_CC, E_WARNING, no key \%s\ 
passed in optval, key);
 +  return FAILURE;
 +  }
 +  valcp = *val;
 +  zval_add_ref(valcp);
 +  convert_to_string_ex(val);
 +  if (!php_set_inet46_addr(ss, ss_len, Z_STRVAL_P(valcp), sock 
TSRMLS_CC)) {
 +  zval_ptr_dtor(valcp);
 +  return FAILURE;
 +  }
 +  zval_ptr_dtor(valcp);
 +  return SUCCESS;
 +}
 +
 +static int php_do_mcast_opt(php_socket *php_sock, int level, int optname, 
zval **arg4 TSRMLS_DC)
 +{
 +  HashTable   *opt_ht;
 +  unsigned intif_index;
 +  int retval;
 +  int (*mcast_req_fun)(php_socket *, int, struct sockaddr *, socklen_t,
 +  unsigned TSRMLS_DC);
 +#ifdef HAS_MCAST_EXT
 +  int (*mcast_sreq_fun)(php_socket *, int, struct sockaddr *, socklen_t,
 +  

Re: [PHP-CVS] com php-src: Merge branch 'PHP-5.4' into PHP-5.5: ext/sockets/multicast.c ext/sockets/multicast.h ext/sockets/sockaddr_conv.c

2013-10-02 Thread Michael Wallner
Gustavo, feel free to improve the aesthetics of my merge.
I was quite surprised by the amount of difference of the source layout :)

On 2 October 2013 15:55, Michael Wallner m...@php.net wrote:
 Commit:2ba39268151549f03140ec3d260cf9489336ec93
 Author:Michael Wallner m...@php.net Wed, 2 Oct 2013 15:55:38 
 +0200
 Parents:   60e38b3243577abc80ce6bbcfb0b4125b08acb85 
 9209c19f8f7eef807cb457b32d3ab517ff8dc178
 Branches:  PHP-5.5 master

 Link:   
 http://git.php.net/?p=php-src.git;a=commitdiff;h=2ba39268151549f03140ec3d260cf9489336ec93

 Log:
 Merge branch 'PHP-5.4' into PHP-5.5

 * PHP-5.4:
   fix bug #65808the socket_connect() won't work with IPv6 address
   5.4.22-dev now

 Conflicts:
 configure.in
 ext/sockets/sockets.c
 main/php_version.h

 Bugs:
 https://bugs.php.net/65808

 Changed paths:
   MM  ext/sockets/multicast.c
   MM  ext/sockets/multicast.h
   MA  ext/sockets/sockaddr_conv.c


 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
Regards,
Mike

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php