From nobody Fri May 16 04:11:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501785893807333.7871970691723; Thu, 3 Aug 2017 11:44:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9ED12C058EA8; Thu, 3 Aug 2017 18:44:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 714FD600CD; Thu, 3 Aug 2017 18:44:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2D9B01803B22; Thu, 3 Aug 2017 18:44:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v73IZUdh026124 for ; Thu, 3 Aug 2017 14:35:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id D484160179; Thu, 3 Aug 2017 18:35:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF037600CA for ; Thu, 3 Aug 2017 18:35:29 +0000 (UTC) Received: from mail-qt0-f171.google.com (mail-qt0-f171.google.com [209.85.216.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 159A8C04B938 for ; Thu, 3 Aug 2017 18:35:22 +0000 (UTC) Received: by mail-qt0-f171.google.com with SMTP id 16so12727263qtz.4 for ; Thu, 03 Aug 2017 11:35:22 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id b142sm23906990qka.37.2017.08.03.11.35.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Aug 2017 11:35:18 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9ED12C058EA8 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9ED12C058EA8 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iTx9oWYc" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 159A8C04B938 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzrudy@gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 159A8C04B938 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=GdUj7qRFvxaBtdh24zmcxwz7tolvM5fq0vzaDgro/vI=; b=iTx9oWYcugEBt28DMTJPpWX3cQGhrXwDVCj2CIas1IsiNlR5gnOV2H7UadeXaoB/Qh tPjxlrdfIkB99X8uTDKU3aSRJFhYcTN7zIDOkiCS7GCeFQNh2zmBJyWjKfp79fD/+6NU I2gaV2m10aaLJfmTtqRtWwV0HBtb7EsP6e5EX72gcB4rAaxp8rq/mq73htitEdGAYYFD jQScIxCjwYByUwNcl3HzweGobJV2Tseu9gsdDAJ+sI+bjKtCb5ee/r/fAY9gD127fWnR d4ZD5nlCxrwKnzIX1SOGH5HddT1O/0PAyCUpDbmvA1FJexEd/NebFd/7dGBZFg/NfKzn +kzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=GdUj7qRFvxaBtdh24zmcxwz7tolvM5fq0vzaDgro/vI=; b=CQGuw7NrL8zhAn6X/ItgMh9K2EeYxv/yiI1wSC2pPoPlvjeT2Ig53VIfjFWqfAlVFS yBX3mgspycbQN/uavvxXAc/RzplQPI/2CQDGzI/NdSb1en6yJnQ5CAwj9ivGpnHqIa6v y85Lq1735mB9vKNaV8SNzwmiWU/PaH9CrE/SQZm120qIjJsrILLcOEdPouqYbHHWaCwL rJkcqV9BO4pHyr0pS8fnfGZiNo1j28pawUVdKGaKrrIaPIAat1YU0XjLWTPbfZ90bmIX X3lYR4Y2KXe3KlQOmPh9sVQmn4vF7EttFhgs0uWZ9F3Tg9vlIlZTvDnHGR+9JCi2vIwq Erug== X-Gm-Message-State: AIVw111jTI6apA/yFXYvVAgN7CStpYaABrDn8cLjyWJggcta1cPiB94a tXEYM67Pi9X2+QrjQFk= X-Received: by 10.200.57.81 with SMTP id t17mr3702489qtb.45.1501785319341; Thu, 03 Aug 2017 11:35:19 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Thu, 3 Aug 2017 14:35:08 -0400 Message-Id: <20170803183509.1250-11-dzrudy@gmail.com> In-Reply-To: <20170803183509.1250-1-dzrudy@gmail.com> References: <20170803183509.1250-1-dzrudy@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 03 Aug 2017 18:35:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 03 Aug 2017 18:35:22 +0000 (UTC) for IP:'209.85.216.171' DOMAIN:'mail-qt0-f171.google.com' HELO:'mail-qt0-f171.google.com' FROM:'dzrudy@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.43 (DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.216.171 mail-qt0-f171.google.com 209.85.216.171 mail-qt0-f171.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH v2 10/11] Split up the bindings for libvirt NWFilter API X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 03 Aug 2017 18:44:52 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- src/Makefile.am | 3 +- src/libvirt-nwfilter.c | 415 +++++++++++++++++++++++++++++++++++++++++++++ src/libvirt-nwfilter.h | 66 ++++++++ src/libvirt-php.c | 445 +--------------------------------------------= ---- src/libvirt-php.h | 28 ---- 5 files changed, 487 insertions(+), 470 deletions(-) create mode 100644 src/libvirt-nwfilter.c create mode 100644 src/libvirt-nwfilter.h diff --git a/src/Makefile.am b/src/Makefile.am index 30bebad..707a1e8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,7 +29,8 @@ libvirt_php_la_SOURCES =3D \ libvirt-snapshot.c libvirt-snapshot.h \ libvirt-storage.c libvirt-storage.h \ libvirt-network.c libvirt-network.h \ - libvirt-nodedev.c libvirt-nodedev.h + libvirt-nodedev.c libvirt-nodedev.h \ + libvirt-nwfilter.c libvirt-nwfilter.h libvirt_php_la_CFLAGS =3D \ $(AM_CFLAGS) \ -DCOMPILE_DL_LIBVIRT=3D1 diff --git a/src/libvirt-nwfilter.c b/src/libvirt-nwfilter.c new file mode 100644 index 0000000..87dbb0b --- /dev/null +++ b/src/libvirt-nwfilter.c @@ -0,0 +1,415 @@ +/* + * libvirt-nwfilter.c: The PHP bindings to libvirt NWFilter API + * + * See COPYING for the license of this software + */ + +#include + +#include "libvirt-php.h" +#include "libvirt-nwfilter.h" + +DEBUG_INIT("nwfilter"); + +void +php_libvirt_nwfilter_dtor(virt_resource *rsrc TSRMLS_DC) +{ + php_libvirt_nwfilter *nwfilter =3D (php_libvirt_nwfilter *) rsrc->ptr; + int rv =3D 0; + + if (nwfilter !=3D NULL) { + if (nwfilter->nwfilter !=3D NULL) { + if (!check_resource_allocation(NULL, INT_RESOURCE_NWFILTER, nw= filter->nwfilter TSRMLS_CC)) { + nwfilter->nwfilter =3D NULL; + efree(nwfilter); + + return; + } + rv =3D virNWFilterFree(nwfilter->nwfilter); + if (rv !=3D 0) { + DPRINTF("%s: virNWFilterFree(%p) returned %d\n", __FUNCTIO= N__, nwfilter->nwfilter, rv); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virNWFilterFr= ee failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); + } else { + DPRINTF("%s: virNWFilterFee(%p) completed successfully\n",= __FUNCTION__, nwfilter->nwfilter); + resource_change_counter(INT_RESOURCE_NWFILTER, nwfilter->c= onn->conn, nwfilter->nwfilter, 0 TSRMLS_CC); + } + nwfilter->nwfilter =3D NULL; + } + efree(nwfilter); + } +} + +/* + * Function name: libvirt_nwfilter_define_xml + * Since version: 0.5.4 + * Description: Function is used to define a new nwfilter based on the= XML description + * Arguments: @res [resource]: libvirt connection resource + * @xml [string]: XML string definition of nwfilter to be= defined + * Returns: libvirt nwfilter resource of newly defined nwfilter + */ +PHP_FUNCTION(libvirt_nwfilter_define_xml) +{ + php_libvirt_connection *conn =3D NULL; + php_libvirt_nwfilter *res_nwfilter =3D NULL; + virNWFilter *nwfilter; + zval *zconn; + char *xml =3D NULL; + strsize_t xml_len; + + GET_CONNECTION_FROM_ARGS("rs", &zconn, &xml, &xml_len); + + if ((nwfilter =3D virNWFilterDefineXML(conn->conn, xml)) =3D=3D NULL) { + set_error_if_unset("Cannot define a new NWFilter" TSRMLS_CC); + RETURN_FALSE; + } + + res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvirt_n= wfilter)); + res_nwfilter->nwfilter =3D nwfilter; + res_nwfilter->conn =3D conn; + + resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, + res_nwfilter->nwfilter, 1 TSRMLS_CC); + + VIRT_REGISTER_RESOURCE(res_nwfilter, le_libvirt_nwfilter); +} + +/* + * Function name: libvirt_nwfilter_undefine + * Since version: 0.5.4 + * Description: Function is used to undefine already defined nwfilter + * Arguments: @res [resource]: libvirt nwfilter resource + * Returns: TRUE for success, FALSE on error + */ +PHP_FUNCTION(libvirt_nwfilter_undefine) +{ + php_libvirt_nwfilter *nwfilter =3D NULL; + zval *znwfilter; + + GET_NWFILTER_FROM_ARGS("r", &znwfilter); + + if (virNWFilterUndefine(nwfilter->nwfilter) !=3D 0) + RETURN_FALSE; + + RETURN_TRUE; +} + +/* + * Function name: libvirt_nwfilter_get_xml_desc + * Since version: 0.5.4 + * Description: Function is used to get the XML description for the nw= filter + * Arguments: @res [resource]: libvirt nwfilter resource + * @xpath [string]: optional xPath expression string to g= et just this entry, can be NULL + * Returns: nwfilter XML string or result of xPath expression + */ +PHP_FUNCTION(libvirt_nwfilter_get_xml_desc) +{ + php_libvirt_nwfilter *nwfilter =3D NULL; + zval *znwfilter; + char *xml =3D NULL; + char *xpath =3D NULL; + char *tmp; + strsize_t xpath_len; + int retval =3D -1; + + GET_NWFILTER_FROM_ARGS("r|s", &znwfilter, &xpath, &xpath_len); + + if (xpath_len < 1) + xpath =3D NULL; + + xml =3D virNWFilterGetXMLDesc(nwfilter->nwfilter, 0); + + if (xml =3D=3D NULL) { + set_error_if_unset("Cannot get nwfilter XML" TSRMLS_CC); + RETURN_FALSE; + } + + tmp =3D get_string_from_xpath(xml, xpath, NULL, &retval); + + if (tmp =3D=3D NULL || retval < 0) + VIRT_RETVAL_STRING(xml); + else + VIRT_RETVAL_STRING(tmp); + + free(xml); + free(tmp); +} + +/* + * Function name: libvirt_nwfilter_get_uuid_string + * Since version: 0.5.4 + * Description: Function is used to get nwfilter's UUID in string form= at + * Arguments: @res [resource]: libvirt nwfilter resource + * Returns: nwfilter UUID string or FALSE on failure + */ +PHP_FUNCTION(libvirt_nwfilter_get_uuid_string) +{ + php_libvirt_nwfilter *nwfilter =3D NULL; + zval *znwfilter; + char *uuid =3D NULL; + int ret =3D -1; + + GET_NWFILTER_FROM_ARGS("r", &znwfilter); + + uuid =3D (char *) emalloc(VIR_UUID_STRING_BUFLEN); + ret =3D virNWFilterGetUUIDString(nwfilter->nwfilter, uuid); + + DPRINTF("%s: virNWFilterGetUUIDString(%p) returned %d (%s)\n", PHPFUNC, + nwfilter->nwfilter, ret, uuid); + + if (ret !=3D 0) + RETURN_FALSE; + + VIRT_RETURN_STRING(uuid); + efree(uuid); +} + +/* + * Function name: libvirt_nwfilter_get_uuid + * Since version: 0.5.3 + * Descirption: Function is used to get nwfilter's UUID in binary form= at + * Arguments: @res [resource]: libvirt netowrk resource + * Returns: nwfilter UUID in binary format or FALSE on failure + */ +PHP_FUNCTION(libvirt_nwfilter_get_uuid) +{ + php_libvirt_nwfilter *nwfilter =3D NULL; + zval *znwfilter; + char *uuid =3D NULL; + int ret =3D -1; + + GET_NWFILTER_FROM_ARGS("r", &znwfilter); + + uuid =3D (char *) emalloc(VIR_UUID_BUFLEN); + ret =3D virNWFilterGetUUID(nwfilter->nwfilter, (unsigned char *) uuid); + + DPRINTF("%s: virNWFilterUUID(%p, %p) returned %d\n", PHPFUNC, + nwfilter->nwfilter, uuid, ret); + + if (ret !=3D 0) + RETURN_FALSE; + + VIRT_RETVAL_STRING(uuid); + efree(uuid); +} + +/* + * Function name: libvirt_nwfilter_get_name + * Since version: 0.5.4 + * Description: Function is used to get nwfilter's name + * Arguments: @res [resource]: libvirt nwfilter resource + * Returns: nwfilter name string or FALSE on failure + */ +PHP_FUNCTION(libvirt_nwfilter_get_name) +{ + php_libvirt_nwfilter *nwfilter =3D NULL; + zval *znwfilter; + const char *name =3D NULL; + + GET_NWFILTER_FROM_ARGS("r", &znwfilter); + name =3D virNWFilterGetName(nwfilter->nwfilter); + + DPRINTF("%s: virNWFilterGetName(%p) returned %s\n", PHPFUNC, + nwfilter->nwfilter, name); + + if (name =3D=3D NULL) + RETURN_FALSE; + + /* name should not be freed as its lifetime is the same as nwfilter re= source */ + VIRT_RETURN_STRING(name); +} + +/* + * Function name: libvirt_nwfilter_lookup_by_name + * Since version: 0.5.4 + * Description: This functions is used to lookup for the nwfilter by i= t's name + * Arguments: @res [resource]: libvirt connection resource + * @name [string]: name of the nwfilter to get the resour= ce + * Returns: libvirt nwfilter resource + */ +PHP_FUNCTION(libvirt_nwfilter_lookup_by_name) +{ + php_libvirt_nwfilter *res_nwfilter =3D NULL; + php_libvirt_connection *conn =3D NULL; + virNWFilterPtr nwfilter =3D NULL; + zval *zconn; + strsize_t name_len; + char *name =3D NULL; + + GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); + + if (name =3D=3D NULL || name_len < 1) + RETURN_FALSE; + + nwfilter =3D virNWFilterLookupByName(conn->conn, name); + + if (nwfilter =3D=3D NULL) + RETURN_FALSE; + + res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvirt_n= wfilter)); + res_nwfilter->conn =3D conn; + res_nwfilter->nwfilter =3D nwfilter; + + resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, + res_nwfilter->nwfilter, 1 TSRMLS_CC); + + VIRT_REGISTER_RESOURCE(res_nwfilter, le_libvirt_nwfilter); +} + +/* + * Function name: libvirt_nwfilter_lookup_by_uuid_string + * Since version: 0.5.4 + * Description: Function is used to lookup for nwfilter identified by = UUID string + * Arguments: @res [resource]: libvirt connection resource + * @uuid [string]: UUID string to look for nwfilter + * Returns: libvirt nwfilter resource + */ +PHP_FUNCTION(libvirt_nwfilter_lookup_by_uuid_string) +{ + php_libvirt_nwfilter *res_nwfilter =3D NULL; + php_libvirt_connection *conn =3D NULL; + virNWFilterPtr nwfilter =3D NULL; + zval *zconn; + char *uuid =3D NULL; + strsize_t uuid_len; + + GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); + + if (uuid =3D=3D NULL || uuid_len < 1) + RETURN_FALSE; + + nwfilter =3D virNWFilterLookupByUUIDString(conn->conn, uuid); + + if (nwfilter =3D=3D NULL) + RETURN_FALSE; + + res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvirt_n= wfilter)); + res_nwfilter->conn =3D conn; + res_nwfilter->nwfilter =3D nwfilter; + + resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, + res_nwfilter->nwfilter, 1 TSRMLS_CC); + + VIRT_REGISTER_RESOURCE(res_nwfilter, le_libvirt_nwfilter); +} + +/* + * Function name: libvirt_nwfilter_lookup_by_uuid + * Since version: 0.5.4 + * Description: Function is used to lookup for nwfilter by it's UUID i= n the binary format + * Arguments: @res [resource]: libvirt connection resource from libv= irt_connect() + * @uuid [string]: binary defined UUID to look for + * Returns: libvirt nwfilter resource + */ +PHP_FUNCTION(libvirt_nwfilter_lookup_by_uuid) +{ + php_libvirt_nwfilter *res_nwfilter =3D NULL; + php_libvirt_connection *conn =3D NULL; + virNWFilterPtr nwfilter =3D NULL; + zval *zconn; + strsize_t uuid_len; + unsigned char *uuid =3D NULL; + + GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); + + if ((uuid =3D=3D NULL) || (uuid_len < 1)) + RETURN_FALSE; + + nwfilter =3D virNWFilterLookupByUUID(conn->conn, uuid); + + if (nwfilter =3D=3D NULL) + RETURN_FALSE; + + res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvirt_n= wfilter)); + res_nwfilter->conn =3D conn; + res_nwfilter->nwfilter =3D nwfilter; + + resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, + res_nwfilter->nwfilter, 1 TSRMLS_CC); + + VIRT_REGISTER_RESOURCE(res_nwfilter, le_libvirt_nwfilter); +} + +/* + * Function name: libvirt_list_all_nwfilters + * Since version: 0.5.4 + * Description: Function is used to list nwfilters on the connection + * Arguments: @res [resource]: libvirt connection resource + * Returns: libvirt nwfilter resources array for the connection + */ +PHP_FUNCTION(libvirt_list_all_nwfilters) +{ + php_libvirt_nwfilter *res_nwfilter; + php_libvirt_connection *conn =3D NULL; + virNWFilterPtr *filters =3D NULL; + virNWFilterPtr nwfilter =3D NULL; + zval *zconn; + int count =3D -1; + size_t i =3D 0; + + GET_CONNECTION_FROM_ARGS("r", &zconn); + + /* in current libvirt version, flags are not used for this, so passing= 0 */ + if ((count =3D virConnectListAllNWFilters(conn->conn, &filters, 0)) < = 0) + RETURN_FALSE; + + DPRINTF("%s: Found %d nwfilters\n", PHPFUNC, count); + + array_init(return_value); + + for (i =3D 0; i < count; i++) { + nwfilter =3D filters[i]; + res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvi= rt_nwfilter)); + res_nwfilter->nwfilter =3D nwfilter; + res_nwfilter->conn =3D conn; + + resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, + res_nwfilter->nwfilter, 1 TSRMLS_CC); + VIRT_REGISTER_LIST_RESOURCE(nwfilter); + } +} + +/* + * Function name: libvirt_list_nwfilters + * Since version: 0.5.4 + * Description: Function is used to list nwfilters on the connection + * Arguments: @res [resource]: libvirt connection resource + * Returns: libvirt nwfilter names array for the connection + */ +PHP_FUNCTION(libvirt_list_nwfilters) +{ + php_libvirt_connection *conn =3D NULL; + zval *zconn; + int count =3D -1; + int expectedcount =3D -1; + char **names; + int i, done =3D 0; + + GET_CONNECTION_FROM_ARGS("r", &zconn); + + array_init(return_value); + + if ((expectedcount =3D virConnectNumOfNWFilters(conn->conn)) < 0) + RETURN_FALSE; + + names =3D (char **) emalloc(expectedcount * sizeof(char *)); + count =3D virConnectListNWFilters(conn->conn, names, expectedcount); + + if (count !=3D expectedcount || count < 0) { + efree(names); + DPRINTF("%s: virConnectListNWFilters returned %d filters, while %d= was " + "expected\n", PHPFUNC, count, expectedcount); + RETURN_FALSE; + } + + for (i =3D 0; i < count; i++) { + VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); + free(names[i]); + } + + efree(names); + done++; + + + if (!done) + RETURN_FALSE; +} diff --git a/src/libvirt-nwfilter.h b/src/libvirt-nwfilter.h new file mode 100644 index 0000000..c0cebb3 --- /dev/null +++ b/src/libvirt-nwfilter.h @@ -0,0 +1,66 @@ +/* + * libvirt-nwfilter.h: libvirt PHP binding for the NWFilter driver + * + * See COPYING for the license of this software + */ + +#ifndef __LIBVIRT_NWFILTER_H__ +# define __LIBVIRT_NWFILTER_H__ + +# include "libvirt-connection.h" + +# define PHP_LIBVIRT_NWFILTER_RES_NAME "Libvirt nwfilter" +# define INT_RESOURCE_NWFILTER 0x60 + +# define PHP_FE_LIBVIRT_NWFILTER = \ + PHP_FE(libvirt_nwfilter_define_xml, arginfo_libvirt_conn_xm= l) \ + PHP_FE(libvirt_nwfilter_undefine, arginfo_libvirt_conn) = \ + PHP_FE(libvirt_nwfilter_get_xml_desc, arginfo_libvirt_conn_xp= ath) \ + PHP_FE(libvirt_nwfilter_get_uuid_string, arginfo_libvirt_conn) = \ + PHP_FE(libvirt_nwfilter_get_uuid, arginfo_libvirt_conn) = \ + PHP_FE(libvirt_nwfilter_get_name, arginfo_libvirt_conn) = \ + PHP_FE(libvirt_nwfilter_lookup_by_name, arginfo_libvirt_conn_na= me) \ + PHP_FE(libvirt_nwfilter_lookup_by_uuid_string, arginfo_libvirt_conn_uu= id) \ + PHP_FE(libvirt_nwfilter_lookup_by_uuid, arginfo_libvirt_conn_uu= id) \ + PHP_FE(libvirt_list_all_nwfilters, arginfo_libvirt_conn) = \ + PHP_FE(libvirt_list_nwfilters, arginfo_libvirt_conn) + +# define GET_NWFILTER_FROM_ARGS(args, ...) = \ + do { = \ + reset_error(TSRMLS_C); = \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, = \ + args, = \ + __VA_ARGS__) =3D=3D FAILURE) { = \ + set_error("Invalid arguments" TSRMLS_CC); = \ + RETURN_FALSE; = \ + } = \ + = \ + VIRT_FETCH_RESOURCE(nwfilter, php_libvirt_nwfilter *, &znwfilter, = \ + PHP_LIBVIRT_NWFILTER_RES_NAME, = \ + le_libvirt_nwfilter); = \ + if ((nwfilter =3D=3D NULL) || (nwfilter->nwfilter =3D=3D NULL)) = \ + RETURN_FALSE; = \ + } while (0) = \ + +int le_libvirt_nwfilter; + +typedef struct _php_libvirt_nwfilter { + virNWFilterPtr nwfilter; + php_libvirt_connection* conn; +} php_libvirt_nwfilter; + +void php_libvirt_nwfilter_dtor(virt_resource *rsrc TSRMLS_DC); + +PHP_FUNCTION(libvirt_nwfilter_define_xml); +PHP_FUNCTION(libvirt_nwfilter_undefine); +PHP_FUNCTION(libvirt_nwfilter_get_xml_desc); +PHP_FUNCTION(libvirt_nwfilter_get_name); +PHP_FUNCTION(libvirt_nwfilter_get_uuid_string); +PHP_FUNCTION(libvirt_nwfilter_get_uuid); +PHP_FUNCTION(libvirt_nwfilter_lookup_by_name); +PHP_FUNCTION(libvirt_nwfilter_lookup_by_uuid_string); +PHP_FUNCTION(libvirt_nwfilter_lookup_by_uuid); +PHP_FUNCTION(libvirt_list_all_nwfilters); +PHP_FUNCTION(libvirt_list_nwfilters); + +#endif diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 6fa1436..b20d839 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -27,6 +27,7 @@ #include "libvirt-storage.h" #include "libvirt-network.h" #include "libvirt-nodedev.h" +#include "libvirt-nwfilter.h" =20 DEBUG_INIT("core"); =20 @@ -39,9 +40,6 @@ const char *features[] =3D { NULL }; const char *features_binaries[] =3D { NULL }; #endif =20 -/* ZEND thread safe per request globals definition */ -int le_libvirt_nwfilter; - ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_connect, 0, 0, 0) ZEND_ARG_INFO(0, url) ZEND_ARG_INFO(0, readonly) @@ -471,8 +469,6 @@ ZEND_ARG_INFO(0, flags) ZEND_END_ARG_INFO() =20 static zend_function_entry libvirt_functions[] =3D { - /* Common functions */ - PHP_FE(libvirt_get_last_error, arginfo_libvirt_void) PHP_FE_LIBVIRT_CONNECTION PHP_FE_LIBVIRT_STREAM PHP_FE_LIBVIRT_DOMAIN @@ -481,19 +477,9 @@ static zend_function_entry libvirt_functions[] =3D { PHP_FE_LIBVIRT_NETWORK PHP_FE_LIBVIRT_NODE PHP_FE_LIBVIRT_NODEDEV - /* NWFilter functions */ - PHP_FE(libvirt_nwfilter_define_xml, arginfo_libvirt_conn_xml) - PHP_FE(libvirt_nwfilter_undefine, arginfo_libvirt_conn) - PHP_FE(libvirt_nwfilter_get_xml_desc, arginfo_libvirt_conn_xpat= h) - PHP_FE(libvirt_nwfilter_get_uuid_string, arginfo_libvirt_conn) - PHP_FE(libvirt_nwfilter_get_uuid, arginfo_libvirt_conn) - PHP_FE(libvirt_nwfilter_get_name, arginfo_libvirt_conn) - PHP_FE(libvirt_nwfilter_lookup_by_name, arginfo_libvirt_conn_name) - PHP_FE(libvirt_nwfilter_lookup_by_uuid_string, arginfo_libvirt_conn_uu= id) - PHP_FE(libvirt_nwfilter_lookup_by_uuid, arginfo_libvirt_conn_uuid) - /* List functions */ - PHP_FE(libvirt_list_all_nwfilters, arginfo_libvirt_conn) - PHP_FE(libvirt_list_nwfilters, arginfo_libvirt_conn) + PHP_FE_LIBVIRT_NWFILTER + /* Common functions */ + PHP_FE(libvirt_get_last_error, arginfo_libvirt_void) /* Version information and common function */ PHP_FE(libvirt_version, arginfo_libvirt_opttype) PHP_FE(libvirt_check_version, arginfo_libvirt_check_ver= sion) @@ -1173,34 +1159,6 @@ int is_local_connection(virConnectPtr conn) #endif } =20 -/* Destructor for nwfilter resource */ -static void php_libvirt_nwfilter_dtor(virt_resource *rsrc TSRMLS_DC) -{ - php_libvirt_nwfilter *nwfilter =3D (php_libvirt_nwfilter *) rsrc->ptr; - int rv =3D 0; - - if (nwfilter !=3D NULL) { - if (nwfilter->nwfilter !=3D NULL) { - if (!check_resource_allocation(NULL, INT_RESOURCE_NWFILTER, nw= filter->nwfilter TSRMLS_CC)) { - nwfilter->nwfilter =3D NULL; - efree(nwfilter); - - return; - } - rv =3D virNWFilterFree(nwfilter->nwfilter); - if (rv !=3D 0) { - DPRINTF("%s: virNWFilterFree(%p) returned %d\n", __FUNCTIO= N__, nwfilter->nwfilter, rv); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virNWFilterFr= ee failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } else { - DPRINTF("%s: virNWFilterFee(%p) completed successfully\n",= __FUNCTION__, nwfilter->nwfilter); - resource_change_counter(INT_RESOURCE_NWFILTER, nwfilter->c= onn->conn, nwfilter->nwfilter, 0 TSRMLS_CC); - } - nwfilter->nwfilter =3D NULL; - } - efree(nwfilter); - } -} - /* ZEND Module inicialization function */ PHP_MINIT_FUNCTION(libvirt) { @@ -1525,22 +1483,6 @@ PHP_MSHUTDOWN_FUNCTION(libvirt) return SUCCESS; } =20 -/* Macros for obtaining resources from arguments */ -#define GET_NWFILTER_FROM_ARGS(args, ...) = \ - do { = \ - reset_error(TSRMLS_C); = \ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_AR= GS__) =3D=3D FAILURE) { \ - set_error("Invalid arguments" TSRMLS_CC); = \ - RETURN_FALSE; = \ - } = \ - = \ - VIRT_FETCH_RESOURCE(nwfilter, php_libvirt_nwfilter *, &znwfilter, = \ - PHP_LIBVIRT_NWFILTER_RES_NAME, le_libvirt_nwfi= lter); \ - if ((nwfilter =3D=3D NULL) || (nwfilter->nwfilter =3D=3D NULL)) = \ - RETURN_FALSE; = \ - } while (0) = \ - - /* Common functions */ =20 /* @@ -2513,385 +2455,6 @@ void parse_array(zval *arr, tVMDisk *disk, tVMNetwo= rk *network) } VIRT_FOREACH_END(); } =20 -/* Listing functions */ - -/* - * Function name: libvirt_list_all_nwfilters - * Since version: 0.5.4 - * Description: Function is used to list nwfilters on the connection - * Arguments: @res [resource]: libvirt connection resource - * Returns: libvirt nwfilter resources array for the connection - */ -PHP_FUNCTION(libvirt_list_all_nwfilters) -{ - php_libvirt_nwfilter *res_nwfilter; - php_libvirt_connection *conn =3D NULL; - virNWFilterPtr *filters =3D NULL; - virNWFilterPtr nwfilter =3D NULL; - zval *zconn; - int count =3D -1; - size_t i =3D 0; - - GET_CONNECTION_FROM_ARGS("r", &zconn); - - /* in current libvirt version, flags are not used for this, so passing= 0 */ - if ((count =3D virConnectListAllNWFilters(conn->conn, &filters, 0)) < = 0) - RETURN_FALSE; - - DPRINTF("%s: Found %d nwfilters\n", PHPFUNC, count); - - array_init(return_value); - - for (i =3D 0; i < count; i++) { - nwfilter =3D filters[i]; - res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvi= rt_nwfilter)); - res_nwfilter->nwfilter =3D nwfilter; - res_nwfilter->conn =3D conn; - - resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, - res_nwfilter->nwfilter, 1 TSRMLS_CC); - VIRT_REGISTER_LIST_RESOURCE(nwfilter); - } -} - -/* - * Function name: libvirt_list_nwfilters - * Since version: 0.5.4 - * Description: Function is used to list nwfilters on the connection - * Arguments: @res [resource]: libvirt connection resource - * Returns: libvirt nwfilter names array for the connection - */ -PHP_FUNCTION(libvirt_list_nwfilters) -{ - php_libvirt_connection *conn =3D NULL; - zval *zconn; - int count =3D -1; - int expectedcount =3D -1; - char **names; - int i, done =3D 0; - - GET_CONNECTION_FROM_ARGS("r", &zconn); - - array_init(return_value); - - if ((expectedcount =3D virConnectNumOfNWFilters(conn->conn)) < 0) - RETURN_FALSE; - - names =3D (char **) emalloc(expectedcount * sizeof(char *)); - count =3D virConnectListNWFilters(conn->conn, names, expectedcount); - - if (count !=3D expectedcount || count < 0) { - efree(names); - DPRINTF("%s: virConnectListNWFilters returned %d filters, while %d= was " - "expected\n", PHPFUNC, count, expectedcount); - RETURN_FALSE; - } - - for (i =3D 0; i < count; i++) { - VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); - free(names[i]); - } - - efree(names); - done++; - - - if (!done) - RETURN_FALSE; -} - -/* NWFilter functions */ - -/* - * Function name: libvirt_nwfilter_define_xml - * Since version: 0.5.4 - * Description: Function is used to define a new nwfilter based on the= XML description - * Arguments: @res [resource]: libvirt connection resource - * @xml [string]: XML string definition of nwfilter to be= defined - * Returns: libvirt nwfilter resource of newly defined nwfilter - */ -PHP_FUNCTION(libvirt_nwfilter_define_xml) -{ - php_libvirt_connection *conn =3D NULL; - php_libvirt_nwfilter *res_nwfilter =3D NULL; - virNWFilter *nwfilter; - zval *zconn; - char *xml =3D NULL; - strsize_t xml_len; - - GET_CONNECTION_FROM_ARGS("rs", &zconn, &xml, &xml_len); - - if ((nwfilter =3D virNWFilterDefineXML(conn->conn, xml)) =3D=3D NULL) { - set_error_if_unset("Cannot define a new NWFilter" TSRMLS_CC); - RETURN_FALSE; - } - - res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvirt_n= wfilter)); - res_nwfilter->nwfilter =3D nwfilter; - res_nwfilter->conn =3D conn; - - resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, - res_nwfilter->nwfilter, 1 TSRMLS_CC); - - VIRT_REGISTER_RESOURCE(res_nwfilter, le_libvirt_nwfilter); -} - -/* - * Function name: libvirt_nwfilter_undefine - * Since version: 0.5.4 - * Description: Function is used to undefine already defined nwfilter - * Arguments: @res [resource]: libvirt nwfilter resource - * Returns: TRUE for success, FALSE on error - */ -PHP_FUNCTION(libvirt_nwfilter_undefine) -{ - php_libvirt_nwfilter *nwfilter =3D NULL; - zval *znwfilter; - - GET_NWFILTER_FROM_ARGS("r", &znwfilter); - - if (virNWFilterUndefine(nwfilter->nwfilter) !=3D 0) - RETURN_FALSE; - - RETURN_TRUE; -} - -/* - * Function name: libvirt_nwfilter_get_xml_desc - * Since version: 0.5.4 - * Description: Function is used to get the XML description for the nw= filter - * Arguments: @res [resource]: libvirt nwfilter resource - * @xpath [string]: optional xPath expression string to g= et just this entry, can be NULL - * Returns: nwfilter XML string or result of xPath expression - */ -PHP_FUNCTION(libvirt_nwfilter_get_xml_desc) -{ - php_libvirt_nwfilter *nwfilter =3D NULL; - zval *znwfilter; - char *xml =3D NULL; - char *xpath =3D NULL; - char *tmp; - strsize_t xpath_len; - int retval =3D -1; - - GET_NWFILTER_FROM_ARGS("r|s", &znwfilter, &xpath, &xpath_len); - - if (xpath_len < 1) - xpath =3D NULL; - - xml =3D virNWFilterGetXMLDesc(nwfilter->nwfilter, 0); - - if (xml =3D=3D NULL) { - set_error_if_unset("Cannot get nwfilter XML" TSRMLS_CC); - RETURN_FALSE; - } - - tmp =3D get_string_from_xpath(xml, xpath, NULL, &retval); - - if (tmp =3D=3D NULL || retval < 0) - VIRT_RETVAL_STRING(xml); - else - VIRT_RETVAL_STRING(tmp); - - free(xml); - free(tmp); -} - -/* - * Function name: libvirt_nwfilter_get_uuid_string - * Since version: 0.5.4 - * Description: Function is used to get nwfilter's UUID in string form= at - * Arguments: @res [resource]: libvirt nwfilter resource - * Returns: nwfilter UUID string or FALSE on failure - */ -PHP_FUNCTION(libvirt_nwfilter_get_uuid_string) -{ - php_libvirt_nwfilter *nwfilter =3D NULL; - zval *znwfilter; - char *uuid =3D NULL; - int ret =3D -1; - - GET_NWFILTER_FROM_ARGS("r", &znwfilter); - - uuid =3D (char *) emalloc(VIR_UUID_STRING_BUFLEN); - ret =3D virNWFilterGetUUIDString(nwfilter->nwfilter, uuid); - - DPRINTF("%s: virNWFilterGetUUIDString(%p) returned %d (%s)\n", PHPFUNC, - nwfilter->nwfilter, ret, uuid); - - if (ret !=3D 0) - RETURN_FALSE; - - VIRT_RETURN_STRING(uuid); - efree(uuid); -} - -/* - * Function name: libvirt_nwfilter_get_uuid - * Since version: 0.5.3 - * Descirption: Function is used to get nwfilter's UUID in binary form= at - * Arguments: @res [resource]: libvirt netowrk resource - * Returns: nwfilter UUID in binary format or FALSE on failure - */ -PHP_FUNCTION(libvirt_nwfilter_get_uuid) -{ - php_libvirt_nwfilter *nwfilter =3D NULL; - zval *znwfilter; - char *uuid =3D NULL; - int ret =3D -1; - - GET_NWFILTER_FROM_ARGS("r", &znwfilter); - - uuid =3D (char *) emalloc(VIR_UUID_BUFLEN); - ret =3D virNWFilterGetUUID(nwfilter->nwfilter, (unsigned char *) uuid); - - DPRINTF("%s: virNWFilterUUID(%p, %p) returned %d\n", PHPFUNC, - nwfilter->nwfilter, uuid, ret); - - if (ret !=3D 0) - RETURN_FALSE; - - VIRT_RETVAL_STRING(uuid); - efree(uuid); -} - -/* - * Function name: libvirt_nwfilter_get_name - * Since version: 0.5.4 - * Description: Function is used to get nwfilter's name - * Arguments: @res [resource]: libvirt nwfilter resource - * Returns: nwfilter name string or FALSE on failure - */ -PHP_FUNCTION(libvirt_nwfilter_get_name) -{ - php_libvirt_nwfilter *nwfilter =3D NULL; - zval *znwfilter; - const char *name =3D NULL; - - GET_NWFILTER_FROM_ARGS("r", &znwfilter); - name =3D virNWFilterGetName(nwfilter->nwfilter); - - DPRINTF("%s: virNWFilterGetName(%p) returned %s\n", PHPFUNC, - nwfilter->nwfilter, name); - - if (name =3D=3D NULL) - RETURN_FALSE; - - /* name should not be freed as its lifetime is the same as nwfilter re= source */ - VIRT_RETURN_STRING(name); -} - -/* - * Function name: libvirt_nwfilter_lookup_by_name - * Since version: 0.5.4 - * Description: This functions is used to lookup for the nwfilter by i= t's name - * Arguments: @res [resource]: libvirt connection resource - * @name [string]: name of the nwfilter to get the resour= ce - * Returns: libvirt nwfilter resource - */ -PHP_FUNCTION(libvirt_nwfilter_lookup_by_name) -{ - php_libvirt_nwfilter *res_nwfilter =3D NULL; - php_libvirt_connection *conn =3D NULL; - virNWFilterPtr nwfilter =3D NULL; - zval *zconn; - strsize_t name_len; - char *name =3D NULL; - - GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); - - if (name =3D=3D NULL || name_len < 1) - RETURN_FALSE; - - nwfilter =3D virNWFilterLookupByName(conn->conn, name); - - if (nwfilter =3D=3D NULL) - RETURN_FALSE; - - res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvirt_n= wfilter)); - res_nwfilter->conn =3D conn; - res_nwfilter->nwfilter =3D nwfilter; - - resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, - res_nwfilter->nwfilter, 1 TSRMLS_CC); - - VIRT_REGISTER_RESOURCE(res_nwfilter, le_libvirt_nwfilter); -} - -/* - * Function name: libvirt_nwfilter_lookup_by_uuid_string - * Since version: 0.5.4 - * Description: Function is used to lookup for nwfilter identified by = UUID string - * Arguments: @res [resource]: libvirt connection resource - * @uuid [string]: UUID string to look for nwfilter - * Returns: libvirt nwfilter resource - */ -PHP_FUNCTION(libvirt_nwfilter_lookup_by_uuid_string) -{ - php_libvirt_nwfilter *res_nwfilter =3D NULL; - php_libvirt_connection *conn =3D NULL; - virNWFilterPtr nwfilter =3D NULL; - zval *zconn; - char *uuid =3D NULL; - strsize_t uuid_len; - - GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); - - if (uuid =3D=3D NULL || uuid_len < 1) - RETURN_FALSE; - - nwfilter =3D virNWFilterLookupByUUIDString(conn->conn, uuid); - - if (nwfilter =3D=3D NULL) - RETURN_FALSE; - - res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvirt_n= wfilter)); - res_nwfilter->conn =3D conn; - res_nwfilter->nwfilter =3D nwfilter; - - resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, - res_nwfilter->nwfilter, 1 TSRMLS_CC); - - VIRT_REGISTER_RESOURCE(res_nwfilter, le_libvirt_nwfilter); -} - -/* - * Function name: libvirt_nwfilter_lookup_by_uuid - * Since version: 0.5.4 - * Description: Function is used to lookup for nwfilter by it's UUID i= n the binary format - * Arguments: @res [resource]: libvirt connection resource from libv= irt_connect() - * @uuid [string]: binary defined UUID to look for - * Returns: libvirt nwfilter resource - */ -PHP_FUNCTION(libvirt_nwfilter_lookup_by_uuid) -{ - php_libvirt_nwfilter *res_nwfilter =3D NULL; - php_libvirt_connection *conn =3D NULL; - virNWFilterPtr nwfilter =3D NULL; - zval *zconn; - strsize_t uuid_len; - unsigned char *uuid =3D NULL; - - GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); - - if ((uuid =3D=3D NULL) || (uuid_len < 1)) - RETURN_FALSE; - - nwfilter =3D virNWFilterLookupByUUID(conn->conn, uuid); - - if (nwfilter =3D=3D NULL) - RETURN_FALSE; - - res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvirt_n= wfilter)); - res_nwfilter->conn =3D conn; - res_nwfilter->nwfilter =3D nwfilter; - - resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, - res_nwfilter->nwfilter, 1 TSRMLS_CC); - - VIRT_REGISTER_RESOURCE(res_nwfilter, le_libvirt_nwfilter); -} - /* * Function name: libvirt_version * Since version: 0.4.1(-1) diff --git a/src/libvirt-php.h b/src/libvirt-php.h index c35bd69..8d13a6b 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -107,9 +107,6 @@ typedef uint64_t arch_uint; #define PHP_LIBVIRT_WORLD_VERSION VERSION #define PHP_LIBVIRT_WORLD_EXTNAME "libvirt" =20 -/* Internal resource identifier objects */ -#define INT_RESOURCE_NWFILTER 0x60 - typedef struct tTokenizer { char **tokens; int numTokens; @@ -137,15 +134,6 @@ typedef struct tVMNetwork { char *model; } tVMNetwork; =20 -/* TODO: temporary forward declaration until other parts are "modularized"= */ -typedef struct _php_libvirt_connection php_libvirt_connection; - -/* Libvirt-php types */ -typedef struct _php_libvirt_nwfilter { - virNWFilterPtr nwfilter; - php_libvirt_connection* conn; -} php_libvirt_nwfilter; - typedef struct _php_libvirt_hash_key_info { char *name; unsigned int length; @@ -198,8 +186,6 @@ const char *get_feature_binary(const char *name); long get_next_free_numeric_value(virDomainPtr domain, char *xpath); int get_subnet_bits(char *ip); =20 -#define PHP_LIBVIRT_NWFILTER_RES_NAME "Libvirt nwfilter" - PHP_MINIT_FUNCTION(libvirt); PHP_MSHUTDOWN_FUNCTION(libvirt); PHP_RINIT_FUNCTION(libvirt); @@ -208,20 +194,6 @@ PHP_MINFO_FUNCTION(libvirt); =20 /* Common functions */ PHP_FUNCTION(libvirt_get_last_error); -/* NWFilter functions */ -PHP_FUNCTION(libvirt_nwfilter_define_xml); -PHP_FUNCTION(libvirt_nwfilter_undefine); -PHP_FUNCTION(libvirt_nwfilter_get_xml_desc); -PHP_FUNCTION(libvirt_nwfilter_get_name); -PHP_FUNCTION(libvirt_nwfilter_get_uuid_string); -PHP_FUNCTION(libvirt_nwfilter_get_uuid); -PHP_FUNCTION(libvirt_nwfilter_lookup_by_name); -PHP_FUNCTION(libvirt_nwfilter_lookup_by_uuid_string); -PHP_FUNCTION(libvirt_nwfilter_lookup_by_uuid); -/* Listing functions */ -PHP_FUNCTION(libvirt_list_all_nwfilters); -PHP_FUNCTION(libvirt_list_nwfilters); -/* Common functions */ PHP_FUNCTION(libvirt_version); PHP_FUNCTION(libvirt_check_version); PHP_FUNCTION(libvirt_has_feature); --=20 2.13.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list