From nobody Wed Feb 11 01:36:39 2026 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.zoho.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 1498158916052849.3431053708957; Thu, 22 Jun 2017 12:15:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8E19142890; Thu, 22 Jun 2017 19:15:12 +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 0B0365D967; Thu, 22 Jun 2017 19:15:11 +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 E09E61800C88; Thu, 22 Jun 2017 19:15:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5MJEFdm013753 for ; Thu, 22 Jun 2017 15:14:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3EBCC68D42; Thu, 22 Jun 2017 19:14:15 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3771F65E9B for ; Thu, 22 Jun 2017 19:14:15 +0000 (UTC) Received: from mail-qk0-f176.google.com (mail-qk0-f176.google.com [209.85.220.176]) (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 3F1E514288E for ; Thu, 22 Jun 2017 19:14:13 +0000 (UTC) Received: by mail-qk0-f176.google.com with SMTP id d14so19993443qkb.1 for ; Thu, 22 Jun 2017 12:14:13 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id g39sm1837145qtc.12.2017.06.22.12.14.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Jun 2017 12:14:11 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C8E19142890 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C8E19142890 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="jBAwSdag" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3F1E514288E Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3F1E514288E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=iIFyq+tiER7tI+xr5jD74yRFK1LeIxvzJtX3CdaMCAY=; b=jBAwSdag0T6coQwtcmma3poTpP+8lHZKF+0r6plaUaz7VOnR3hBX0eq9jSVNNDr0rI FItlMYntz0vaFmjRMgeKDhEqbg+ok1pWIUpNTjR6eTPB6f2XJQzE17BKYT9aqSigcPJs pzA4rh5ATWFh3X2kVzZvvI0jrxgStC0rUpW4lWSab85XQX0HaUPTjSR9ln63BIOTjtCW C1u74uBHtoNKyPgCGU3rEqctnlSHKuHeYuiG2a4lia8z93ePP8p76OoV5Cr+dxxlvAbK j1H9OfAoMz/puM+j13F3HtOA2KiHZTBkvuHbH/1wUdK/IQBoXlb9VQqeMHatexMG3R6u mQ1w== 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=iIFyq+tiER7tI+xr5jD74yRFK1LeIxvzJtX3CdaMCAY=; b=fiVYrBVFZ6Or5+LUM1/EZ/vSFljUbjxz/f4eKyG4AKJWswgw9YmRE28xe+Q7fkuZ/U 5ll22xjMAhOIJMdmlZDrdjDI6hzVcksjxQTi/yktzOqbqRo7ZJQZAygvDgzLeFbf7eIT As54pk1MaTIVGNm9AK9OxFE39QiFWqjanJmd9zMMlbAPsRd0xJOWur6X8dDAq6Ydw1EV e1farH3lnmetViWrZ2gAGEBTtgJiTtNhBfLIK0Y5UyDOOZ9C+IeOoPmBwdpRgX4BWGtt qpDdohbciwKVyfAxdd3z3L1YWHuTokdwz81X3JgqSaGuEs0XrNWEOxme6+nyBEUxlNV8 7zqw== X-Gm-Message-State: AKS2vOwGBQdL5PX0/xOONWUxvozXIm/42xV/R6PJVrqpX9n30+DF7bpv iAP5tWWNpDJAOxZdWYzcyw== X-Received: by 10.55.74.131 with SMTP id x125mr4958176qka.5.1498158852216; Thu, 22 Jun 2017 12:14:12 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Thu, 22 Jun 2017 15:14:07 -0400 Message-Id: <20170622191407.15570-8-dzamirski@datto.com> In-Reply-To: <20170622191407.15570-1-dzamirski@datto.com> References: <20170622191407.15570-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 22 Jun 2017 19:14:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 22 Jun 2017 19:14:13 +0000 (UTC) for IP:'209.85.220.176' DOMAIN:'mail-qk0-f176.google.com' HELO:'mail-qk0-f176.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: -0.611 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.220.176 mail-qk0-f176.google.com 209.85.220.176 mail-qk0-f176.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH 7/7] implement NWFilter API bindings. 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 22 Jun 2017 19:15:14 +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" adds the following functions: * libvirt_nwfilter_define_xml * libvirt_nwfilter_undefine * libvirt_nwfilter_get_xml_desc * libvirt_nwfilter_get_name * libvirt_nwfilter_get_uuid * libvirt_nwfilter_get_uuid_string * libvirt_nwfilter_lookup_by_name * libvirt_nwfilter_lookup_by_uuid * libvirt_nwfilter_lookup_by_uuid_string * libvirt_list_nwfilters * libvirt_list_all_nwfilters --- src/libvirt-php.c | 390 ++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ src/libvirt-php.h | 12 ++ 2 files changed, 402 insertions(+) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 535d321..5893742 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -645,6 +645,16 @@ static zend_function_entry libvirt_functions[] =3D { PHP_FE(libvirt_nodedev_capabilities, arginfo_libvirt_conn) PHP_FE(libvirt_nodedev_get_xml_desc, arginfo_libvirt_conn_xpat= h) PHP_FE(libvirt_nodedev_get_information, arginfo_libvirt_conn) + /* 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_domains, arginfo_libvirt_conn) PHP_FE(libvirt_list_domain_snapshots, arginfo_libvirt_conn_optf= lags) @@ -659,6 +669,8 @@ static zend_function_entry libvirt_functions[] =3D { PHP_FE(libvirt_list_active_domains, arginfo_libvirt_conn) PHP_FE(libvirt_list_active_domain_ids, arginfo_libvirt_conn) PHP_FE(libvirt_list_inactive_domains, arginfo_libvirt_conn) + PHP_FE(libvirt_list_all_nwfilters, arginfo_libvirt_conn) + PHP_FE(libvirt_list_nwfilters, arginfo_libvirt_conn) /* Version information and common function */ PHP_FE(libvirt_version, arginfo_libvirt_opttype) PHP_FE(libvirt_check_version, arginfo_libvirt_check_ver= sion) @@ -9074,7 +9086,93 @@ PHP_FUNCTION(libvirt_list_nodedevs) efree(names); } =20 + +/* + * 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; +} /* Nodedev functions */ + /* * Function name: libvirt_nodedev_get * Since version: 0.4.1(-1) @@ -9782,6 +9880,298 @@ PHP_FUNCTION(libvirt_network_set_autostart) RETURN_TRUE; } =20 +/* 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 2e7a3ca..7962e33 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -558,10 +558,22 @@ PHP_FUNCTION(libvirt_nodedev_get); PHP_FUNCTION(libvirt_nodedev_capabilities); PHP_FUNCTION(libvirt_nodedev_get_xml_desc); PHP_FUNCTION(libvirt_nodedev_get_information); +/* 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_nodedevs); PHP_FUNCTION(libvirt_list_all_networks); PHP_FUNCTION(libvirt_list_networks); +PHP_FUNCTION(libvirt_list_all_nwfilters); +PHP_FUNCTION(libvirt_list_nwfilters); PHP_FUNCTION(libvirt_list_domains); PHP_FUNCTION(libvirt_list_domain_snapshots); PHP_FUNCTION(libvirt_list_domain_resources); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list