summaryrefslogtreecommitdiff
path: root/ext/sockets/multicast.c
diff options
context:
space:
mode:
authorRasmus Lerdorf <rasmus@php.net>2013-10-31 16:23:38 -0700
committerRasmus Lerdorf <rasmus@php.net>2013-10-31 16:23:38 -0700
commitbb42643ae02c6bb522db169748d29e4be6695b1e (patch)
tree25b73836901583f8e42f5a9c6fe235f88efe7d8e /ext/sockets/multicast.c
parent6b68f44e6b46dffd7fe029eca7afc37f1fa57347 (diff)
parent55ee543e2f73c45c8fa2c51ebef9820a610f70b4 (diff)
downloadphp-git-bb42643ae02c6bb522db169748d29e4be6695b1e.tar.gz
Merge branch 'PHP-5.5' of git.php.net:php-src into PHP-5.5
* 'PHP-5.5' of git.php.net:php-src: (107 commits) Typo fix: umknown -> unknown add news entry about FPM backlog change Fix bug #66008 updated libs_versions.txt Update NEWS Update NEWS Fixed Bug 64760 var_export() does not use full precision for floating-point numbers add bundled libzip LICENSE, as required by BSD License terms - Updated to version 2013.8 (2013h) Use zval* instead of zval** Increased limit for opcache.max_accelerated_files to 1,000,000. (Chris) Improved performance of array_merge() by eliminating useless copying Improved performance of func_get_args() by eliminating useless copying Link to more readmes increase backlog to the highest value everywhere Update NEWS Fixed bug #65950 Field name truncation if the field name is bigger than 32 characters - Updated to version 2013.7 (2013g) Increment version number, since this will be 5.5.6. Added Zend Debugger to the note about the load order (by trash4you at online dot de) ...
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)
{