* add libvirt_network_get_uuid_string
* add libvirt_network_get_uuid
* add libvirt_network_get_name
Those are useful when working with network resources returned from
libvirt_list_all_networks.
---
src/libvirt-php.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/libvirt-php.h | 3 ++
2 files changed, 90 insertions(+)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index fa02457..bfc9b7d 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -721,6 +721,9 @@ static zend_function_entry libvirt_functions[] = {
PHP_FE(libvirt_network_get_information, arginfo_libvirt_conn)
PHP_FE(libvirt_network_get_active, arginfo_libvirt_conn)
PHP_FE(libvirt_network_set_active, arginfo_libvirt_conn_flags)
+ PHP_FE(libvirt_network_get_uuid_string, arginfo_libvirt_conn)
+ PHP_FE(libvirt_network_get_uuid, arginfo_libvirt_conn)
+ PHP_FE(libvirt_network_get_name, arginfo_libvirt_conn)
/* Node functions */
PHP_FE(libvirt_node_get_info, arginfo_libvirt_conn)
PHP_FE(libvirt_node_get_cpu_stats, arginfo_libvirt_conn_optcpunr)
@@ -9915,6 +9918,90 @@ PHP_FUNCTION(libvirt_network_get_xml_desc)
}
/*
+ * Function name: libvirt_network_get_uuid_string
+ * Since version: 0.5.3
+ * Description: Function is used to get network's UUID in string format
+ * Arguments: @res [resource]: libvirt network resource
+ * Returns: network UUID string or FALSE on failure
+ */
+PHP_FUNCTION(libvirt_network_get_uuid_string)
+{
+ php_libvirt_network *network = NULL;
+ zval *znetwork;
+ char *uuid = NULL;
+ int ret = -1;
+
+ GET_NETWORK_FROM_ARGS("r", &znetwork);
+
+ uuid = (char *) emalloc(VIR_UUID_STRING_BUFLEN);
+ ret = virNetworkGetUUIDString(network->network, uuid);
+
+ DPRINTF("%s: virNetworkGetUUIDString(%p) returned %d (%s)\n", PHPFUNC,
+ network->network, ret, uuid);
+
+ if (ret != 0)
+ RETURN_FALSE;
+
+ VIRT_RETURN_STRING(uuid);
+ efree(uuid);
+}
+
+/*
+ * Function name: libvirt_network_get_uuid
+ * Since version: 0.5.3
+ * Descirption: Function is used to get network's UUID in binary format
+ * Arguments: @res [resource]: libvirt netowrk resource
+ * Returns: network UUID in binary format or FALSE on failure
+ */
+PHP_FUNCTION(libvirt_network_get_uuid)
+{
+ php_libvirt_network *network = NULL;
+ zval *znetwork;
+ char *uuid = NULL;
+ int ret = -1;
+
+ GET_NETWORK_FROM_ARGS("r", &znetwork);
+
+ uuid = (char *) emalloc(VIR_UUID_BUFLEN);
+ ret = virNetworkGetUUID(network->network, (unsigned char *)uuid);
+
+ DPRINTF("%s: virNetworkGetUUID(%p, %p) returned %d\n", PHPFUNC,
+ network->network, uuid, ret);
+
+ if (ret != 0)
+ RETURN_FALSE;
+
+ VIRT_RETVAL_STRING(uuid);
+ efree(uuid);
+}
+
+/*
+ * Function name: libvirt_network_get_name
+ * Since version: 0.5.3
+ * Description: Function is used to get network's name
+ * Arguments: @res [resource]: libvirt network resource
+ * Returns: network name string or FALSE on failure
+ */
+PHP_FUNCTION(libvirt_network_get_name)
+{
+ php_libvirt_network *network = NULL;
+ zval *znetwork;
+ const char *name = NULL;
+
+ GET_NETWORK_FROM_ARGS("r", &znetwork);
+ name = virNetworkGetName(network->network);
+
+ DPRINTF("%s: virNetworkGetName(%p) returned %s\n", PHPFUNC,
+ network->network, name);
+
+ if (name == NULL)
+ RETURN_FALSE;
+
+ /* name should not be freed as its lifetime is the same as network resource */
+ VIRT_RETURN_STRING(name);
+}
+
+/*
* Function name: libvirt_version
* Since version: 0.4.1(-1)
* Description: Function is used to get libvirt, driver and libvirt-php version
numbers. Can be used for information purposes, for version checking please use
libvirt_check_version() defined below
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index 1a003f5..f87d180 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -420,6 +420,9 @@ PHP_FUNCTION(libvirt_network_get_bridge);
PHP_FUNCTION(libvirt_network_get_information);
PHP_FUNCTION(libvirt_network_get_active);
PHP_FUNCTION(libvirt_network_set_active);
+PHP_FUNCTION(libvirt_network_get_uuid_string);
+PHP_FUNCTION(libvirt_network_get_uuid);
+PHP_FUNCTION(libvirt_network_get_name);
/* Nodedev functions */
PHP_FUNCTION(libvirt_nodedev_get);
PHP_FUNCTION(libvirt_nodedev_capabilities);
--
2.12.2