From nobody Sun Apr 28 11:41:07 2024 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; 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 1499858782009822.4651712606031; Wed, 12 Jul 2017 04:26:22 -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 D36FD3B702; Wed, 12 Jul 2017 11:26:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BF775D9CB; Wed, 12 Jul 2017 11:26:17 +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 A4DD14A492; Wed, 12 Jul 2017 11:26:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6CBQD7s008016 for ; Wed, 12 Jul 2017 07:26:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id C3BDC61F24; Wed, 12 Jul 2017 11:26:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BBA1E5D6A6 for ; Wed, 12 Jul 2017 11:26:10 +0000 (UTC) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 46821A4FB2 for ; Wed, 12 Jul 2017 11:26:09 +0000 (UTC) Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BC63CABB3 for ; Wed, 12 Jul 2017 11:26:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D36FD3B702 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ext-mx06.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 D36FD3B702 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 46821A4FB2 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thipp@suse.de DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 46821A4FB2 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Thomas Hipp To: libvir-list@redhat.com Date: Wed, 12 Jul 2017 13:26:03 +0200 Message-Id: <20170712112603.26828-1-thipp@suse.de> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 12 Jul 2017 11:26:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 12 Jul 2017 11:26:09 +0000 (UTC) for IP:'195.135.220.15' DOMAIN:'mx2.suse.de' HELO:'mx1.suse.de' FROM:'thipp@suse.de' RCPT:'' X-RedHat-Spam-Score: -1.502 (BAYES_50, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS) 195.135.220.15 mx2.suse.de 195.135.220.15 mx2.suse.de X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH go-xml] Add support for NAT in network forward 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.30]); Wed, 12 Jul 2017 11:26:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add support for NAT in network forward, and add test code. Signed-off-by: Thomas Hipp --- network.go | 20 ++++++++++++++++++-- network_test.go | 31 +++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/network.go b/network.go index cc850a1..3635ad2 100644 --- a/network.go +++ b/network.go @@ -41,9 +41,25 @@ type NetworkDomain struct { LocalOnly string `xml:"localOnly,attr,omitempty"` } =20 +type NetworkForwardNATAddress struct { + Start string `xml:"start,attr"` + End string `xml:"end,attr"` +} + +type NetworkForwardNATPort struct { + Start uint `xml:"start,attr"` + End uint `xml:"end,attr"` +} + +type NetworkForwardNAT struct { + Addresses []NetworkForwardNATAddress `xml:"address"` + Ports []NetworkForwardNATPort `xml:"port"` +} + type NetworkForward struct { - Mode string `xml:"mode,attr,omitempty"` - Dev string `xml:"dev,attr,omitempty"` + Mode string `xml:"mode,attr,omitempty"` + Dev string `xml:"dev,attr,omitempty"` + NAT *NetworkForwardNAT `xml:"nat"` } =20 type NetworkMAC struct { diff --git a/network_test.go b/network_test.go index 5269398..65f4d53 100644 --- a/network_test.go +++ b/network_test.go @@ -67,6 +67,20 @@ var networkTestData =3D []struct { }, Forward: &NetworkForward{ Mode: "nat", + NAT: &NetworkForwardNAT{ + Addresses: []NetworkForwardNATAddress{ + NetworkForwardNATAddress{ + Start: "1.2.3.4", + End: "1.2.3.10", + }, + }, + Ports: []NetworkForwardNATPort{ + NetworkForwardNATPort{ + Start: 500, + End: 1000, + }, + }, + }, }, IPs: []NetworkIP{ NetworkIP{ @@ -89,9 +103,9 @@ var networkTestData =3D []struct { }, }, NetworkIP{ - Family: "ipv6", - Address:"2001:db8:ca2:2::1", - Prefix: "64", + Family: "ipv6", + Address: "2001:db8:ca2:2::1", + Prefix: "64", DHCP: &NetworkDHCP{ Hosts: []NetworkDHCPHost{ NetworkDHCPHost{ @@ -99,8 +113,8 @@ var networkTestData =3D []struct { Name: "paul", }, NetworkDHCPHost{ - ID: "0:1:0:1:18:aa:62:fe:0:16:3e:44:55:66", - IP: "2001:db8:ca2:2:3::2", + ID: "0:1:0:1:18:aa:62:fe:0:16:3e:44:55:66", + IP: "2001:db8:ca2:2:3::2", }, }, }, @@ -111,7 +125,12 @@ var networkTestData =3D []struct { ``, ` test`, ` `, - ` `, + ` `, + ` `, + `
`, + ` `, + `
`, + `
`, ` `, ` `, ` `, --=20 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list