X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-ares;a=blobdiff_plain;f=php_ares.c;h=680c4d9c8cf9cead446a1bb4155f7e7fc8679e48;hp=050b161f533e531fc8d4c6b5c5c67db5e57b0683;hb=9aea024d8b1de196394cf6b5dc868628d92154b4;hpb=e4dbafb68e9de85db0a228abca4d0bd30bf87499 diff --git a/php_ares.c b/php_ares.c index 050b161..680c4d9 100644 --- a/php_ares.c +++ b/php_ares.c @@ -589,6 +589,17 @@ local php_ares_options *php_ares_options_ctor(php_ares_options *options, HashTab options->flags |= ARES_OPT_LOOKUPS; options->strct.lookups = estrdup(Z_STRVAL_PP(opt)); } +#ifdef ARES_OPT_ROTATE + if ((SUCCESS == zend_hash_find(ht, "rotate", sizeof("rotate"), (void *) &opt)) && i_zend_is_true(*opt)) { + options->flags |= ARES_OPT_ROTATE; + } +#endif +#ifdef ARES_OPT_EDNSPSZ + if ((SUCCESS == zend_hash_find(ht, "ednspsz", sizeof("ednspsz"), (void *) &opt)) && is_numeric(opt, &lval)) { + options->flags |= ARES_OPT_EDNSPSZ; + options->strct.ednspsz = lval; + } +#endif } return options; @@ -1082,7 +1093,7 @@ static PHP_FUNCTION(ares_init) php_ares *ares = NULL; int err; - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!", &opt_array)) { + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a/!", &opt_array)) { RETURN_FALSE; } @@ -1102,6 +1113,65 @@ static PHP_FUNCTION(ares_init) } /* }}} */ +#ifdef HAVE_ARES_SET_LOCAL_DEV +/* {{{ proto void ares_set_local_dev(resource ares, string dev) + Set the local interface name to bind to. */ +static PHP_FUNCTION(ares_set_local_dev) +{ + zval *rsrc; + char *dev_str = NULL; + int dev_len = 0; + php_ares *ares; + + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!", &rsrc, &dev_str, &dev_len)) { + RETURN_FALSE; + } + ZEND_FETCH_RESOURCE(ares, php_ares *, &rsrc, -1, PHP_ARES_LE_NAME, le_ares); + + ares_set_local_dev(ares->channel, dev_str); +} +#endif + +#ifdef HAVE_ARES_SET_LOCAL_IP4 +/* {{{ proto void ares_set_local_ip4(resource ares, int addr) + Set the local IPv4 address to bind to. */ +static PHP_FUNCTION(ares_set_local_ip4) +{ + zval *rsrc; + long ip4_num; + php_ares *ares; + + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &rsrc, &ip4_num)) { + RETURN_FALSE; + } + ZEND_FETCH_RESOURCE(ares, php_ares *, &rsrc, -1, PHP_ARES_LE_NAME, le_ares); + + ares_set_local_ip4(ares->channel, (unsigned int) ip4_num); +} +#endif + +#ifdef HAVE_ARES_SET_LOCAL_IP6 +/* {{{ proto void ares_set_local_ip6(resource ares, string addr128bit) + Set the local IPv6 address to bind to. */ +static PHP_FUNCTION(ares_set_local_ip6) +{ + zval *rsrc; + char *ip6_str; + int ip6_len; + php_ares *ares; + + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &rsrc, &ip6_str, &ip6_len)) { + RETURN_FALSE; + } + if (16 != ip6_len) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Binary IPv6 address string must be exactly 16 bytes long"); + } + ZEND_FETCH_RESOURCE(ares, php_ares *, &rsrc, -1, PHP_ARES_LE_NAME, le_ares); + + ares_set_local_ip6(ares->channel, (unsigned char *) ip6_str); +} +#endif + /* {{{ proto void ares_destroy(resource ares) Destroy the ares handle */ static PHP_FUNCTION(ares_destroy)