summaryrefslogtreecommitdiff
path: root/ext/sockets/multicast.c
diff options
context:
space:
mode:
authorMichael Wallner <mike@php.net>2013-10-02 15:55:38 +0200
committerMichael Wallner <mike@php.net>2013-10-02 15:55:38 +0200
commit2ba39268151549f03140ec3d260cf9489336ec93 (patch)
tree8e17ec062b521a83525ee9d39304fdfe94ef72aa /ext/sockets/multicast.c
parent60e38b3243577abc80ce6bbcfb0b4125b08acb85 (diff)
parent9209c19f8f7eef807cb457b32d3ab517ff8dc178 (diff)
downloadphp-git-2ba39268151549f03140ec3d260cf9489336ec93.tar.gz
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: fix bug #65808 the socket_connect() won't work with IPv6 address 5.4.22-dev now Conflicts: configure.in ext/sockets/sockets.c main/php_version.h
Diffstat (limited to 'ext/sockets/multicast.c')
-rw-r--r--ext/sockets/multicast.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/ext/sockets/multicast.c b/ext/sockets/multicast.c
index 7466c6266e..ecf3a65a32 100644
--- a/ext/sockets/multicast.c
+++ b/ext/sockets/multicast.c
@@ -63,6 +63,28 @@ static const char *_php_source_op_to_string(enum source_op sop);
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;
@@ -78,31 +100,17 @@ static int php_get_if_index_from_zval(zval *val, unsigned *out TSRMLS_DC)
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)
{