Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add net_get_interfaces() #2935

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -962,6 +962,9 @@ ZEND_BEGIN_ARG_INFO(arginfo_gethostname, 0)
ZEND_END_ARG_INFO()
#endif

ZEND_BEGIN_ARG_INFO(arginfo_net_get_interfaces, 0)
ZEND_END_ARG_INFO()

#if defined(PHP_WIN32) || HAVE_DNS_SEARCH_FUNC
ZEND_BEGIN_ARG_INFO_EX(arginfo_dns_check_record, 0, 0, 1)
ZEND_ARG_INFO(0, host)
@@ -2955,7 +2958,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */
PHP_FE(fmod, arginfo_fmod)
PHP_FE(intdiv, arginfo_intdiv)
#ifdef HAVE_INET_NTOP
PHP_RAW_NAMED_FE(inet_ntop, php_inet_ntop, arginfo_inet_ntop)
PHP_RAW_NAMED_FE(inet_ntop, zif_inet_ntop, arginfo_inet_ntop)
#endif
#ifdef HAVE_INET_PTON
PHP_RAW_NAMED_FE(inet_pton, php_inet_pton, arginfo_inet_pton)
@@ -3060,6 +3063,10 @@ const zend_function_entry basic_functions[] = { /* {{{ */
PHP_FE(gethostname, arginfo_gethostname)
#endif

#if defined(PHP_WIN32) || HAVE_GETIFADDRS
PHP_FE(net_get_interfaces, arginfo_net_get_interfaces)
#endif

#if defined(PHP_WIN32) || HAVE_DNS_SEARCH_FUNC

PHP_FE(dns_check_record, arginfo_dns_check_record)
@@ -3897,7 +3904,7 @@ PHP_FUNCTION(constant)
#ifdef HAVE_INET_NTOP
/* {{{ proto string inet_ntop(string in_addr)
Converts a packed inet address to a human readable IP address string */
PHP_NAMED_FUNCTION(php_inet_ntop)
PHP_NAMED_FUNCTION(zif_inet_ntop)
{
char *address;
size_t address_len;
@@ -56,7 +56,7 @@ PHP_FUNCTION(time_sleep_until);
#endif
PHP_FUNCTION(flush);
#ifdef HAVE_INET_NTOP
PHP_NAMED_FUNCTION(php_inet_ntop);
PHP_NAMED_FUNCTION(zif_inet_ntop);
#endif
#ifdef HAVE_INET_PTON
PHP_NAMED_FUNCTION(php_inet_pton);
@@ -126,6 +126,8 @@ PHP_FUNCTION(sys_getloadavg);
PHP_FUNCTION(is_uploaded_file);
PHP_FUNCTION(move_uploaded_file);

PHP_FUNCTION(net_get_interfaces);

/* From the INI parser */
PHP_FUNCTION(parse_ini_file);
PHP_FUNCTION(parse_ini_string);
@@ -448,6 +448,26 @@ if test "$PHP_PASSWORD_ARGON2" != "no"; then
])
fi

dnl
dnl net_get_interfaces
dnl
AC_CHECK_HEADERS([net/if.h netdb.h])
AC_MSG_CHECKING([for usable getifaddrs])
AC_TRY_LINK([
#include <ifaddrs.h>
],[
struct ifaddrs *interfaces;
if (!getifaddrs(&interfaces)) {
freeifaddrs(interfaces);
}
], [ac_have_getifaddrs=yes], [ac_have_getifaddrs=no])
if test "$ac_have_getifaddrs" = "yes" ; then
AC_DEFINE(HAVE_GETIFADDRS, 1, [whether getifaddrs is present and usable])
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi

dnl
dnl Setup extension sources
dnl
@@ -462,7 +482,7 @@ PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32.
http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \
var_unserializer.c ftok.c sha1.c user_filters.c uuencode.c \
filters.c proc_open.c streamsfuncs.c http.c password.c \
random.c,,,
random.c net.c,,,
-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)

PHP_ADD_MAKEFILE_FRAGMENT
@@ -22,13 +22,15 @@ AC_DEFINE("PHP_USE_PHP_CRYPT_R", 1);

CHECK_HEADER_ADD_INCLUDE("timelib_config.h", "CFLAGS_STANDARD", "ext/date/lib");

ADD_FLAG("LIBS_STANDARD", "iphlpapi.lib");

This comment has been minimized.

Copy link
@KalleZ

KalleZ Nov 24, 2017

Member

@weltling tho we only use iphlpapi here, wouldn't you think its better put in toolset_setup_common_libs() in win32/confutils.js, ext/standard can't be disabled anyway

This comment has been minimized.

Copy link
@weltling

weltling Nov 24, 2017

Contributor

@KalleZ would work as well, but shouldn't be necessary. $(LIBS) is put for every binary unit, whereby iphlpapi.lib is only required for standard. The linker will ignore it anyway, if there are no symbols used.

This comment has been minimized.

Copy link
@sgolemon

sgolemon Nov 24, 2017

Author Contributor

It sounds like six of one, half a dozen of the other. I honestly don't mind either way, but I read @weltling's comment (and @KalleZ's 👍) as "don't bother moving it. Correct me if that's wrong.


EXTENSION("standard", "array.c base64.c basic_functions.c browscap.c \
crc32.c crypt.c crypt_freesec.c crypt_blowfish.c crypt_sha256.c \
crypt_sha512.c php_crypt_r.c \
cyr_convert.c datetime.c dir.c dl.c dns.c dns_win32.c exec.c \
file.c filestat.c formatted_print.c fsock.c head.c html.c image.c \
info.c iptc.c lcg.c link_win32.c mail.c math.c md5.c metaphone.c microtime.c \
pack.c pageinfo.c quot_print.c rand.c mt_rand.c soundex.c \
net.c pack.c pageinfo.c quot_print.c rand.c mt_rand.c soundex.c \
string.c scanf.c syslog.c type.c uniqid.c url.c var.c \
versioning.c assert.c strnatcmp.c levenshtein.c incomplete_class.c \
url_scanner_ex.c ftp_fopen_wrapper.c http_fopen_wrapper.c \
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.