From 1f3f54f58625d9a72671f6293ae6f0cb758161a1 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 27 Jan 2019 21:59:28 +0000 Subject: [PATCH] list interfaces/adding just "binary" state status. --- ext/standard/net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/standard/net.c b/ext/standard/net.c index 3bb3d09e2f..6bec7f06b5 100644 --- a/ext/standard/net.c +++ b/ext/standard/net.c @@ -252,6 +252,8 @@ PHP_FUNCTION(net_get_interfaces) { } add_assoc_zval(&iface, "unicast", &unicast); + add_assoc_bool(&iface, "up", (p->OperStatus == IfOperStatusUp)); + add_assoc_zval(return_value, p->AdapterName, &iface); } @@ -271,7 +273,7 @@ PHP_FUNCTION(net_get_interfaces) { array_init(return_value); for (p = addrs; p; p = p->ifa_next) { zval *iface = zend_hash_str_find(Z_ARR_P(return_value), p->ifa_name, strlen(p->ifa_name)); - zval *unicast; + zval *unicast, *status; if (!iface) { zval newif; @@ -291,6 +293,10 @@ PHP_FUNCTION(net_get_interfaces) { p->ifa_addr, p->ifa_netmask, (p->ifa_flags & IFF_BROADCAST) ? p->ifa_broadaddr : NULL, (p->ifa_flags & IFF_POINTOPOINT) ? p->ifa_dstaddr : NULL); + status = zend_hash_str_find(Z_ARR_P(iface), "up", sizeof("up") - 1); + if (!status) { + add_assoc_bool(iface, "up", ((p->ifa_flags & IFF_UP) != 0)); + } } freeifaddrs(addrs); -- 2.40.0