]> granicus.if.org Git - php/commitdiff
list interfaces/adding just "binary" state status.
authorDavid Carlier <devnexen@gmail.com>
Sun, 27 Jan 2019 21:59:28 +0000 (21:59 +0000)
committerPeter Kokot <peterkokot@gmail.com>
Sat, 11 May 2019 18:29:09 +0000 (20:29 +0200)
ext/standard/net.c

index 3bb3d09e2f5d7bac148aea962e822c1e173e79bc..6bec7f06b556c20c8a644e398493b618e86c7225 100644 (file)
@@ -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);