@cryptotaxi247 / kubo / commits / fe00ad8a2

nat upnp and pmp libs

Juan Batiz-Benet committed Jan 24, 2015 at 12:41 UTC fe00ad8a2c23745de6a412315034816c0fd8df43
30 files changed +13138
Godeps/Godeps.json
+12
@@ -92,6 +92,10 @@
92 "ImportPath": "github.com/facebookgo/stackerr",
93 "Rev": "060fbf9364c89acd41bf710e9e92915a90e7a5b5"
94 },
95 + {
96 + "ImportPath": "github.com/fd/go-nat",
97 + "Rev": "50e7633d5f27d81490026a13e5b92d2e42d8c6bb"
98 + },
99 {
100 "ImportPath": "github.com/gorilla/context",
101 "Rev": "14f550f51af52180c2eefed15e5fd18d63c0a64a"
@@ -117,10 +121,18 @@
121 "Comment": "v0.9.0-11-g6b1ef89",
122 "Rev": "6b1ef893dc11e0447abda6da20a5203481878dda"
123 },
124 + {
125 + "ImportPath": "github.com/huin/goupnp",
126 + "Rev": "223008361153d7d434c1f0ac990cd3fcae6931f5"
127 + },
128 {
129 "ImportPath": "github.com/inconshreveable/go-update",
130 "Rev": "221d034a558b4c21b0624b2a450c076913854a57"
131 },
132 + {
133 + "ImportPath": "github.com/jackpal/go-nat-pmp",
134 + "Rev": "a45aa3d54aef73b504e15eb71bea0e5565b5e6e1"
135 + },
136 {
137 "ImportPath": "github.com/jbenet/go-base58",
138 "Rev": "568a28d73fd97651d3442392036a658b6976eed5"
Godeps/_workspace/src/github.com/fd/go-nat/LICENSE new
+191
@@ -0,0 +1,191 @@
1 +Apache License
2 +Version 2.0, January 2004
3 +http://www.apache.org/licenses/
4 +
5 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 +
7 +1. Definitions.
8 +
9 +"License" shall mean the terms and conditions for use, reproduction, and
10 +distribution as defined by Sections 1 through 9 of this document.
11 +
12 +"Licensor" shall mean the copyright owner or entity authorized by the copyright
13 +owner that is granting the License.
14 +
15 +"Legal Entity" shall mean the union of the acting entity and all other entities
16 +that control, are controlled by, or are under common control with that entity.
17 +For the purposes of this definition, "control" means (i) the power, direct or
18 +indirect, to cause the direction or management of such entity, whether by
19 +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20 +outstanding shares, or (iii) beneficial ownership of such entity.
21 +
22 +"You" (or "Your") shall mean an individual or Legal Entity exercising
23 +permissions granted by this License.
24 +
25 +"Source" form shall mean the preferred form for making modifications, including
26 +but not limited to software source code, documentation source, and configuration
27 +files.
28 +
29 +"Object" form shall mean any form resulting from mechanical transformation or
30 +translation of a Source form, including but not limited to compiled object code,
31 +generated documentation, and conversions to other media types.
32 +
33 +"Work" shall mean the work of authorship, whether in Source or Object form, made
34 +available under the License, as indicated by a copyright notice that is included
35 +in or attached to the work (an example is provided in the Appendix below).
36 +
37 +"Derivative Works" shall mean any work, whether in Source or Object form, that
38 +is based on (or derived from) the Work and for which the editorial revisions,
39 +annotations, elaborations, or other modifications represent, as a whole, an
40 +original work of authorship. For the purposes of this License, Derivative Works
41 +shall not include works that remain separable from, or merely link (or bind by
42 +name) to the interfaces of, the Work and Derivative Works thereof.
43 +
44 +"Contribution" shall mean any work of authorship, including the original version
45 +of the Work and any modifications or additions to that Work or Derivative Works
46 +thereof, that is intentionally submitted to Licensor for inclusion in the Work
47 +by the copyright owner or by an individual or Legal Entity authorized to submit
48 +on behalf of the copyright owner. For the purposes of this definition,
49 +"submitted" means any form of electronic, verbal, or written communication sent
50 +to the Licensor or its representatives, including but not limited to
51 +communication on electronic mailing lists, source code control systems, and
52 +issue tracking systems that are managed by, or on behalf of, the Licensor for
53 +the purpose of discussing and improving the Work, but excluding communication
54 +that is conspicuously marked or otherwise designated in writing by the copyright
55 +owner as "Not a Contribution."
56 +
57 +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58 +of whom a Contribution has been received by Licensor and subsequently
59 +incorporated within the Work.
60 +
61 +2. Grant of Copyright License.
62 +
63 +Subject to the terms and conditions of this License, each Contributor hereby
64 +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
65 +irrevocable copyright license to reproduce, prepare Derivative Works of,
66 +publicly display, publicly perform, sublicense, and distribute the Work and such
67 +Derivative Works in Source or Object form.
68 +
69 +3. Grant of Patent License.
70 +
71 +Subject to the terms and conditions of this License, each Contributor hereby
72 +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
73 +irrevocable (except as stated in this section) patent license to make, have
74 +made, use, offer to sell, sell, import, and otherwise transfer the Work, where
75 +such license applies only to those patent claims licensable by such Contributor
76 +that are necessarily infringed by their Contribution(s) alone or by combination
77 +of their Contribution(s) with the Work to which such Contribution(s) was
78 +submitted. If You institute patent litigation against any entity (including a
79 +cross-claim or counterclaim in a lawsuit) alleging that the Work or a
80 +Contribution incorporated within the Work constitutes direct or contributory
81 +patent infringement, then any patent licenses granted to You under this License
82 +for that Work shall terminate as of the date such litigation is filed.
83 +
84 +4. Redistribution.
85 +
86 +You may reproduce and distribute copies of the Work or Derivative Works thereof
87 +in any medium, with or without modifications, and in Source or Object form,
88 +provided that You meet the following conditions:
89 +
90 +You must give any other recipients of the Work or Derivative Works a copy of
91 +this License; and
92 +You must cause any modified files to carry prominent notices stating that You
93 +changed the files; and
94 +You must retain, in the Source form of any Derivative Works that You distribute,
95 +all copyright, patent, trademark, and attribution notices from the Source form
96 +of the Work, excluding those notices that do not pertain to any part of the
97 +Derivative Works; and
98 +If the Work includes a "NOTICE" text file as part of its distribution, then any
99 +Derivative Works that You distribute must include a readable copy of the
100 +attribution notices contained within such NOTICE file, excluding those notices
101 +that do not pertain to any part of the Derivative Works, in at least one of the
102 +following places: within a NOTICE text file distributed as part of the
103 +Derivative Works; within the Source form or documentation, if provided along
104 +with the Derivative Works; or, within a display generated by the Derivative
105 +Works, if and wherever such third-party notices normally appear. The contents of
106 +the NOTICE file are for informational purposes only and do not modify the
107 +License. You may add Your own attribution notices within Derivative Works that
108 +You distribute, alongside or as an addendum to the NOTICE text from the Work,
109 +provided that such additional attribution notices cannot be construed as
110 +modifying the License.
111 +You may add Your own copyright statement to Your modifications and may provide
112 +additional or different license terms and conditions for use, reproduction, or
113 +distribution of Your modifications, or for any such Derivative Works as a whole,
114 +provided Your use, reproduction, and distribution of the Work otherwise complies
115 +with the conditions stated in this License.
116 +
117 +5. Submission of Contributions.
118 +
119 +Unless You explicitly state otherwise, any Contribution intentionally submitted
120 +for inclusion in the Work by You to the Licensor shall be under the terms and
121 +conditions of this License, without any additional terms or conditions.
122 +Notwithstanding the above, nothing herein shall supersede or modify the terms of
123 +any separate license agreement you may have executed with Licensor regarding
124 +such Contributions.
125 +
126 +6. Trademarks.
127 +
128 +This License does not grant permission to use the trade names, trademarks,
129 +service marks, or product names of the Licensor, except as required for
130 +reasonable and customary use in describing the origin of the Work and
131 +reproducing the content of the NOTICE file.
132 +
133 +7. Disclaimer of Warranty.
134 +
135 +Unless required by applicable law or agreed to in writing, Licensor provides the
136 +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
137 +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
138 +including, without limitation, any warranties or conditions of TITLE,
139 +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
140 +solely responsible for determining the appropriateness of using or
141 +redistributing the Work and assume any risks associated with Your exercise of
142 +permissions under this License.
143 +
144 +8. Limitation of Liability.
145 +
146 +In no event and under no legal theory, whether in tort (including negligence),
147 +contract, or otherwise, unless required by applicable law (such as deliberate
148 +and grossly negligent acts) or agreed to in writing, shall any Contributor be
149 +liable to You for damages, including any direct, indirect, special, incidental,
150 +or consequential damages of any character arising as a result of this License or
151 +out of the use or inability to use the Work (including but not limited to
152 +damages for loss of goodwill, work stoppage, computer failure or malfunction, or
153 +any and all other commercial damages or losses), even if such Contributor has
154 +been advised of the possibility of such damages.
155 +
156 +9. Accepting Warranty or Additional Liability.
157 +
158 +While redistributing the Work or Derivative Works thereof, You may choose to
159 +offer, and charge a fee for, acceptance of support, warranty, indemnity, or
160 +other liability obligations and/or rights consistent with this License. However,
161 +in accepting such obligations, You may act only on Your own behalf and on Your
162 +sole responsibility, not on behalf of any other Contributor, and only if You
163 +agree to indemnify, defend, and hold each Contributor harmless for any liability
164 +incurred by, or claims asserted against, such Contributor by reason of your
165 +accepting any such warranty or additional liability.
166 +
167 +END OF TERMS AND CONDITIONS
168 +
169 +APPENDIX: How to apply the Apache License to your work
170 +
171 +To apply the Apache License to your work, attach the following boilerplate
172 +notice, with the fields enclosed by brackets "[]" replaced with your own
173 +identifying information. (Don't include the brackets!) The text should be
174 +enclosed in the appropriate comment syntax for the file format. We also
175 +recommend that a file or class name and description of purpose be included on
176 +the same "printed page" as the copyright notice for easier identification within
177 +third-party archives.
178 +
179 + Copyright [yyyy] [name of copyright owner]
180 +
181 + Licensed under the Apache License, Version 2.0 (the "License");
182 + you may not use this file except in compliance with the License.
183 + You may obtain a copy of the License at
184 +
185 + http://www.apache.org/licenses/LICENSE-2.0
186 +
187 + Unless required by applicable law or agreed to in writing, software
188 + distributed under the License is distributed on an "AS IS" BASIS,
189 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190 + See the License for the specific language governing permissions and
191 + limitations under the License.
Godeps/_workspace/src/github.com/fd/go-nat/README.md new
+3
@@ -0,0 +1,3 @@
1 +# go-nat
2 +
3 +[![GoDoc](https://godoc.org/github.com/fd/go-nat?status.svg)](https://godoc.org/github.com/fd/go-nat) [![status](https://sourcegraph.com/api/repos/github.com/fd/go-nat/.badges/status.png)](https://sourcegraph.com/github.com/fd/go-nat)
Godeps/_workspace/src/github.com/fd/go-nat/nat.go new
+54
@@ -0,0 +1,54 @@
1 +// Package nat implements NAT handling facilities
2 +package nat
3 +
4 +import (
5 + "errors"
6 + "math"
7 + "math/rand"
8 + "net"
9 + "time"
10 +)
11 +
12 +var ErrNoExternalAddress = errors.New("no external address")
13 +var ErrNoInternalAddress = errors.New("no internal address")
14 +var ErrNoNATFound = errors.New("no NAT found")
15 +
16 +// protocol is either "udp" or "tcp"
17 +type NAT interface {
18 + // Type returns the kind of NAT port mapping service that is used
19 + Type() string
20 +
21 + // GetDeviceAddress returns the internal address of the gateway device.
22 + GetDeviceAddress() (addr net.IP, err error)
23 +
24 + // GetExternalAddress returns the external address of the gateway device.
25 + GetExternalAddress() (addr net.IP, err error)
26 +
27 + // GetInternalAddress returns the address of the local host.
28 + GetInternalAddress() (addr net.IP, err error)
29 +
30 + // AddPortMapping maps a port on the local host to an external port.
31 + AddPortMapping(protocol string, internalPort int, description string, timeout time.Duration) (mappedExternalPort int, err error)
32 +
33 + // DeletePortMapping removes a port mapping.
34 + DeletePortMapping(protocol string, internalPort int) (err error)
35 +}
36 +
37 +// DiscoverGateway attempts to find a gateway device.
38 +func DiscoverGateway() (NAT, error) {
39 + select {
40 + case nat := <-discoverUPNP_IG1():
41 + return nat, nil
42 + case nat := <-discoverUPNP_IG2():
43 + return nat, nil
44 + case nat := <-discoverNATPMP():
45 + return nat, nil
46 + case <-time.After(10 * time.Second):
47 + return nil, ErrNoNATFound
48 + }
49 +}
50 +
51 +func randomPort() int {
52 + rand.Seed(time.Now().UnixNano())
53 + return rand.Intn(math.MaxUint16-10000) + 10000
54 +}
Godeps/_workspace/src/github.com/fd/go-nat/natpmp.go new
+178
@@ -0,0 +1,178 @@
1 +package nat
2 +
3 +import (
4 + "net"
5 + "time"
6 +
7 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jackpal/go-nat-pmp"
8 +)
9 +
10 +var (
11 + _ NAT = (*natpmp_NAT)(nil)
12 +)
13 +
14 +func natpmp_PotentialGateways() ([]net.IP, error) {
15 + _, ipNet_10, err := net.ParseCIDR("10.0.0.0/8")
16 + if err != nil {
17 + panic(err)
18 + }
19 +
20 + _, ipNet_172_16, err := net.ParseCIDR("172.16.0.0/12")
21 + if err != nil {
22 + panic(err)
23 + }
24 +
25 + _, ipNet_192_168, err := net.ParseCIDR("192.168.0.0/16")
26 + if err != nil {
27 + panic(err)
28 + }
29 +
30 + ifaces, err := net.Interfaces()
31 + if err != nil {
32 + return nil, err
33 + }
34 +
35 + var ips []net.IP
36 +
37 + for _, iface := range ifaces {
38 + addrs, err := iface.Addrs()
39 + if err != nil {
40 + return nil, err
41 + }
42 +
43 + for _, addr := range addrs {
44 + switch x := addr.(type) {
45 + case *net.IPNet:
46 + var ipNet *net.IPNet
47 + if ipNet_10.Contains(x.IP) {
48 + ipNet = ipNet_10
49 + } else if ipNet_172_16.Contains(x.IP) {
50 + ipNet = ipNet_172_16
51 + } else if ipNet_192_168.Contains(x.IP) {
52 + ipNet = ipNet_192_168
53 + }
54 +
55 + if ipNet != nil {
56 + ip := x.IP.Mask(x.Mask)
57 + ip = ip.To4()
58 + if ip != nil {
59 + ip[3] = ip[3] | 0x01
60 + ips = append(ips, ip)
61 + }
62 + }
63 + }
64 + }
65 + }
66 +
67 + if len(ips) == 0 {
68 + return nil, ErrNoNATFound
69 + }
70 +
71 + return ips, nil
72 +}
73 +
74 +func discoverNATPMP() <-chan NAT {
75 + ips, err := natpmp_PotentialGateways()
76 + if err != nil {
77 + return nil
78 + }
79 +
80 + res := make(chan NAT, len(ips))
81 +
82 + for _, ip := range ips {
83 + go discoverNATPMPWithAddr(res, ip)
84 + }
85 +
86 + return res
87 +}
88 +
89 +func discoverNATPMPWithAddr(c chan NAT, ip net.IP) {
90 + client := natpmp.NewClient(ip)
91 + _, err := client.GetExternalAddress()
92 + if err != nil {
93 + return
94 + }
95 +
96 + c <- &natpmp_NAT{client, ip, make(map[int]int)}
97 +}
98 +
99 +type natpmp_NAT struct {
100 + c *natpmp.Client
101 + gateway net.IP
102 + ports map[int]int
103 +}
104 +
105 +func (n *natpmp_NAT) GetDeviceAddress() (addr net.IP, err error) {
106 + return n.gateway, nil
107 +}
108 +
109 +func (n *natpmp_NAT) GetInternalAddress() (addr net.IP, err error) {
110 + ifaces, err := net.Interfaces()
111 + if err != nil {
112 + return nil, err
113 + }
114 +
115 + for _, iface := range ifaces {
116 + addrs, err := iface.Addrs()
117 + if err != nil {
118 + return nil, err
119 + }
120 +
121 + for _, addr := range addrs {
122 + switch x := addr.(type) {
123 + case *net.IPNet:
124 + if x.Contains(n.gateway) {
125 + return x.IP, nil
126 + }
127 + }
128 + }
129 + }
130 +
131 + return nil, ErrNoInternalAddress
132 +}
133 +
134 +func (n *natpmp_NAT) GetExternalAddress() (addr net.IP, err error) {
135 + res, err := n.c.GetExternalAddress()
136 + if err != nil {
137 + return nil, err
138 + }
139 +
140 + d := res.ExternalIPAddress
141 + return net.IPv4(d[0], d[1], d[2], d[3]), nil
142 +}
143 +
144 +func (n *natpmp_NAT) AddPortMapping(protocol string, internalPort int, description string, timeout time.Duration) (int, error) {
145 + var (
146 + err error
147 + )
148 +
149 + timeoutInSeconds := int(timeout / time.Second)
150 +
151 + if externalPort := n.ports[internalPort]; externalPort > 0 {
152 + _, err = n.c.AddPortMapping(protocol, internalPort, externalPort, timeoutInSeconds)
153 + if err == nil {
154 + n.ports[internalPort] = externalPort
155 + return externalPort, nil
156 + }
157 + }
158 +
159 + for i := 0; i < 3; i++ {
160 + externalPort := randomPort()
161 + _, err = n.c.AddPortMapping(protocol, internalPort, externalPort, timeoutInSeconds)
162 + if err == nil {
163 + n.ports[internalPort] = externalPort
164 + return externalPort, nil
165 + }
166 + }
167 +
168 + return 0, err
169 +}
170 +
171 +func (n *natpmp_NAT) DeletePortMapping(protocol string, internalPort int) (err error) {
172 + delete(n.ports, internalPort)
173 + return nil
174 +}
175 +
176 +func (n *natpmp_NAT) Type() string {
177 + return "NAT-PMP"
178 +}
Godeps/_workspace/src/github.com/fd/go-nat/upnp.go new
+239
@@ -0,0 +1,239 @@
1 +package nat
2 +
3 +import (
4 + "net"
5 + "time"
6 +
7 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp"
8 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway1"
9 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway2"
10 +)
11 +
12 +var (
13 + _ NAT = (*upnp_NAT)(nil)
14 +)
15 +
16 +func discoverUPNP_IG1() <-chan NAT {
17 + res := make(chan NAT, 1)
18 + go func() {
19 +
20 + // find devices
21 + devs, err := goupnp.DiscoverDevices(internetgateway1.URN_WANConnectionDevice_1)
22 + if err != nil {
23 + return
24 + }
25 +
26 + for _, dev := range devs {
27 + if dev.Root == nil {
28 + continue
29 + }
30 +
31 + dev.Root.Device.VisitServices(func(srv *goupnp.Service) {
32 + switch srv.ServiceType {
33 + case internetgateway1.URN_WANIPConnection_1:
34 + client := &internetgateway1.WANIPConnection1{ServiceClient: goupnp.ServiceClient{
35 + SOAPClient: srv.NewSOAPClient(),
36 + RootDevice: dev.Root,
37 + Service: srv,
38 + }}
39 + _, isNat, err := client.GetNATRSIPStatus()
40 + if err == nil && isNat {
41 + res <- &upnp_NAT{client, make(map[int]int), "UPNP (IG1-IP1)", dev.Root}
42 + return
43 + }
44 +
45 + case internetgateway1.URN_WANPPPConnection_1:
46 + client := &internetgateway1.WANPPPConnection1{ServiceClient: goupnp.ServiceClient{
47 + SOAPClient: srv.NewSOAPClient(),
48 + RootDevice: dev.Root,
49 + Service: srv,
50 + }}
51 + _, isNat, err := client.GetNATRSIPStatus()
52 + if err == nil && isNat {
53 + res <- &upnp_NAT{client, make(map[int]int), "UPNP (IG1-PPP1)", dev.Root}
54 + return
55 + }
56 +
57 + }
58 + })
59 + }
60 +
61 + }()
62 + return res
63 +}
64 +
65 +func discoverUPNP_IG2() <-chan NAT {
66 + res := make(chan NAT, 1)
67 + go func() {
68 +
69 + // find devices
70 + devs, err := goupnp.DiscoverDevices(internetgateway2.URN_WANConnectionDevice_2)
71 + if err != nil {
72 + return
73 + }
74 +
75 + for _, dev := range devs {
76 + if dev.Root == nil {
77 + continue
78 + }
79 +
80 + dev.Root.Device.VisitServices(func(srv *goupnp.Service) {
81 + switch srv.ServiceType {
82 + case internetgateway2.URN_WANIPConnection_1:
83 + client := &internetgateway2.WANIPConnection1{ServiceClient: goupnp.ServiceClient{
84 + SOAPClient: srv.NewSOAPClient(),
85 + RootDevice: dev.Root,
86 + Service: srv,
87 + }}
88 + _, isNat, err := client.GetNATRSIPStatus()
89 + if err == nil && isNat {
90 + res <- &upnp_NAT{client, make(map[int]int), "UPNP (IG2-IP1)", dev.Root}
91 + return
92 + }
93 +
94 + case internetgateway2.URN_WANIPConnection_2:
95 + client := &internetgateway2.WANIPConnection2{ServiceClient: goupnp.ServiceClient{
96 + SOAPClient: srv.NewSOAPClient(),
97 + RootDevice: dev.Root,
98 + Service: srv,
99 + }}
100 + _, isNat, err := client.GetNATRSIPStatus()
101 + if err == nil && isNat {
102 + res <- &upnp_NAT{client, make(map[int]int), "UPNP (IG2-IP2)", dev.Root}
103 + return
104 + }
105 +
106 + case internetgateway2.URN_WANPPPConnection_1:
107 + client := &internetgateway2.WANPPPConnection1{ServiceClient: goupnp.ServiceClient{
108 + SOAPClient: srv.NewSOAPClient(),
109 + RootDevice: dev.Root,
110 + Service: srv,
111 + }}
112 + _, isNat, err := client.GetNATRSIPStatus()
113 + if err == nil && isNat {
114 + res <- &upnp_NAT{client, make(map[int]int), "UPNP (IG2-PPP1)", dev.Root}
115 + return
116 + }
117 +
118 + }
119 + })
120 + }
121 +
122 + }()
123 + return res
124 +}
125 +
126 +type upnp_NAT_Client interface {
127 + GetExternalIPAddress() (string, error)
128 + AddPortMapping(string, uint16, string, uint16, string, bool, string, uint32) error
129 + DeletePortMapping(string, uint16, string) error
130 +}
131 +
132 +type upnp_NAT struct {
133 + c upnp_NAT_Client
134 + ports map[int]int
135 + typ string
136 + rootDevice *goupnp.RootDevice
137 +}
138 +
139 +func (u *upnp_NAT) GetExternalAddress() (addr net.IP, err error) {
140 + ipString, err := u.c.GetExternalIPAddress()
141 + if err != nil {
142 + return nil, err
143 + }
144 +
145 + ip := net.ParseIP(ipString)
146 + if ip == nil {
147 + return nil, ErrNoExternalAddress
148 + }
149 +
150 + return ip, nil
151 +}
152 +
153 +func mapProtocol(s string) string {
154 + switch s {
155 + case "udp":
156 + return "UDP"
157 + case "tcp":
158 + return "TCP"
159 + default:
160 + panic("invalid protocol: " + s)
161 + }
162 +}
163 +
164 +func (u *upnp_NAT) AddPortMapping(protocol string, internalPort int, description string, timeout time.Duration) (int, error) {
165 + ip, err := u.GetInternalAddress()
166 + if err != nil {
167 + return 0, nil
168 + }
169 +
170 + timeoutInSeconds := uint32(timeout / time.Second)
171 +
172 + if externalPort := u.ports[internalPort]; externalPort > 0 {
173 + err = u.c.AddPortMapping("", uint16(externalPort), mapProtocol(protocol), uint16(internalPort), ip.String(), true, description, timeoutInSeconds)
174 + if err == nil {
175 + return externalPort, nil
176 + }
177 + }
178 +
179 + for i := 0; i < 3; i++ {
180 + externalPort := randomPort()
181 + err = u.c.AddPortMapping("", uint16(externalPort), mapProtocol(protocol), uint16(internalPort), ip.String(), true, description, timeoutInSeconds)
182 + if err == nil {
183 + u.ports[internalPort] = externalPort
184 + return externalPort, nil
185 + }
186 + }
187 +
188 + return 0, err
189 +}
190 +
191 +func (u *upnp_NAT) DeletePortMapping(protocol string, internalPort int) error {
192 + if externalPort := u.ports[internalPort]; externalPort > 0 {
193 + delete(u.ports, internalPort)
194 + return u.c.DeletePortMapping("", uint16(externalPort), mapProtocol(protocol))
195 + }
196 +
197 + return nil
198 +}
199 +
200 +func (u *upnp_NAT) GetDeviceAddress() (net.IP, error) {
201 + addr, err := net.ResolveUDPAddr("udp4", u.rootDevice.URLBase.Host)
202 + if err != nil {
203 + return nil, err
204 + }
205 +
206 + return addr.IP, nil
207 +}
208 +
209 +func (u *upnp_NAT) GetInternalAddress() (net.IP, error) {
210 + devAddr, err := u.GetDeviceAddress()
211 + if err != nil {
212 + return nil, err
213 + }
214 +
215 + ifaces, err := net.Interfaces()
216 + if err != nil {
217 + return nil, err
218 + }
219 +
220 + for _, iface := range ifaces {
221 + addrs, err := iface.Addrs()
222 + if err != nil {
223 + return nil, err
224 + }
225 +
226 + for _, addr := range addrs {
227 + switch x := addr.(type) {
228 + case *net.IPNet:
229 + if x.Contains(devAddr) {
230 + return x.IP, nil
231 + }
232 + }
233 + }
234 + }
235 +
236 + return nil, ErrNoInternalAddress
237 +}
238 +
239 +func (n *upnp_NAT) Type() string { return n.typ }
Godeps/_workspace/src/github.com/huin/goupnp/LICENSE new
+23
@@ -0,0 +1,23 @@
1 +Copyright (c) 2013, John Beisley <greatred@gmail.com>
2 +All rights reserved.
3 +
4 +Redistribution and use in source and binary forms, with or without modification,
5 +are permitted provided that the following conditions are met:
6 +
7 +* Redistributions of source code must retain the above copyright notice, this
8 + list of conditions and the following disclaimer.
9 +
10 +* Redistributions in binary form must reproduce the above copyright notice, this
11 + list of conditions and the following disclaimer in the documentation and/or
12 + other materials provided with the distribution.
13 +
14 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
18 +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Godeps/_workspace/src/github.com/huin/goupnp/README.md new
+14
@@ -0,0 +1,14 @@
1 +goupnp is a UPnP client library for Go
2 +
3 +Installation
4 +------------
5 +
6 +Run `go get -u github.com/huin/goupnp`.
7 +
8 +Regenerating dcps generated source code:
9 +----------------------------------------
10 +
11 +1. Install gotasks: `go get -u github.com/jingweno/gotask`
12 +2. Change to the gotasks directory: `cd gotasks`
13 +3. Download UPnP specification data (if not done already): `wget http://upnp.org/resources/upnpresources.zip`
14 +4. Regenerate source code: `gotask specgen -s upnpresources.zip -o ../dcps`
Godeps/_workspace/src/github.com/huin/goupnp/cmd/example_httpu_serving/example_httpu_serving.go new
+20
@@ -0,0 +1,20 @@
1 +package main
2 +
3 +import (
4 + "log"
5 + "net/http"
6 +
7 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/httpu"
8 +)
9 +
10 +func main() {
11 + srv := httpu.Server{
12 + Addr: "239.255.255.250:1900",
13 + Multicast: true,
14 + Handler: httpu.HandlerFunc(func(r *http.Request) {
15 + log.Printf("Got %s %s message from %v: %v", r.Method, r.URL.Path, r.RemoteAddr, r.Header)
16 + }),
17 + }
18 + err := srv.ListenAndServe()
19 + log.Printf("Serving failed with error: %v", err)
20 +}
Godeps/_workspace/src/github.com/huin/goupnp/cmd/example_internetgateway1/example_internetgateway1.go new
+67
@@ -0,0 +1,67 @@
1 +package main
2 +
3 +import (
4 + "fmt"
5 + "log"
6 +
7 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway1"
8 +)
9 +
10 +func main() {
11 + clients, errors, err := internetgateway1.NewWANPPPConnection1Clients()
12 + if err != nil {
13 + log.Fatal(err)
14 + }
15 +
16 + fmt.Printf("Got %d errors finding servers and %d successfully discovered.\n",
17 + len(errors), len(clients))
18 + for i, e := range errors {
19 + fmt.Printf("Error finding server #%d: %v\n", i+1, e)
20 + }
21 +
22 + for _, c := range clients {
23 + dev := &c.ServiceClient.RootDevice.Device
24 + srv := c.ServiceClient.Service
25 + fmt.Println(dev.FriendlyName, " :: ", srv.String())
26 + scpd, err := srv.RequestSCDP()
27 + if err != nil {
28 + fmt.Printf(" Error requesting service SCPD: %v\n", err)
29 + } else {
30 + fmt.Println(" Available actions:")
31 + for _, action := range scpd.Actions {
32 + fmt.Printf(" * %s\n", action.Name)
33 + for _, arg := range action.Arguments {
34 + var varDesc string
35 + if stateVar := scpd.GetStateVariable(arg.RelatedStateVariable); stateVar != nil {
36 + varDesc = fmt.Sprintf(" (%s)", stateVar.DataType.Name)
37 + }
38 + fmt.Printf(" * [%s] %s%s\n", arg.Direction, arg.Name, varDesc)
39 + }
40 + }
41 + }
42 +
43 + if scpd == nil || scpd.GetAction("GetExternalIPAddress") != nil {
44 + ip, err := c.GetExternalIPAddress()
45 + fmt.Println("GetExternalIPAddress: ", ip, err)
46 + }
47 +
48 + if scpd == nil || scpd.GetAction("GetStatusInfo") != nil {
49 + status, lastErr, uptime, err := c.GetStatusInfo()
50 + fmt.Println("GetStatusInfo: ", status, lastErr, uptime, err)
51 + }
52 +
53 + if scpd == nil || scpd.GetAction("GetIdleDisconnectTime") != nil {
54 + idleTime, err := c.GetIdleDisconnectTime()
55 + fmt.Println("GetIdleDisconnectTime: ", idleTime, err)
56 + }
57 +
58 + if scpd == nil || scpd.GetAction("AddPortMapping") != nil {
59 + err := c.AddPortMapping("", 5000, "TCP", 5001, "192.168.1.2", true, "Test port mapping", 0)
60 + fmt.Println("AddPortMapping: ", err)
61 + }
62 + if scpd == nil || scpd.GetAction("DeletePortMapping") != nil {
63 + err := c.DeletePortMapping("", 5000, "TCP")
64 + fmt.Println("DeletePortMapping: ", err)
65 + }
66 + }
67 +}
Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway1/internetgateway1.go new
+3957
@@ -0,0 +1,3957 @@
1 +// Client for UPnP Device Control Protocol Internet Gateway Device v1.
2 +//
3 +// This DCP is documented in detail at: http://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v1-Device.pdf
4 +//
5 +// Typically, use one of the New* functions to discover services on the local
6 +// network.
7 +package internetgateway1
8 +
9 +// Generated file - do not edit by hand. See README.md
10 +
11 +import (
12 + "time"
13 +
14 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp"
15 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/soap"
16 +)
17 +
18 +// Hack to avoid Go complaining if time isn't used.
19 +var _ time.Time
20 +
21 +// Device URNs:
22 +const (
23 + URN_LANDevice_1 = "urn:schemas-upnp-org:device:LANDevice:1"
24 + URN_WANConnectionDevice_1 = "urn:schemas-upnp-org:device:WANConnectionDevice:1"
25 + URN_WANDevice_1 = "urn:schemas-upnp-org:device:WANDevice:1"
26 +)
27 +
28 +// Service URNs:
29 +const (
30 + URN_LANHostConfigManagement_1 = "urn:schemas-upnp-org:service:LANHostConfigManagement:1"
31 + URN_Layer3Forwarding_1 = "urn:schemas-upnp-org:service:Layer3Forwarding:1"
32 + URN_WANCableLinkConfig_1 = "urn:schemas-upnp-org:service:WANCableLinkConfig:1"
33 + URN_WANCommonInterfaceConfig_1 = "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"
34 + URN_WANDSLLinkConfig_1 = "urn:schemas-upnp-org:service:WANDSLLinkConfig:1"
35 + URN_WANEthernetLinkConfig_1 = "urn:schemas-upnp-org:service:WANEthernetLinkConfig:1"
36 + URN_WANIPConnection_1 = "urn:schemas-upnp-org:service:WANIPConnection:1"
37 + URN_WANPOTSLinkConfig_1 = "urn:schemas-upnp-org:service:WANPOTSLinkConfig:1"
38 + URN_WANPPPConnection_1 = "urn:schemas-upnp-org:service:WANPPPConnection:1"
39 +)
40 +
41 +// LANHostConfigManagement1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:LANHostConfigManagement:1". See
42 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
43 +// are provided for informational value.
44 +type LANHostConfigManagement1 struct {
45 + goupnp.ServiceClient
46 +}
47 +
48 +// NewLANHostConfigManagement1Clients discovers instances of the service on the network,
49 +// and returns clients to any that are found. errors will contain an error for
50 +// any devices that replied but which could not be queried, and err will be set
51 +// if the discovery process failed outright.
52 +//
53 +// This is a typical entry calling point into this package.
54 +func NewLANHostConfigManagement1Clients() (clients []*LANHostConfigManagement1, errors []error, err error) {
55 + var genericClients []goupnp.ServiceClient
56 + if genericClients, errors, err = goupnp.NewServiceClients(URN_LANHostConfigManagement_1); err != nil {
57 + return
58 + }
59 + clients = make([]*LANHostConfigManagement1, len(genericClients))
60 + for i := range genericClients {
61 + clients[i] = &LANHostConfigManagement1{genericClients[i]}
62 + }
63 + return
64 +}
65 +
66 +// Arguments:
67 +//
68 +// * NewDHCPServerConfigurable:
69 +//
70 +//
71 +func (client *LANHostConfigManagement1) SetDHCPServerConfigurable(NewDHCPServerConfigurable bool) (err error) {
72 + // Request structure.
73 + request := &struct {
74 + NewDHCPServerConfigurable string
75 + }{}
76 + // BEGIN Marshal arguments into request.
77 +
78 + if request.NewDHCPServerConfigurable, err = soap.MarshalBoolean(NewDHCPServerConfigurable); err != nil {
79 + return
80 + }
81 + // END Marshal arguments into request.
82 +
83 + // Response structure.
84 + response := interface{}(nil)
85 +
86 + // Perform the SOAP call.
87 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetDHCPServerConfigurable", request, response); err != nil {
88 + return
89 + }
90 +
91 + // BEGIN Unmarshal arguments from response.
92 +
93 + // END Unmarshal arguments from response.
94 + return
95 +}
96 +
97 +//
98 +//
99 +// Return values:
100 +//
101 +// * NewDHCPServerConfigurable:
102 +func (client *LANHostConfigManagement1) GetDHCPServerConfigurable() (NewDHCPServerConfigurable bool, err error) {
103 + // Request structure.
104 + request := interface{}(nil)
105 + // BEGIN Marshal arguments into request.
106 +
107 + // END Marshal arguments into request.
108 +
109 + // Response structure.
110 + response := &struct {
111 + NewDHCPServerConfigurable string
112 + }{}
113 +
114 + // Perform the SOAP call.
115 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetDHCPServerConfigurable", request, response); err != nil {
116 + return
117 + }
118 +
119 + // BEGIN Unmarshal arguments from response.
120 +
121 + if NewDHCPServerConfigurable, err = soap.UnmarshalBoolean(response.NewDHCPServerConfigurable); err != nil {
122 + return
123 + }
124 + // END Unmarshal arguments from response.
125 + return
126 +}
127 +
128 +// Arguments:
129 +//
130 +// * NewDHCPRelay:
131 +//
132 +//
133 +func (client *LANHostConfigManagement1) SetDHCPRelay(NewDHCPRelay bool) (err error) {
134 + // Request structure.
135 + request := &struct {
136 + NewDHCPRelay string
137 + }{}
138 + // BEGIN Marshal arguments into request.
139 +
140 + if request.NewDHCPRelay, err = soap.MarshalBoolean(NewDHCPRelay); err != nil {
141 + return
142 + }
143 + // END Marshal arguments into request.
144 +
145 + // Response structure.
146 + response := interface{}(nil)
147 +
148 + // Perform the SOAP call.
149 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetDHCPRelay", request, response); err != nil {
150 + return
151 + }
152 +
153 + // BEGIN Unmarshal arguments from response.
154 +
155 + // END Unmarshal arguments from response.
156 + return
157 +}
158 +
159 +//
160 +//
161 +// Return values:
162 +//
163 +// * NewDHCPRelay:
164 +func (client *LANHostConfigManagement1) GetDHCPRelay() (NewDHCPRelay bool, err error) {
165 + // Request structure.
166 + request := interface{}(nil)
167 + // BEGIN Marshal arguments into request.
168 +
169 + // END Marshal arguments into request.
170 +
171 + // Response structure.
172 + response := &struct {
173 + NewDHCPRelay string
174 + }{}
175 +
176 + // Perform the SOAP call.
177 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetDHCPRelay", request, response); err != nil {
178 + return
179 + }
180 +
181 + // BEGIN Unmarshal arguments from response.
182 +
183 + if NewDHCPRelay, err = soap.UnmarshalBoolean(response.NewDHCPRelay); err != nil {
184 + return
185 + }
186 + // END Unmarshal arguments from response.
187 + return
188 +}
189 +
190 +// Arguments:
191 +//
192 +// * NewSubnetMask:
193 +//
194 +//
195 +func (client *LANHostConfigManagement1) SetSubnetMask(NewSubnetMask string) (err error) {
196 + // Request structure.
197 + request := &struct {
198 + NewSubnetMask string
199 + }{}
200 + // BEGIN Marshal arguments into request.
201 +
202 + if request.NewSubnetMask, err = soap.MarshalString(NewSubnetMask); err != nil {
203 + return
204 + }
205 + // END Marshal arguments into request.
206 +
207 + // Response structure.
208 + response := interface{}(nil)
209 +
210 + // Perform the SOAP call.
211 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetSubnetMask", request, response); err != nil {
212 + return
213 + }
214 +
215 + // BEGIN Unmarshal arguments from response.
216 +
217 + // END Unmarshal arguments from response.
218 + return
219 +}
220 +
221 +//
222 +//
223 +// Return values:
224 +//
225 +// * NewSubnetMask:
226 +func (client *LANHostConfigManagement1) GetSubnetMask() (NewSubnetMask string, err error) {
227 + // Request structure.
228 + request := interface{}(nil)
229 + // BEGIN Marshal arguments into request.
230 +
231 + // END Marshal arguments into request.
232 +
233 + // Response structure.
234 + response := &struct {
235 + NewSubnetMask string
236 + }{}
237 +
238 + // Perform the SOAP call.
239 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetSubnetMask", request, response); err != nil {
240 + return
241 + }
242 +
243 + // BEGIN Unmarshal arguments from response.
244 +
245 + if NewSubnetMask, err = soap.UnmarshalString(response.NewSubnetMask); err != nil {
246 + return
247 + }
248 + // END Unmarshal arguments from response.
249 + return
250 +}
251 +
252 +// Arguments:
253 +//
254 +// * NewIPRouters:
255 +//
256 +//
257 +func (client *LANHostConfigManagement1) SetIPRouter(NewIPRouters string) (err error) {
258 + // Request structure.
259 + request := &struct {
260 + NewIPRouters string
261 + }{}
262 + // BEGIN Marshal arguments into request.
263 +
264 + if request.NewIPRouters, err = soap.MarshalString(NewIPRouters); err != nil {
265 + return
266 + }
267 + // END Marshal arguments into request.
268 +
269 + // Response structure.
270 + response := interface{}(nil)
271 +
272 + // Perform the SOAP call.
273 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetIPRouter", request, response); err != nil {
274 + return
275 + }
276 +
277 + // BEGIN Unmarshal arguments from response.
278 +
279 + // END Unmarshal arguments from response.
280 + return
281 +}
282 +
283 +// Arguments:
284 +//
285 +// * NewIPRouters:
286 +//
287 +//
288 +func (client *LANHostConfigManagement1) DeleteIPRouter(NewIPRouters string) (err error) {
289 + // Request structure.
290 + request := &struct {
291 + NewIPRouters string
292 + }{}
293 + // BEGIN Marshal arguments into request.
294 +
295 + if request.NewIPRouters, err = soap.MarshalString(NewIPRouters); err != nil {
296 + return
297 + }
298 + // END Marshal arguments into request.
299 +
300 + // Response structure.
301 + response := interface{}(nil)
302 +
303 + // Perform the SOAP call.
304 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "DeleteIPRouter", request, response); err != nil {
305 + return
306 + }
307 +
308 + // BEGIN Unmarshal arguments from response.
309 +
310 + // END Unmarshal arguments from response.
311 + return
312 +}
313 +
314 +//
315 +//
316 +// Return values:
317 +//
318 +// * NewIPRouters:
319 +func (client *LANHostConfigManagement1) GetIPRoutersList() (NewIPRouters string, err error) {
320 + // Request structure.
321 + request := interface{}(nil)
322 + // BEGIN Marshal arguments into request.
323 +
324 + // END Marshal arguments into request.
325 +
326 + // Response structure.
327 + response := &struct {
328 + NewIPRouters string
329 + }{}
330 +
331 + // Perform the SOAP call.
332 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetIPRoutersList", request, response); err != nil {
333 + return
334 + }
335 +
336 + // BEGIN Unmarshal arguments from response.
337 +
338 + if NewIPRouters, err = soap.UnmarshalString(response.NewIPRouters); err != nil {
339 + return
340 + }
341 + // END Unmarshal arguments from response.
342 + return
343 +}
344 +
345 +// Arguments:
346 +//
347 +// * NewDomainName:
348 +//
349 +//
350 +func (client *LANHostConfigManagement1) SetDomainName(NewDomainName string) (err error) {
351 + // Request structure.
352 + request := &struct {
353 + NewDomainName string
354 + }{}
355 + // BEGIN Marshal arguments into request.
356 +
357 + if request.NewDomainName, err = soap.MarshalString(NewDomainName); err != nil {
358 + return
359 + }
360 + // END Marshal arguments into request.
361 +
362 + // Response structure.
363 + response := interface{}(nil)
364 +
365 + // Perform the SOAP call.
366 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetDomainName", request, response); err != nil {
367 + return
368 + }
369 +
370 + // BEGIN Unmarshal arguments from response.
371 +
372 + // END Unmarshal arguments from response.
373 + return
374 +}
375 +
376 +//
377 +//
378 +// Return values:
379 +//
380 +// * NewDomainName:
381 +func (client *LANHostConfigManagement1) GetDomainName() (NewDomainName string, err error) {
382 + // Request structure.
383 + request := interface{}(nil)
384 + // BEGIN Marshal arguments into request.
385 +
386 + // END Marshal arguments into request.
387 +
388 + // Response structure.
389 + response := &struct {
390 + NewDomainName string
391 + }{}
392 +
393 + // Perform the SOAP call.
394 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetDomainName", request, response); err != nil {
395 + return
396 + }
397 +
398 + // BEGIN Unmarshal arguments from response.
399 +
400 + if NewDomainName, err = soap.UnmarshalString(response.NewDomainName); err != nil {
401 + return
402 + }
403 + // END Unmarshal arguments from response.
404 + return
405 +}
406 +
407 +// Arguments:
408 +//
409 +// * NewMinAddress:
410 +//
411 +// * NewMaxAddress:
412 +//
413 +//
414 +func (client *LANHostConfigManagement1) SetAddressRange(NewMinAddress string, NewMaxAddress string) (err error) {
415 + // Request structure.
416 + request := &struct {
417 + NewMinAddress string
418 +
419 + NewMaxAddress string
420 + }{}
421 + // BEGIN Marshal arguments into request.
422 +
423 + if request.NewMinAddress, err = soap.MarshalString(NewMinAddress); err != nil {
424 + return
425 + }
426 + if request.NewMaxAddress, err = soap.MarshalString(NewMaxAddress); err != nil {
427 + return
428 + }
429 + // END Marshal arguments into request.
430 +
431 + // Response structure.
432 + response := interface{}(nil)
433 +
434 + // Perform the SOAP call.
435 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetAddressRange", request, response); err != nil {
436 + return
437 + }
438 +
439 + // BEGIN Unmarshal arguments from response.
440 +
441 + // END Unmarshal arguments from response.
442 + return
443 +}
444 +
445 +//
446 +//
447 +// Return values:
448 +//
449 +// * NewMinAddress:
450 +//
451 +// * NewMaxAddress:
452 +func (client *LANHostConfigManagement1) GetAddressRange() (NewMinAddress string, NewMaxAddress string, err error) {
453 + // Request structure.
454 + request := interface{}(nil)
455 + // BEGIN Marshal arguments into request.
456 +
457 + // END Marshal arguments into request.
458 +
459 + // Response structure.
460 + response := &struct {
461 + NewMinAddress string
462 +
463 + NewMaxAddress string
464 + }{}
465 +
466 + // Perform the SOAP call.
467 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetAddressRange", request, response); err != nil {
468 + return
469 + }
470 +
471 + // BEGIN Unmarshal arguments from response.
472 +
473 + if NewMinAddress, err = soap.UnmarshalString(response.NewMinAddress); err != nil {
474 + return
475 + }
476 + if NewMaxAddress, err = soap.UnmarshalString(response.NewMaxAddress); err != nil {
477 + return
478 + }
479 + // END Unmarshal arguments from response.
480 + return
481 +}
482 +
483 +// Arguments:
484 +//
485 +// * NewReservedAddresses:
486 +//
487 +//
488 +func (client *LANHostConfigManagement1) SetReservedAddress(NewReservedAddresses string) (err error) {
489 + // Request structure.
490 + request := &struct {
491 + NewReservedAddresses string
492 + }{}
493 + // BEGIN Marshal arguments into request.
494 +
495 + if request.NewReservedAddresses, err = soap.MarshalString(NewReservedAddresses); err != nil {
496 + return
497 + }
498 + // END Marshal arguments into request.
499 +
500 + // Response structure.
501 + response := interface{}(nil)
502 +
503 + // Perform the SOAP call.
504 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetReservedAddress", request, response); err != nil {
505 + return
506 + }
507 +
508 + // BEGIN Unmarshal arguments from response.
509 +
510 + // END Unmarshal arguments from response.
511 + return
512 +}
513 +
514 +// Arguments:
515 +//
516 +// * NewReservedAddresses:
517 +//
518 +//
519 +func (client *LANHostConfigManagement1) DeleteReservedAddress(NewReservedAddresses string) (err error) {
520 + // Request structure.
521 + request := &struct {
522 + NewReservedAddresses string
523 + }{}
524 + // BEGIN Marshal arguments into request.
525 +
526 + if request.NewReservedAddresses, err = soap.MarshalString(NewReservedAddresses); err != nil {
527 + return
528 + }
529 + // END Marshal arguments into request.
530 +
531 + // Response structure.
532 + response := interface{}(nil)
533 +
534 + // Perform the SOAP call.
535 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "DeleteReservedAddress", request, response); err != nil {
536 + return
537 + }
538 +
539 + // BEGIN Unmarshal arguments from response.
540 +
541 + // END Unmarshal arguments from response.
542 + return
543 +}
544 +
545 +//
546 +//
547 +// Return values:
548 +//
549 +// * NewReservedAddresses:
550 +func (client *LANHostConfigManagement1) GetReservedAddresses() (NewReservedAddresses string, err error) {
551 + // Request structure.
552 + request := interface{}(nil)
553 + // BEGIN Marshal arguments into request.
554 +
555 + // END Marshal arguments into request.
556 +
557 + // Response structure.
558 + response := &struct {
559 + NewReservedAddresses string
560 + }{}
561 +
562 + // Perform the SOAP call.
563 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetReservedAddresses", request, response); err != nil {
564 + return
565 + }
566 +
567 + // BEGIN Unmarshal arguments from response.
568 +
569 + if NewReservedAddresses, err = soap.UnmarshalString(response.NewReservedAddresses); err != nil {
570 + return
571 + }
572 + // END Unmarshal arguments from response.
573 + return
574 +}
575 +
576 +// Arguments:
577 +//
578 +// * NewDNSServers:
579 +//
580 +//
581 +func (client *LANHostConfigManagement1) SetDNSServer(NewDNSServers string) (err error) {
582 + // Request structure.
583 + request := &struct {
584 + NewDNSServers string
585 + }{}
586 + // BEGIN Marshal arguments into request.
587 +
588 + if request.NewDNSServers, err = soap.MarshalString(NewDNSServers); err != nil {
589 + return
590 + }
591 + // END Marshal arguments into request.
592 +
593 + // Response structure.
594 + response := interface{}(nil)
595 +
596 + // Perform the SOAP call.
597 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetDNSServer", request, response); err != nil {
598 + return
599 + }
600 +
601 + // BEGIN Unmarshal arguments from response.
602 +
603 + // END Unmarshal arguments from response.
604 + return
605 +}
606 +
607 +// Arguments:
608 +//
609 +// * NewDNSServers:
610 +//
611 +//
612 +func (client *LANHostConfigManagement1) DeleteDNSServer(NewDNSServers string) (err error) {
613 + // Request structure.
614 + request := &struct {
615 + NewDNSServers string
616 + }{}
617 + // BEGIN Marshal arguments into request.
618 +
619 + if request.NewDNSServers, err = soap.MarshalString(NewDNSServers); err != nil {
620 + return
621 + }
622 + // END Marshal arguments into request.
623 +
624 + // Response structure.
625 + response := interface{}(nil)
626 +
627 + // Perform the SOAP call.
628 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "DeleteDNSServer", request, response); err != nil {
629 + return
630 + }
631 +
632 + // BEGIN Unmarshal arguments from response.
633 +
634 + // END Unmarshal arguments from response.
635 + return
636 +}
637 +
638 +//
639 +//
640 +// Return values:
641 +//
642 +// * NewDNSServers:
643 +func (client *LANHostConfigManagement1) GetDNSServers() (NewDNSServers string, err error) {
644 + // Request structure.
645 + request := interface{}(nil)
646 + // BEGIN Marshal arguments into request.
647 +
648 + // END Marshal arguments into request.
649 +
650 + // Response structure.
651 + response := &struct {
652 + NewDNSServers string
653 + }{}
654 +
655 + // Perform the SOAP call.
656 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetDNSServers", request, response); err != nil {
657 + return
658 + }
659 +
660 + // BEGIN Unmarshal arguments from response.
661 +
662 + if NewDNSServers, err = soap.UnmarshalString(response.NewDNSServers); err != nil {
663 + return
664 + }
665 + // END Unmarshal arguments from response.
666 + return
667 +}
668 +
669 +// Layer3Forwarding1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:Layer3Forwarding:1". See
670 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
671 +// are provided for informational value.
672 +type Layer3Forwarding1 struct {
673 + goupnp.ServiceClient
674 +}
675 +
676 +// NewLayer3Forwarding1Clients discovers instances of the service on the network,
677 +// and returns clients to any that are found. errors will contain an error for
678 +// any devices that replied but which could not be queried, and err will be set
679 +// if the discovery process failed outright.
680 +//
681 +// This is a typical entry calling point into this package.
682 +func NewLayer3Forwarding1Clients() (clients []*Layer3Forwarding1, errors []error, err error) {
683 + var genericClients []goupnp.ServiceClient
684 + if genericClients, errors, err = goupnp.NewServiceClients(URN_Layer3Forwarding_1); err != nil {
685 + return
686 + }
687 + clients = make([]*Layer3Forwarding1, len(genericClients))
688 + for i := range genericClients {
689 + clients[i] = &Layer3Forwarding1{genericClients[i]}
690 + }
691 + return
692 +}
693 +
694 +// Arguments:
695 +//
696 +// * NewDefaultConnectionService:
697 +//
698 +//
699 +func (client *Layer3Forwarding1) SetDefaultConnectionService(NewDefaultConnectionService string) (err error) {
700 + // Request structure.
701 + request := &struct {
702 + NewDefaultConnectionService string
703 + }{}
704 + // BEGIN Marshal arguments into request.
705 +
706 + if request.NewDefaultConnectionService, err = soap.MarshalString(NewDefaultConnectionService); err != nil {
707 + return
708 + }
709 + // END Marshal arguments into request.
710 +
711 + // Response structure.
712 + response := interface{}(nil)
713 +
714 + // Perform the SOAP call.
715 + if err = client.SOAPClient.PerformAction(URN_Layer3Forwarding_1, "SetDefaultConnectionService", request, response); err != nil {
716 + return
717 + }
718 +
719 + // BEGIN Unmarshal arguments from response.
720 +
721 + // END Unmarshal arguments from response.
722 + return
723 +}
724 +
725 +//
726 +//
727 +// Return values:
728 +//
729 +// * NewDefaultConnectionService:
730 +func (client *Layer3Forwarding1) GetDefaultConnectionService() (NewDefaultConnectionService string, err error) {
731 + // Request structure.
732 + request := interface{}(nil)
733 + // BEGIN Marshal arguments into request.
734 +
735 + // END Marshal arguments into request.
736 +
737 + // Response structure.
738 + response := &struct {
739 + NewDefaultConnectionService string
740 + }{}
741 +
742 + // Perform the SOAP call.
743 + if err = client.SOAPClient.PerformAction(URN_Layer3Forwarding_1, "GetDefaultConnectionService", request, response); err != nil {
744 + return
745 + }
746 +
747 + // BEGIN Unmarshal arguments from response.
748 +
749 + if NewDefaultConnectionService, err = soap.UnmarshalString(response.NewDefaultConnectionService); err != nil {
750 + return
751 + }
752 + // END Unmarshal arguments from response.
753 + return
754 +}
755 +
756 +// WANCableLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANCableLinkConfig:1". See
757 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
758 +// are provided for informational value.
759 +type WANCableLinkConfig1 struct {
760 + goupnp.ServiceClient
761 +}
762 +
763 +// NewWANCableLinkConfig1Clients discovers instances of the service on the network,
764 +// and returns clients to any that are found. errors will contain an error for
765 +// any devices that replied but which could not be queried, and err will be set
766 +// if the discovery process failed outright.
767 +//
768 +// This is a typical entry calling point into this package.
769 +func NewWANCableLinkConfig1Clients() (clients []*WANCableLinkConfig1, errors []error, err error) {
770 + var genericClients []goupnp.ServiceClient
771 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANCableLinkConfig_1); err != nil {
772 + return
773 + }
774 + clients = make([]*WANCableLinkConfig1, len(genericClients))
775 + for i := range genericClients {
776 + clients[i] = &WANCableLinkConfig1{genericClients[i]}
777 + }
778 + return
779 +}
780 +
781 +//
782 +//
783 +// Return values:
784 +//
785 +// * NewCableLinkConfigState: allowed values: notReady, dsSyncComplete, usParamAcquired, rangingComplete, ipComplete, todEstablished, paramTransferComplete, registrationComplete, operational, accessDenied
786 +//
787 +// * NewLinkType: allowed values: Ethernet
788 +func (client *WANCableLinkConfig1) GetCableLinkConfigInfo() (NewCableLinkConfigState string, NewLinkType string, err error) {
789 + // Request structure.
790 + request := interface{}(nil)
791 + // BEGIN Marshal arguments into request.
792 +
793 + // END Marshal arguments into request.
794 +
795 + // Response structure.
796 + response := &struct {
797 + NewCableLinkConfigState string
798 +
799 + NewLinkType string
800 + }{}
801 +
802 + // Perform the SOAP call.
803 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetCableLinkConfigInfo", request, response); err != nil {
804 + return
805 + }
806 +
807 + // BEGIN Unmarshal arguments from response.
808 +
809 + if NewCableLinkConfigState, err = soap.UnmarshalString(response.NewCableLinkConfigState); err != nil {
810 + return
811 + }
812 + if NewLinkType, err = soap.UnmarshalString(response.NewLinkType); err != nil {
813 + return
814 + }
815 + // END Unmarshal arguments from response.
816 + return
817 +}
818 +
819 +//
820 +//
821 +// Return values:
822 +//
823 +// * NewDownstreamFrequency:
824 +func (client *WANCableLinkConfig1) GetDownstreamFrequency() (NewDownstreamFrequency uint32, err error) {
825 + // Request structure.
826 + request := interface{}(nil)
827 + // BEGIN Marshal arguments into request.
828 +
829 + // END Marshal arguments into request.
830 +
831 + // Response structure.
832 + response := &struct {
833 + NewDownstreamFrequency string
834 + }{}
835 +
836 + // Perform the SOAP call.
837 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetDownstreamFrequency", request, response); err != nil {
838 + return
839 + }
840 +
841 + // BEGIN Unmarshal arguments from response.
842 +
843 + if NewDownstreamFrequency, err = soap.UnmarshalUi4(response.NewDownstreamFrequency); err != nil {
844 + return
845 + }
846 + // END Unmarshal arguments from response.
847 + return
848 +}
849 +
850 +//
851 +//
852 +// Return values:
853 +//
854 +// * NewDownstreamModulation: allowed values: 64QAM, 256QAM
855 +func (client *WANCableLinkConfig1) GetDownstreamModulation() (NewDownstreamModulation string, err error) {
856 + // Request structure.
857 + request := interface{}(nil)
858 + // BEGIN Marshal arguments into request.
859 +
860 + // END Marshal arguments into request.
861 +
862 + // Response structure.
863 + response := &struct {
864 + NewDownstreamModulation string
865 + }{}
866 +
867 + // Perform the SOAP call.
868 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetDownstreamModulation", request, response); err != nil {
869 + return
870 + }
871 +
872 + // BEGIN Unmarshal arguments from response.
873 +
874 + if NewDownstreamModulation, err = soap.UnmarshalString(response.NewDownstreamModulation); err != nil {
875 + return
876 + }
877 + // END Unmarshal arguments from response.
878 + return
879 +}
880 +
881 +//
882 +//
883 +// Return values:
884 +//
885 +// * NewUpstreamFrequency:
886 +func (client *WANCableLinkConfig1) GetUpstreamFrequency() (NewUpstreamFrequency uint32, err error) {
887 + // Request structure.
888 + request := interface{}(nil)
889 + // BEGIN Marshal arguments into request.
890 +
891 + // END Marshal arguments into request.
892 +
893 + // Response structure.
894 + response := &struct {
895 + NewUpstreamFrequency string
896 + }{}
897 +
898 + // Perform the SOAP call.
899 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetUpstreamFrequency", request, response); err != nil {
900 + return
901 + }
902 +
903 + // BEGIN Unmarshal arguments from response.
904 +
905 + if NewUpstreamFrequency, err = soap.UnmarshalUi4(response.NewUpstreamFrequency); err != nil {
906 + return
907 + }
908 + // END Unmarshal arguments from response.
909 + return
910 +}
911 +
912 +//
913 +//
914 +// Return values:
915 +//
916 +// * NewUpstreamModulation: allowed values: QPSK, 16QAM
917 +func (client *WANCableLinkConfig1) GetUpstreamModulation() (NewUpstreamModulation string, err error) {
918 + // Request structure.
919 + request := interface{}(nil)
920 + // BEGIN Marshal arguments into request.
921 +
922 + // END Marshal arguments into request.
923 +
924 + // Response structure.
925 + response := &struct {
926 + NewUpstreamModulation string
927 + }{}
928 +
929 + // Perform the SOAP call.
930 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetUpstreamModulation", request, response); err != nil {
931 + return
932 + }
933 +
934 + // BEGIN Unmarshal arguments from response.
935 +
936 + if NewUpstreamModulation, err = soap.UnmarshalString(response.NewUpstreamModulation); err != nil {
937 + return
938 + }
939 + // END Unmarshal arguments from response.
940 + return
941 +}
942 +
943 +//
944 +//
945 +// Return values:
946 +//
947 +// * NewUpstreamChannelID:
948 +func (client *WANCableLinkConfig1) GetUpstreamChannelID() (NewUpstreamChannelID uint32, err error) {
949 + // Request structure.
950 + request := interface{}(nil)
951 + // BEGIN Marshal arguments into request.
952 +
953 + // END Marshal arguments into request.
954 +
955 + // Response structure.
956 + response := &struct {
957 + NewUpstreamChannelID string
958 + }{}
959 +
960 + // Perform the SOAP call.
961 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetUpstreamChannelID", request, response); err != nil {
962 + return
963 + }
964 +
965 + // BEGIN Unmarshal arguments from response.
966 +
967 + if NewUpstreamChannelID, err = soap.UnmarshalUi4(response.NewUpstreamChannelID); err != nil {
968 + return
969 + }
970 + // END Unmarshal arguments from response.
971 + return
972 +}
973 +
974 +//
975 +//
976 +// Return values:
977 +//
978 +// * NewUpstreamPowerLevel:
979 +func (client *WANCableLinkConfig1) GetUpstreamPowerLevel() (NewUpstreamPowerLevel uint32, err error) {
980 + // Request structure.
981 + request := interface{}(nil)
982 + // BEGIN Marshal arguments into request.
983 +
984 + // END Marshal arguments into request.
985 +
986 + // Response structure.
987 + response := &struct {
988 + NewUpstreamPowerLevel string
989 + }{}
990 +
991 + // Perform the SOAP call.
992 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetUpstreamPowerLevel", request, response); err != nil {
993 + return
994 + }
995 +
996 + // BEGIN Unmarshal arguments from response.
997 +
998 + if NewUpstreamPowerLevel, err = soap.UnmarshalUi4(response.NewUpstreamPowerLevel); err != nil {
999 + return
1000 + }
1001 + // END Unmarshal arguments from response.
1002 + return
1003 +}
1004 +
1005 +//
1006 +//
1007 +// Return values:
1008 +//
1009 +// * NewBPIEncryptionEnabled:
1010 +func (client *WANCableLinkConfig1) GetBPIEncryptionEnabled() (NewBPIEncryptionEnabled bool, err error) {
1011 + // Request structure.
1012 + request := interface{}(nil)
1013 + // BEGIN Marshal arguments into request.
1014 +
1015 + // END Marshal arguments into request.
1016 +
1017 + // Response structure.
1018 + response := &struct {
1019 + NewBPIEncryptionEnabled string
1020 + }{}
1021 +
1022 + // Perform the SOAP call.
1023 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetBPIEncryptionEnabled", request, response); err != nil {
1024 + return
1025 + }
1026 +
1027 + // BEGIN Unmarshal arguments from response.
1028 +
1029 + if NewBPIEncryptionEnabled, err = soap.UnmarshalBoolean(response.NewBPIEncryptionEnabled); err != nil {
1030 + return
1031 + }
1032 + // END Unmarshal arguments from response.
1033 + return
1034 +}
1035 +
1036 +//
1037 +//
1038 +// Return values:
1039 +//
1040 +// * NewConfigFile:
1041 +func (client *WANCableLinkConfig1) GetConfigFile() (NewConfigFile string, err error) {
1042 + // Request structure.
1043 + request := interface{}(nil)
1044 + // BEGIN Marshal arguments into request.
1045 +
1046 + // END Marshal arguments into request.
1047 +
1048 + // Response structure.
1049 + response := &struct {
1050 + NewConfigFile string
1051 + }{}
1052 +
1053 + // Perform the SOAP call.
1054 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetConfigFile", request, response); err != nil {
1055 + return
1056 + }
1057 +
1058 + // BEGIN Unmarshal arguments from response.
1059 +
1060 + if NewConfigFile, err = soap.UnmarshalString(response.NewConfigFile); err != nil {
1061 + return
1062 + }
1063 + // END Unmarshal arguments from response.
1064 + return
1065 +}
1066 +
1067 +//
1068 +//
1069 +// Return values:
1070 +//
1071 +// * NewTFTPServer:
1072 +func (client *WANCableLinkConfig1) GetTFTPServer() (NewTFTPServer string, err error) {
1073 + // Request structure.
1074 + request := interface{}(nil)
1075 + // BEGIN Marshal arguments into request.
1076 +
1077 + // END Marshal arguments into request.
1078 +
1079 + // Response structure.
1080 + response := &struct {
1081 + NewTFTPServer string
1082 + }{}
1083 +
1084 + // Perform the SOAP call.
1085 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetTFTPServer", request, response); err != nil {
1086 + return
1087 + }
1088 +
1089 + // BEGIN Unmarshal arguments from response.
1090 +
1091 + if NewTFTPServer, err = soap.UnmarshalString(response.NewTFTPServer); err != nil {
1092 + return
1093 + }
1094 + // END Unmarshal arguments from response.
1095 + return
1096 +}
1097 +
1098 +// WANCommonInterfaceConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1". See
1099 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
1100 +// are provided for informational value.
1101 +type WANCommonInterfaceConfig1 struct {
1102 + goupnp.ServiceClient
1103 +}
1104 +
1105 +// NewWANCommonInterfaceConfig1Clients discovers instances of the service on the network,
1106 +// and returns clients to any that are found. errors will contain an error for
1107 +// any devices that replied but which could not be queried, and err will be set
1108 +// if the discovery process failed outright.
1109 +//
1110 +// This is a typical entry calling point into this package.
1111 +func NewWANCommonInterfaceConfig1Clients() (clients []*WANCommonInterfaceConfig1, errors []error, err error) {
1112 + var genericClients []goupnp.ServiceClient
1113 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANCommonInterfaceConfig_1); err != nil {
1114 + return
1115 + }
1116 + clients = make([]*WANCommonInterfaceConfig1, len(genericClients))
1117 + for i := range genericClients {
1118 + clients[i] = &WANCommonInterfaceConfig1{genericClients[i]}
1119 + }
1120 + return
1121 +}
1122 +
1123 +// Arguments:
1124 +//
1125 +// * NewEnabledForInternet:
1126 +//
1127 +//
1128 +func (client *WANCommonInterfaceConfig1) SetEnabledForInternet(NewEnabledForInternet bool) (err error) {
1129 + // Request structure.
1130 + request := &struct {
1131 + NewEnabledForInternet string
1132 + }{}
1133 + // BEGIN Marshal arguments into request.
1134 +
1135 + if request.NewEnabledForInternet, err = soap.MarshalBoolean(NewEnabledForInternet); err != nil {
1136 + return
1137 + }
1138 + // END Marshal arguments into request.
1139 +
1140 + // Response structure.
1141 + response := interface{}(nil)
1142 +
1143 + // Perform the SOAP call.
1144 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "SetEnabledForInternet", request, response); err != nil {
1145 + return
1146 + }
1147 +
1148 + // BEGIN Unmarshal arguments from response.
1149 +
1150 + // END Unmarshal arguments from response.
1151 + return
1152 +}
1153 +
1154 +//
1155 +//
1156 +// Return values:
1157 +//
1158 +// * NewEnabledForInternet:
1159 +func (client *WANCommonInterfaceConfig1) GetEnabledForInternet() (NewEnabledForInternet bool, err error) {
1160 + // Request structure.
1161 + request := interface{}(nil)
1162 + // BEGIN Marshal arguments into request.
1163 +
1164 + // END Marshal arguments into request.
1165 +
1166 + // Response structure.
1167 + response := &struct {
1168 + NewEnabledForInternet string
1169 + }{}
1170 +
1171 + // Perform the SOAP call.
1172 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetEnabledForInternet", request, response); err != nil {
1173 + return
1174 + }
1175 +
1176 + // BEGIN Unmarshal arguments from response.
1177 +
1178 + if NewEnabledForInternet, err = soap.UnmarshalBoolean(response.NewEnabledForInternet); err != nil {
1179 + return
1180 + }
1181 + // END Unmarshal arguments from response.
1182 + return
1183 +}
1184 +
1185 +//
1186 +//
1187 +// Return values:
1188 +//
1189 +// * NewWANAccessType: allowed values: DSL, POTS, Cable, Ethernet
1190 +//
1191 +// * NewLayer1UpstreamMaxBitRate:
1192 +//
1193 +// * NewLayer1DownstreamMaxBitRate:
1194 +//
1195 +// * NewPhysicalLinkStatus: allowed values: Up, Down
1196 +func (client *WANCommonInterfaceConfig1) GetCommonLinkProperties() (NewWANAccessType string, NewLayer1UpstreamMaxBitRate uint32, NewLayer1DownstreamMaxBitRate uint32, NewPhysicalLinkStatus string, err error) {
1197 + // Request structure.
1198 + request := interface{}(nil)
1199 + // BEGIN Marshal arguments into request.
1200 +
1201 + // END Marshal arguments into request.
1202 +
1203 + // Response structure.
1204 + response := &struct {
1205 + NewWANAccessType string
1206 +
1207 + NewLayer1UpstreamMaxBitRate string
1208 +
1209 + NewLayer1DownstreamMaxBitRate string
1210 +
1211 + NewPhysicalLinkStatus string
1212 + }{}
1213 +
1214 + // Perform the SOAP call.
1215 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetCommonLinkProperties", request, response); err != nil {
1216 + return
1217 + }
1218 +
1219 + // BEGIN Unmarshal arguments from response.
1220 +
1221 + if NewWANAccessType, err = soap.UnmarshalString(response.NewWANAccessType); err != nil {
1222 + return
1223 + }
1224 + if NewLayer1UpstreamMaxBitRate, err = soap.UnmarshalUi4(response.NewLayer1UpstreamMaxBitRate); err != nil {
1225 + return
1226 + }
1227 + if NewLayer1DownstreamMaxBitRate, err = soap.UnmarshalUi4(response.NewLayer1DownstreamMaxBitRate); err != nil {
1228 + return
1229 + }
1230 + if NewPhysicalLinkStatus, err = soap.UnmarshalString(response.NewPhysicalLinkStatus); err != nil {
1231 + return
1232 + }
1233 + // END Unmarshal arguments from response.
1234 + return
1235 +}
1236 +
1237 +//
1238 +//
1239 +// Return values:
1240 +//
1241 +// * NewWANAccessProvider:
1242 +func (client *WANCommonInterfaceConfig1) GetWANAccessProvider() (NewWANAccessProvider string, err error) {
1243 + // Request structure.
1244 + request := interface{}(nil)
1245 + // BEGIN Marshal arguments into request.
1246 +
1247 + // END Marshal arguments into request.
1248 +
1249 + // Response structure.
1250 + response := &struct {
1251 + NewWANAccessProvider string
1252 + }{}
1253 +
1254 + // Perform the SOAP call.
1255 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetWANAccessProvider", request, response); err != nil {
1256 + return
1257 + }
1258 +
1259 + // BEGIN Unmarshal arguments from response.
1260 +
1261 + if NewWANAccessProvider, err = soap.UnmarshalString(response.NewWANAccessProvider); err != nil {
1262 + return
1263 + }
1264 + // END Unmarshal arguments from response.
1265 + return
1266 +}
1267 +
1268 +//
1269 +//
1270 +// Return values:
1271 +//
1272 +// * NewMaximumActiveConnections: allowed value range: minimum=1, step=1
1273 +func (client *WANCommonInterfaceConfig1) GetMaximumActiveConnections() (NewMaximumActiveConnections uint16, err error) {
1274 + // Request structure.
1275 + request := interface{}(nil)
1276 + // BEGIN Marshal arguments into request.
1277 +
1278 + // END Marshal arguments into request.
1279 +
1280 + // Response structure.
1281 + response := &struct {
1282 + NewMaximumActiveConnections string
1283 + }{}
1284 +
1285 + // Perform the SOAP call.
1286 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetMaximumActiveConnections", request, response); err != nil {
1287 + return
1288 + }
1289 +
1290 + // BEGIN Unmarshal arguments from response.
1291 +
1292 + if NewMaximumActiveConnections, err = soap.UnmarshalUi2(response.NewMaximumActiveConnections); err != nil {
1293 + return
1294 + }
1295 + // END Unmarshal arguments from response.
1296 + return
1297 +}
1298 +
1299 +//
1300 +//
1301 +// Return values:
1302 +//
1303 +// * NewTotalBytesSent:
1304 +func (client *WANCommonInterfaceConfig1) GetTotalBytesSent() (NewTotalBytesSent uint32, err error) {
1305 + // Request structure.
1306 + request := interface{}(nil)
1307 + // BEGIN Marshal arguments into request.
1308 +
1309 + // END Marshal arguments into request.
1310 +
1311 + // Response structure.
1312 + response := &struct {
1313 + NewTotalBytesSent string
1314 + }{}
1315 +
1316 + // Perform the SOAP call.
1317 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetTotalBytesSent", request, response); err != nil {
1318 + return
1319 + }
1320 +
1321 + // BEGIN Unmarshal arguments from response.
1322 +
1323 + if NewTotalBytesSent, err = soap.UnmarshalUi4(response.NewTotalBytesSent); err != nil {
1324 + return
1325 + }
1326 + // END Unmarshal arguments from response.
1327 + return
1328 +}
1329 +
1330 +//
1331 +//
1332 +// Return values:
1333 +//
1334 +// * NewTotalBytesReceived:
1335 +func (client *WANCommonInterfaceConfig1) GetTotalBytesReceived() (NewTotalBytesReceived uint32, err error) {
1336 + // Request structure.
1337 + request := interface{}(nil)
1338 + // BEGIN Marshal arguments into request.
1339 +
1340 + // END Marshal arguments into request.
1341 +
1342 + // Response structure.
1343 + response := &struct {
1344 + NewTotalBytesReceived string
1345 + }{}
1346 +
1347 + // Perform the SOAP call.
1348 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetTotalBytesReceived", request, response); err != nil {
1349 + return
1350 + }
1351 +
1352 + // BEGIN Unmarshal arguments from response.
1353 +
1354 + if NewTotalBytesReceived, err = soap.UnmarshalUi4(response.NewTotalBytesReceived); err != nil {
1355 + return
1356 + }
1357 + // END Unmarshal arguments from response.
1358 + return
1359 +}
1360 +
1361 +//
1362 +//
1363 +// Return values:
1364 +//
1365 +// * NewTotalPacketsSent:
1366 +func (client *WANCommonInterfaceConfig1) GetTotalPacketsSent() (NewTotalPacketsSent uint32, err error) {
1367 + // Request structure.
1368 + request := interface{}(nil)
1369 + // BEGIN Marshal arguments into request.
1370 +
1371 + // END Marshal arguments into request.
1372 +
1373 + // Response structure.
1374 + response := &struct {
1375 + NewTotalPacketsSent string
1376 + }{}
1377 +
1378 + // Perform the SOAP call.
1379 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetTotalPacketsSent", request, response); err != nil {
1380 + return
1381 + }
1382 +
1383 + // BEGIN Unmarshal arguments from response.
1384 +
1385 + if NewTotalPacketsSent, err = soap.UnmarshalUi4(response.NewTotalPacketsSent); err != nil {
1386 + return
1387 + }
1388 + // END Unmarshal arguments from response.
1389 + return
1390 +}
1391 +
1392 +//
1393 +//
1394 +// Return values:
1395 +//
1396 +// * NewTotalPacketsReceived:
1397 +func (client *WANCommonInterfaceConfig1) GetTotalPacketsReceived() (NewTotalPacketsReceived uint32, err error) {
1398 + // Request structure.
1399 + request := interface{}(nil)
1400 + // BEGIN Marshal arguments into request.
1401 +
1402 + // END Marshal arguments into request.
1403 +
1404 + // Response structure.
1405 + response := &struct {
1406 + NewTotalPacketsReceived string
1407 + }{}
1408 +
1409 + // Perform the SOAP call.
1410 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetTotalPacketsReceived", request, response); err != nil {
1411 + return
1412 + }
1413 +
1414 + // BEGIN Unmarshal arguments from response.
1415 +
1416 + if NewTotalPacketsReceived, err = soap.UnmarshalUi4(response.NewTotalPacketsReceived); err != nil {
1417 + return
1418 + }
1419 + // END Unmarshal arguments from response.
1420 + return
1421 +}
1422 +
1423 +// Arguments:
1424 +//
1425 +// * NewActiveConnectionIndex:
1426 +//
1427 +// Return values:
1428 +//
1429 +// * NewActiveConnDeviceContainer:
1430 +//
1431 +// * NewActiveConnectionServiceID:
1432 +func (client *WANCommonInterfaceConfig1) GetActiveConnection(NewActiveConnectionIndex uint16) (NewActiveConnDeviceContainer string, NewActiveConnectionServiceID string, err error) {
1433 + // Request structure.
1434 + request := &struct {
1435 + NewActiveConnectionIndex string
1436 + }{}
1437 + // BEGIN Marshal arguments into request.
1438 +
1439 + if request.NewActiveConnectionIndex, err = soap.MarshalUi2(NewActiveConnectionIndex); err != nil {
1440 + return
1441 + }
1442 + // END Marshal arguments into request.
1443 +
1444 + // Response structure.
1445 + response := &struct {
1446 + NewActiveConnDeviceContainer string
1447 +
1448 + NewActiveConnectionServiceID string
1449 + }{}
1450 +
1451 + // Perform the SOAP call.
1452 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetActiveConnection", request, response); err != nil {
1453 + return
1454 + }
1455 +
1456 + // BEGIN Unmarshal arguments from response.
1457 +
1458 + if NewActiveConnDeviceContainer, err = soap.UnmarshalString(response.NewActiveConnDeviceContainer); err != nil {
1459 + return
1460 + }
1461 + if NewActiveConnectionServiceID, err = soap.UnmarshalString(response.NewActiveConnectionServiceID); err != nil {
1462 + return
1463 + }
1464 + // END Unmarshal arguments from response.
1465 + return
1466 +}
1467 +
1468 +// WANDSLLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANDSLLinkConfig:1". See
1469 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
1470 +// are provided for informational value.
1471 +type WANDSLLinkConfig1 struct {
1472 + goupnp.ServiceClient
1473 +}
1474 +
1475 +// NewWANDSLLinkConfig1Clients discovers instances of the service on the network,
1476 +// and returns clients to any that are found. errors will contain an error for
1477 +// any devices that replied but which could not be queried, and err will be set
1478 +// if the discovery process failed outright.
1479 +//
1480 +// This is a typical entry calling point into this package.
1481 +func NewWANDSLLinkConfig1Clients() (clients []*WANDSLLinkConfig1, errors []error, err error) {
1482 + var genericClients []goupnp.ServiceClient
1483 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANDSLLinkConfig_1); err != nil {
1484 + return
1485 + }
1486 + clients = make([]*WANDSLLinkConfig1, len(genericClients))
1487 + for i := range genericClients {
1488 + clients[i] = &WANDSLLinkConfig1{genericClients[i]}
1489 + }
1490 + return
1491 +}
1492 +
1493 +// Arguments:
1494 +//
1495 +// * NewLinkType:
1496 +//
1497 +//
1498 +func (client *WANDSLLinkConfig1) SetDSLLinkType(NewLinkType string) (err error) {
1499 + // Request structure.
1500 + request := &struct {
1501 + NewLinkType string
1502 + }{}
1503 + // BEGIN Marshal arguments into request.
1504 +
1505 + if request.NewLinkType, err = soap.MarshalString(NewLinkType); err != nil {
1506 + return
1507 + }
1508 + // END Marshal arguments into request.
1509 +
1510 + // Response structure.
1511 + response := interface{}(nil)
1512 +
1513 + // Perform the SOAP call.
1514 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "SetDSLLinkType", request, response); err != nil {
1515 + return
1516 + }
1517 +
1518 + // BEGIN Unmarshal arguments from response.
1519 +
1520 + // END Unmarshal arguments from response.
1521 + return
1522 +}
1523 +
1524 +//
1525 +//
1526 +// Return values:
1527 +//
1528 +// * NewLinkType:
1529 +//
1530 +// * NewLinkStatus: allowed values: Up, Down
1531 +func (client *WANDSLLinkConfig1) GetDSLLinkInfo() (NewLinkType string, NewLinkStatus string, err error) {
1532 + // Request structure.
1533 + request := interface{}(nil)
1534 + // BEGIN Marshal arguments into request.
1535 +
1536 + // END Marshal arguments into request.
1537 +
1538 + // Response structure.
1539 + response := &struct {
1540 + NewLinkType string
1541 +
1542 + NewLinkStatus string
1543 + }{}
1544 +
1545 + // Perform the SOAP call.
1546 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "GetDSLLinkInfo", request, response); err != nil {
1547 + return
1548 + }
1549 +
1550 + // BEGIN Unmarshal arguments from response.
1551 +
1552 + if NewLinkType, err = soap.UnmarshalString(response.NewLinkType); err != nil {
1553 + return
1554 + }
1555 + if NewLinkStatus, err = soap.UnmarshalString(response.NewLinkStatus); err != nil {
1556 + return
1557 + }
1558 + // END Unmarshal arguments from response.
1559 + return
1560 +}
1561 +
1562 +//
1563 +//
1564 +// Return values:
1565 +//
1566 +// * NewAutoConfig:
1567 +func (client *WANDSLLinkConfig1) GetAutoConfig() (NewAutoConfig bool, err error) {
1568 + // Request structure.
1569 + request := interface{}(nil)
1570 + // BEGIN Marshal arguments into request.
1571 +
1572 + // END Marshal arguments into request.
1573 +
1574 + // Response structure.
1575 + response := &struct {
1576 + NewAutoConfig string
1577 + }{}
1578 +
1579 + // Perform the SOAP call.
1580 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "GetAutoConfig", request, response); err != nil {
1581 + return
1582 + }
1583 +
1584 + // BEGIN Unmarshal arguments from response.
1585 +
1586 + if NewAutoConfig, err = soap.UnmarshalBoolean(response.NewAutoConfig); err != nil {
1587 + return
1588 + }
1589 + // END Unmarshal arguments from response.
1590 + return
1591 +}
1592 +
1593 +//
1594 +//
1595 +// Return values:
1596 +//
1597 +// * NewModulationType:
1598 +func (client *WANDSLLinkConfig1) GetModulationType() (NewModulationType string, err error) {
1599 + // Request structure.
1600 + request := interface{}(nil)
1601 + // BEGIN Marshal arguments into request.
1602 +
1603 + // END Marshal arguments into request.
1604 +
1605 + // Response structure.
1606 + response := &struct {
1607 + NewModulationType string
1608 + }{}
1609 +
1610 + // Perform the SOAP call.
1611 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "GetModulationType", request, response); err != nil {
1612 + return
1613 + }
1614 +
1615 + // BEGIN Unmarshal arguments from response.
1616 +
1617 + if NewModulationType, err = soap.UnmarshalString(response.NewModulationType); err != nil {
1618 + return
1619 + }
1620 + // END Unmarshal arguments from response.
1621 + return
1622 +}
1623 +
1624 +// Arguments:
1625 +//
1626 +// * NewDestinationAddress:
1627 +//
1628 +//
1629 +func (client *WANDSLLinkConfig1) SetDestinationAddress(NewDestinationAddress string) (err error) {
1630 + // Request structure.
1631 + request := &struct {
1632 + NewDestinationAddress string
1633 + }{}
1634 + // BEGIN Marshal arguments into request.
1635 +
1636 + if request.NewDestinationAddress, err = soap.MarshalString(NewDestinationAddress); err != nil {
1637 + return
1638 + }
1639 + // END Marshal arguments into request.
1640 +
1641 + // Response structure.
1642 + response := interface{}(nil)
1643 +
1644 + // Perform the SOAP call.
1645 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "SetDestinationAddress", request, response); err != nil {
1646 + return
1647 + }
1648 +
1649 + // BEGIN Unmarshal arguments from response.
1650 +
1651 + // END Unmarshal arguments from response.
1652 + return
1653 +}
1654 +
1655 +//
1656 +//
1657 +// Return values:
1658 +//
1659 +// * NewDestinationAddress:
1660 +func (client *WANDSLLinkConfig1) GetDestinationAddress() (NewDestinationAddress string, err error) {
1661 + // Request structure.
1662 + request := interface{}(nil)
1663 + // BEGIN Marshal arguments into request.
1664 +
1665 + // END Marshal arguments into request.
1666 +
1667 + // Response structure.
1668 + response := &struct {
1669 + NewDestinationAddress string
1670 + }{}
1671 +
1672 + // Perform the SOAP call.
1673 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "GetDestinationAddress", request, response); err != nil {
1674 + return
1675 + }
1676 +
1677 + // BEGIN Unmarshal arguments from response.
1678 +
1679 + if NewDestinationAddress, err = soap.UnmarshalString(response.NewDestinationAddress); err != nil {
1680 + return
1681 + }
1682 + // END Unmarshal arguments from response.
1683 + return
1684 +}
1685 +
1686 +// Arguments:
1687 +//
1688 +// * NewATMEncapsulation:
1689 +//
1690 +//
1691 +func (client *WANDSLLinkConfig1) SetATMEncapsulation(NewATMEncapsulation string) (err error) {
1692 + // Request structure.
1693 + request := &struct {
1694 + NewATMEncapsulation string
1695 + }{}
1696 + // BEGIN Marshal arguments into request.
1697 +
1698 + if request.NewATMEncapsulation, err = soap.MarshalString(NewATMEncapsulation); err != nil {
1699 + return
1700 + }
1701 + // END Marshal arguments into request.
1702 +
1703 + // Response structure.
1704 + response := interface{}(nil)
1705 +
1706 + // Perform the SOAP call.
1707 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "SetATMEncapsulation", request, response); err != nil {
1708 + return
1709 + }
1710 +
1711 + // BEGIN Unmarshal arguments from response.
1712 +
1713 + // END Unmarshal arguments from response.
1714 + return
1715 +}
1716 +
1717 +//
1718 +//
1719 +// Return values:
1720 +//
1721 +// * NewATMEncapsulation:
1722 +func (client *WANDSLLinkConfig1) GetATMEncapsulation() (NewATMEncapsulation string, err error) {
1723 + // Request structure.
1724 + request := interface{}(nil)
1725 + // BEGIN Marshal arguments into request.
1726 +
1727 + // END Marshal arguments into request.
1728 +
1729 + // Response structure.
1730 + response := &struct {
1731 + NewATMEncapsulation string
1732 + }{}
1733 +
1734 + // Perform the SOAP call.
1735 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "GetATMEncapsulation", request, response); err != nil {
1736 + return
1737 + }
1738 +
1739 + // BEGIN Unmarshal arguments from response.
1740 +
1741 + if NewATMEncapsulation, err = soap.UnmarshalString(response.NewATMEncapsulation); err != nil {
1742 + return
1743 + }
1744 + // END Unmarshal arguments from response.
1745 + return
1746 +}
1747 +
1748 +// Arguments:
1749 +//
1750 +// * NewFCSPreserved:
1751 +//
1752 +//
1753 +func (client *WANDSLLinkConfig1) SetFCSPreserved(NewFCSPreserved bool) (err error) {
1754 + // Request structure.
1755 + request := &struct {
1756 + NewFCSPreserved string
1757 + }{}
1758 + // BEGIN Marshal arguments into request.
1759 +
1760 + if request.NewFCSPreserved, err = soap.MarshalBoolean(NewFCSPreserved); err != nil {
1761 + return
1762 + }
1763 + // END Marshal arguments into request.
1764 +
1765 + // Response structure.
1766 + response := interface{}(nil)
1767 +
1768 + // Perform the SOAP call.
1769 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "SetFCSPreserved", request, response); err != nil {
1770 + return
1771 + }
1772 +
1773 + // BEGIN Unmarshal arguments from response.
1774 +
1775 + // END Unmarshal arguments from response.
1776 + return
1777 +}
1778 +
1779 +//
1780 +//
1781 +// Return values:
1782 +//
1783 +// * NewFCSPreserved:
1784 +func (client *WANDSLLinkConfig1) GetFCSPreserved() (NewFCSPreserved bool, err error) {
1785 + // Request structure.
1786 + request := interface{}(nil)
1787 + // BEGIN Marshal arguments into request.
1788 +
1789 + // END Marshal arguments into request.
1790 +
1791 + // Response structure.
1792 + response := &struct {
1793 + NewFCSPreserved string
1794 + }{}
1795 +
1796 + // Perform the SOAP call.
1797 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "GetFCSPreserved", request, response); err != nil {
1798 + return
1799 + }
1800 +
1801 + // BEGIN Unmarshal arguments from response.
1802 +
1803 + if NewFCSPreserved, err = soap.UnmarshalBoolean(response.NewFCSPreserved); err != nil {
1804 + return
1805 + }
1806 + // END Unmarshal arguments from response.
1807 + return
1808 +}
1809 +
1810 +// WANEthernetLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANEthernetLinkConfig:1". See
1811 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
1812 +// are provided for informational value.
1813 +type WANEthernetLinkConfig1 struct {
1814 + goupnp.ServiceClient
1815 +}
1816 +
1817 +// NewWANEthernetLinkConfig1Clients discovers instances of the service on the network,
1818 +// and returns clients to any that are found. errors will contain an error for
1819 +// any devices that replied but which could not be queried, and err will be set
1820 +// if the discovery process failed outright.
1821 +//
1822 +// This is a typical entry calling point into this package.
1823 +func NewWANEthernetLinkConfig1Clients() (clients []*WANEthernetLinkConfig1, errors []error, err error) {
1824 + var genericClients []goupnp.ServiceClient
1825 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANEthernetLinkConfig_1); err != nil {
1826 + return
1827 + }
1828 + clients = make([]*WANEthernetLinkConfig1, len(genericClients))
1829 + for i := range genericClients {
1830 + clients[i] = &WANEthernetLinkConfig1{genericClients[i]}
1831 + }
1832 + return
1833 +}
1834 +
1835 +//
1836 +//
1837 +// Return values:
1838 +//
1839 +// * NewEthernetLinkStatus: allowed values: Up, Down
1840 +func (client *WANEthernetLinkConfig1) GetEthernetLinkStatus() (NewEthernetLinkStatus string, err error) {
1841 + // Request structure.
1842 + request := interface{}(nil)
1843 + // BEGIN Marshal arguments into request.
1844 +
1845 + // END Marshal arguments into request.
1846 +
1847 + // Response structure.
1848 + response := &struct {
1849 + NewEthernetLinkStatus string
1850 + }{}
1851 +
1852 + // Perform the SOAP call.
1853 + if err = client.SOAPClient.PerformAction(URN_WANEthernetLinkConfig_1, "GetEthernetLinkStatus", request, response); err != nil {
1854 + return
1855 + }
1856 +
1857 + // BEGIN Unmarshal arguments from response.
1858 +
1859 + if NewEthernetLinkStatus, err = soap.UnmarshalString(response.NewEthernetLinkStatus); err != nil {
1860 + return
1861 + }
1862 + // END Unmarshal arguments from response.
1863 + return
1864 +}
1865 +
1866 +// WANIPConnection1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANIPConnection:1". See
1867 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
1868 +// are provided for informational value.
1869 +type WANIPConnection1 struct {
1870 + goupnp.ServiceClient
1871 +}
1872 +
1873 +// NewWANIPConnection1Clients discovers instances of the service on the network,
1874 +// and returns clients to any that are found. errors will contain an error for
1875 +// any devices that replied but which could not be queried, and err will be set
1876 +// if the discovery process failed outright.
1877 +//
1878 +// This is a typical entry calling point into this package.
1879 +func NewWANIPConnection1Clients() (clients []*WANIPConnection1, errors []error, err error) {
1880 + var genericClients []goupnp.ServiceClient
1881 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANIPConnection_1); err != nil {
1882 + return
1883 + }
1884 + clients = make([]*WANIPConnection1, len(genericClients))
1885 + for i := range genericClients {
1886 + clients[i] = &WANIPConnection1{genericClients[i]}
1887 + }
1888 + return
1889 +}
1890 +
1891 +// Arguments:
1892 +//
1893 +// * NewConnectionType:
1894 +//
1895 +//
1896 +func (client *WANIPConnection1) SetConnectionType(NewConnectionType string) (err error) {
1897 + // Request structure.
1898 + request := &struct {
1899 + NewConnectionType string
1900 + }{}
1901 + // BEGIN Marshal arguments into request.
1902 +
1903 + if request.NewConnectionType, err = soap.MarshalString(NewConnectionType); err != nil {
1904 + return
1905 + }
1906 + // END Marshal arguments into request.
1907 +
1908 + // Response structure.
1909 + response := interface{}(nil)
1910 +
1911 + // Perform the SOAP call.
1912 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "SetConnectionType", request, response); err != nil {
1913 + return
1914 + }
1915 +
1916 + // BEGIN Unmarshal arguments from response.
1917 +
1918 + // END Unmarshal arguments from response.
1919 + return
1920 +}
1921 +
1922 +//
1923 +//
1924 +// Return values:
1925 +//
1926 +// * NewConnectionType:
1927 +//
1928 +// * NewPossibleConnectionTypes: allowed values: Unconfigured, IP_Routed, IP_Bridged
1929 +func (client *WANIPConnection1) GetConnectionTypeInfo() (NewConnectionType string, NewPossibleConnectionTypes string, err error) {
1930 + // Request structure.
1931 + request := interface{}(nil)
1932 + // BEGIN Marshal arguments into request.
1933 +
1934 + // END Marshal arguments into request.
1935 +
1936 + // Response structure.
1937 + response := &struct {
1938 + NewConnectionType string
1939 +
1940 + NewPossibleConnectionTypes string
1941 + }{}
1942 +
1943 + // Perform the SOAP call.
1944 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetConnectionTypeInfo", request, response); err != nil {
1945 + return
1946 + }
1947 +
1948 + // BEGIN Unmarshal arguments from response.
1949 +
1950 + if NewConnectionType, err = soap.UnmarshalString(response.NewConnectionType); err != nil {
1951 + return
1952 + }
1953 + if NewPossibleConnectionTypes, err = soap.UnmarshalString(response.NewPossibleConnectionTypes); err != nil {
1954 + return
1955 + }
1956 + // END Unmarshal arguments from response.
1957 + return
1958 +}
1959 +
1960 +//
1961 +//
1962 +//
1963 +func (client *WANIPConnection1) RequestConnection() (err error) {
1964 + // Request structure.
1965 + request := interface{}(nil)
1966 + // BEGIN Marshal arguments into request.
1967 +
1968 + // END Marshal arguments into request.
1969 +
1970 + // Response structure.
1971 + response := interface{}(nil)
1972 +
1973 + // Perform the SOAP call.
1974 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "RequestConnection", request, response); err != nil {
1975 + return
1976 + }
1977 +
1978 + // BEGIN Unmarshal arguments from response.
1979 +
1980 + // END Unmarshal arguments from response.
1981 + return
1982 +}
1983 +
1984 +//
1985 +//
1986 +//
1987 +func (client *WANIPConnection1) RequestTermination() (err error) {
1988 + // Request structure.
1989 + request := interface{}(nil)
1990 + // BEGIN Marshal arguments into request.
1991 +
1992 + // END Marshal arguments into request.
1993 +
1994 + // Response structure.
1995 + response := interface{}(nil)
1996 +
1997 + // Perform the SOAP call.
1998 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "RequestTermination", request, response); err != nil {
1999 + return
2000 + }
2001 +
2002 + // BEGIN Unmarshal arguments from response.
2003 +
2004 + // END Unmarshal arguments from response.
2005 + return
2006 +}
2007 +
2008 +//
2009 +//
2010 +//
2011 +func (client *WANIPConnection1) ForceTermination() (err error) {
2012 + // Request structure.
2013 + request := interface{}(nil)
2014 + // BEGIN Marshal arguments into request.
2015 +
2016 + // END Marshal arguments into request.
2017 +
2018 + // Response structure.
2019 + response := interface{}(nil)
2020 +
2021 + // Perform the SOAP call.
2022 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "ForceTermination", request, response); err != nil {
2023 + return
2024 + }
2025 +
2026 + // BEGIN Unmarshal arguments from response.
2027 +
2028 + // END Unmarshal arguments from response.
2029 + return
2030 +}
2031 +
2032 +// Arguments:
2033 +//
2034 +// * NewAutoDisconnectTime:
2035 +//
2036 +//
2037 +func (client *WANIPConnection1) SetAutoDisconnectTime(NewAutoDisconnectTime uint32) (err error) {
2038 + // Request structure.
2039 + request := &struct {
2040 + NewAutoDisconnectTime string
2041 + }{}
2042 + // BEGIN Marshal arguments into request.
2043 +
2044 + if request.NewAutoDisconnectTime, err = soap.MarshalUi4(NewAutoDisconnectTime); err != nil {
2045 + return
2046 + }
2047 + // END Marshal arguments into request.
2048 +
2049 + // Response structure.
2050 + response := interface{}(nil)
2051 +
2052 + // Perform the SOAP call.
2053 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "SetAutoDisconnectTime", request, response); err != nil {
2054 + return
2055 + }
2056 +
2057 + // BEGIN Unmarshal arguments from response.
2058 +
2059 + // END Unmarshal arguments from response.
2060 + return
2061 +}
2062 +
2063 +// Arguments:
2064 +//
2065 +// * NewIdleDisconnectTime:
2066 +//
2067 +//
2068 +func (client *WANIPConnection1) SetIdleDisconnectTime(NewIdleDisconnectTime uint32) (err error) {
2069 + // Request structure.
2070 + request := &struct {
2071 + NewIdleDisconnectTime string
2072 + }{}
2073 + // BEGIN Marshal arguments into request.
2074 +
2075 + if request.NewIdleDisconnectTime, err = soap.MarshalUi4(NewIdleDisconnectTime); err != nil {
2076 + return
2077 + }
2078 + // END Marshal arguments into request.
2079 +
2080 + // Response structure.
2081 + response := interface{}(nil)
2082 +
2083 + // Perform the SOAP call.
2084 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "SetIdleDisconnectTime", request, response); err != nil {
2085 + return
2086 + }
2087 +
2088 + // BEGIN Unmarshal arguments from response.
2089 +
2090 + // END Unmarshal arguments from response.
2091 + return
2092 +}
2093 +
2094 +// Arguments:
2095 +//
2096 +// * NewWarnDisconnectDelay:
2097 +//
2098 +//
2099 +func (client *WANIPConnection1) SetWarnDisconnectDelay(NewWarnDisconnectDelay uint32) (err error) {
2100 + // Request structure.
2101 + request := &struct {
2102 + NewWarnDisconnectDelay string
2103 + }{}
2104 + // BEGIN Marshal arguments into request.
2105 +
2106 + if request.NewWarnDisconnectDelay, err = soap.MarshalUi4(NewWarnDisconnectDelay); err != nil {
2107 + return
2108 + }
2109 + // END Marshal arguments into request.
2110 +
2111 + // Response structure.
2112 + response := interface{}(nil)
2113 +
2114 + // Perform the SOAP call.
2115 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "SetWarnDisconnectDelay", request, response); err != nil {
2116 + return
2117 + }
2118 +
2119 + // BEGIN Unmarshal arguments from response.
2120 +
2121 + // END Unmarshal arguments from response.
2122 + return
2123 +}
2124 +
2125 +//
2126 +//
2127 +// Return values:
2128 +//
2129 +// * NewConnectionStatus: allowed values: Unconfigured, Connected, Disconnected
2130 +//
2131 +// * NewLastConnectionError: allowed values: ERROR_NONE
2132 +//
2133 +// * NewUptime:
2134 +func (client *WANIPConnection1) GetStatusInfo() (NewConnectionStatus string, NewLastConnectionError string, NewUptime uint32, err error) {
2135 + // Request structure.
2136 + request := interface{}(nil)
2137 + // BEGIN Marshal arguments into request.
2138 +
2139 + // END Marshal arguments into request.
2140 +
2141 + // Response structure.
2142 + response := &struct {
2143 + NewConnectionStatus string
2144 +
2145 + NewLastConnectionError string
2146 +
2147 + NewUptime string
2148 + }{}
2149 +
2150 + // Perform the SOAP call.
2151 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetStatusInfo", request, response); err != nil {
2152 + return
2153 + }
2154 +
2155 + // BEGIN Unmarshal arguments from response.
2156 +
2157 + if NewConnectionStatus, err = soap.UnmarshalString(response.NewConnectionStatus); err != nil {
2158 + return
2159 + }
2160 + if NewLastConnectionError, err = soap.UnmarshalString(response.NewLastConnectionError); err != nil {
2161 + return
2162 + }
2163 + if NewUptime, err = soap.UnmarshalUi4(response.NewUptime); err != nil {
2164 + return
2165 + }
2166 + // END Unmarshal arguments from response.
2167 + return
2168 +}
2169 +
2170 +//
2171 +//
2172 +// Return values:
2173 +//
2174 +// * NewAutoDisconnectTime:
2175 +func (client *WANIPConnection1) GetAutoDisconnectTime() (NewAutoDisconnectTime uint32, err error) {
2176 + // Request structure.
2177 + request := interface{}(nil)
2178 + // BEGIN Marshal arguments into request.
2179 +
2180 + // END Marshal arguments into request.
2181 +
2182 + // Response structure.
2183 + response := &struct {
2184 + NewAutoDisconnectTime string
2185 + }{}
2186 +
2187 + // Perform the SOAP call.
2188 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetAutoDisconnectTime", request, response); err != nil {
2189 + return
2190 + }
2191 +
2192 + // BEGIN Unmarshal arguments from response.
2193 +
2194 + if NewAutoDisconnectTime, err = soap.UnmarshalUi4(response.NewAutoDisconnectTime); err != nil {
2195 + return
2196 + }
2197 + // END Unmarshal arguments from response.
2198 + return
2199 +}
2200 +
2201 +//
2202 +//
2203 +// Return values:
2204 +//
2205 +// * NewIdleDisconnectTime:
2206 +func (client *WANIPConnection1) GetIdleDisconnectTime() (NewIdleDisconnectTime uint32, err error) {
2207 + // Request structure.
2208 + request := interface{}(nil)
2209 + // BEGIN Marshal arguments into request.
2210 +
2211 + // END Marshal arguments into request.
2212 +
2213 + // Response structure.
2214 + response := &struct {
2215 + NewIdleDisconnectTime string
2216 + }{}
2217 +
2218 + // Perform the SOAP call.
2219 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetIdleDisconnectTime", request, response); err != nil {
2220 + return
2221 + }
2222 +
2223 + // BEGIN Unmarshal arguments from response.
2224 +
2225 + if NewIdleDisconnectTime, err = soap.UnmarshalUi4(response.NewIdleDisconnectTime); err != nil {
2226 + return
2227 + }
2228 + // END Unmarshal arguments from response.
2229 + return
2230 +}
2231 +
2232 +//
2233 +//
2234 +// Return values:
2235 +//
2236 +// * NewWarnDisconnectDelay:
2237 +func (client *WANIPConnection1) GetWarnDisconnectDelay() (NewWarnDisconnectDelay uint32, err error) {
2238 + // Request structure.
2239 + request := interface{}(nil)
2240 + // BEGIN Marshal arguments into request.
2241 +
2242 + // END Marshal arguments into request.
2243 +
2244 + // Response structure.
2245 + response := &struct {
2246 + NewWarnDisconnectDelay string
2247 + }{}
2248 +
2249 + // Perform the SOAP call.
2250 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetWarnDisconnectDelay", request, response); err != nil {
2251 + return
2252 + }
2253 +
2254 + // BEGIN Unmarshal arguments from response.
2255 +
2256 + if NewWarnDisconnectDelay, err = soap.UnmarshalUi4(response.NewWarnDisconnectDelay); err != nil {
2257 + return
2258 + }
2259 + // END Unmarshal arguments from response.
2260 + return
2261 +}
2262 +
2263 +//
2264 +//
2265 +// Return values:
2266 +//
2267 +// * NewRSIPAvailable:
2268 +//
2269 +// * NewNATEnabled:
2270 +func (client *WANIPConnection1) GetNATRSIPStatus() (NewRSIPAvailable bool, NewNATEnabled bool, err error) {
2271 + // Request structure.
2272 + request := interface{}(nil)
2273 + // BEGIN Marshal arguments into request.
2274 +
2275 + // END Marshal arguments into request.
2276 +
2277 + // Response structure.
2278 + response := &struct {
2279 + NewRSIPAvailable string
2280 +
2281 + NewNATEnabled string
2282 + }{}
2283 +
2284 + // Perform the SOAP call.
2285 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetNATRSIPStatus", request, response); err != nil {
2286 + return
2287 + }
2288 +
2289 + // BEGIN Unmarshal arguments from response.
2290 +
2291 + if NewRSIPAvailable, err = soap.UnmarshalBoolean(response.NewRSIPAvailable); err != nil {
2292 + return
2293 + }
2294 + if NewNATEnabled, err = soap.UnmarshalBoolean(response.NewNATEnabled); err != nil {
2295 + return
2296 + }
2297 + // END Unmarshal arguments from response.
2298 + return
2299 +}
2300 +
2301 +// Arguments:
2302 +//
2303 +// * NewPortMappingIndex:
2304 +//
2305 +// Return values:
2306 +//
2307 +// * NewRemoteHost:
2308 +//
2309 +// * NewExternalPort:
2310 +//
2311 +// * NewProtocol: allowed values: TCP, UDP
2312 +//
2313 +// * NewInternalPort:
2314 +//
2315 +// * NewInternalClient:
2316 +//
2317 +// * NewEnabled:
2318 +//
2319 +// * NewPortMappingDescription:
2320 +//
2321 +// * NewLeaseDuration:
2322 +func (client *WANIPConnection1) GetGenericPortMappingEntry(NewPortMappingIndex uint16) (NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
2323 + // Request structure.
2324 + request := &struct {
2325 + NewPortMappingIndex string
2326 + }{}
2327 + // BEGIN Marshal arguments into request.
2328 +
2329 + if request.NewPortMappingIndex, err = soap.MarshalUi2(NewPortMappingIndex); err != nil {
2330 + return
2331 + }
2332 + // END Marshal arguments into request.
2333 +
2334 + // Response structure.
2335 + response := &struct {
2336 + NewRemoteHost string
2337 +
2338 + NewExternalPort string
2339 +
2340 + NewProtocol string
2341 +
2342 + NewInternalPort string
2343 +
2344 + NewInternalClient string
2345 +
2346 + NewEnabled string
2347 +
2348 + NewPortMappingDescription string
2349 +
2350 + NewLeaseDuration string
2351 + }{}
2352 +
2353 + // Perform the SOAP call.
2354 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetGenericPortMappingEntry", request, response); err != nil {
2355 + return
2356 + }
2357 +
2358 + // BEGIN Unmarshal arguments from response.
2359 +
2360 + if NewRemoteHost, err = soap.UnmarshalString(response.NewRemoteHost); err != nil {
2361 + return
2362 + }
2363 + if NewExternalPort, err = soap.UnmarshalUi2(response.NewExternalPort); err != nil {
2364 + return
2365 + }
2366 + if NewProtocol, err = soap.UnmarshalString(response.NewProtocol); err != nil {
2367 + return
2368 + }
2369 + if NewInternalPort, err = soap.UnmarshalUi2(response.NewInternalPort); err != nil {
2370 + return
2371 + }
2372 + if NewInternalClient, err = soap.UnmarshalString(response.NewInternalClient); err != nil {
2373 + return
2374 + }
2375 + if NewEnabled, err = soap.UnmarshalBoolean(response.NewEnabled); err != nil {
2376 + return
2377 + }
2378 + if NewPortMappingDescription, err = soap.UnmarshalString(response.NewPortMappingDescription); err != nil {
2379 + return
2380 + }
2381 + if NewLeaseDuration, err = soap.UnmarshalUi4(response.NewLeaseDuration); err != nil {
2382 + return
2383 + }
2384 + // END Unmarshal arguments from response.
2385 + return
2386 +}
2387 +
2388 +// Arguments:
2389 +//
2390 +// * NewRemoteHost:
2391 +//
2392 +// * NewExternalPort:
2393 +//
2394 +// * NewProtocol: allowed values: TCP, UDP
2395 +//
2396 +// Return values:
2397 +//
2398 +// * NewInternalPort:
2399 +//
2400 +// * NewInternalClient:
2401 +//
2402 +// * NewEnabled:
2403 +//
2404 +// * NewPortMappingDescription:
2405 +//
2406 +// * NewLeaseDuration:
2407 +func (client *WANIPConnection1) GetSpecificPortMappingEntry(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
2408 + // Request structure.
2409 + request := &struct {
2410 + NewRemoteHost string
2411 +
2412 + NewExternalPort string
2413 +
2414 + NewProtocol string
2415 + }{}
2416 + // BEGIN Marshal arguments into request.
2417 +
2418 + if request.NewRemoteHost, err = soap.MarshalString(NewRemoteHost); err != nil {
2419 + return
2420 + }
2421 + if request.NewExternalPort, err = soap.MarshalUi2(NewExternalPort); err != nil {
2422 + return
2423 + }
2424 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
2425 + return
2426 + }
2427 + // END Marshal arguments into request.
2428 +
2429 + // Response structure.
2430 + response := &struct {
2431 + NewInternalPort string
2432 +
2433 + NewInternalClient string
2434 +
2435 + NewEnabled string
2436 +
2437 + NewPortMappingDescription string
2438 +
2439 + NewLeaseDuration string
2440 + }{}
2441 +
2442 + // Perform the SOAP call.
2443 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetSpecificPortMappingEntry", request, response); err != nil {
2444 + return
2445 + }
2446 +
2447 + // BEGIN Unmarshal arguments from response.
2448 +
2449 + if NewInternalPort, err = soap.UnmarshalUi2(response.NewInternalPort); err != nil {
2450 + return
2451 + }
2452 + if NewInternalClient, err = soap.UnmarshalString(response.NewInternalClient); err != nil {
2453 + return
2454 + }
2455 + if NewEnabled, err = soap.UnmarshalBoolean(response.NewEnabled); err != nil {
2456 + return
2457 + }
2458 + if NewPortMappingDescription, err = soap.UnmarshalString(response.NewPortMappingDescription); err != nil {
2459 + return
2460 + }
2461 + if NewLeaseDuration, err = soap.UnmarshalUi4(response.NewLeaseDuration); err != nil {
2462 + return
2463 + }
2464 + // END Unmarshal arguments from response.
2465 + return
2466 +}
2467 +
2468 +// Arguments:
2469 +//
2470 +// * NewRemoteHost:
2471 +//
2472 +// * NewExternalPort:
2473 +//
2474 +// * NewProtocol: allowed values: TCP, UDP
2475 +//
2476 +// * NewInternalPort:
2477 +//
2478 +// * NewInternalClient:
2479 +//
2480 +// * NewEnabled:
2481 +//
2482 +// * NewPortMappingDescription:
2483 +//
2484 +// * NewLeaseDuration:
2485 +//
2486 +//
2487 +func (client *WANIPConnection1) AddPortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32) (err error) {
2488 + // Request structure.
2489 + request := &struct {
2490 + NewRemoteHost string
2491 +
2492 + NewExternalPort string
2493 +
2494 + NewProtocol string
2495 +
2496 + NewInternalPort string
2497 +
2498 + NewInternalClient string
2499 +
2500 + NewEnabled string
2501 +
2502 + NewPortMappingDescription string
2503 +
2504 + NewLeaseDuration string
2505 + }{}
2506 + // BEGIN Marshal arguments into request.
2507 +
2508 + if request.NewRemoteHost, err = soap.MarshalString(NewRemoteHost); err != nil {
2509 + return
2510 + }
2511 + if request.NewExternalPort, err = soap.MarshalUi2(NewExternalPort); err != nil {
2512 + return
2513 + }
2514 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
2515 + return
2516 + }
2517 + if request.NewInternalPort, err = soap.MarshalUi2(NewInternalPort); err != nil {
2518 + return
2519 + }
2520 + if request.NewInternalClient, err = soap.MarshalString(NewInternalClient); err != nil {
2521 + return
2522 + }
2523 + if request.NewEnabled, err = soap.MarshalBoolean(NewEnabled); err != nil {
2524 + return
2525 + }
2526 + if request.NewPortMappingDescription, err = soap.MarshalString(NewPortMappingDescription); err != nil {
2527 + return
2528 + }
2529 + if request.NewLeaseDuration, err = soap.MarshalUi4(NewLeaseDuration); err != nil {
2530 + return
2531 + }
2532 + // END Marshal arguments into request.
2533 +
2534 + // Response structure.
2535 + response := interface{}(nil)
2536 +
2537 + // Perform the SOAP call.
2538 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "AddPortMapping", request, response); err != nil {
2539 + return
2540 + }
2541 +
2542 + // BEGIN Unmarshal arguments from response.
2543 +
2544 + // END Unmarshal arguments from response.
2545 + return
2546 +}
2547 +
2548 +// Arguments:
2549 +//
2550 +// * NewRemoteHost:
2551 +//
2552 +// * NewExternalPort:
2553 +//
2554 +// * NewProtocol: allowed values: TCP, UDP
2555 +//
2556 +//
2557 +func (client *WANIPConnection1) DeletePortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (err error) {
2558 + // Request structure.
2559 + request := &struct {
2560 + NewRemoteHost string
2561 +
2562 + NewExternalPort string
2563 +
2564 + NewProtocol string
2565 + }{}
2566 + // BEGIN Marshal arguments into request.
2567 +
2568 + if request.NewRemoteHost, err = soap.MarshalString(NewRemoteHost); err != nil {
2569 + return
2570 + }
2571 + if request.NewExternalPort, err = soap.MarshalUi2(NewExternalPort); err != nil {
2572 + return
2573 + }
2574 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
2575 + return
2576 + }
2577 + // END Marshal arguments into request.
2578 +
2579 + // Response structure.
2580 + response := interface{}(nil)
2581 +
2582 + // Perform the SOAP call.
2583 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "DeletePortMapping", request, response); err != nil {
2584 + return
2585 + }
2586 +
2587 + // BEGIN Unmarshal arguments from response.
2588 +
2589 + // END Unmarshal arguments from response.
2590 + return
2591 +}
2592 +
2593 +//
2594 +//
2595 +// Return values:
2596 +//
2597 +// * NewExternalIPAddress:
2598 +func (client *WANIPConnection1) GetExternalIPAddress() (NewExternalIPAddress string, err error) {
2599 + // Request structure.
2600 + request := interface{}(nil)
2601 + // BEGIN Marshal arguments into request.
2602 +
2603 + // END Marshal arguments into request.
2604 +
2605 + // Response structure.
2606 + response := &struct {
2607 + NewExternalIPAddress string
2608 + }{}
2609 +
2610 + // Perform the SOAP call.
2611 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetExternalIPAddress", request, response); err != nil {
2612 + return
2613 + }
2614 +
2615 + // BEGIN Unmarshal arguments from response.
2616 +
2617 + if NewExternalIPAddress, err = soap.UnmarshalString(response.NewExternalIPAddress); err != nil {
2618 + return
2619 + }
2620 + // END Unmarshal arguments from response.
2621 + return
2622 +}
2623 +
2624 +// WANPOTSLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANPOTSLinkConfig:1". See
2625 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
2626 +// are provided for informational value.
2627 +type WANPOTSLinkConfig1 struct {
2628 + goupnp.ServiceClient
2629 +}
2630 +
2631 +// NewWANPOTSLinkConfig1Clients discovers instances of the service on the network,
2632 +// and returns clients to any that are found. errors will contain an error for
2633 +// any devices that replied but which could not be queried, and err will be set
2634 +// if the discovery process failed outright.
2635 +//
2636 +// This is a typical entry calling point into this package.
2637 +func NewWANPOTSLinkConfig1Clients() (clients []*WANPOTSLinkConfig1, errors []error, err error) {
2638 + var genericClients []goupnp.ServiceClient
2639 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANPOTSLinkConfig_1); err != nil {
2640 + return
2641 + }
2642 + clients = make([]*WANPOTSLinkConfig1, len(genericClients))
2643 + for i := range genericClients {
2644 + clients[i] = &WANPOTSLinkConfig1{genericClients[i]}
2645 + }
2646 + return
2647 +}
2648 +
2649 +// Arguments:
2650 +//
2651 +// * NewISPPhoneNumber:
2652 +//
2653 +// * NewISPInfo:
2654 +//
2655 +// * NewLinkType: allowed values: PPP_Dialup
2656 +//
2657 +//
2658 +func (client *WANPOTSLinkConfig1) SetISPInfo(NewISPPhoneNumber string, NewISPInfo string, NewLinkType string) (err error) {
2659 + // Request structure.
2660 + request := &struct {
2661 + NewISPPhoneNumber string
2662 +
2663 + NewISPInfo string
2664 +
2665 + NewLinkType string
2666 + }{}
2667 + // BEGIN Marshal arguments into request.
2668 +
2669 + if request.NewISPPhoneNumber, err = soap.MarshalString(NewISPPhoneNumber); err != nil {
2670 + return
2671 + }
2672 + if request.NewISPInfo, err = soap.MarshalString(NewISPInfo); err != nil {
2673 + return
2674 + }
2675 + if request.NewLinkType, err = soap.MarshalString(NewLinkType); err != nil {
2676 + return
2677 + }
2678 + // END Marshal arguments into request.
2679 +
2680 + // Response structure.
2681 + response := interface{}(nil)
2682 +
2683 + // Perform the SOAP call.
2684 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "SetISPInfo", request, response); err != nil {
2685 + return
2686 + }
2687 +
2688 + // BEGIN Unmarshal arguments from response.
2689 +
2690 + // END Unmarshal arguments from response.
2691 + return
2692 +}
2693 +
2694 +// Arguments:
2695 +//
2696 +// * NewNumberOfRetries:
2697 +//
2698 +// * NewDelayBetweenRetries:
2699 +//
2700 +//
2701 +func (client *WANPOTSLinkConfig1) SetCallRetryInfo(NewNumberOfRetries uint32, NewDelayBetweenRetries uint32) (err error) {
2702 + // Request structure.
2703 + request := &struct {
2704 + NewNumberOfRetries string
2705 +
2706 + NewDelayBetweenRetries string
2707 + }{}
2708 + // BEGIN Marshal arguments into request.
2709 +
2710 + if request.NewNumberOfRetries, err = soap.MarshalUi4(NewNumberOfRetries); err != nil {
2711 + return
2712 + }
2713 + if request.NewDelayBetweenRetries, err = soap.MarshalUi4(NewDelayBetweenRetries); err != nil {
2714 + return
2715 + }
2716 + // END Marshal arguments into request.
2717 +
2718 + // Response structure.
2719 + response := interface{}(nil)
2720 +
2721 + // Perform the SOAP call.
2722 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "SetCallRetryInfo", request, response); err != nil {
2723 + return
2724 + }
2725 +
2726 + // BEGIN Unmarshal arguments from response.
2727 +
2728 + // END Unmarshal arguments from response.
2729 + return
2730 +}
2731 +
2732 +//
2733 +//
2734 +// Return values:
2735 +//
2736 +// * NewISPPhoneNumber:
2737 +//
2738 +// * NewISPInfo:
2739 +//
2740 +// * NewLinkType: allowed values: PPP_Dialup
2741 +func (client *WANPOTSLinkConfig1) GetISPInfo() (NewISPPhoneNumber string, NewISPInfo string, NewLinkType string, err error) {
2742 + // Request structure.
2743 + request := interface{}(nil)
2744 + // BEGIN Marshal arguments into request.
2745 +
2746 + // END Marshal arguments into request.
2747 +
2748 + // Response structure.
2749 + response := &struct {
2750 + NewISPPhoneNumber string
2751 +
2752 + NewISPInfo string
2753 +
2754 + NewLinkType string
2755 + }{}
2756 +
2757 + // Perform the SOAP call.
2758 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetISPInfo", request, response); err != nil {
2759 + return
2760 + }
2761 +
2762 + // BEGIN Unmarshal arguments from response.
2763 +
2764 + if NewISPPhoneNumber, err = soap.UnmarshalString(response.NewISPPhoneNumber); err != nil {
2765 + return
2766 + }
2767 + if NewISPInfo, err = soap.UnmarshalString(response.NewISPInfo); err != nil {
2768 + return
2769 + }
2770 + if NewLinkType, err = soap.UnmarshalString(response.NewLinkType); err != nil {
2771 + return
2772 + }
2773 + // END Unmarshal arguments from response.
2774 + return
2775 +}
2776 +
2777 +//
2778 +//
2779 +// Return values:
2780 +//
2781 +// * NewNumberOfRetries:
2782 +//
2783 +// * NewDelayBetweenRetries:
2784 +func (client *WANPOTSLinkConfig1) GetCallRetryInfo() (NewNumberOfRetries uint32, NewDelayBetweenRetries uint32, err error) {
2785 + // Request structure.
2786 + request := interface{}(nil)
2787 + // BEGIN Marshal arguments into request.
2788 +
2789 + // END Marshal arguments into request.
2790 +
2791 + // Response structure.
2792 + response := &struct {
2793 + NewNumberOfRetries string
2794 +
2795 + NewDelayBetweenRetries string
2796 + }{}
2797 +
2798 + // Perform the SOAP call.
2799 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetCallRetryInfo", request, response); err != nil {
2800 + return
2801 + }
2802 +
2803 + // BEGIN Unmarshal arguments from response.
2804 +
2805 + if NewNumberOfRetries, err = soap.UnmarshalUi4(response.NewNumberOfRetries); err != nil {
2806 + return
2807 + }
2808 + if NewDelayBetweenRetries, err = soap.UnmarshalUi4(response.NewDelayBetweenRetries); err != nil {
2809 + return
2810 + }
2811 + // END Unmarshal arguments from response.
2812 + return
2813 +}
2814 +
2815 +//
2816 +//
2817 +// Return values:
2818 +//
2819 +// * NewFclass:
2820 +func (client *WANPOTSLinkConfig1) GetFclass() (NewFclass string, err error) {
2821 + // Request structure.
2822 + request := interface{}(nil)
2823 + // BEGIN Marshal arguments into request.
2824 +
2825 + // END Marshal arguments into request.
2826 +
2827 + // Response structure.
2828 + response := &struct {
2829 + NewFclass string
2830 + }{}
2831 +
2832 + // Perform the SOAP call.
2833 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetFclass", request, response); err != nil {
2834 + return
2835 + }
2836 +
2837 + // BEGIN Unmarshal arguments from response.
2838 +
2839 + if NewFclass, err = soap.UnmarshalString(response.NewFclass); err != nil {
2840 + return
2841 + }
2842 + // END Unmarshal arguments from response.
2843 + return
2844 +}
2845 +
2846 +//
2847 +//
2848 +// Return values:
2849 +//
2850 +// * NewDataModulationSupported:
2851 +func (client *WANPOTSLinkConfig1) GetDataModulationSupported() (NewDataModulationSupported string, err error) {
2852 + // Request structure.
2853 + request := interface{}(nil)
2854 + // BEGIN Marshal arguments into request.
2855 +
2856 + // END Marshal arguments into request.
2857 +
2858 + // Response structure.
2859 + response := &struct {
2860 + NewDataModulationSupported string
2861 + }{}
2862 +
2863 + // Perform the SOAP call.
2864 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetDataModulationSupported", request, response); err != nil {
2865 + return
2866 + }
2867 +
2868 + // BEGIN Unmarshal arguments from response.
2869 +
2870 + if NewDataModulationSupported, err = soap.UnmarshalString(response.NewDataModulationSupported); err != nil {
2871 + return
2872 + }
2873 + // END Unmarshal arguments from response.
2874 + return
2875 +}
2876 +
2877 +//
2878 +//
2879 +// Return values:
2880 +//
2881 +// * NewDataProtocol:
2882 +func (client *WANPOTSLinkConfig1) GetDataProtocol() (NewDataProtocol string, err error) {
2883 + // Request structure.
2884 + request := interface{}(nil)
2885 + // BEGIN Marshal arguments into request.
2886 +
2887 + // END Marshal arguments into request.
2888 +
2889 + // Response structure.
2890 + response := &struct {
2891 + NewDataProtocol string
2892 + }{}
2893 +
2894 + // Perform the SOAP call.
2895 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetDataProtocol", request, response); err != nil {
2896 + return
2897 + }
2898 +
2899 + // BEGIN Unmarshal arguments from response.
2900 +
2901 + if NewDataProtocol, err = soap.UnmarshalString(response.NewDataProtocol); err != nil {
2902 + return
2903 + }
2904 + // END Unmarshal arguments from response.
2905 + return
2906 +}
2907 +
2908 +//
2909 +//
2910 +// Return values:
2911 +//
2912 +// * NewDataCompression:
2913 +func (client *WANPOTSLinkConfig1) GetDataCompression() (NewDataCompression string, err error) {
2914 + // Request structure.
2915 + request := interface{}(nil)
2916 + // BEGIN Marshal arguments into request.
2917 +
2918 + // END Marshal arguments into request.
2919 +
2920 + // Response structure.
2921 + response := &struct {
2922 + NewDataCompression string
2923 + }{}
2924 +
2925 + // Perform the SOAP call.
2926 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetDataCompression", request, response); err != nil {
2927 + return
2928 + }
2929 +
2930 + // BEGIN Unmarshal arguments from response.
2931 +
2932 + if NewDataCompression, err = soap.UnmarshalString(response.NewDataCompression); err != nil {
2933 + return
2934 + }
2935 + // END Unmarshal arguments from response.
2936 + return
2937 +}
2938 +
2939 +//
2940 +//
2941 +// Return values:
2942 +//
2943 +// * NewPlusVTRCommandSupported:
2944 +func (client *WANPOTSLinkConfig1) GetPlusVTRCommandSupported() (NewPlusVTRCommandSupported bool, err error) {
2945 + // Request structure.
2946 + request := interface{}(nil)
2947 + // BEGIN Marshal arguments into request.
2948 +
2949 + // END Marshal arguments into request.
2950 +
2951 + // Response structure.
2952 + response := &struct {
2953 + NewPlusVTRCommandSupported string
2954 + }{}
2955 +
2956 + // Perform the SOAP call.
2957 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetPlusVTRCommandSupported", request, response); err != nil {
2958 + return
2959 + }
2960 +
2961 + // BEGIN Unmarshal arguments from response.
2962 +
2963 + if NewPlusVTRCommandSupported, err = soap.UnmarshalBoolean(response.NewPlusVTRCommandSupported); err != nil {
2964 + return
2965 + }
2966 + // END Unmarshal arguments from response.
2967 + return
2968 +}
2969 +
2970 +// WANPPPConnection1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANPPPConnection:1". See
2971 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
2972 +// are provided for informational value.
2973 +type WANPPPConnection1 struct {
2974 + goupnp.ServiceClient
2975 +}
2976 +
2977 +// NewWANPPPConnection1Clients discovers instances of the service on the network,
2978 +// and returns clients to any that are found. errors will contain an error for
2979 +// any devices that replied but which could not be queried, and err will be set
2980 +// if the discovery process failed outright.
2981 +//
2982 +// This is a typical entry calling point into this package.
2983 +func NewWANPPPConnection1Clients() (clients []*WANPPPConnection1, errors []error, err error) {
2984 + var genericClients []goupnp.ServiceClient
2985 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANPPPConnection_1); err != nil {
2986 + return
2987 + }
2988 + clients = make([]*WANPPPConnection1, len(genericClients))
2989 + for i := range genericClients {
2990 + clients[i] = &WANPPPConnection1{genericClients[i]}
2991 + }
2992 + return
2993 +}
2994 +
2995 +// Arguments:
2996 +//
2997 +// * NewConnectionType:
2998 +//
2999 +//
3000 +func (client *WANPPPConnection1) SetConnectionType(NewConnectionType string) (err error) {
3001 + // Request structure.
3002 + request := &struct {
3003 + NewConnectionType string
3004 + }{}
3005 + // BEGIN Marshal arguments into request.
3006 +
3007 + if request.NewConnectionType, err = soap.MarshalString(NewConnectionType); err != nil {
3008 + return
3009 + }
3010 + // END Marshal arguments into request.
3011 +
3012 + // Response structure.
3013 + response := interface{}(nil)
3014 +
3015 + // Perform the SOAP call.
3016 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "SetConnectionType", request, response); err != nil {
3017 + return
3018 + }
3019 +
3020 + // BEGIN Unmarshal arguments from response.
3021 +
3022 + // END Unmarshal arguments from response.
3023 + return
3024 +}
3025 +
3026 +//
3027 +//
3028 +// Return values:
3029 +//
3030 +// * NewConnectionType:
3031 +//
3032 +// * NewPossibleConnectionTypes: allowed values: Unconfigured, IP_Routed, DHCP_Spoofed, PPPoE_Bridged, PPTP_Relay, L2TP_Relay, PPPoE_Relay
3033 +func (client *WANPPPConnection1) GetConnectionTypeInfo() (NewConnectionType string, NewPossibleConnectionTypes string, err error) {
3034 + // Request structure.
3035 + request := interface{}(nil)
3036 + // BEGIN Marshal arguments into request.
3037 +
3038 + // END Marshal arguments into request.
3039 +
3040 + // Response structure.
3041 + response := &struct {
3042 + NewConnectionType string
3043 +
3044 + NewPossibleConnectionTypes string
3045 + }{}
3046 +
3047 + // Perform the SOAP call.
3048 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetConnectionTypeInfo", request, response); err != nil {
3049 + return
3050 + }
3051 +
3052 + // BEGIN Unmarshal arguments from response.
3053 +
3054 + if NewConnectionType, err = soap.UnmarshalString(response.NewConnectionType); err != nil {
3055 + return
3056 + }
3057 + if NewPossibleConnectionTypes, err = soap.UnmarshalString(response.NewPossibleConnectionTypes); err != nil {
3058 + return
3059 + }
3060 + // END Unmarshal arguments from response.
3061 + return
3062 +}
3063 +
3064 +// Arguments:
3065 +//
3066 +// * NewUserName:
3067 +//
3068 +// * NewPassword:
3069 +//
3070 +//
3071 +func (client *WANPPPConnection1) ConfigureConnection(NewUserName string, NewPassword string) (err error) {
3072 + // Request structure.
3073 + request := &struct {
3074 + NewUserName string
3075 +
3076 + NewPassword string
3077 + }{}
3078 + // BEGIN Marshal arguments into request.
3079 +
3080 + if request.NewUserName, err = soap.MarshalString(NewUserName); err != nil {
3081 + return
3082 + }
3083 + if request.NewPassword, err = soap.MarshalString(NewPassword); err != nil {
3084 + return
3085 + }
3086 + // END Marshal arguments into request.
3087 +
3088 + // Response structure.
3089 + response := interface{}(nil)
3090 +
3091 + // Perform the SOAP call.
3092 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "ConfigureConnection", request, response); err != nil {
3093 + return
3094 + }
3095 +
3096 + // BEGIN Unmarshal arguments from response.
3097 +
3098 + // END Unmarshal arguments from response.
3099 + return
3100 +}
3101 +
3102 +//
3103 +//
3104 +//
3105 +func (client *WANPPPConnection1) RequestConnection() (err error) {
3106 + // Request structure.
3107 + request := interface{}(nil)
3108 + // BEGIN Marshal arguments into request.
3109 +
3110 + // END Marshal arguments into request.
3111 +
3112 + // Response structure.
3113 + response := interface{}(nil)
3114 +
3115 + // Perform the SOAP call.
3116 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "RequestConnection", request, response); err != nil {
3117 + return
3118 + }
3119 +
3120 + // BEGIN Unmarshal arguments from response.
3121 +
3122 + // END Unmarshal arguments from response.
3123 + return
3124 +}
3125 +
3126 +//
3127 +//
3128 +//
3129 +func (client *WANPPPConnection1) RequestTermination() (err error) {
3130 + // Request structure.
3131 + request := interface{}(nil)
3132 + // BEGIN Marshal arguments into request.
3133 +
3134 + // END Marshal arguments into request.
3135 +
3136 + // Response structure.
3137 + response := interface{}(nil)
3138 +
3139 + // Perform the SOAP call.
3140 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "RequestTermination", request, response); err != nil {
3141 + return
3142 + }
3143 +
3144 + // BEGIN Unmarshal arguments from response.
3145 +
3146 + // END Unmarshal arguments from response.
3147 + return
3148 +}
3149 +
3150 +//
3151 +//
3152 +//
3153 +func (client *WANPPPConnection1) ForceTermination() (err error) {
3154 + // Request structure.
3155 + request := interface{}(nil)
3156 + // BEGIN Marshal arguments into request.
3157 +
3158 + // END Marshal arguments into request.
3159 +
3160 + // Response structure.
3161 + response := interface{}(nil)
3162 +
3163 + // Perform the SOAP call.
3164 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "ForceTermination", request, response); err != nil {
3165 + return
3166 + }
3167 +
3168 + // BEGIN Unmarshal arguments from response.
3169 +
3170 + // END Unmarshal arguments from response.
3171 + return
3172 +}
3173 +
3174 +// Arguments:
3175 +//
3176 +// * NewAutoDisconnectTime:
3177 +//
3178 +//
3179 +func (client *WANPPPConnection1) SetAutoDisconnectTime(NewAutoDisconnectTime uint32) (err error) {
3180 + // Request structure.
3181 + request := &struct {
3182 + NewAutoDisconnectTime string
3183 + }{}
3184 + // BEGIN Marshal arguments into request.
3185 +
3186 + if request.NewAutoDisconnectTime, err = soap.MarshalUi4(NewAutoDisconnectTime); err != nil {
3187 + return
3188 + }
3189 + // END Marshal arguments into request.
3190 +
3191 + // Response structure.
3192 + response := interface{}(nil)
3193 +
3194 + // Perform the SOAP call.
3195 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "SetAutoDisconnectTime", request, response); err != nil {
3196 + return
3197 + }
3198 +
3199 + // BEGIN Unmarshal arguments from response.
3200 +
3201 + // END Unmarshal arguments from response.
3202 + return
3203 +}
3204 +
3205 +// Arguments:
3206 +//
3207 +// * NewIdleDisconnectTime:
3208 +//
3209 +//
3210 +func (client *WANPPPConnection1) SetIdleDisconnectTime(NewIdleDisconnectTime uint32) (err error) {
3211 + // Request structure.
3212 + request := &struct {
3213 + NewIdleDisconnectTime string
3214 + }{}
3215 + // BEGIN Marshal arguments into request.
3216 +
3217 + if request.NewIdleDisconnectTime, err = soap.MarshalUi4(NewIdleDisconnectTime); err != nil {
3218 + return
3219 + }
3220 + // END Marshal arguments into request.
3221 +
3222 + // Response structure.
3223 + response := interface{}(nil)
3224 +
3225 + // Perform the SOAP call.
3226 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "SetIdleDisconnectTime", request, response); err != nil {
3227 + return
3228 + }
3229 +
3230 + // BEGIN Unmarshal arguments from response.
3231 +
3232 + // END Unmarshal arguments from response.
3233 + return
3234 +}
3235 +
3236 +// Arguments:
3237 +//
3238 +// * NewWarnDisconnectDelay:
3239 +//
3240 +//
3241 +func (client *WANPPPConnection1) SetWarnDisconnectDelay(NewWarnDisconnectDelay uint32) (err error) {
3242 + // Request structure.
3243 + request := &struct {
3244 + NewWarnDisconnectDelay string
3245 + }{}
3246 + // BEGIN Marshal arguments into request.
3247 +
3248 + if request.NewWarnDisconnectDelay, err = soap.MarshalUi4(NewWarnDisconnectDelay); err != nil {
3249 + return
3250 + }
3251 + // END Marshal arguments into request.
3252 +
3253 + // Response structure.
3254 + response := interface{}(nil)
3255 +
3256 + // Perform the SOAP call.
3257 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "SetWarnDisconnectDelay", request, response); err != nil {
3258 + return
3259 + }
3260 +
3261 + // BEGIN Unmarshal arguments from response.
3262 +
3263 + // END Unmarshal arguments from response.
3264 + return
3265 +}
3266 +
3267 +//
3268 +//
3269 +// Return values:
3270 +//
3271 +// * NewConnectionStatus: allowed values: Unconfigured, Connected, Disconnected
3272 +//
3273 +// * NewLastConnectionError: allowed values: ERROR_NONE
3274 +//
3275 +// * NewUptime:
3276 +func (client *WANPPPConnection1) GetStatusInfo() (NewConnectionStatus string, NewLastConnectionError string, NewUptime uint32, err error) {
3277 + // Request structure.
3278 + request := interface{}(nil)
3279 + // BEGIN Marshal arguments into request.
3280 +
3281 + // END Marshal arguments into request.
3282 +
3283 + // Response structure.
3284 + response := &struct {
3285 + NewConnectionStatus string
3286 +
3287 + NewLastConnectionError string
3288 +
3289 + NewUptime string
3290 + }{}
3291 +
3292 + // Perform the SOAP call.
3293 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetStatusInfo", request, response); err != nil {
3294 + return
3295 + }
3296 +
3297 + // BEGIN Unmarshal arguments from response.
3298 +
3299 + if NewConnectionStatus, err = soap.UnmarshalString(response.NewConnectionStatus); err != nil {
3300 + return
3301 + }
3302 + if NewLastConnectionError, err = soap.UnmarshalString(response.NewLastConnectionError); err != nil {
3303 + return
3304 + }
3305 + if NewUptime, err = soap.UnmarshalUi4(response.NewUptime); err != nil {
3306 + return
3307 + }
3308 + // END Unmarshal arguments from response.
3309 + return
3310 +}
3311 +
3312 +//
3313 +//
3314 +// Return values:
3315 +//
3316 +// * NewUpstreamMaxBitRate:
3317 +//
3318 +// * NewDownstreamMaxBitRate:
3319 +func (client *WANPPPConnection1) GetLinkLayerMaxBitRates() (NewUpstreamMaxBitRate uint32, NewDownstreamMaxBitRate uint32, err error) {
3320 + // Request structure.
3321 + request := interface{}(nil)
3322 + // BEGIN Marshal arguments into request.
3323 +
3324 + // END Marshal arguments into request.
3325 +
3326 + // Response structure.
3327 + response := &struct {
3328 + NewUpstreamMaxBitRate string
3329 +
3330 + NewDownstreamMaxBitRate string
3331 + }{}
3332 +
3333 + // Perform the SOAP call.
3334 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetLinkLayerMaxBitRates", request, response); err != nil {
3335 + return
3336 + }
3337 +
3338 + // BEGIN Unmarshal arguments from response.
3339 +
3340 + if NewUpstreamMaxBitRate, err = soap.UnmarshalUi4(response.NewUpstreamMaxBitRate); err != nil {
3341 + return
3342 + }
3343 + if NewDownstreamMaxBitRate, err = soap.UnmarshalUi4(response.NewDownstreamMaxBitRate); err != nil {
3344 + return
3345 + }
3346 + // END Unmarshal arguments from response.
3347 + return
3348 +}
3349 +
3350 +//
3351 +//
3352 +// Return values:
3353 +//
3354 +// * NewPPPEncryptionProtocol:
3355 +func (client *WANPPPConnection1) GetPPPEncryptionProtocol() (NewPPPEncryptionProtocol string, err error) {
3356 + // Request structure.
3357 + request := interface{}(nil)
3358 + // BEGIN Marshal arguments into request.
3359 +
3360 + // END Marshal arguments into request.
3361 +
3362 + // Response structure.
3363 + response := &struct {
3364 + NewPPPEncryptionProtocol string
3365 + }{}
3366 +
3367 + // Perform the SOAP call.
3368 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetPPPEncryptionProtocol", request, response); err != nil {
3369 + return
3370 + }
3371 +
3372 + // BEGIN Unmarshal arguments from response.
3373 +
3374 + if NewPPPEncryptionProtocol, err = soap.UnmarshalString(response.NewPPPEncryptionProtocol); err != nil {
3375 + return
3376 + }
3377 + // END Unmarshal arguments from response.
3378 + return
3379 +}
3380 +
3381 +//
3382 +//
3383 +// Return values:
3384 +//
3385 +// * NewPPPCompressionProtocol:
3386 +func (client *WANPPPConnection1) GetPPPCompressionProtocol() (NewPPPCompressionProtocol string, err error) {
3387 + // Request structure.
3388 + request := interface{}(nil)
3389 + // BEGIN Marshal arguments into request.
3390 +
3391 + // END Marshal arguments into request.
3392 +
3393 + // Response structure.
3394 + response := &struct {
3395 + NewPPPCompressionProtocol string
3396 + }{}
3397 +
3398 + // Perform the SOAP call.
3399 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetPPPCompressionProtocol", request, response); err != nil {
3400 + return
3401 + }
3402 +
3403 + // BEGIN Unmarshal arguments from response.
3404 +
3405 + if NewPPPCompressionProtocol, err = soap.UnmarshalString(response.NewPPPCompressionProtocol); err != nil {
3406 + return
3407 + }
3408 + // END Unmarshal arguments from response.
3409 + return
3410 +}
3411 +
3412 +//
3413 +//
3414 +// Return values:
3415 +//
3416 +// * NewPPPAuthenticationProtocol:
3417 +func (client *WANPPPConnection1) GetPPPAuthenticationProtocol() (NewPPPAuthenticationProtocol string, err error) {
3418 + // Request structure.
3419 + request := interface{}(nil)
3420 + // BEGIN Marshal arguments into request.
3421 +
3422 + // END Marshal arguments into request.
3423 +
3424 + // Response structure.
3425 + response := &struct {
3426 + NewPPPAuthenticationProtocol string
3427 + }{}
3428 +
3429 + // Perform the SOAP call.
3430 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetPPPAuthenticationProtocol", request, response); err != nil {
3431 + return
3432 + }
3433 +
3434 + // BEGIN Unmarshal arguments from response.
3435 +
3436 + if NewPPPAuthenticationProtocol, err = soap.UnmarshalString(response.NewPPPAuthenticationProtocol); err != nil {
3437 + return
3438 + }
3439 + // END Unmarshal arguments from response.
3440 + return
3441 +}
3442 +
3443 +//
3444 +//
3445 +// Return values:
3446 +//
3447 +// * NewUserName:
3448 +func (client *WANPPPConnection1) GetUserName() (NewUserName string, err error) {
3449 + // Request structure.
3450 + request := interface{}(nil)
3451 + // BEGIN Marshal arguments into request.
3452 +
3453 + // END Marshal arguments into request.
3454 +
3455 + // Response structure.
3456 + response := &struct {
3457 + NewUserName string
3458 + }{}
3459 +
3460 + // Perform the SOAP call.
3461 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetUserName", request, response); err != nil {
3462 + return
3463 + }
3464 +
3465 + // BEGIN Unmarshal arguments from response.
3466 +
3467 + if NewUserName, err = soap.UnmarshalString(response.NewUserName); err != nil {
3468 + return
3469 + }
3470 + // END Unmarshal arguments from response.
3471 + return
3472 +}
3473 +
3474 +//
3475 +//
3476 +// Return values:
3477 +//
3478 +// * NewPassword:
3479 +func (client *WANPPPConnection1) GetPassword() (NewPassword string, err error) {
3480 + // Request structure.
3481 + request := interface{}(nil)
3482 + // BEGIN Marshal arguments into request.
3483 +
3484 + // END Marshal arguments into request.
3485 +
3486 + // Response structure.
3487 + response := &struct {
3488 + NewPassword string
3489 + }{}
3490 +
3491 + // Perform the SOAP call.
3492 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetPassword", request, response); err != nil {
3493 + return
3494 + }
3495 +
3496 + // BEGIN Unmarshal arguments from response.
3497 +
3498 + if NewPassword, err = soap.UnmarshalString(response.NewPassword); err != nil {
3499 + return
3500 + }
3501 + // END Unmarshal arguments from response.
3502 + return
3503 +}
3504 +
3505 +//
3506 +//
3507 +// Return values:
3508 +//
3509 +// * NewAutoDisconnectTime:
3510 +func (client *WANPPPConnection1) GetAutoDisconnectTime() (NewAutoDisconnectTime uint32, err error) {
3511 + // Request structure.
3512 + request := interface{}(nil)
3513 + // BEGIN Marshal arguments into request.
3514 +
3515 + // END Marshal arguments into request.
3516 +
3517 + // Response structure.
3518 + response := &struct {
3519 + NewAutoDisconnectTime string
3520 + }{}
3521 +
3522 + // Perform the SOAP call.
3523 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetAutoDisconnectTime", request, response); err != nil {
3524 + return
3525 + }
3526 +
3527 + // BEGIN Unmarshal arguments from response.
3528 +
3529 + if NewAutoDisconnectTime, err = soap.UnmarshalUi4(response.NewAutoDisconnectTime); err != nil {
3530 + return
3531 + }
3532 + // END Unmarshal arguments from response.
3533 + return
3534 +}
3535 +
3536 +//
3537 +//
3538 +// Return values:
3539 +//
3540 +// * NewIdleDisconnectTime:
3541 +func (client *WANPPPConnection1) GetIdleDisconnectTime() (NewIdleDisconnectTime uint32, err error) {
3542 + // Request structure.
3543 + request := interface{}(nil)
3544 + // BEGIN Marshal arguments into request.
3545 +
3546 + // END Marshal arguments into request.
3547 +
3548 + // Response structure.
3549 + response := &struct {
3550 + NewIdleDisconnectTime string
3551 + }{}
3552 +
3553 + // Perform the SOAP call.
3554 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetIdleDisconnectTime", request, response); err != nil {
3555 + return
3556 + }
3557 +
3558 + // BEGIN Unmarshal arguments from response.
3559 +
3560 + if NewIdleDisconnectTime, err = soap.UnmarshalUi4(response.NewIdleDisconnectTime); err != nil {
3561 + return
3562 + }
3563 + // END Unmarshal arguments from response.
3564 + return
3565 +}
3566 +
3567 +//
3568 +//
3569 +// Return values:
3570 +//
3571 +// * NewWarnDisconnectDelay:
3572 +func (client *WANPPPConnection1) GetWarnDisconnectDelay() (NewWarnDisconnectDelay uint32, err error) {
3573 + // Request structure.
3574 + request := interface{}(nil)
3575 + // BEGIN Marshal arguments into request.
3576 +
3577 + // END Marshal arguments into request.
3578 +
3579 + // Response structure.
3580 + response := &struct {
3581 + NewWarnDisconnectDelay string
3582 + }{}
3583 +
3584 + // Perform the SOAP call.
3585 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetWarnDisconnectDelay", request, response); err != nil {
3586 + return
3587 + }
3588 +
3589 + // BEGIN Unmarshal arguments from response.
3590 +
3591 + if NewWarnDisconnectDelay, err = soap.UnmarshalUi4(response.NewWarnDisconnectDelay); err != nil {
3592 + return
3593 + }
3594 + // END Unmarshal arguments from response.
3595 + return
3596 +}
3597 +
3598 +//
3599 +//
3600 +// Return values:
3601 +//
3602 +// * NewRSIPAvailable:
3603 +//
3604 +// * NewNATEnabled:
3605 +func (client *WANPPPConnection1) GetNATRSIPStatus() (NewRSIPAvailable bool, NewNATEnabled bool, err error) {
3606 + // Request structure.
3607 + request := interface{}(nil)
3608 + // BEGIN Marshal arguments into request.
3609 +
3610 + // END Marshal arguments into request.
3611 +
3612 + // Response structure.
3613 + response := &struct {
3614 + NewRSIPAvailable string
3615 +
3616 + NewNATEnabled string
3617 + }{}
3618 +
3619 + // Perform the SOAP call.
3620 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetNATRSIPStatus", request, response); err != nil {
3621 + return
3622 + }
3623 +
3624 + // BEGIN Unmarshal arguments from response.
3625 +
3626 + if NewRSIPAvailable, err = soap.UnmarshalBoolean(response.NewRSIPAvailable); err != nil {
3627 + return
3628 + }
3629 + if NewNATEnabled, err = soap.UnmarshalBoolean(response.NewNATEnabled); err != nil {
3630 + return
3631 + }
3632 + // END Unmarshal arguments from response.
3633 + return
3634 +}
3635 +
3636 +// Arguments:
3637 +//
3638 +// * NewPortMappingIndex:
3639 +//
3640 +// Return values:
3641 +//
3642 +// * NewRemoteHost:
3643 +//
3644 +// * NewExternalPort:
3645 +//
3646 +// * NewProtocol: allowed values: TCP, UDP
3647 +//
3648 +// * NewInternalPort:
3649 +//
3650 +// * NewInternalClient:
3651 +//
3652 +// * NewEnabled:
3653 +//
3654 +// * NewPortMappingDescription:
3655 +//
3656 +// * NewLeaseDuration:
3657 +func (client *WANPPPConnection1) GetGenericPortMappingEntry(NewPortMappingIndex uint16) (NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
3658 + // Request structure.
3659 + request := &struct {
3660 + NewPortMappingIndex string
3661 + }{}
3662 + // BEGIN Marshal arguments into request.
3663 +
3664 + if request.NewPortMappingIndex, err = soap.MarshalUi2(NewPortMappingIndex); err != nil {
3665 + return
3666 + }
3667 + // END Marshal arguments into request.
3668 +
3669 + // Response structure.
3670 + response := &struct {
3671 + NewRemoteHost string
3672 +
3673 + NewExternalPort string
3674 +
3675 + NewProtocol string
3676 +
3677 + NewInternalPort string
3678 +
3679 + NewInternalClient string
3680 +
3681 + NewEnabled string
3682 +
3683 + NewPortMappingDescription string
3684 +
3685 + NewLeaseDuration string
3686 + }{}
3687 +
3688 + // Perform the SOAP call.
3689 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetGenericPortMappingEntry", request, response); err != nil {
3690 + return
3691 + }
3692 +
3693 + // BEGIN Unmarshal arguments from response.
3694 +
3695 + if NewRemoteHost, err = soap.UnmarshalString(response.NewRemoteHost); err != nil {
3696 + return
3697 + }
3698 + if NewExternalPort, err = soap.UnmarshalUi2(response.NewExternalPort); err != nil {
3699 + return
3700 + }
3701 + if NewProtocol, err = soap.UnmarshalString(response.NewProtocol); err != nil {
3702 + return
3703 + }
3704 + if NewInternalPort, err = soap.UnmarshalUi2(response.NewInternalPort); err != nil {
3705 + return
3706 + }
3707 + if NewInternalClient, err = soap.UnmarshalString(response.NewInternalClient); err != nil {
3708 + return
3709 + }
3710 + if NewEnabled, err = soap.UnmarshalBoolean(response.NewEnabled); err != nil {
3711 + return
3712 + }
3713 + if NewPortMappingDescription, err = soap.UnmarshalString(response.NewPortMappingDescription); err != nil {
3714 + return
3715 + }
3716 + if NewLeaseDuration, err = soap.UnmarshalUi4(response.NewLeaseDuration); err != nil {
3717 + return
3718 + }
3719 + // END Unmarshal arguments from response.
3720 + return
3721 +}
3722 +
3723 +// Arguments:
3724 +//
3725 +// * NewRemoteHost:
3726 +//
3727 +// * NewExternalPort:
3728 +//
3729 +// * NewProtocol: allowed values: TCP, UDP
3730 +//
3731 +// Return values:
3732 +//
3733 +// * NewInternalPort:
3734 +//
3735 +// * NewInternalClient:
3736 +//
3737 +// * NewEnabled:
3738 +//
3739 +// * NewPortMappingDescription:
3740 +//
3741 +// * NewLeaseDuration:
3742 +func (client *WANPPPConnection1) GetSpecificPortMappingEntry(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
3743 + // Request structure.
3744 + request := &struct {
3745 + NewRemoteHost string
3746 +
3747 + NewExternalPort string
3748 +
3749 + NewProtocol string
3750 + }{}
3751 + // BEGIN Marshal arguments into request.
3752 +
3753 + if request.NewRemoteHost, err = soap.MarshalString(NewRemoteHost); err != nil {
3754 + return
3755 + }
3756 + if request.NewExternalPort, err = soap.MarshalUi2(NewExternalPort); err != nil {
3757 + return
3758 + }
3759 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
3760 + return
3761 + }
3762 + // END Marshal arguments into request.
3763 +
3764 + // Response structure.
3765 + response := &struct {
3766 + NewInternalPort string
3767 +
3768 + NewInternalClient string
3769 +
3770 + NewEnabled string
3771 +
3772 + NewPortMappingDescription string
3773 +
3774 + NewLeaseDuration string
3775 + }{}
3776 +
3777 + // Perform the SOAP call.
3778 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetSpecificPortMappingEntry", request, response); err != nil {
3779 + return
3780 + }
3781 +
3782 + // BEGIN Unmarshal arguments from response.
3783 +
3784 + if NewInternalPort, err = soap.UnmarshalUi2(response.NewInternalPort); err != nil {
3785 + return
3786 + }
3787 + if NewInternalClient, err = soap.UnmarshalString(response.NewInternalClient); err != nil {
3788 + return
3789 + }
3790 + if NewEnabled, err = soap.UnmarshalBoolean(response.NewEnabled); err != nil {
3791 + return
3792 + }
3793 + if NewPortMappingDescription, err = soap.UnmarshalString(response.NewPortMappingDescription); err != nil {
3794 + return
3795 + }
3796 + if NewLeaseDuration, err = soap.UnmarshalUi4(response.NewLeaseDuration); err != nil {
3797 + return
3798 + }
3799 + // END Unmarshal arguments from response.
3800 + return
3801 +}
3802 +
3803 +// Arguments:
3804 +//
3805 +// * NewRemoteHost:
3806 +//
3807 +// * NewExternalPort:
3808 +//
3809 +// * NewProtocol: allowed values: TCP, UDP
3810 +//
3811 +// * NewInternalPort:
3812 +//
3813 +// * NewInternalClient:
3814 +//
3815 +// * NewEnabled:
3816 +//
3817 +// * NewPortMappingDescription:
3818 +//
3819 +// * NewLeaseDuration:
3820 +//
3821 +//
3822 +func (client *WANPPPConnection1) AddPortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32) (err error) {
3823 + // Request structure.
3824 + request := &struct {
3825 + NewRemoteHost string
3826 +
3827 + NewExternalPort string
3828 +
3829 + NewProtocol string
3830 +
3831 + NewInternalPort string
3832 +
3833 + NewInternalClient string
3834 +
3835 + NewEnabled string
3836 +
3837 + NewPortMappingDescription string
3838 +
3839 + NewLeaseDuration string
3840 + }{}
3841 + // BEGIN Marshal arguments into request.
3842 +
3843 + if request.NewRemoteHost, err = soap.MarshalString(NewRemoteHost); err != nil {
3844 + return
3845 + }
3846 + if request.NewExternalPort, err = soap.MarshalUi2(NewExternalPort); err != nil {
3847 + return
3848 + }
3849 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
3850 + return
3851 + }
3852 + if request.NewInternalPort, err = soap.MarshalUi2(NewInternalPort); err != nil {
3853 + return
3854 + }
3855 + if request.NewInternalClient, err = soap.MarshalString(NewInternalClient); err != nil {
3856 + return
3857 + }
3858 + if request.NewEnabled, err = soap.MarshalBoolean(NewEnabled); err != nil {
3859 + return
3860 + }
3861 + if request.NewPortMappingDescription, err = soap.MarshalString(NewPortMappingDescription); err != nil {
3862 + return
3863 + }
3864 + if request.NewLeaseDuration, err = soap.MarshalUi4(NewLeaseDuration); err != nil {
3865 + return
3866 + }
3867 + // END Marshal arguments into request.
3868 +
3869 + // Response structure.
3870 + response := interface{}(nil)
3871 +
3872 + // Perform the SOAP call.
3873 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "AddPortMapping", request, response); err != nil {
3874 + return
3875 + }
3876 +
3877 + // BEGIN Unmarshal arguments from response.
3878 +
3879 + // END Unmarshal arguments from response.
3880 + return
3881 +}
3882 +
3883 +// Arguments:
3884 +//
3885 +// * NewRemoteHost:
3886 +//
3887 +// * NewExternalPort:
3888 +//
3889 +// * NewProtocol: allowed values: TCP, UDP
3890 +//
3891 +//
3892 +func (client *WANPPPConnection1) DeletePortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (err error) {
3893 + // Request structure.
3894 + request := &struct {
3895 + NewRemoteHost string
3896 +
3897 + NewExternalPort string
3898 +
3899 + NewProtocol string
3900 + }{}
3901 + // BEGIN Marshal arguments into request.
3902 +
3903 + if request.NewRemoteHost, err = soap.MarshalString(NewRemoteHost); err != nil {
3904 + return
3905 + }
3906 + if request.NewExternalPort, err = soap.MarshalUi2(NewExternalPort); err != nil {
3907 + return
3908 + }
3909 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
3910 + return
3911 + }
3912 + // END Marshal arguments into request.
3913 +
3914 + // Response structure.
3915 + response := interface{}(nil)
3916 +
3917 + // Perform the SOAP call.
3918 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "DeletePortMapping", request, response); err != nil {
3919 + return
3920 + }
3921 +
3922 + // BEGIN Unmarshal arguments from response.
3923 +
3924 + // END Unmarshal arguments from response.
3925 + return
3926 +}
3927 +
3928 +//
3929 +//
3930 +// Return values:
3931 +//
3932 +// * NewExternalIPAddress:
3933 +func (client *WANPPPConnection1) GetExternalIPAddress() (NewExternalIPAddress string, err error) {
3934 + // Request structure.
3935 + request := interface{}(nil)
3936 + // BEGIN Marshal arguments into request.
3937 +
3938 + // END Marshal arguments into request.
3939 +
3940 + // Response structure.
3941 + response := &struct {
3942 + NewExternalIPAddress string
3943 + }{}
3944 +
3945 + // Perform the SOAP call.
3946 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetExternalIPAddress", request, response); err != nil {
3947 + return
3948 + }
3949 +
3950 + // BEGIN Unmarshal arguments from response.
3951 +
3952 + if NewExternalIPAddress, err = soap.UnmarshalString(response.NewExternalIPAddress); err != nil {
3953 + return
3954 + }
3955 + // END Unmarshal arguments from response.
3956 + return
3957 +}
Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway2/internetgateway2.go new
+5271
@@ -0,0 +1,5271 @@
1 +// Client for UPnP Device Control Protocol Internet Gateway Device v2.
2 +//
3 +// This DCP is documented in detail at: http://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v2-Device.pdf
4 +//
5 +// Typically, use one of the New* functions to discover services on the local
6 +// network.
7 +package internetgateway2
8 +
9 +// Generated file - do not edit by hand. See README.md
10 +
11 +import (
12 + "time"
13 +
14 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp"
15 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/soap"
16 +)
17 +
18 +// Hack to avoid Go complaining if time isn't used.
19 +var _ time.Time
20 +
21 +// Device URNs:
22 +const (
23 + URN_LANDevice_1 = "urn:schemas-upnp-org:device:LANDevice:1"
24 + URN_WANConnectionDevice_1 = "urn:schemas-upnp-org:device:WANConnectionDevice:1"
25 + URN_WANConnectionDevice_2 = "urn:schemas-upnp-org:device:WANConnectionDevice:2"
26 + URN_WANDevice_1 = "urn:schemas-upnp-org:device:WANDevice:1"
27 + URN_WANDevice_2 = "urn:schemas-upnp-org:device:WANDevice:2"
28 +)
29 +
30 +// Service URNs:
31 +const (
32 + URN_LANHostConfigManagement_1 = "urn:schemas-upnp-org:service:LANHostConfigManagement:1"
33 + URN_Layer3Forwarding_1 = "urn:schemas-upnp-org:service:Layer3Forwarding:1"
34 + URN_WANCableLinkConfig_1 = "urn:schemas-upnp-org:service:WANCableLinkConfig:1"
35 + URN_WANCommonInterfaceConfig_1 = "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"
36 + URN_WANDSLLinkConfig_1 = "urn:schemas-upnp-org:service:WANDSLLinkConfig:1"
37 + URN_WANEthernetLinkConfig_1 = "urn:schemas-upnp-org:service:WANEthernetLinkConfig:1"
38 + URN_WANIPConnection_1 = "urn:schemas-upnp-org:service:WANIPConnection:1"
39 + URN_WANIPConnection_2 = "urn:schemas-upnp-org:service:WANIPConnection:2"
40 + URN_WANIPv6FirewallControl_1 = "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1"
41 + URN_WANPOTSLinkConfig_1 = "urn:schemas-upnp-org:service:WANPOTSLinkConfig:1"
42 + URN_WANPPPConnection_1 = "urn:schemas-upnp-org:service:WANPPPConnection:1"
43 +)
44 +
45 +// LANHostConfigManagement1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:LANHostConfigManagement:1". See
46 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
47 +// are provided for informational value.
48 +type LANHostConfigManagement1 struct {
49 + goupnp.ServiceClient
50 +}
51 +
52 +// NewLANHostConfigManagement1Clients discovers instances of the service on the network,
53 +// and returns clients to any that are found. errors will contain an error for
54 +// any devices that replied but which could not be queried, and err will be set
55 +// if the discovery process failed outright.
56 +//
57 +// This is a typical entry calling point into this package.
58 +func NewLANHostConfigManagement1Clients() (clients []*LANHostConfigManagement1, errors []error, err error) {
59 + var genericClients []goupnp.ServiceClient
60 + if genericClients, errors, err = goupnp.NewServiceClients(URN_LANHostConfigManagement_1); err != nil {
61 + return
62 + }
63 + clients = make([]*LANHostConfigManagement1, len(genericClients))
64 + for i := range genericClients {
65 + clients[i] = &LANHostConfigManagement1{genericClients[i]}
66 + }
67 + return
68 +}
69 +
70 +// Arguments:
71 +//
72 +// * NewDHCPServerConfigurable:
73 +//
74 +//
75 +func (client *LANHostConfigManagement1) SetDHCPServerConfigurable(NewDHCPServerConfigurable bool) (err error) {
76 + // Request structure.
77 + request := &struct {
78 + NewDHCPServerConfigurable string
79 + }{}
80 + // BEGIN Marshal arguments into request.
81 +
82 + if request.NewDHCPServerConfigurable, err = soap.MarshalBoolean(NewDHCPServerConfigurable); err != nil {
83 + return
84 + }
85 + // END Marshal arguments into request.
86 +
87 + // Response structure.
88 + response := interface{}(nil)
89 +
90 + // Perform the SOAP call.
91 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetDHCPServerConfigurable", request, response); err != nil {
92 + return
93 + }
94 +
95 + // BEGIN Unmarshal arguments from response.
96 +
97 + // END Unmarshal arguments from response.
98 + return
99 +}
100 +
101 +//
102 +//
103 +// Return values:
104 +//
105 +// * NewDHCPServerConfigurable:
106 +func (client *LANHostConfigManagement1) GetDHCPServerConfigurable() (NewDHCPServerConfigurable bool, err error) {
107 + // Request structure.
108 + request := interface{}(nil)
109 + // BEGIN Marshal arguments into request.
110 +
111 + // END Marshal arguments into request.
112 +
113 + // Response structure.
114 + response := &struct {
115 + NewDHCPServerConfigurable string
116 + }{}
117 +
118 + // Perform the SOAP call.
119 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetDHCPServerConfigurable", request, response); err != nil {
120 + return
121 + }
122 +
123 + // BEGIN Unmarshal arguments from response.
124 +
125 + if NewDHCPServerConfigurable, err = soap.UnmarshalBoolean(response.NewDHCPServerConfigurable); err != nil {
126 + return
127 + }
128 + // END Unmarshal arguments from response.
129 + return
130 +}
131 +
132 +// Arguments:
133 +//
134 +// * NewDHCPRelay:
135 +//
136 +//
137 +func (client *LANHostConfigManagement1) SetDHCPRelay(NewDHCPRelay bool) (err error) {
138 + // Request structure.
139 + request := &struct {
140 + NewDHCPRelay string
141 + }{}
142 + // BEGIN Marshal arguments into request.
143 +
144 + if request.NewDHCPRelay, err = soap.MarshalBoolean(NewDHCPRelay); err != nil {
145 + return
146 + }
147 + // END Marshal arguments into request.
148 +
149 + // Response structure.
150 + response := interface{}(nil)
151 +
152 + // Perform the SOAP call.
153 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetDHCPRelay", request, response); err != nil {
154 + return
155 + }
156 +
157 + // BEGIN Unmarshal arguments from response.
158 +
159 + // END Unmarshal arguments from response.
160 + return
161 +}
162 +
163 +//
164 +//
165 +// Return values:
166 +//
167 +// * NewDHCPRelay:
168 +func (client *LANHostConfigManagement1) GetDHCPRelay() (NewDHCPRelay bool, err error) {
169 + // Request structure.
170 + request := interface{}(nil)
171 + // BEGIN Marshal arguments into request.
172 +
173 + // END Marshal arguments into request.
174 +
175 + // Response structure.
176 + response := &struct {
177 + NewDHCPRelay string
178 + }{}
179 +
180 + // Perform the SOAP call.
181 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetDHCPRelay", request, response); err != nil {
182 + return
183 + }
184 +
185 + // BEGIN Unmarshal arguments from response.
186 +
187 + if NewDHCPRelay, err = soap.UnmarshalBoolean(response.NewDHCPRelay); err != nil {
188 + return
189 + }
190 + // END Unmarshal arguments from response.
191 + return
192 +}
193 +
194 +// Arguments:
195 +//
196 +// * NewSubnetMask:
197 +//
198 +//
199 +func (client *LANHostConfigManagement1) SetSubnetMask(NewSubnetMask string) (err error) {
200 + // Request structure.
201 + request := &struct {
202 + NewSubnetMask string
203 + }{}
204 + // BEGIN Marshal arguments into request.
205 +
206 + if request.NewSubnetMask, err = soap.MarshalString(NewSubnetMask); err != nil {
207 + return
208 + }
209 + // END Marshal arguments into request.
210 +
211 + // Response structure.
212 + response := interface{}(nil)
213 +
214 + // Perform the SOAP call.
215 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetSubnetMask", request, response); err != nil {
216 + return
217 + }
218 +
219 + // BEGIN Unmarshal arguments from response.
220 +
221 + // END Unmarshal arguments from response.
222 + return
223 +}
224 +
225 +//
226 +//
227 +// Return values:
228 +//
229 +// * NewSubnetMask:
230 +func (client *LANHostConfigManagement1) GetSubnetMask() (NewSubnetMask string, err error) {
231 + // Request structure.
232 + request := interface{}(nil)
233 + // BEGIN Marshal arguments into request.
234 +
235 + // END Marshal arguments into request.
236 +
237 + // Response structure.
238 + response := &struct {
239 + NewSubnetMask string
240 + }{}
241 +
242 + // Perform the SOAP call.
243 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetSubnetMask", request, response); err != nil {
244 + return
245 + }
246 +
247 + // BEGIN Unmarshal arguments from response.
248 +
249 + if NewSubnetMask, err = soap.UnmarshalString(response.NewSubnetMask); err != nil {
250 + return
251 + }
252 + // END Unmarshal arguments from response.
253 + return
254 +}
255 +
256 +// Arguments:
257 +//
258 +// * NewIPRouters:
259 +//
260 +//
261 +func (client *LANHostConfigManagement1) SetIPRouter(NewIPRouters string) (err error) {
262 + // Request structure.
263 + request := &struct {
264 + NewIPRouters string
265 + }{}
266 + // BEGIN Marshal arguments into request.
267 +
268 + if request.NewIPRouters, err = soap.MarshalString(NewIPRouters); err != nil {
269 + return
270 + }
271 + // END Marshal arguments into request.
272 +
273 + // Response structure.
274 + response := interface{}(nil)
275 +
276 + // Perform the SOAP call.
277 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetIPRouter", request, response); err != nil {
278 + return
279 + }
280 +
281 + // BEGIN Unmarshal arguments from response.
282 +
283 + // END Unmarshal arguments from response.
284 + return
285 +}
286 +
287 +// Arguments:
288 +//
289 +// * NewIPRouters:
290 +//
291 +//
292 +func (client *LANHostConfigManagement1) DeleteIPRouter(NewIPRouters string) (err error) {
293 + // Request structure.
294 + request := &struct {
295 + NewIPRouters string
296 + }{}
297 + // BEGIN Marshal arguments into request.
298 +
299 + if request.NewIPRouters, err = soap.MarshalString(NewIPRouters); err != nil {
300 + return
301 + }
302 + // END Marshal arguments into request.
303 +
304 + // Response structure.
305 + response := interface{}(nil)
306 +
307 + // Perform the SOAP call.
308 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "DeleteIPRouter", request, response); err != nil {
309 + return
310 + }
311 +
312 + // BEGIN Unmarshal arguments from response.
313 +
314 + // END Unmarshal arguments from response.
315 + return
316 +}
317 +
318 +//
319 +//
320 +// Return values:
321 +//
322 +// * NewIPRouters:
323 +func (client *LANHostConfigManagement1) GetIPRoutersList() (NewIPRouters string, err error) {
324 + // Request structure.
325 + request := interface{}(nil)
326 + // BEGIN Marshal arguments into request.
327 +
328 + // END Marshal arguments into request.
329 +
330 + // Response structure.
331 + response := &struct {
332 + NewIPRouters string
333 + }{}
334 +
335 + // Perform the SOAP call.
336 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetIPRoutersList", request, response); err != nil {
337 + return
338 + }
339 +
340 + // BEGIN Unmarshal arguments from response.
341 +
342 + if NewIPRouters, err = soap.UnmarshalString(response.NewIPRouters); err != nil {
343 + return
344 + }
345 + // END Unmarshal arguments from response.
346 + return
347 +}
348 +
349 +// Arguments:
350 +//
351 +// * NewDomainName:
352 +//
353 +//
354 +func (client *LANHostConfigManagement1) SetDomainName(NewDomainName string) (err error) {
355 + // Request structure.
356 + request := &struct {
357 + NewDomainName string
358 + }{}
359 + // BEGIN Marshal arguments into request.
360 +
361 + if request.NewDomainName, err = soap.MarshalString(NewDomainName); err != nil {
362 + return
363 + }
364 + // END Marshal arguments into request.
365 +
366 + // Response structure.
367 + response := interface{}(nil)
368 +
369 + // Perform the SOAP call.
370 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetDomainName", request, response); err != nil {
371 + return
372 + }
373 +
374 + // BEGIN Unmarshal arguments from response.
375 +
376 + // END Unmarshal arguments from response.
377 + return
378 +}
379 +
380 +//
381 +//
382 +// Return values:
383 +//
384 +// * NewDomainName:
385 +func (client *LANHostConfigManagement1) GetDomainName() (NewDomainName string, err error) {
386 + // Request structure.
387 + request := interface{}(nil)
388 + // BEGIN Marshal arguments into request.
389 +
390 + // END Marshal arguments into request.
391 +
392 + // Response structure.
393 + response := &struct {
394 + NewDomainName string
395 + }{}
396 +
397 + // Perform the SOAP call.
398 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetDomainName", request, response); err != nil {
399 + return
400 + }
401 +
402 + // BEGIN Unmarshal arguments from response.
403 +
404 + if NewDomainName, err = soap.UnmarshalString(response.NewDomainName); err != nil {
405 + return
406 + }
407 + // END Unmarshal arguments from response.
408 + return
409 +}
410 +
411 +// Arguments:
412 +//
413 +// * NewMinAddress:
414 +//
415 +// * NewMaxAddress:
416 +//
417 +//
418 +func (client *LANHostConfigManagement1) SetAddressRange(NewMinAddress string, NewMaxAddress string) (err error) {
419 + // Request structure.
420 + request := &struct {
421 + NewMinAddress string
422 +
423 + NewMaxAddress string
424 + }{}
425 + // BEGIN Marshal arguments into request.
426 +
427 + if request.NewMinAddress, err = soap.MarshalString(NewMinAddress); err != nil {
428 + return
429 + }
430 + if request.NewMaxAddress, err = soap.MarshalString(NewMaxAddress); err != nil {
431 + return
432 + }
433 + // END Marshal arguments into request.
434 +
435 + // Response structure.
436 + response := interface{}(nil)
437 +
438 + // Perform the SOAP call.
439 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetAddressRange", request, response); err != nil {
440 + return
441 + }
442 +
443 + // BEGIN Unmarshal arguments from response.
444 +
445 + // END Unmarshal arguments from response.
446 + return
447 +}
448 +
449 +//
450 +//
451 +// Return values:
452 +//
453 +// * NewMinAddress:
454 +//
455 +// * NewMaxAddress:
456 +func (client *LANHostConfigManagement1) GetAddressRange() (NewMinAddress string, NewMaxAddress string, err error) {
457 + // Request structure.
458 + request := interface{}(nil)
459 + // BEGIN Marshal arguments into request.
460 +
461 + // END Marshal arguments into request.
462 +
463 + // Response structure.
464 + response := &struct {
465 + NewMinAddress string
466 +
467 + NewMaxAddress string
468 + }{}
469 +
470 + // Perform the SOAP call.
471 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetAddressRange", request, response); err != nil {
472 + return
473 + }
474 +
475 + // BEGIN Unmarshal arguments from response.
476 +
477 + if NewMinAddress, err = soap.UnmarshalString(response.NewMinAddress); err != nil {
478 + return
479 + }
480 + if NewMaxAddress, err = soap.UnmarshalString(response.NewMaxAddress); err != nil {
481 + return
482 + }
483 + // END Unmarshal arguments from response.
484 + return
485 +}
486 +
487 +// Arguments:
488 +//
489 +// * NewReservedAddresses:
490 +//
491 +//
492 +func (client *LANHostConfigManagement1) SetReservedAddress(NewReservedAddresses string) (err error) {
493 + // Request structure.
494 + request := &struct {
495 + NewReservedAddresses string
496 + }{}
497 + // BEGIN Marshal arguments into request.
498 +
499 + if request.NewReservedAddresses, err = soap.MarshalString(NewReservedAddresses); err != nil {
500 + return
501 + }
502 + // END Marshal arguments into request.
503 +
504 + // Response structure.
505 + response := interface{}(nil)
506 +
507 + // Perform the SOAP call.
508 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetReservedAddress", request, response); err != nil {
509 + return
510 + }
511 +
512 + // BEGIN Unmarshal arguments from response.
513 +
514 + // END Unmarshal arguments from response.
515 + return
516 +}
517 +
518 +// Arguments:
519 +//
520 +// * NewReservedAddresses:
521 +//
522 +//
523 +func (client *LANHostConfigManagement1) DeleteReservedAddress(NewReservedAddresses string) (err error) {
524 + // Request structure.
525 + request := &struct {
526 + NewReservedAddresses string
527 + }{}
528 + // BEGIN Marshal arguments into request.
529 +
530 + if request.NewReservedAddresses, err = soap.MarshalString(NewReservedAddresses); err != nil {
531 + return
532 + }
533 + // END Marshal arguments into request.
534 +
535 + // Response structure.
536 + response := interface{}(nil)
537 +
538 + // Perform the SOAP call.
539 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "DeleteReservedAddress", request, response); err != nil {
540 + return
541 + }
542 +
543 + // BEGIN Unmarshal arguments from response.
544 +
545 + // END Unmarshal arguments from response.
546 + return
547 +}
548 +
549 +//
550 +//
551 +// Return values:
552 +//
553 +// * NewReservedAddresses:
554 +func (client *LANHostConfigManagement1) GetReservedAddresses() (NewReservedAddresses string, err error) {
555 + // Request structure.
556 + request := interface{}(nil)
557 + // BEGIN Marshal arguments into request.
558 +
559 + // END Marshal arguments into request.
560 +
561 + // Response structure.
562 + response := &struct {
563 + NewReservedAddresses string
564 + }{}
565 +
566 + // Perform the SOAP call.
567 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetReservedAddresses", request, response); err != nil {
568 + return
569 + }
570 +
571 + // BEGIN Unmarshal arguments from response.
572 +
573 + if NewReservedAddresses, err = soap.UnmarshalString(response.NewReservedAddresses); err != nil {
574 + return
575 + }
576 + // END Unmarshal arguments from response.
577 + return
578 +}
579 +
580 +// Arguments:
581 +//
582 +// * NewDNSServers:
583 +//
584 +//
585 +func (client *LANHostConfigManagement1) SetDNSServer(NewDNSServers string) (err error) {
586 + // Request structure.
587 + request := &struct {
588 + NewDNSServers string
589 + }{}
590 + // BEGIN Marshal arguments into request.
591 +
592 + if request.NewDNSServers, err = soap.MarshalString(NewDNSServers); err != nil {
593 + return
594 + }
595 + // END Marshal arguments into request.
596 +
597 + // Response structure.
598 + response := interface{}(nil)
599 +
600 + // Perform the SOAP call.
601 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "SetDNSServer", request, response); err != nil {
602 + return
603 + }
604 +
605 + // BEGIN Unmarshal arguments from response.
606 +
607 + // END Unmarshal arguments from response.
608 + return
609 +}
610 +
611 +// Arguments:
612 +//
613 +// * NewDNSServers:
614 +//
615 +//
616 +func (client *LANHostConfigManagement1) DeleteDNSServer(NewDNSServers string) (err error) {
617 + // Request structure.
618 + request := &struct {
619 + NewDNSServers string
620 + }{}
621 + // BEGIN Marshal arguments into request.
622 +
623 + if request.NewDNSServers, err = soap.MarshalString(NewDNSServers); err != nil {
624 + return
625 + }
626 + // END Marshal arguments into request.
627 +
628 + // Response structure.
629 + response := interface{}(nil)
630 +
631 + // Perform the SOAP call.
632 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "DeleteDNSServer", request, response); err != nil {
633 + return
634 + }
635 +
636 + // BEGIN Unmarshal arguments from response.
637 +
638 + // END Unmarshal arguments from response.
639 + return
640 +}
641 +
642 +//
643 +//
644 +// Return values:
645 +//
646 +// * NewDNSServers:
647 +func (client *LANHostConfigManagement1) GetDNSServers() (NewDNSServers string, err error) {
648 + // Request structure.
649 + request := interface{}(nil)
650 + // BEGIN Marshal arguments into request.
651 +
652 + // END Marshal arguments into request.
653 +
654 + // Response structure.
655 + response := &struct {
656 + NewDNSServers string
657 + }{}
658 +
659 + // Perform the SOAP call.
660 + if err = client.SOAPClient.PerformAction(URN_LANHostConfigManagement_1, "GetDNSServers", request, response); err != nil {
661 + return
662 + }
663 +
664 + // BEGIN Unmarshal arguments from response.
665 +
666 + if NewDNSServers, err = soap.UnmarshalString(response.NewDNSServers); err != nil {
667 + return
668 + }
669 + // END Unmarshal arguments from response.
670 + return
671 +}
672 +
673 +// Layer3Forwarding1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:Layer3Forwarding:1". See
674 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
675 +// are provided for informational value.
676 +type Layer3Forwarding1 struct {
677 + goupnp.ServiceClient
678 +}
679 +
680 +// NewLayer3Forwarding1Clients discovers instances of the service on the network,
681 +// and returns clients to any that are found. errors will contain an error for
682 +// any devices that replied but which could not be queried, and err will be set
683 +// if the discovery process failed outright.
684 +//
685 +// This is a typical entry calling point into this package.
686 +func NewLayer3Forwarding1Clients() (clients []*Layer3Forwarding1, errors []error, err error) {
687 + var genericClients []goupnp.ServiceClient
688 + if genericClients, errors, err = goupnp.NewServiceClients(URN_Layer3Forwarding_1); err != nil {
689 + return
690 + }
691 + clients = make([]*Layer3Forwarding1, len(genericClients))
692 + for i := range genericClients {
693 + clients[i] = &Layer3Forwarding1{genericClients[i]}
694 + }
695 + return
696 +}
697 +
698 +// Arguments:
699 +//
700 +// * NewDefaultConnectionService:
701 +//
702 +//
703 +func (client *Layer3Forwarding1) SetDefaultConnectionService(NewDefaultConnectionService string) (err error) {
704 + // Request structure.
705 + request := &struct {
706 + NewDefaultConnectionService string
707 + }{}
708 + // BEGIN Marshal arguments into request.
709 +
710 + if request.NewDefaultConnectionService, err = soap.MarshalString(NewDefaultConnectionService); err != nil {
711 + return
712 + }
713 + // END Marshal arguments into request.
714 +
715 + // Response structure.
716 + response := interface{}(nil)
717 +
718 + // Perform the SOAP call.
719 + if err = client.SOAPClient.PerformAction(URN_Layer3Forwarding_1, "SetDefaultConnectionService", request, response); err != nil {
720 + return
721 + }
722 +
723 + // BEGIN Unmarshal arguments from response.
724 +
725 + // END Unmarshal arguments from response.
726 + return
727 +}
728 +
729 +//
730 +//
731 +// Return values:
732 +//
733 +// * NewDefaultConnectionService:
734 +func (client *Layer3Forwarding1) GetDefaultConnectionService() (NewDefaultConnectionService string, err error) {
735 + // Request structure.
736 + request := interface{}(nil)
737 + // BEGIN Marshal arguments into request.
738 +
739 + // END Marshal arguments into request.
740 +
741 + // Response structure.
742 + response := &struct {
743 + NewDefaultConnectionService string
744 + }{}
745 +
746 + // Perform the SOAP call.
747 + if err = client.SOAPClient.PerformAction(URN_Layer3Forwarding_1, "GetDefaultConnectionService", request, response); err != nil {
748 + return
749 + }
750 +
751 + // BEGIN Unmarshal arguments from response.
752 +
753 + if NewDefaultConnectionService, err = soap.UnmarshalString(response.NewDefaultConnectionService); err != nil {
754 + return
755 + }
756 + // END Unmarshal arguments from response.
757 + return
758 +}
759 +
760 +// WANCableLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANCableLinkConfig:1". See
761 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
762 +// are provided for informational value.
763 +type WANCableLinkConfig1 struct {
764 + goupnp.ServiceClient
765 +}
766 +
767 +// NewWANCableLinkConfig1Clients discovers instances of the service on the network,
768 +// and returns clients to any that are found. errors will contain an error for
769 +// any devices that replied but which could not be queried, and err will be set
770 +// if the discovery process failed outright.
771 +//
772 +// This is a typical entry calling point into this package.
773 +func NewWANCableLinkConfig1Clients() (clients []*WANCableLinkConfig1, errors []error, err error) {
774 + var genericClients []goupnp.ServiceClient
775 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANCableLinkConfig_1); err != nil {
776 + return
777 + }
778 + clients = make([]*WANCableLinkConfig1, len(genericClients))
779 + for i := range genericClients {
780 + clients[i] = &WANCableLinkConfig1{genericClients[i]}
781 + }
782 + return
783 +}
784 +
785 +//
786 +//
787 +// Return values:
788 +//
789 +// * NewCableLinkConfigState: allowed values: notReady, dsSyncComplete, usParamAcquired, rangingComplete, ipComplete, todEstablished, paramTransferComplete, registrationComplete, operational, accessDenied
790 +//
791 +// * NewLinkType: allowed values: Ethernet
792 +func (client *WANCableLinkConfig1) GetCableLinkConfigInfo() (NewCableLinkConfigState string, NewLinkType string, err error) {
793 + // Request structure.
794 + request := interface{}(nil)
795 + // BEGIN Marshal arguments into request.
796 +
797 + // END Marshal arguments into request.
798 +
799 + // Response structure.
800 + response := &struct {
801 + NewCableLinkConfigState string
802 +
803 + NewLinkType string
804 + }{}
805 +
806 + // Perform the SOAP call.
807 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetCableLinkConfigInfo", request, response); err != nil {
808 + return
809 + }
810 +
811 + // BEGIN Unmarshal arguments from response.
812 +
813 + if NewCableLinkConfigState, err = soap.UnmarshalString(response.NewCableLinkConfigState); err != nil {
814 + return
815 + }
816 + if NewLinkType, err = soap.UnmarshalString(response.NewLinkType); err != nil {
817 + return
818 + }
819 + // END Unmarshal arguments from response.
820 + return
821 +}
822 +
823 +//
824 +//
825 +// Return values:
826 +//
827 +// * NewDownstreamFrequency:
828 +func (client *WANCableLinkConfig1) GetDownstreamFrequency() (NewDownstreamFrequency uint32, err error) {
829 + // Request structure.
830 + request := interface{}(nil)
831 + // BEGIN Marshal arguments into request.
832 +
833 + // END Marshal arguments into request.
834 +
835 + // Response structure.
836 + response := &struct {
837 + NewDownstreamFrequency string
838 + }{}
839 +
840 + // Perform the SOAP call.
841 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetDownstreamFrequency", request, response); err != nil {
842 + return
843 + }
844 +
845 + // BEGIN Unmarshal arguments from response.
846 +
847 + if NewDownstreamFrequency, err = soap.UnmarshalUi4(response.NewDownstreamFrequency); err != nil {
848 + return
849 + }
850 + // END Unmarshal arguments from response.
851 + return
852 +}
853 +
854 +//
855 +//
856 +// Return values:
857 +//
858 +// * NewDownstreamModulation: allowed values: 64QAM, 256QAM
859 +func (client *WANCableLinkConfig1) GetDownstreamModulation() (NewDownstreamModulation string, err error) {
860 + // Request structure.
861 + request := interface{}(nil)
862 + // BEGIN Marshal arguments into request.
863 +
864 + // END Marshal arguments into request.
865 +
866 + // Response structure.
867 + response := &struct {
868 + NewDownstreamModulation string
869 + }{}
870 +
871 + // Perform the SOAP call.
872 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetDownstreamModulation", request, response); err != nil {
873 + return
874 + }
875 +
876 + // BEGIN Unmarshal arguments from response.
877 +
878 + if NewDownstreamModulation, err = soap.UnmarshalString(response.NewDownstreamModulation); err != nil {
879 + return
880 + }
881 + // END Unmarshal arguments from response.
882 + return
883 +}
884 +
885 +//
886 +//
887 +// Return values:
888 +//
889 +// * NewUpstreamFrequency:
890 +func (client *WANCableLinkConfig1) GetUpstreamFrequency() (NewUpstreamFrequency uint32, err error) {
891 + // Request structure.
892 + request := interface{}(nil)
893 + // BEGIN Marshal arguments into request.
894 +
895 + // END Marshal arguments into request.
896 +
897 + // Response structure.
898 + response := &struct {
899 + NewUpstreamFrequency string
900 + }{}
901 +
902 + // Perform the SOAP call.
903 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetUpstreamFrequency", request, response); err != nil {
904 + return
905 + }
906 +
907 + // BEGIN Unmarshal arguments from response.
908 +
909 + if NewUpstreamFrequency, err = soap.UnmarshalUi4(response.NewUpstreamFrequency); err != nil {
910 + return
911 + }
912 + // END Unmarshal arguments from response.
913 + return
914 +}
915 +
916 +//
917 +//
918 +// Return values:
919 +//
920 +// * NewUpstreamModulation: allowed values: QPSK, 16QAM
921 +func (client *WANCableLinkConfig1) GetUpstreamModulation() (NewUpstreamModulation string, err error) {
922 + // Request structure.
923 + request := interface{}(nil)
924 + // BEGIN Marshal arguments into request.
925 +
926 + // END Marshal arguments into request.
927 +
928 + // Response structure.
929 + response := &struct {
930 + NewUpstreamModulation string
931 + }{}
932 +
933 + // Perform the SOAP call.
934 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetUpstreamModulation", request, response); err != nil {
935 + return
936 + }
937 +
938 + // BEGIN Unmarshal arguments from response.
939 +
940 + if NewUpstreamModulation, err = soap.UnmarshalString(response.NewUpstreamModulation); err != nil {
941 + return
942 + }
943 + // END Unmarshal arguments from response.
944 + return
945 +}
946 +
947 +//
948 +//
949 +// Return values:
950 +//
951 +// * NewUpstreamChannelID:
952 +func (client *WANCableLinkConfig1) GetUpstreamChannelID() (NewUpstreamChannelID uint32, err error) {
953 + // Request structure.
954 + request := interface{}(nil)
955 + // BEGIN Marshal arguments into request.
956 +
957 + // END Marshal arguments into request.
958 +
959 + // Response structure.
960 + response := &struct {
961 + NewUpstreamChannelID string
962 + }{}
963 +
964 + // Perform the SOAP call.
965 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetUpstreamChannelID", request, response); err != nil {
966 + return
967 + }
968 +
969 + // BEGIN Unmarshal arguments from response.
970 +
971 + if NewUpstreamChannelID, err = soap.UnmarshalUi4(response.NewUpstreamChannelID); err != nil {
972 + return
973 + }
974 + // END Unmarshal arguments from response.
975 + return
976 +}
977 +
978 +//
979 +//
980 +// Return values:
981 +//
982 +// * NewUpstreamPowerLevel:
983 +func (client *WANCableLinkConfig1) GetUpstreamPowerLevel() (NewUpstreamPowerLevel uint32, err error) {
984 + // Request structure.
985 + request := interface{}(nil)
986 + // BEGIN Marshal arguments into request.
987 +
988 + // END Marshal arguments into request.
989 +
990 + // Response structure.
991 + response := &struct {
992 + NewUpstreamPowerLevel string
993 + }{}
994 +
995 + // Perform the SOAP call.
996 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetUpstreamPowerLevel", request, response); err != nil {
997 + return
998 + }
999 +
1000 + // BEGIN Unmarshal arguments from response.
1001 +
1002 + if NewUpstreamPowerLevel, err = soap.UnmarshalUi4(response.NewUpstreamPowerLevel); err != nil {
1003 + return
1004 + }
1005 + // END Unmarshal arguments from response.
1006 + return
1007 +}
1008 +
1009 +//
1010 +//
1011 +// Return values:
1012 +//
1013 +// * NewBPIEncryptionEnabled:
1014 +func (client *WANCableLinkConfig1) GetBPIEncryptionEnabled() (NewBPIEncryptionEnabled bool, err error) {
1015 + // Request structure.
1016 + request := interface{}(nil)
1017 + // BEGIN Marshal arguments into request.
1018 +
1019 + // END Marshal arguments into request.
1020 +
1021 + // Response structure.
1022 + response := &struct {
1023 + NewBPIEncryptionEnabled string
1024 + }{}
1025 +
1026 + // Perform the SOAP call.
1027 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetBPIEncryptionEnabled", request, response); err != nil {
1028 + return
1029 + }
1030 +
1031 + // BEGIN Unmarshal arguments from response.
1032 +
1033 + if NewBPIEncryptionEnabled, err = soap.UnmarshalBoolean(response.NewBPIEncryptionEnabled); err != nil {
1034 + return
1035 + }
1036 + // END Unmarshal arguments from response.
1037 + return
1038 +}
1039 +
1040 +//
1041 +//
1042 +// Return values:
1043 +//
1044 +// * NewConfigFile:
1045 +func (client *WANCableLinkConfig1) GetConfigFile() (NewConfigFile string, err error) {
1046 + // Request structure.
1047 + request := interface{}(nil)
1048 + // BEGIN Marshal arguments into request.
1049 +
1050 + // END Marshal arguments into request.
1051 +
1052 + // Response structure.
1053 + response := &struct {
1054 + NewConfigFile string
1055 + }{}
1056 +
1057 + // Perform the SOAP call.
1058 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetConfigFile", request, response); err != nil {
1059 + return
1060 + }
1061 +
1062 + // BEGIN Unmarshal arguments from response.
1063 +
1064 + if NewConfigFile, err = soap.UnmarshalString(response.NewConfigFile); err != nil {
1065 + return
1066 + }
1067 + // END Unmarshal arguments from response.
1068 + return
1069 +}
1070 +
1071 +//
1072 +//
1073 +// Return values:
1074 +//
1075 +// * NewTFTPServer:
1076 +func (client *WANCableLinkConfig1) GetTFTPServer() (NewTFTPServer string, err error) {
1077 + // Request structure.
1078 + request := interface{}(nil)
1079 + // BEGIN Marshal arguments into request.
1080 +
1081 + // END Marshal arguments into request.
1082 +
1083 + // Response structure.
1084 + response := &struct {
1085 + NewTFTPServer string
1086 + }{}
1087 +
1088 + // Perform the SOAP call.
1089 + if err = client.SOAPClient.PerformAction(URN_WANCableLinkConfig_1, "GetTFTPServer", request, response); err != nil {
1090 + return
1091 + }
1092 +
1093 + // BEGIN Unmarshal arguments from response.
1094 +
1095 + if NewTFTPServer, err = soap.UnmarshalString(response.NewTFTPServer); err != nil {
1096 + return
1097 + }
1098 + // END Unmarshal arguments from response.
1099 + return
1100 +}
1101 +
1102 +// WANCommonInterfaceConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1". See
1103 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
1104 +// are provided for informational value.
1105 +type WANCommonInterfaceConfig1 struct {
1106 + goupnp.ServiceClient
1107 +}
1108 +
1109 +// NewWANCommonInterfaceConfig1Clients discovers instances of the service on the network,
1110 +// and returns clients to any that are found. errors will contain an error for
1111 +// any devices that replied but which could not be queried, and err will be set
1112 +// if the discovery process failed outright.
1113 +//
1114 +// This is a typical entry calling point into this package.
1115 +func NewWANCommonInterfaceConfig1Clients() (clients []*WANCommonInterfaceConfig1, errors []error, err error) {
1116 + var genericClients []goupnp.ServiceClient
1117 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANCommonInterfaceConfig_1); err != nil {
1118 + return
1119 + }
1120 + clients = make([]*WANCommonInterfaceConfig1, len(genericClients))
1121 + for i := range genericClients {
1122 + clients[i] = &WANCommonInterfaceConfig1{genericClients[i]}
1123 + }
1124 + return
1125 +}
1126 +
1127 +// Arguments:
1128 +//
1129 +// * NewEnabledForInternet:
1130 +//
1131 +//
1132 +func (client *WANCommonInterfaceConfig1) SetEnabledForInternet(NewEnabledForInternet bool) (err error) {
1133 + // Request structure.
1134 + request := &struct {
1135 + NewEnabledForInternet string
1136 + }{}
1137 + // BEGIN Marshal arguments into request.
1138 +
1139 + if request.NewEnabledForInternet, err = soap.MarshalBoolean(NewEnabledForInternet); err != nil {
1140 + return
1141 + }
1142 + // END Marshal arguments into request.
1143 +
1144 + // Response structure.
1145 + response := interface{}(nil)
1146 +
1147 + // Perform the SOAP call.
1148 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "SetEnabledForInternet", request, response); err != nil {
1149 + return
1150 + }
1151 +
1152 + // BEGIN Unmarshal arguments from response.
1153 +
1154 + // END Unmarshal arguments from response.
1155 + return
1156 +}
1157 +
1158 +//
1159 +//
1160 +// Return values:
1161 +//
1162 +// * NewEnabledForInternet:
1163 +func (client *WANCommonInterfaceConfig1) GetEnabledForInternet() (NewEnabledForInternet bool, err error) {
1164 + // Request structure.
1165 + request := interface{}(nil)
1166 + // BEGIN Marshal arguments into request.
1167 +
1168 + // END Marshal arguments into request.
1169 +
1170 + // Response structure.
1171 + response := &struct {
1172 + NewEnabledForInternet string
1173 + }{}
1174 +
1175 + // Perform the SOAP call.
1176 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetEnabledForInternet", request, response); err != nil {
1177 + return
1178 + }
1179 +
1180 + // BEGIN Unmarshal arguments from response.
1181 +
1182 + if NewEnabledForInternet, err = soap.UnmarshalBoolean(response.NewEnabledForInternet); err != nil {
1183 + return
1184 + }
1185 + // END Unmarshal arguments from response.
1186 + return
1187 +}
1188 +
1189 +//
1190 +//
1191 +// Return values:
1192 +//
1193 +// * NewWANAccessType: allowed values: DSL, POTS, Cable, Ethernet
1194 +//
1195 +// * NewLayer1UpstreamMaxBitRate:
1196 +//
1197 +// * NewLayer1DownstreamMaxBitRate:
1198 +//
1199 +// * NewPhysicalLinkStatus: allowed values: Up, Down
1200 +func (client *WANCommonInterfaceConfig1) GetCommonLinkProperties() (NewWANAccessType string, NewLayer1UpstreamMaxBitRate uint32, NewLayer1DownstreamMaxBitRate uint32, NewPhysicalLinkStatus string, err error) {
1201 + // Request structure.
1202 + request := interface{}(nil)
1203 + // BEGIN Marshal arguments into request.
1204 +
1205 + // END Marshal arguments into request.
1206 +
1207 + // Response structure.
1208 + response := &struct {
1209 + NewWANAccessType string
1210 +
1211 + NewLayer1UpstreamMaxBitRate string
1212 +
1213 + NewLayer1DownstreamMaxBitRate string
1214 +
1215 + NewPhysicalLinkStatus string
1216 + }{}
1217 +
1218 + // Perform the SOAP call.
1219 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetCommonLinkProperties", request, response); err != nil {
1220 + return
1221 + }
1222 +
1223 + // BEGIN Unmarshal arguments from response.
1224 +
1225 + if NewWANAccessType, err = soap.UnmarshalString(response.NewWANAccessType); err != nil {
1226 + return
1227 + }
1228 + if NewLayer1UpstreamMaxBitRate, err = soap.UnmarshalUi4(response.NewLayer1UpstreamMaxBitRate); err != nil {
1229 + return
1230 + }
1231 + if NewLayer1DownstreamMaxBitRate, err = soap.UnmarshalUi4(response.NewLayer1DownstreamMaxBitRate); err != nil {
1232 + return
1233 + }
1234 + if NewPhysicalLinkStatus, err = soap.UnmarshalString(response.NewPhysicalLinkStatus); err != nil {
1235 + return
1236 + }
1237 + // END Unmarshal arguments from response.
1238 + return
1239 +}
1240 +
1241 +//
1242 +//
1243 +// Return values:
1244 +//
1245 +// * NewWANAccessProvider:
1246 +func (client *WANCommonInterfaceConfig1) GetWANAccessProvider() (NewWANAccessProvider string, err error) {
1247 + // Request structure.
1248 + request := interface{}(nil)
1249 + // BEGIN Marshal arguments into request.
1250 +
1251 + // END Marshal arguments into request.
1252 +
1253 + // Response structure.
1254 + response := &struct {
1255 + NewWANAccessProvider string
1256 + }{}
1257 +
1258 + // Perform the SOAP call.
1259 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetWANAccessProvider", request, response); err != nil {
1260 + return
1261 + }
1262 +
1263 + // BEGIN Unmarshal arguments from response.
1264 +
1265 + if NewWANAccessProvider, err = soap.UnmarshalString(response.NewWANAccessProvider); err != nil {
1266 + return
1267 + }
1268 + // END Unmarshal arguments from response.
1269 + return
1270 +}
1271 +
1272 +//
1273 +//
1274 +// Return values:
1275 +//
1276 +// * NewMaximumActiveConnections: allowed value range: minimum=1, step=1
1277 +func (client *WANCommonInterfaceConfig1) GetMaximumActiveConnections() (NewMaximumActiveConnections uint16, err error) {
1278 + // Request structure.
1279 + request := interface{}(nil)
1280 + // BEGIN Marshal arguments into request.
1281 +
1282 + // END Marshal arguments into request.
1283 +
1284 + // Response structure.
1285 + response := &struct {
1286 + NewMaximumActiveConnections string
1287 + }{}
1288 +
1289 + // Perform the SOAP call.
1290 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetMaximumActiveConnections", request, response); err != nil {
1291 + return
1292 + }
1293 +
1294 + // BEGIN Unmarshal arguments from response.
1295 +
1296 + if NewMaximumActiveConnections, err = soap.UnmarshalUi2(response.NewMaximumActiveConnections); err != nil {
1297 + return
1298 + }
1299 + // END Unmarshal arguments from response.
1300 + return
1301 +}
1302 +
1303 +//
1304 +//
1305 +// Return values:
1306 +//
1307 +// * NewTotalBytesSent:
1308 +func (client *WANCommonInterfaceConfig1) GetTotalBytesSent() (NewTotalBytesSent uint32, err error) {
1309 + // Request structure.
1310 + request := interface{}(nil)
1311 + // BEGIN Marshal arguments into request.
1312 +
1313 + // END Marshal arguments into request.
1314 +
1315 + // Response structure.
1316 + response := &struct {
1317 + NewTotalBytesSent string
1318 + }{}
1319 +
1320 + // Perform the SOAP call.
1321 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetTotalBytesSent", request, response); err != nil {
1322 + return
1323 + }
1324 +
1325 + // BEGIN Unmarshal arguments from response.
1326 +
1327 + if NewTotalBytesSent, err = soap.UnmarshalUi4(response.NewTotalBytesSent); err != nil {
1328 + return
1329 + }
1330 + // END Unmarshal arguments from response.
1331 + return
1332 +}
1333 +
1334 +//
1335 +//
1336 +// Return values:
1337 +//
1338 +// * NewTotalBytesReceived:
1339 +func (client *WANCommonInterfaceConfig1) GetTotalBytesReceived() (NewTotalBytesReceived uint32, err error) {
1340 + // Request structure.
1341 + request := interface{}(nil)
1342 + // BEGIN Marshal arguments into request.
1343 +
1344 + // END Marshal arguments into request.
1345 +
1346 + // Response structure.
1347 + response := &struct {
1348 + NewTotalBytesReceived string
1349 + }{}
1350 +
1351 + // Perform the SOAP call.
1352 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetTotalBytesReceived", request, response); err != nil {
1353 + return
1354 + }
1355 +
1356 + // BEGIN Unmarshal arguments from response.
1357 +
1358 + if NewTotalBytesReceived, err = soap.UnmarshalUi4(response.NewTotalBytesReceived); err != nil {
1359 + return
1360 + }
1361 + // END Unmarshal arguments from response.
1362 + return
1363 +}
1364 +
1365 +//
1366 +//
1367 +// Return values:
1368 +//
1369 +// * NewTotalPacketsSent:
1370 +func (client *WANCommonInterfaceConfig1) GetTotalPacketsSent() (NewTotalPacketsSent uint32, err error) {
1371 + // Request structure.
1372 + request := interface{}(nil)
1373 + // BEGIN Marshal arguments into request.
1374 +
1375 + // END Marshal arguments into request.
1376 +
1377 + // Response structure.
1378 + response := &struct {
1379 + NewTotalPacketsSent string
1380 + }{}
1381 +
1382 + // Perform the SOAP call.
1383 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetTotalPacketsSent", request, response); err != nil {
1384 + return
1385 + }
1386 +
1387 + // BEGIN Unmarshal arguments from response.
1388 +
1389 + if NewTotalPacketsSent, err = soap.UnmarshalUi4(response.NewTotalPacketsSent); err != nil {
1390 + return
1391 + }
1392 + // END Unmarshal arguments from response.
1393 + return
1394 +}
1395 +
1396 +//
1397 +//
1398 +// Return values:
1399 +//
1400 +// * NewTotalPacketsReceived:
1401 +func (client *WANCommonInterfaceConfig1) GetTotalPacketsReceived() (NewTotalPacketsReceived uint32, err error) {
1402 + // Request structure.
1403 + request := interface{}(nil)
1404 + // BEGIN Marshal arguments into request.
1405 +
1406 + // END Marshal arguments into request.
1407 +
1408 + // Response structure.
1409 + response := &struct {
1410 + NewTotalPacketsReceived string
1411 + }{}
1412 +
1413 + // Perform the SOAP call.
1414 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetTotalPacketsReceived", request, response); err != nil {
1415 + return
1416 + }
1417 +
1418 + // BEGIN Unmarshal arguments from response.
1419 +
1420 + if NewTotalPacketsReceived, err = soap.UnmarshalUi4(response.NewTotalPacketsReceived); err != nil {
1421 + return
1422 + }
1423 + // END Unmarshal arguments from response.
1424 + return
1425 +}
1426 +
1427 +// Arguments:
1428 +//
1429 +// * NewActiveConnectionIndex:
1430 +//
1431 +// Return values:
1432 +//
1433 +// * NewActiveConnDeviceContainer:
1434 +//
1435 +// * NewActiveConnectionServiceID:
1436 +func (client *WANCommonInterfaceConfig1) GetActiveConnection(NewActiveConnectionIndex uint16) (NewActiveConnDeviceContainer string, NewActiveConnectionServiceID string, err error) {
1437 + // Request structure.
1438 + request := &struct {
1439 + NewActiveConnectionIndex string
1440 + }{}
1441 + // BEGIN Marshal arguments into request.
1442 +
1443 + if request.NewActiveConnectionIndex, err = soap.MarshalUi2(NewActiveConnectionIndex); err != nil {
1444 + return
1445 + }
1446 + // END Marshal arguments into request.
1447 +
1448 + // Response structure.
1449 + response := &struct {
1450 + NewActiveConnDeviceContainer string
1451 +
1452 + NewActiveConnectionServiceID string
1453 + }{}
1454 +
1455 + // Perform the SOAP call.
1456 + if err = client.SOAPClient.PerformAction(URN_WANCommonInterfaceConfig_1, "GetActiveConnection", request, response); err != nil {
1457 + return
1458 + }
1459 +
1460 + // BEGIN Unmarshal arguments from response.
1461 +
1462 + if NewActiveConnDeviceContainer, err = soap.UnmarshalString(response.NewActiveConnDeviceContainer); err != nil {
1463 + return
1464 + }
1465 + if NewActiveConnectionServiceID, err = soap.UnmarshalString(response.NewActiveConnectionServiceID); err != nil {
1466 + return
1467 + }
1468 + // END Unmarshal arguments from response.
1469 + return
1470 +}
1471 +
1472 +// WANDSLLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANDSLLinkConfig:1". See
1473 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
1474 +// are provided for informational value.
1475 +type WANDSLLinkConfig1 struct {
1476 + goupnp.ServiceClient
1477 +}
1478 +
1479 +// NewWANDSLLinkConfig1Clients discovers instances of the service on the network,
1480 +// and returns clients to any that are found. errors will contain an error for
1481 +// any devices that replied but which could not be queried, and err will be set
1482 +// if the discovery process failed outright.
1483 +//
1484 +// This is a typical entry calling point into this package.
1485 +func NewWANDSLLinkConfig1Clients() (clients []*WANDSLLinkConfig1, errors []error, err error) {
1486 + var genericClients []goupnp.ServiceClient
1487 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANDSLLinkConfig_1); err != nil {
1488 + return
1489 + }
1490 + clients = make([]*WANDSLLinkConfig1, len(genericClients))
1491 + for i := range genericClients {
1492 + clients[i] = &WANDSLLinkConfig1{genericClients[i]}
1493 + }
1494 + return
1495 +}
1496 +
1497 +// Arguments:
1498 +//
1499 +// * NewLinkType:
1500 +//
1501 +//
1502 +func (client *WANDSLLinkConfig1) SetDSLLinkType(NewLinkType string) (err error) {
1503 + // Request structure.
1504 + request := &struct {
1505 + NewLinkType string
1506 + }{}
1507 + // BEGIN Marshal arguments into request.
1508 +
1509 + if request.NewLinkType, err = soap.MarshalString(NewLinkType); err != nil {
1510 + return
1511 + }
1512 + // END Marshal arguments into request.
1513 +
1514 + // Response structure.
1515 + response := interface{}(nil)
1516 +
1517 + // Perform the SOAP call.
1518 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "SetDSLLinkType", request, response); err != nil {
1519 + return
1520 + }
1521 +
1522 + // BEGIN Unmarshal arguments from response.
1523 +
1524 + // END Unmarshal arguments from response.
1525 + return
1526 +}
1527 +
1528 +//
1529 +//
1530 +// Return values:
1531 +//
1532 +// * NewLinkType:
1533 +//
1534 +// * NewLinkStatus: allowed values: Up, Down
1535 +func (client *WANDSLLinkConfig1) GetDSLLinkInfo() (NewLinkType string, NewLinkStatus string, err error) {
1536 + // Request structure.
1537 + request := interface{}(nil)
1538 + // BEGIN Marshal arguments into request.
1539 +
1540 + // END Marshal arguments into request.
1541 +
1542 + // Response structure.
1543 + response := &struct {
1544 + NewLinkType string
1545 +
1546 + NewLinkStatus string
1547 + }{}
1548 +
1549 + // Perform the SOAP call.
1550 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "GetDSLLinkInfo", request, response); err != nil {
1551 + return
1552 + }
1553 +
1554 + // BEGIN Unmarshal arguments from response.
1555 +
1556 + if NewLinkType, err = soap.UnmarshalString(response.NewLinkType); err != nil {
1557 + return
1558 + }
1559 + if NewLinkStatus, err = soap.UnmarshalString(response.NewLinkStatus); err != nil {
1560 + return
1561 + }
1562 + // END Unmarshal arguments from response.
1563 + return
1564 +}
1565 +
1566 +//
1567 +//
1568 +// Return values:
1569 +//
1570 +// * NewAutoConfig:
1571 +func (client *WANDSLLinkConfig1) GetAutoConfig() (NewAutoConfig bool, err error) {
1572 + // Request structure.
1573 + request := interface{}(nil)
1574 + // BEGIN Marshal arguments into request.
1575 +
1576 + // END Marshal arguments into request.
1577 +
1578 + // Response structure.
1579 + response := &struct {
1580 + NewAutoConfig string
1581 + }{}
1582 +
1583 + // Perform the SOAP call.
1584 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "GetAutoConfig", request, response); err != nil {
1585 + return
1586 + }
1587 +
1588 + // BEGIN Unmarshal arguments from response.
1589 +
1590 + if NewAutoConfig, err = soap.UnmarshalBoolean(response.NewAutoConfig); err != nil {
1591 + return
1592 + }
1593 + // END Unmarshal arguments from response.
1594 + return
1595 +}
1596 +
1597 +//
1598 +//
1599 +// Return values:
1600 +//
1601 +// * NewModulationType:
1602 +func (client *WANDSLLinkConfig1) GetModulationType() (NewModulationType string, err error) {
1603 + // Request structure.
1604 + request := interface{}(nil)
1605 + // BEGIN Marshal arguments into request.
1606 +
1607 + // END Marshal arguments into request.
1608 +
1609 + // Response structure.
1610 + response := &struct {
1611 + NewModulationType string
1612 + }{}
1613 +
1614 + // Perform the SOAP call.
1615 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "GetModulationType", request, response); err != nil {
1616 + return
1617 + }
1618 +
1619 + // BEGIN Unmarshal arguments from response.
1620 +
1621 + if NewModulationType, err = soap.UnmarshalString(response.NewModulationType); err != nil {
1622 + return
1623 + }
1624 + // END Unmarshal arguments from response.
1625 + return
1626 +}
1627 +
1628 +// Arguments:
1629 +//
1630 +// * NewDestinationAddress:
1631 +//
1632 +//
1633 +func (client *WANDSLLinkConfig1) SetDestinationAddress(NewDestinationAddress string) (err error) {
1634 + // Request structure.
1635 + request := &struct {
1636 + NewDestinationAddress string
1637 + }{}
1638 + // BEGIN Marshal arguments into request.
1639 +
1640 + if request.NewDestinationAddress, err = soap.MarshalString(NewDestinationAddress); err != nil {
1641 + return
1642 + }
1643 + // END Marshal arguments into request.
1644 +
1645 + // Response structure.
1646 + response := interface{}(nil)
1647 +
1648 + // Perform the SOAP call.
1649 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "SetDestinationAddress", request, response); err != nil {
1650 + return
1651 + }
1652 +
1653 + // BEGIN Unmarshal arguments from response.
1654 +
1655 + // END Unmarshal arguments from response.
1656 + return
1657 +}
1658 +
1659 +//
1660 +//
1661 +// Return values:
1662 +//
1663 +// * NewDestinationAddress:
1664 +func (client *WANDSLLinkConfig1) GetDestinationAddress() (NewDestinationAddress string, err error) {
1665 + // Request structure.
1666 + request := interface{}(nil)
1667 + // BEGIN Marshal arguments into request.
1668 +
1669 + // END Marshal arguments into request.
1670 +
1671 + // Response structure.
1672 + response := &struct {
1673 + NewDestinationAddress string
1674 + }{}
1675 +
1676 + // Perform the SOAP call.
1677 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "GetDestinationAddress", request, response); err != nil {
1678 + return
1679 + }
1680 +
1681 + // BEGIN Unmarshal arguments from response.
1682 +
1683 + if NewDestinationAddress, err = soap.UnmarshalString(response.NewDestinationAddress); err != nil {
1684 + return
1685 + }
1686 + // END Unmarshal arguments from response.
1687 + return
1688 +}
1689 +
1690 +// Arguments:
1691 +//
1692 +// * NewATMEncapsulation:
1693 +//
1694 +//
1695 +func (client *WANDSLLinkConfig1) SetATMEncapsulation(NewATMEncapsulation string) (err error) {
1696 + // Request structure.
1697 + request := &struct {
1698 + NewATMEncapsulation string
1699 + }{}
1700 + // BEGIN Marshal arguments into request.
1701 +
1702 + if request.NewATMEncapsulation, err = soap.MarshalString(NewATMEncapsulation); err != nil {
1703 + return
1704 + }
1705 + // END Marshal arguments into request.
1706 +
1707 + // Response structure.
1708 + response := interface{}(nil)
1709 +
1710 + // Perform the SOAP call.
1711 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "SetATMEncapsulation", request, response); err != nil {
1712 + return
1713 + }
1714 +
1715 + // BEGIN Unmarshal arguments from response.
1716 +
1717 + // END Unmarshal arguments from response.
1718 + return
1719 +}
1720 +
1721 +//
1722 +//
1723 +// Return values:
1724 +//
1725 +// * NewATMEncapsulation:
1726 +func (client *WANDSLLinkConfig1) GetATMEncapsulation() (NewATMEncapsulation string, err error) {
1727 + // Request structure.
1728 + request := interface{}(nil)
1729 + // BEGIN Marshal arguments into request.
1730 +
1731 + // END Marshal arguments into request.
1732 +
1733 + // Response structure.
1734 + response := &struct {
1735 + NewATMEncapsulation string
1736 + }{}
1737 +
1738 + // Perform the SOAP call.
1739 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "GetATMEncapsulation", request, response); err != nil {
1740 + return
1741 + }
1742 +
1743 + // BEGIN Unmarshal arguments from response.
1744 +
1745 + if NewATMEncapsulation, err = soap.UnmarshalString(response.NewATMEncapsulation); err != nil {
1746 + return
1747 + }
1748 + // END Unmarshal arguments from response.
1749 + return
1750 +}
1751 +
1752 +// Arguments:
1753 +//
1754 +// * NewFCSPreserved:
1755 +//
1756 +//
1757 +func (client *WANDSLLinkConfig1) SetFCSPreserved(NewFCSPreserved bool) (err error) {
1758 + // Request structure.
1759 + request := &struct {
1760 + NewFCSPreserved string
1761 + }{}
1762 + // BEGIN Marshal arguments into request.
1763 +
1764 + if request.NewFCSPreserved, err = soap.MarshalBoolean(NewFCSPreserved); err != nil {
1765 + return
1766 + }
1767 + // END Marshal arguments into request.
1768 +
1769 + // Response structure.
1770 + response := interface{}(nil)
1771 +
1772 + // Perform the SOAP call.
1773 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "SetFCSPreserved", request, response); err != nil {
1774 + return
1775 + }
1776 +
1777 + // BEGIN Unmarshal arguments from response.
1778 +
1779 + // END Unmarshal arguments from response.
1780 + return
1781 +}
1782 +
1783 +//
1784 +//
1785 +// Return values:
1786 +//
1787 +// * NewFCSPreserved:
1788 +func (client *WANDSLLinkConfig1) GetFCSPreserved() (NewFCSPreserved bool, err error) {
1789 + // Request structure.
1790 + request := interface{}(nil)
1791 + // BEGIN Marshal arguments into request.
1792 +
1793 + // END Marshal arguments into request.
1794 +
1795 + // Response structure.
1796 + response := &struct {
1797 + NewFCSPreserved string
1798 + }{}
1799 +
1800 + // Perform the SOAP call.
1801 + if err = client.SOAPClient.PerformAction(URN_WANDSLLinkConfig_1, "GetFCSPreserved", request, response); err != nil {
1802 + return
1803 + }
1804 +
1805 + // BEGIN Unmarshal arguments from response.
1806 +
1807 + if NewFCSPreserved, err = soap.UnmarshalBoolean(response.NewFCSPreserved); err != nil {
1808 + return
1809 + }
1810 + // END Unmarshal arguments from response.
1811 + return
1812 +}
1813 +
1814 +// WANEthernetLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANEthernetLinkConfig:1". See
1815 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
1816 +// are provided for informational value.
1817 +type WANEthernetLinkConfig1 struct {
1818 + goupnp.ServiceClient
1819 +}
1820 +
1821 +// NewWANEthernetLinkConfig1Clients discovers instances of the service on the network,
1822 +// and returns clients to any that are found. errors will contain an error for
1823 +// any devices that replied but which could not be queried, and err will be set
1824 +// if the discovery process failed outright.
1825 +//
1826 +// This is a typical entry calling point into this package.
1827 +func NewWANEthernetLinkConfig1Clients() (clients []*WANEthernetLinkConfig1, errors []error, err error) {
1828 + var genericClients []goupnp.ServiceClient
1829 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANEthernetLinkConfig_1); err != nil {
1830 + return
1831 + }
1832 + clients = make([]*WANEthernetLinkConfig1, len(genericClients))
1833 + for i := range genericClients {
1834 + clients[i] = &WANEthernetLinkConfig1{genericClients[i]}
1835 + }
1836 + return
1837 +}
1838 +
1839 +//
1840 +//
1841 +// Return values:
1842 +//
1843 +// * NewEthernetLinkStatus: allowed values: Up, Down
1844 +func (client *WANEthernetLinkConfig1) GetEthernetLinkStatus() (NewEthernetLinkStatus string, err error) {
1845 + // Request structure.
1846 + request := interface{}(nil)
1847 + // BEGIN Marshal arguments into request.
1848 +
1849 + // END Marshal arguments into request.
1850 +
1851 + // Response structure.
1852 + response := &struct {
1853 + NewEthernetLinkStatus string
1854 + }{}
1855 +
1856 + // Perform the SOAP call.
1857 + if err = client.SOAPClient.PerformAction(URN_WANEthernetLinkConfig_1, "GetEthernetLinkStatus", request, response); err != nil {
1858 + return
1859 + }
1860 +
1861 + // BEGIN Unmarshal arguments from response.
1862 +
1863 + if NewEthernetLinkStatus, err = soap.UnmarshalString(response.NewEthernetLinkStatus); err != nil {
1864 + return
1865 + }
1866 + // END Unmarshal arguments from response.
1867 + return
1868 +}
1869 +
1870 +// WANIPConnection1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANIPConnection:1". See
1871 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
1872 +// are provided for informational value.
1873 +type WANIPConnection1 struct {
1874 + goupnp.ServiceClient
1875 +}
1876 +
1877 +// NewWANIPConnection1Clients discovers instances of the service on the network,
1878 +// and returns clients to any that are found. errors will contain an error for
1879 +// any devices that replied but which could not be queried, and err will be set
1880 +// if the discovery process failed outright.
1881 +//
1882 +// This is a typical entry calling point into this package.
1883 +func NewWANIPConnection1Clients() (clients []*WANIPConnection1, errors []error, err error) {
1884 + var genericClients []goupnp.ServiceClient
1885 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANIPConnection_1); err != nil {
1886 + return
1887 + }
1888 + clients = make([]*WANIPConnection1, len(genericClients))
1889 + for i := range genericClients {
1890 + clients[i] = &WANIPConnection1{genericClients[i]}
1891 + }
1892 + return
1893 +}
1894 +
1895 +// Arguments:
1896 +//
1897 +// * NewConnectionType:
1898 +//
1899 +//
1900 +func (client *WANIPConnection1) SetConnectionType(NewConnectionType string) (err error) {
1901 + // Request structure.
1902 + request := &struct {
1903 + NewConnectionType string
1904 + }{}
1905 + // BEGIN Marshal arguments into request.
1906 +
1907 + if request.NewConnectionType, err = soap.MarshalString(NewConnectionType); err != nil {
1908 + return
1909 + }
1910 + // END Marshal arguments into request.
1911 +
1912 + // Response structure.
1913 + response := interface{}(nil)
1914 +
1915 + // Perform the SOAP call.
1916 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "SetConnectionType", request, response); err != nil {
1917 + return
1918 + }
1919 +
1920 + // BEGIN Unmarshal arguments from response.
1921 +
1922 + // END Unmarshal arguments from response.
1923 + return
1924 +}
1925 +
1926 +//
1927 +//
1928 +// Return values:
1929 +//
1930 +// * NewConnectionType:
1931 +//
1932 +// * NewPossibleConnectionTypes: allowed values: Unconfigured, IP_Routed, IP_Bridged
1933 +func (client *WANIPConnection1) GetConnectionTypeInfo() (NewConnectionType string, NewPossibleConnectionTypes string, err error) {
1934 + // Request structure.
1935 + request := interface{}(nil)
1936 + // BEGIN Marshal arguments into request.
1937 +
1938 + // END Marshal arguments into request.
1939 +
1940 + // Response structure.
1941 + response := &struct {
1942 + NewConnectionType string
1943 +
1944 + NewPossibleConnectionTypes string
1945 + }{}
1946 +
1947 + // Perform the SOAP call.
1948 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetConnectionTypeInfo", request, response); err != nil {
1949 + return
1950 + }
1951 +
1952 + // BEGIN Unmarshal arguments from response.
1953 +
1954 + if NewConnectionType, err = soap.UnmarshalString(response.NewConnectionType); err != nil {
1955 + return
1956 + }
1957 + if NewPossibleConnectionTypes, err = soap.UnmarshalString(response.NewPossibleConnectionTypes); err != nil {
1958 + return
1959 + }
1960 + // END Unmarshal arguments from response.
1961 + return
1962 +}
1963 +
1964 +//
1965 +//
1966 +//
1967 +func (client *WANIPConnection1) RequestConnection() (err error) {
1968 + // Request structure.
1969 + request := interface{}(nil)
1970 + // BEGIN Marshal arguments into request.
1971 +
1972 + // END Marshal arguments into request.
1973 +
1974 + // Response structure.
1975 + response := interface{}(nil)
1976 +
1977 + // Perform the SOAP call.
1978 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "RequestConnection", request, response); err != nil {
1979 + return
1980 + }
1981 +
1982 + // BEGIN Unmarshal arguments from response.
1983 +
1984 + // END Unmarshal arguments from response.
1985 + return
1986 +}
1987 +
1988 +//
1989 +//
1990 +//
1991 +func (client *WANIPConnection1) RequestTermination() (err error) {
1992 + // Request structure.
1993 + request := interface{}(nil)
1994 + // BEGIN Marshal arguments into request.
1995 +
1996 + // END Marshal arguments into request.
1997 +
1998 + // Response structure.
1999 + response := interface{}(nil)
2000 +
2001 + // Perform the SOAP call.
2002 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "RequestTermination", request, response); err != nil {
2003 + return
2004 + }
2005 +
2006 + // BEGIN Unmarshal arguments from response.
2007 +
2008 + // END Unmarshal arguments from response.
2009 + return
2010 +}
2011 +
2012 +//
2013 +//
2014 +//
2015 +func (client *WANIPConnection1) ForceTermination() (err error) {
2016 + // Request structure.
2017 + request := interface{}(nil)
2018 + // BEGIN Marshal arguments into request.
2019 +
2020 + // END Marshal arguments into request.
2021 +
2022 + // Response structure.
2023 + response := interface{}(nil)
2024 +
2025 + // Perform the SOAP call.
2026 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "ForceTermination", request, response); err != nil {
2027 + return
2028 + }
2029 +
2030 + // BEGIN Unmarshal arguments from response.
2031 +
2032 + // END Unmarshal arguments from response.
2033 + return
2034 +}
2035 +
2036 +// Arguments:
2037 +//
2038 +// * NewAutoDisconnectTime:
2039 +//
2040 +//
2041 +func (client *WANIPConnection1) SetAutoDisconnectTime(NewAutoDisconnectTime uint32) (err error) {
2042 + // Request structure.
2043 + request := &struct {
2044 + NewAutoDisconnectTime string
2045 + }{}
2046 + // BEGIN Marshal arguments into request.
2047 +
2048 + if request.NewAutoDisconnectTime, err = soap.MarshalUi4(NewAutoDisconnectTime); err != nil {
2049 + return
2050 + }
2051 + // END Marshal arguments into request.
2052 +
2053 + // Response structure.
2054 + response := interface{}(nil)
2055 +
2056 + // Perform the SOAP call.
2057 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "SetAutoDisconnectTime", request, response); err != nil {
2058 + return
2059 + }
2060 +
2061 + // BEGIN Unmarshal arguments from response.
2062 +
2063 + // END Unmarshal arguments from response.
2064 + return
2065 +}
2066 +
2067 +// Arguments:
2068 +//
2069 +// * NewIdleDisconnectTime:
2070 +//
2071 +//
2072 +func (client *WANIPConnection1) SetIdleDisconnectTime(NewIdleDisconnectTime uint32) (err error) {
2073 + // Request structure.
2074 + request := &struct {
2075 + NewIdleDisconnectTime string
2076 + }{}
2077 + // BEGIN Marshal arguments into request.
2078 +
2079 + if request.NewIdleDisconnectTime, err = soap.MarshalUi4(NewIdleDisconnectTime); err != nil {
2080 + return
2081 + }
2082 + // END Marshal arguments into request.
2083 +
2084 + // Response structure.
2085 + response := interface{}(nil)
2086 +
2087 + // Perform the SOAP call.
2088 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "SetIdleDisconnectTime", request, response); err != nil {
2089 + return
2090 + }
2091 +
2092 + // BEGIN Unmarshal arguments from response.
2093 +
2094 + // END Unmarshal arguments from response.
2095 + return
2096 +}
2097 +
2098 +// Arguments:
2099 +//
2100 +// * NewWarnDisconnectDelay:
2101 +//
2102 +//
2103 +func (client *WANIPConnection1) SetWarnDisconnectDelay(NewWarnDisconnectDelay uint32) (err error) {
2104 + // Request structure.
2105 + request := &struct {
2106 + NewWarnDisconnectDelay string
2107 + }{}
2108 + // BEGIN Marshal arguments into request.
2109 +
2110 + if request.NewWarnDisconnectDelay, err = soap.MarshalUi4(NewWarnDisconnectDelay); err != nil {
2111 + return
2112 + }
2113 + // END Marshal arguments into request.
2114 +
2115 + // Response structure.
2116 + response := interface{}(nil)
2117 +
2118 + // Perform the SOAP call.
2119 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "SetWarnDisconnectDelay", request, response); err != nil {
2120 + return
2121 + }
2122 +
2123 + // BEGIN Unmarshal arguments from response.
2124 +
2125 + // END Unmarshal arguments from response.
2126 + return
2127 +}
2128 +
2129 +//
2130 +//
2131 +// Return values:
2132 +//
2133 +// * NewConnectionStatus: allowed values: Unconfigured, Connected, Disconnected
2134 +//
2135 +// * NewLastConnectionError: allowed values: ERROR_NONE
2136 +//
2137 +// * NewUptime:
2138 +func (client *WANIPConnection1) GetStatusInfo() (NewConnectionStatus string, NewLastConnectionError string, NewUptime uint32, err error) {
2139 + // Request structure.
2140 + request := interface{}(nil)
2141 + // BEGIN Marshal arguments into request.
2142 +
2143 + // END Marshal arguments into request.
2144 +
2145 + // Response structure.
2146 + response := &struct {
2147 + NewConnectionStatus string
2148 +
2149 + NewLastConnectionError string
2150 +
2151 + NewUptime string
2152 + }{}
2153 +
2154 + // Perform the SOAP call.
2155 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetStatusInfo", request, response); err != nil {
2156 + return
2157 + }
2158 +
2159 + // BEGIN Unmarshal arguments from response.
2160 +
2161 + if NewConnectionStatus, err = soap.UnmarshalString(response.NewConnectionStatus); err != nil {
2162 + return
2163 + }
2164 + if NewLastConnectionError, err = soap.UnmarshalString(response.NewLastConnectionError); err != nil {
2165 + return
2166 + }
2167 + if NewUptime, err = soap.UnmarshalUi4(response.NewUptime); err != nil {
2168 + return
2169 + }
2170 + // END Unmarshal arguments from response.
2171 + return
2172 +}
2173 +
2174 +//
2175 +//
2176 +// Return values:
2177 +//
2178 +// * NewAutoDisconnectTime:
2179 +func (client *WANIPConnection1) GetAutoDisconnectTime() (NewAutoDisconnectTime uint32, err error) {
2180 + // Request structure.
2181 + request := interface{}(nil)
2182 + // BEGIN Marshal arguments into request.
2183 +
2184 + // END Marshal arguments into request.
2185 +
2186 + // Response structure.
2187 + response := &struct {
2188 + NewAutoDisconnectTime string
2189 + }{}
2190 +
2191 + // Perform the SOAP call.
2192 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetAutoDisconnectTime", request, response); err != nil {
2193 + return
2194 + }
2195 +
2196 + // BEGIN Unmarshal arguments from response.
2197 +
2198 + if NewAutoDisconnectTime, err = soap.UnmarshalUi4(response.NewAutoDisconnectTime); err != nil {
2199 + return
2200 + }
2201 + // END Unmarshal arguments from response.
2202 + return
2203 +}
2204 +
2205 +//
2206 +//
2207 +// Return values:
2208 +//
2209 +// * NewIdleDisconnectTime:
2210 +func (client *WANIPConnection1) GetIdleDisconnectTime() (NewIdleDisconnectTime uint32, err error) {
2211 + // Request structure.
2212 + request := interface{}(nil)
2213 + // BEGIN Marshal arguments into request.
2214 +
2215 + // END Marshal arguments into request.
2216 +
2217 + // Response structure.
2218 + response := &struct {
2219 + NewIdleDisconnectTime string
2220 + }{}
2221 +
2222 + // Perform the SOAP call.
2223 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetIdleDisconnectTime", request, response); err != nil {
2224 + return
2225 + }
2226 +
2227 + // BEGIN Unmarshal arguments from response.
2228 +
2229 + if NewIdleDisconnectTime, err = soap.UnmarshalUi4(response.NewIdleDisconnectTime); err != nil {
2230 + return
2231 + }
2232 + // END Unmarshal arguments from response.
2233 + return
2234 +}
2235 +
2236 +//
2237 +//
2238 +// Return values:
2239 +//
2240 +// * NewWarnDisconnectDelay:
2241 +func (client *WANIPConnection1) GetWarnDisconnectDelay() (NewWarnDisconnectDelay uint32, err error) {
2242 + // Request structure.
2243 + request := interface{}(nil)
2244 + // BEGIN Marshal arguments into request.
2245 +
2246 + // END Marshal arguments into request.
2247 +
2248 + // Response structure.
2249 + response := &struct {
2250 + NewWarnDisconnectDelay string
2251 + }{}
2252 +
2253 + // Perform the SOAP call.
2254 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetWarnDisconnectDelay", request, response); err != nil {
2255 + return
2256 + }
2257 +
2258 + // BEGIN Unmarshal arguments from response.
2259 +
2260 + if NewWarnDisconnectDelay, err = soap.UnmarshalUi4(response.NewWarnDisconnectDelay); err != nil {
2261 + return
2262 + }
2263 + // END Unmarshal arguments from response.
2264 + return
2265 +}
2266 +
2267 +//
2268 +//
2269 +// Return values:
2270 +//
2271 +// * NewRSIPAvailable:
2272 +//
2273 +// * NewNATEnabled:
2274 +func (client *WANIPConnection1) GetNATRSIPStatus() (NewRSIPAvailable bool, NewNATEnabled bool, err error) {
2275 + // Request structure.
2276 + request := interface{}(nil)
2277 + // BEGIN Marshal arguments into request.
2278 +
2279 + // END Marshal arguments into request.
2280 +
2281 + // Response structure.
2282 + response := &struct {
2283 + NewRSIPAvailable string
2284 +
2285 + NewNATEnabled string
2286 + }{}
2287 +
2288 + // Perform the SOAP call.
2289 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetNATRSIPStatus", request, response); err != nil {
2290 + return
2291 + }
2292 +
2293 + // BEGIN Unmarshal arguments from response.
2294 +
2295 + if NewRSIPAvailable, err = soap.UnmarshalBoolean(response.NewRSIPAvailable); err != nil {
2296 + return
2297 + }
2298 + if NewNATEnabled, err = soap.UnmarshalBoolean(response.NewNATEnabled); err != nil {
2299 + return
2300 + }
2301 + // END Unmarshal arguments from response.
2302 + return
2303 +}
2304 +
2305 +// Arguments:
2306 +//
2307 +// * NewPortMappingIndex:
2308 +//
2309 +// Return values:
2310 +//
2311 +// * NewRemoteHost:
2312 +//
2313 +// * NewExternalPort:
2314 +//
2315 +// * NewProtocol: allowed values: TCP, UDP
2316 +//
2317 +// * NewInternalPort:
2318 +//
2319 +// * NewInternalClient:
2320 +//
2321 +// * NewEnabled:
2322 +//
2323 +// * NewPortMappingDescription:
2324 +//
2325 +// * NewLeaseDuration:
2326 +func (client *WANIPConnection1) GetGenericPortMappingEntry(NewPortMappingIndex uint16) (NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
2327 + // Request structure.
2328 + request := &struct {
2329 + NewPortMappingIndex string
2330 + }{}
2331 + // BEGIN Marshal arguments into request.
2332 +
2333 + if request.NewPortMappingIndex, err = soap.MarshalUi2(NewPortMappingIndex); err != nil {
2334 + return
2335 + }
2336 + // END Marshal arguments into request.
2337 +
2338 + // Response structure.
2339 + response := &struct {
2340 + NewRemoteHost string
2341 +
2342 + NewExternalPort string
2343 +
2344 + NewProtocol string
2345 +
2346 + NewInternalPort string
2347 +
2348 + NewInternalClient string
2349 +
2350 + NewEnabled string
2351 +
2352 + NewPortMappingDescription string
2353 +
2354 + NewLeaseDuration string
2355 + }{}
2356 +
2357 + // Perform the SOAP call.
2358 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetGenericPortMappingEntry", request, response); err != nil {
2359 + return
2360 + }
2361 +
2362 + // BEGIN Unmarshal arguments from response.
2363 +
2364 + if NewRemoteHost, err = soap.UnmarshalString(response.NewRemoteHost); err != nil {
2365 + return
2366 + }
2367 + if NewExternalPort, err = soap.UnmarshalUi2(response.NewExternalPort); err != nil {
2368 + return
2369 + }
2370 + if NewProtocol, err = soap.UnmarshalString(response.NewProtocol); err != nil {
2371 + return
2372 + }
2373 + if NewInternalPort, err = soap.UnmarshalUi2(response.NewInternalPort); err != nil {
2374 + return
2375 + }
2376 + if NewInternalClient, err = soap.UnmarshalString(response.NewInternalClient); err != nil {
2377 + return
2378 + }
2379 + if NewEnabled, err = soap.UnmarshalBoolean(response.NewEnabled); err != nil {
2380 + return
2381 + }
2382 + if NewPortMappingDescription, err = soap.UnmarshalString(response.NewPortMappingDescription); err != nil {
2383 + return
2384 + }
2385 + if NewLeaseDuration, err = soap.UnmarshalUi4(response.NewLeaseDuration); err != nil {
2386 + return
2387 + }
2388 + // END Unmarshal arguments from response.
2389 + return
2390 +}
2391 +
2392 +// Arguments:
2393 +//
2394 +// * NewRemoteHost:
2395 +//
2396 +// * NewExternalPort:
2397 +//
2398 +// * NewProtocol: allowed values: TCP, UDP
2399 +//
2400 +// Return values:
2401 +//
2402 +// * NewInternalPort:
2403 +//
2404 +// * NewInternalClient:
2405 +//
2406 +// * NewEnabled:
2407 +//
2408 +// * NewPortMappingDescription:
2409 +//
2410 +// * NewLeaseDuration:
2411 +func (client *WANIPConnection1) GetSpecificPortMappingEntry(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
2412 + // Request structure.
2413 + request := &struct {
2414 + NewRemoteHost string
2415 +
2416 + NewExternalPort string
2417 +
2418 + NewProtocol string
2419 + }{}
2420 + // BEGIN Marshal arguments into request.
2421 +
2422 + if request.NewRemoteHost, err = soap.MarshalString(NewRemoteHost); err != nil {
2423 + return
2424 + }
2425 + if request.NewExternalPort, err = soap.MarshalUi2(NewExternalPort); err != nil {
2426 + return
2427 + }
2428 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
2429 + return
2430 + }
2431 + // END Marshal arguments into request.
2432 +
2433 + // Response structure.
2434 + response := &struct {
2435 + NewInternalPort string
2436 +
2437 + NewInternalClient string
2438 +
2439 + NewEnabled string
2440 +
2441 + NewPortMappingDescription string
2442 +
2443 + NewLeaseDuration string
2444 + }{}
2445 +
2446 + // Perform the SOAP call.
2447 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetSpecificPortMappingEntry", request, response); err != nil {
2448 + return
2449 + }
2450 +
2451 + // BEGIN Unmarshal arguments from response.
2452 +
2453 + if NewInternalPort, err = soap.UnmarshalUi2(response.NewInternalPort); err != nil {
2454 + return
2455 + }
2456 + if NewInternalClient, err = soap.UnmarshalString(response.NewInternalClient); err != nil {
2457 + return
2458 + }
2459 + if NewEnabled, err = soap.UnmarshalBoolean(response.NewEnabled); err != nil {
2460 + return
2461 + }
2462 + if NewPortMappingDescription, err = soap.UnmarshalString(response.NewPortMappingDescription); err != nil {
2463 + return
2464 + }
2465 + if NewLeaseDuration, err = soap.UnmarshalUi4(response.NewLeaseDuration); err != nil {
2466 + return
2467 + }
2468 + // END Unmarshal arguments from response.
2469 + return
2470 +}
2471 +
2472 +// Arguments:
2473 +//
2474 +// * NewRemoteHost:
2475 +//
2476 +// * NewExternalPort:
2477 +//
2478 +// * NewProtocol: allowed values: TCP, UDP
2479 +//
2480 +// * NewInternalPort:
2481 +//
2482 +// * NewInternalClient:
2483 +//
2484 +// * NewEnabled:
2485 +//
2486 +// * NewPortMappingDescription:
2487 +//
2488 +// * NewLeaseDuration:
2489 +//
2490 +//
2491 +func (client *WANIPConnection1) AddPortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32) (err error) {
2492 + // Request structure.
2493 + request := &struct {
2494 + NewRemoteHost string
2495 +
2496 + NewExternalPort string
2497 +
2498 + NewProtocol string
2499 +
2500 + NewInternalPort string
2501 +
2502 + NewInternalClient string
2503 +
2504 + NewEnabled string
2505 +
2506 + NewPortMappingDescription string
2507 +
2508 + NewLeaseDuration string
2509 + }{}
2510 + // BEGIN Marshal arguments into request.
2511 +
2512 + if request.NewRemoteHost, err = soap.MarshalString(NewRemoteHost); err != nil {
2513 + return
2514 + }
2515 + if request.NewExternalPort, err = soap.MarshalUi2(NewExternalPort); err != nil {
2516 + return
2517 + }
2518 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
2519 + return
2520 + }
2521 + if request.NewInternalPort, err = soap.MarshalUi2(NewInternalPort); err != nil {
2522 + return
2523 + }
2524 + if request.NewInternalClient, err = soap.MarshalString(NewInternalClient); err != nil {
2525 + return
2526 + }
2527 + if request.NewEnabled, err = soap.MarshalBoolean(NewEnabled); err != nil {
2528 + return
2529 + }
2530 + if request.NewPortMappingDescription, err = soap.MarshalString(NewPortMappingDescription); err != nil {
2531 + return
2532 + }
2533 + if request.NewLeaseDuration, err = soap.MarshalUi4(NewLeaseDuration); err != nil {
2534 + return
2535 + }
2536 + // END Marshal arguments into request.
2537 +
2538 + // Response structure.
2539 + response := interface{}(nil)
2540 +
2541 + // Perform the SOAP call.
2542 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "AddPortMapping", request, response); err != nil {
2543 + return
2544 + }
2545 +
2546 + // BEGIN Unmarshal arguments from response.
2547 +
2548 + // END Unmarshal arguments from response.
2549 + return
2550 +}
2551 +
2552 +// Arguments:
2553 +//
2554 +// * NewRemoteHost:
2555 +//
2556 +// * NewExternalPort:
2557 +//
2558 +// * NewProtocol: allowed values: TCP, UDP
2559 +//
2560 +//
2561 +func (client *WANIPConnection1) DeletePortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (err error) {
2562 + // Request structure.
2563 + request := &struct {
2564 + NewRemoteHost string
2565 +
2566 + NewExternalPort string
2567 +
2568 + NewProtocol string
2569 + }{}
2570 + // BEGIN Marshal arguments into request.
2571 +
2572 + if request.NewRemoteHost, err = soap.MarshalString(NewRemoteHost); err != nil {
2573 + return
2574 + }
2575 + if request.NewExternalPort, err = soap.MarshalUi2(NewExternalPort); err != nil {
2576 + return
2577 + }
2578 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
2579 + return
2580 + }
2581 + // END Marshal arguments into request.
2582 +
2583 + // Response structure.
2584 + response := interface{}(nil)
2585 +
2586 + // Perform the SOAP call.
2587 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "DeletePortMapping", request, response); err != nil {
2588 + return
2589 + }
2590 +
2591 + // BEGIN Unmarshal arguments from response.
2592 +
2593 + // END Unmarshal arguments from response.
2594 + return
2595 +}
2596 +
2597 +//
2598 +//
2599 +// Return values:
2600 +//
2601 +// * NewExternalIPAddress:
2602 +func (client *WANIPConnection1) GetExternalIPAddress() (NewExternalIPAddress string, err error) {
2603 + // Request structure.
2604 + request := interface{}(nil)
2605 + // BEGIN Marshal arguments into request.
2606 +
2607 + // END Marshal arguments into request.
2608 +
2609 + // Response structure.
2610 + response := &struct {
2611 + NewExternalIPAddress string
2612 + }{}
2613 +
2614 + // Perform the SOAP call.
2615 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_1, "GetExternalIPAddress", request, response); err != nil {
2616 + return
2617 + }
2618 +
2619 + // BEGIN Unmarshal arguments from response.
2620 +
2621 + if NewExternalIPAddress, err = soap.UnmarshalString(response.NewExternalIPAddress); err != nil {
2622 + return
2623 + }
2624 + // END Unmarshal arguments from response.
2625 + return
2626 +}
2627 +
2628 +// WANIPConnection2 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANIPConnection:2". See
2629 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
2630 +// are provided for informational value.
2631 +type WANIPConnection2 struct {
2632 + goupnp.ServiceClient
2633 +}
2634 +
2635 +// NewWANIPConnection2Clients discovers instances of the service on the network,
2636 +// and returns clients to any that are found. errors will contain an error for
2637 +// any devices that replied but which could not be queried, and err will be set
2638 +// if the discovery process failed outright.
2639 +//
2640 +// This is a typical entry calling point into this package.
2641 +func NewWANIPConnection2Clients() (clients []*WANIPConnection2, errors []error, err error) {
2642 + var genericClients []goupnp.ServiceClient
2643 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANIPConnection_2); err != nil {
2644 + return
2645 + }
2646 + clients = make([]*WANIPConnection2, len(genericClients))
2647 + for i := range genericClients {
2648 + clients[i] = &WANIPConnection2{genericClients[i]}
2649 + }
2650 + return
2651 +}
2652 +
2653 +// Arguments:
2654 +//
2655 +// * NewConnectionType: allowed values: Unconfigured, IP_Routed, IP_Bridged
2656 +//
2657 +//
2658 +func (client *WANIPConnection2) SetConnectionType(NewConnectionType string) (err error) {
2659 + // Request structure.
2660 + request := &struct {
2661 + NewConnectionType string
2662 + }{}
2663 + // BEGIN Marshal arguments into request.
2664 +
2665 + if request.NewConnectionType, err = soap.MarshalString(NewConnectionType); err != nil {
2666 + return
2667 + }
2668 + // END Marshal arguments into request.
2669 +
2670 + // Response structure.
2671 + response := interface{}(nil)
2672 +
2673 + // Perform the SOAP call.
2674 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "SetConnectionType", request, response); err != nil {
2675 + return
2676 + }
2677 +
2678 + // BEGIN Unmarshal arguments from response.
2679 +
2680 + // END Unmarshal arguments from response.
2681 + return
2682 +}
2683 +
2684 +//
2685 +//
2686 +// Return values:
2687 +//
2688 +// * NewConnectionType: allowed values: Unconfigured, IP_Routed, IP_Bridged
2689 +//
2690 +// * NewPossibleConnectionTypes:
2691 +func (client *WANIPConnection2) GetConnectionTypeInfo() (NewConnectionType string, NewPossibleConnectionTypes string, err error) {
2692 + // Request structure.
2693 + request := interface{}(nil)
2694 + // BEGIN Marshal arguments into request.
2695 +
2696 + // END Marshal arguments into request.
2697 +
2698 + // Response structure.
2699 + response := &struct {
2700 + NewConnectionType string
2701 +
2702 + NewPossibleConnectionTypes string
2703 + }{}
2704 +
2705 + // Perform the SOAP call.
2706 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "GetConnectionTypeInfo", request, response); err != nil {
2707 + return
2708 + }
2709 +
2710 + // BEGIN Unmarshal arguments from response.
2711 +
2712 + if NewConnectionType, err = soap.UnmarshalString(response.NewConnectionType); err != nil {
2713 + return
2714 + }
2715 + if NewPossibleConnectionTypes, err = soap.UnmarshalString(response.NewPossibleConnectionTypes); err != nil {
2716 + return
2717 + }
2718 + // END Unmarshal arguments from response.
2719 + return
2720 +}
2721 +
2722 +//
2723 +//
2724 +//
2725 +func (client *WANIPConnection2) RequestConnection() (err error) {
2726 + // Request structure.
2727 + request := interface{}(nil)
2728 + // BEGIN Marshal arguments into request.
2729 +
2730 + // END Marshal arguments into request.
2731 +
2732 + // Response structure.
2733 + response := interface{}(nil)
2734 +
2735 + // Perform the SOAP call.
2736 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "RequestConnection", request, response); err != nil {
2737 + return
2738 + }
2739 +
2740 + // BEGIN Unmarshal arguments from response.
2741 +
2742 + // END Unmarshal arguments from response.
2743 + return
2744 +}
2745 +
2746 +//
2747 +//
2748 +//
2749 +func (client *WANIPConnection2) RequestTermination() (err error) {
2750 + // Request structure.
2751 + request := interface{}(nil)
2752 + // BEGIN Marshal arguments into request.
2753 +
2754 + // END Marshal arguments into request.
2755 +
2756 + // Response structure.
2757 + response := interface{}(nil)
2758 +
2759 + // Perform the SOAP call.
2760 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "RequestTermination", request, response); err != nil {
2761 + return
2762 + }
2763 +
2764 + // BEGIN Unmarshal arguments from response.
2765 +
2766 + // END Unmarshal arguments from response.
2767 + return
2768 +}
2769 +
2770 +//
2771 +//
2772 +//
2773 +func (client *WANIPConnection2) ForceTermination() (err error) {
2774 + // Request structure.
2775 + request := interface{}(nil)
2776 + // BEGIN Marshal arguments into request.
2777 +
2778 + // END Marshal arguments into request.
2779 +
2780 + // Response structure.
2781 + response := interface{}(nil)
2782 +
2783 + // Perform the SOAP call.
2784 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "ForceTermination", request, response); err != nil {
2785 + return
2786 + }
2787 +
2788 + // BEGIN Unmarshal arguments from response.
2789 +
2790 + // END Unmarshal arguments from response.
2791 + return
2792 +}
2793 +
2794 +// Arguments:
2795 +//
2796 +// * NewAutoDisconnectTime:
2797 +//
2798 +//
2799 +func (client *WANIPConnection2) SetAutoDisconnectTime(NewAutoDisconnectTime uint32) (err error) {
2800 + // Request structure.
2801 + request := &struct {
2802 + NewAutoDisconnectTime string
2803 + }{}
2804 + // BEGIN Marshal arguments into request.
2805 +
2806 + if request.NewAutoDisconnectTime, err = soap.MarshalUi4(NewAutoDisconnectTime); err != nil {
2807 + return
2808 + }
2809 + // END Marshal arguments into request.
2810 +
2811 + // Response structure.
2812 + response := interface{}(nil)
2813 +
2814 + // Perform the SOAP call.
2815 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "SetAutoDisconnectTime", request, response); err != nil {
2816 + return
2817 + }
2818 +
2819 + // BEGIN Unmarshal arguments from response.
2820 +
2821 + // END Unmarshal arguments from response.
2822 + return
2823 +}
2824 +
2825 +// Arguments:
2826 +//
2827 +// * NewIdleDisconnectTime:
2828 +//
2829 +//
2830 +func (client *WANIPConnection2) SetIdleDisconnectTime(NewIdleDisconnectTime uint32) (err error) {
2831 + // Request structure.
2832 + request := &struct {
2833 + NewIdleDisconnectTime string
2834 + }{}
2835 + // BEGIN Marshal arguments into request.
2836 +
2837 + if request.NewIdleDisconnectTime, err = soap.MarshalUi4(NewIdleDisconnectTime); err != nil {
2838 + return
2839 + }
2840 + // END Marshal arguments into request.
2841 +
2842 + // Response structure.
2843 + response := interface{}(nil)
2844 +
2845 + // Perform the SOAP call.
2846 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "SetIdleDisconnectTime", request, response); err != nil {
2847 + return
2848 + }
2849 +
2850 + // BEGIN Unmarshal arguments from response.
2851 +
2852 + // END Unmarshal arguments from response.
2853 + return
2854 +}
2855 +
2856 +// Arguments:
2857 +//
2858 +// * NewWarnDisconnectDelay:
2859 +//
2860 +//
2861 +func (client *WANIPConnection2) SetWarnDisconnectDelay(NewWarnDisconnectDelay uint32) (err error) {
2862 + // Request structure.
2863 + request := &struct {
2864 + NewWarnDisconnectDelay string
2865 + }{}
2866 + // BEGIN Marshal arguments into request.
2867 +
2868 + if request.NewWarnDisconnectDelay, err = soap.MarshalUi4(NewWarnDisconnectDelay); err != nil {
2869 + return
2870 + }
2871 + // END Marshal arguments into request.
2872 +
2873 + // Response structure.
2874 + response := interface{}(nil)
2875 +
2876 + // Perform the SOAP call.
2877 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "SetWarnDisconnectDelay", request, response); err != nil {
2878 + return
2879 + }
2880 +
2881 + // BEGIN Unmarshal arguments from response.
2882 +
2883 + // END Unmarshal arguments from response.
2884 + return
2885 +}
2886 +
2887 +//
2888 +//
2889 +// Return values:
2890 +//
2891 +// * NewConnectionStatus: allowed values: Unconfigured, Connected, Disconnected
2892 +//
2893 +// * NewLastConnectionError: allowed values: ERROR_NONE
2894 +//
2895 +// * NewUptime:
2896 +func (client *WANIPConnection2) GetStatusInfo() (NewConnectionStatus string, NewLastConnectionError string, NewUptime uint32, err error) {
2897 + // Request structure.
2898 + request := interface{}(nil)
2899 + // BEGIN Marshal arguments into request.
2900 +
2901 + // END Marshal arguments into request.
2902 +
2903 + // Response structure.
2904 + response := &struct {
2905 + NewConnectionStatus string
2906 +
2907 + NewLastConnectionError string
2908 +
2909 + NewUptime string
2910 + }{}
2911 +
2912 + // Perform the SOAP call.
2913 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "GetStatusInfo", request, response); err != nil {
2914 + return
2915 + }
2916 +
2917 + // BEGIN Unmarshal arguments from response.
2918 +
2919 + if NewConnectionStatus, err = soap.UnmarshalString(response.NewConnectionStatus); err != nil {
2920 + return
2921 + }
2922 + if NewLastConnectionError, err = soap.UnmarshalString(response.NewLastConnectionError); err != nil {
2923 + return
2924 + }
2925 + if NewUptime, err = soap.UnmarshalUi4(response.NewUptime); err != nil {
2926 + return
2927 + }
2928 + // END Unmarshal arguments from response.
2929 + return
2930 +}
2931 +
2932 +//
2933 +//
2934 +// Return values:
2935 +//
2936 +// * NewAutoDisconnectTime:
2937 +func (client *WANIPConnection2) GetAutoDisconnectTime() (NewAutoDisconnectTime uint32, err error) {
2938 + // Request structure.
2939 + request := interface{}(nil)
2940 + // BEGIN Marshal arguments into request.
2941 +
2942 + // END Marshal arguments into request.
2943 +
2944 + // Response structure.
2945 + response := &struct {
2946 + NewAutoDisconnectTime string
2947 + }{}
2948 +
2949 + // Perform the SOAP call.
2950 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "GetAutoDisconnectTime", request, response); err != nil {
2951 + return
2952 + }
2953 +
2954 + // BEGIN Unmarshal arguments from response.
2955 +
2956 + if NewAutoDisconnectTime, err = soap.UnmarshalUi4(response.NewAutoDisconnectTime); err != nil {
2957 + return
2958 + }
2959 + // END Unmarshal arguments from response.
2960 + return
2961 +}
2962 +
2963 +//
2964 +//
2965 +// Return values:
2966 +//
2967 +// * NewIdleDisconnectTime:
2968 +func (client *WANIPConnection2) GetIdleDisconnectTime() (NewIdleDisconnectTime uint32, err error) {
2969 + // Request structure.
2970 + request := interface{}(nil)
2971 + // BEGIN Marshal arguments into request.
2972 +
2973 + // END Marshal arguments into request.
2974 +
2975 + // Response structure.
2976 + response := &struct {
2977 + NewIdleDisconnectTime string
2978 + }{}
2979 +
2980 + // Perform the SOAP call.
2981 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "GetIdleDisconnectTime", request, response); err != nil {
2982 + return
2983 + }
2984 +
2985 + // BEGIN Unmarshal arguments from response.
2986 +
2987 + if NewIdleDisconnectTime, err = soap.UnmarshalUi4(response.NewIdleDisconnectTime); err != nil {
2988 + return
2989 + }
2990 + // END Unmarshal arguments from response.
2991 + return
2992 +}
2993 +
2994 +//
2995 +//
2996 +// Return values:
2997 +//
2998 +// * NewWarnDisconnectDelay:
2999 +func (client *WANIPConnection2) GetWarnDisconnectDelay() (NewWarnDisconnectDelay uint32, err error) {
3000 + // Request structure.
3001 + request := interface{}(nil)
3002 + // BEGIN Marshal arguments into request.
3003 +
3004 + // END Marshal arguments into request.
3005 +
3006 + // Response structure.
3007 + response := &struct {
3008 + NewWarnDisconnectDelay string
3009 + }{}
3010 +
3011 + // Perform the SOAP call.
3012 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "GetWarnDisconnectDelay", request, response); err != nil {
3013 + return
3014 + }
3015 +
3016 + // BEGIN Unmarshal arguments from response.
3017 +
3018 + if NewWarnDisconnectDelay, err = soap.UnmarshalUi4(response.NewWarnDisconnectDelay); err != nil {
3019 + return
3020 + }
3021 + // END Unmarshal arguments from response.
3022 + return
3023 +}
3024 +
3025 +//
3026 +//
3027 +// Return values:
3028 +//
3029 +// * NewRSIPAvailable:
3030 +//
3031 +// * NewNATEnabled:
3032 +func (client *WANIPConnection2) GetNATRSIPStatus() (NewRSIPAvailable bool, NewNATEnabled bool, err error) {
3033 + // Request structure.
3034 + request := interface{}(nil)
3035 + // BEGIN Marshal arguments into request.
3036 +
3037 + // END Marshal arguments into request.
3038 +
3039 + // Response structure.
3040 + response := &struct {
3041 + NewRSIPAvailable string
3042 +
3043 + NewNATEnabled string
3044 + }{}
3045 +
3046 + // Perform the SOAP call.
3047 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "GetNATRSIPStatus", request, response); err != nil {
3048 + return
3049 + }
3050 +
3051 + // BEGIN Unmarshal arguments from response.
3052 +
3053 + if NewRSIPAvailable, err = soap.UnmarshalBoolean(response.NewRSIPAvailable); err != nil {
3054 + return
3055 + }
3056 + if NewNATEnabled, err = soap.UnmarshalBoolean(response.NewNATEnabled); err != nil {
3057 + return
3058 + }
3059 + // END Unmarshal arguments from response.
3060 + return
3061 +}
3062 +
3063 +// Arguments:
3064 +//
3065 +// * NewPortMappingIndex:
3066 +//
3067 +// Return values:
3068 +//
3069 +// * NewRemoteHost:
3070 +//
3071 +// * NewExternalPort:
3072 +//
3073 +// * NewProtocol: allowed values: TCP, UDP
3074 +//
3075 +// * NewInternalPort: allowed value range: minimum=1, maximum=65535
3076 +//
3077 +// * NewInternalClient:
3078 +//
3079 +// * NewEnabled:
3080 +//
3081 +// * NewPortMappingDescription:
3082 +//
3083 +// * NewLeaseDuration: allowed value range: minimum=0, maximum=604800
3084 +func (client *WANIPConnection2) GetGenericPortMappingEntry(NewPortMappingIndex uint16) (NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
3085 + // Request structure.
3086 + request := &struct {
3087 + NewPortMappingIndex string
3088 + }{}
3089 + // BEGIN Marshal arguments into request.
3090 +
3091 + if request.NewPortMappingIndex, err = soap.MarshalUi2(NewPortMappingIndex); err != nil {
3092 + return
3093 + }
3094 + // END Marshal arguments into request.
3095 +
3096 + // Response structure.
3097 + response := &struct {
3098 + NewRemoteHost string
3099 +
3100 + NewExternalPort string
3101 +
3102 + NewProtocol string
3103 +
3104 + NewInternalPort string
3105 +
3106 + NewInternalClient string
3107 +
3108 + NewEnabled string
3109 +
3110 + NewPortMappingDescription string
3111 +
3112 + NewLeaseDuration string
3113 + }{}
3114 +
3115 + // Perform the SOAP call.
3116 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "GetGenericPortMappingEntry", request, response); err != nil {
3117 + return
3118 + }
3119 +
3120 + // BEGIN Unmarshal arguments from response.
3121 +
3122 + if NewRemoteHost, err = soap.UnmarshalString(response.NewRemoteHost); err != nil {
3123 + return
3124 + }
3125 + if NewExternalPort, err = soap.UnmarshalUi2(response.NewExternalPort); err != nil {
3126 + return
3127 + }
3128 + if NewProtocol, err = soap.UnmarshalString(response.NewProtocol); err != nil {
3129 + return
3130 + }
3131 + if NewInternalPort, err = soap.UnmarshalUi2(response.NewInternalPort); err != nil {
3132 + return
3133 + }
3134 + if NewInternalClient, err = soap.UnmarshalString(response.NewInternalClient); err != nil {
3135 + return
3136 + }
3137 + if NewEnabled, err = soap.UnmarshalBoolean(response.NewEnabled); err != nil {
3138 + return
3139 + }
3140 + if NewPortMappingDescription, err = soap.UnmarshalString(response.NewPortMappingDescription); err != nil {
3141 + return
3142 + }
3143 + if NewLeaseDuration, err = soap.UnmarshalUi4(response.NewLeaseDuration); err != nil {
3144 + return
3145 + }
3146 + // END Unmarshal arguments from response.
3147 + return
3148 +}
3149 +
3150 +// Arguments:
3151 +//
3152 +// * NewRemoteHost:
3153 +//
3154 +// * NewExternalPort:
3155 +//
3156 +// * NewProtocol: allowed values: TCP, UDP
3157 +//
3158 +// Return values:
3159 +//
3160 +// * NewInternalPort: allowed value range: minimum=1, maximum=65535
3161 +//
3162 +// * NewInternalClient:
3163 +//
3164 +// * NewEnabled:
3165 +//
3166 +// * NewPortMappingDescription:
3167 +//
3168 +// * NewLeaseDuration: allowed value range: minimum=0, maximum=604800
3169 +func (client *WANIPConnection2) GetSpecificPortMappingEntry(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
3170 + // Request structure.
3171 + request := &struct {
3172 + NewRemoteHost string
3173 +
3174 + NewExternalPort string
3175 +
3176 + NewProtocol string
3177 + }{}
3178 + // BEGIN Marshal arguments into request.
3179 +
3180 + if request.NewRemoteHost, err = soap.MarshalString(NewRemoteHost); err != nil {
3181 + return
3182 + }
3183 + if request.NewExternalPort, err = soap.MarshalUi2(NewExternalPort); err != nil {
3184 + return
3185 + }
3186 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
3187 + return
3188 + }
3189 + // END Marshal arguments into request.
3190 +
3191 + // Response structure.
3192 + response := &struct {
3193 + NewInternalPort string
3194 +
3195 + NewInternalClient string
3196 +
3197 + NewEnabled string
3198 +
3199 + NewPortMappingDescription string
3200 +
3201 + NewLeaseDuration string
3202 + }{}
3203 +
3204 + // Perform the SOAP call.
3205 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "GetSpecificPortMappingEntry", request, response); err != nil {
3206 + return
3207 + }
3208 +
3209 + // BEGIN Unmarshal arguments from response.
3210 +
3211 + if NewInternalPort, err = soap.UnmarshalUi2(response.NewInternalPort); err != nil {
3212 + return
3213 + }
3214 + if NewInternalClient, err = soap.UnmarshalString(response.NewInternalClient); err != nil {
3215 + return
3216 + }
3217 + if NewEnabled, err = soap.UnmarshalBoolean(response.NewEnabled); err != nil {
3218 + return
3219 + }
3220 + if NewPortMappingDescription, err = soap.UnmarshalString(response.NewPortMappingDescription); err != nil {
3221 + return
3222 + }
3223 + if NewLeaseDuration, err = soap.UnmarshalUi4(response.NewLeaseDuration); err != nil {
3224 + return
3225 + }
3226 + // END Unmarshal arguments from response.
3227 + return
3228 +}
3229 +
3230 +// Arguments:
3231 +//
3232 +// * NewRemoteHost:
3233 +//
3234 +// * NewExternalPort:
3235 +//
3236 +// * NewProtocol: allowed values: TCP, UDP
3237 +//
3238 +// * NewInternalPort: allowed value range: minimum=1, maximum=65535
3239 +//
3240 +// * NewInternalClient:
3241 +//
3242 +// * NewEnabled:
3243 +//
3244 +// * NewPortMappingDescription:
3245 +//
3246 +// * NewLeaseDuration: allowed value range: minimum=0, maximum=604800
3247 +//
3248 +//
3249 +func (client *WANIPConnection2) AddPortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32) (err error) {
3250 + // Request structure.
3251 + request := &struct {
3252 + NewRemoteHost string
3253 +
3254 + NewExternalPort string
3255 +
3256 + NewProtocol string
3257 +
3258 + NewInternalPort string
3259 +
3260 + NewInternalClient string
3261 +
3262 + NewEnabled string
3263 +
3264 + NewPortMappingDescription string
3265 +
3266 + NewLeaseDuration string
3267 + }{}
3268 + // BEGIN Marshal arguments into request.
3269 +
3270 + if request.NewRemoteHost, err = soap.MarshalString(NewRemoteHost); err != nil {
3271 + return
3272 + }
3273 + if request.NewExternalPort, err = soap.MarshalUi2(NewExternalPort); err != nil {
3274 + return
3275 + }
3276 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
3277 + return
3278 + }
3279 + if request.NewInternalPort, err = soap.MarshalUi2(NewInternalPort); err != nil {
3280 + return
3281 + }
3282 + if request.NewInternalClient, err = soap.MarshalString(NewInternalClient); err != nil {
3283 + return
3284 + }
3285 + if request.NewEnabled, err = soap.MarshalBoolean(NewEnabled); err != nil {
3286 + return
3287 + }
3288 + if request.NewPortMappingDescription, err = soap.MarshalString(NewPortMappingDescription); err != nil {
3289 + return
3290 + }
3291 + if request.NewLeaseDuration, err = soap.MarshalUi4(NewLeaseDuration); err != nil {
3292 + return
3293 + }
3294 + // END Marshal arguments into request.
3295 +
3296 + // Response structure.
3297 + response := interface{}(nil)
3298 +
3299 + // Perform the SOAP call.
3300 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "AddPortMapping", request, response); err != nil {
3301 + return
3302 + }
3303 +
3304 + // BEGIN Unmarshal arguments from response.
3305 +
3306 + // END Unmarshal arguments from response.
3307 + return
3308 +}
3309 +
3310 +// Arguments:
3311 +//
3312 +// * NewRemoteHost:
3313 +//
3314 +// * NewExternalPort:
3315 +//
3316 +// * NewProtocol: allowed values: TCP, UDP
3317 +//
3318 +//
3319 +func (client *WANIPConnection2) DeletePortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (err error) {
3320 + // Request structure.
3321 + request := &struct {
3322 + NewRemoteHost string
3323 +
3324 + NewExternalPort string
3325 +
3326 + NewProtocol string
3327 + }{}
3328 + // BEGIN Marshal arguments into request.
3329 +
3330 + if request.NewRemoteHost, err = soap.MarshalString(NewRemoteHost); err != nil {
3331 + return
3332 + }
3333 + if request.NewExternalPort, err = soap.MarshalUi2(NewExternalPort); err != nil {
3334 + return
3335 + }
3336 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
3337 + return
3338 + }
3339 + // END Marshal arguments into request.
3340 +
3341 + // Response structure.
3342 + response := interface{}(nil)
3343 +
3344 + // Perform the SOAP call.
3345 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "DeletePortMapping", request, response); err != nil {
3346 + return
3347 + }
3348 +
3349 + // BEGIN Unmarshal arguments from response.
3350 +
3351 + // END Unmarshal arguments from response.
3352 + return
3353 +}
3354 +
3355 +// Arguments:
3356 +//
3357 +// * NewStartPort:
3358 +//
3359 +// * NewEndPort:
3360 +//
3361 +// * NewProtocol: allowed values: TCP, UDP
3362 +//
3363 +// * NewManage:
3364 +//
3365 +//
3366 +func (client *WANIPConnection2) DeletePortMappingRange(NewStartPort uint16, NewEndPort uint16, NewProtocol string, NewManage bool) (err error) {
3367 + // Request structure.
3368 + request := &struct {
3369 + NewStartPort string
3370 +
3371 + NewEndPort string
3372 +
3373 + NewProtocol string
3374 +
3375 + NewManage string
3376 + }{}
3377 + // BEGIN Marshal arguments into request.
3378 +
3379 + if request.NewStartPort, err = soap.MarshalUi2(NewStartPort); err != nil {
3380 + return
3381 + }
3382 + if request.NewEndPort, err = soap.MarshalUi2(NewEndPort); err != nil {
3383 + return
3384 + }
3385 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
3386 + return
3387 + }
3388 + if request.NewManage, err = soap.MarshalBoolean(NewManage); err != nil {
3389 + return
3390 + }
3391 + // END Marshal arguments into request.
3392 +
3393 + // Response structure.
3394 + response := interface{}(nil)
3395 +
3396 + // Perform the SOAP call.
3397 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "DeletePortMappingRange", request, response); err != nil {
3398 + return
3399 + }
3400 +
3401 + // BEGIN Unmarshal arguments from response.
3402 +
3403 + // END Unmarshal arguments from response.
3404 + return
3405 +}
3406 +
3407 +//
3408 +//
3409 +// Return values:
3410 +//
3411 +// * NewExternalIPAddress:
3412 +func (client *WANIPConnection2) GetExternalIPAddress() (NewExternalIPAddress string, err error) {
3413 + // Request structure.
3414 + request := interface{}(nil)
3415 + // BEGIN Marshal arguments into request.
3416 +
3417 + // END Marshal arguments into request.
3418 +
3419 + // Response structure.
3420 + response := &struct {
3421 + NewExternalIPAddress string
3422 + }{}
3423 +
3424 + // Perform the SOAP call.
3425 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "GetExternalIPAddress", request, response); err != nil {
3426 + return
3427 + }
3428 +
3429 + // BEGIN Unmarshal arguments from response.
3430 +
3431 + if NewExternalIPAddress, err = soap.UnmarshalString(response.NewExternalIPAddress); err != nil {
3432 + return
3433 + }
3434 + // END Unmarshal arguments from response.
3435 + return
3436 +}
3437 +
3438 +// Arguments:
3439 +//
3440 +// * NewStartPort:
3441 +//
3442 +// * NewEndPort:
3443 +//
3444 +// * NewProtocol: allowed values: TCP, UDP
3445 +//
3446 +// * NewManage:
3447 +//
3448 +// * NewNumberOfPorts:
3449 +//
3450 +// Return values:
3451 +//
3452 +// * NewPortListing:
3453 +func (client *WANIPConnection2) GetListOfPortMappings(NewStartPort uint16, NewEndPort uint16, NewProtocol string, NewManage bool, NewNumberOfPorts uint16) (NewPortListing string, err error) {
3454 + // Request structure.
3455 + request := &struct {
3456 + NewStartPort string
3457 +
3458 + NewEndPort string
3459 +
3460 + NewProtocol string
3461 +
3462 + NewManage string
3463 +
3464 + NewNumberOfPorts string
3465 + }{}
3466 + // BEGIN Marshal arguments into request.
3467 +
3468 + if request.NewStartPort, err = soap.MarshalUi2(NewStartPort); err != nil {
3469 + return
3470 + }
3471 + if request.NewEndPort, err = soap.MarshalUi2(NewEndPort); err != nil {
3472 + return
3473 + }
3474 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
3475 + return
3476 + }
3477 + if request.NewManage, err = soap.MarshalBoolean(NewManage); err != nil {
3478 + return
3479 + }
3480 + if request.NewNumberOfPorts, err = soap.MarshalUi2(NewNumberOfPorts); err != nil {
3481 + return
3482 + }
3483 + // END Marshal arguments into request.
3484 +
3485 + // Response structure.
3486 + response := &struct {
3487 + NewPortListing string
3488 + }{}
3489 +
3490 + // Perform the SOAP call.
3491 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "GetListOfPortMappings", request, response); err != nil {
3492 + return
3493 + }
3494 +
3495 + // BEGIN Unmarshal arguments from response.
3496 +
3497 + if NewPortListing, err = soap.UnmarshalString(response.NewPortListing); err != nil {
3498 + return
3499 + }
3500 + // END Unmarshal arguments from response.
3501 + return
3502 +}
3503 +
3504 +// Arguments:
3505 +//
3506 +// * NewRemoteHost:
3507 +//
3508 +// * NewExternalPort:
3509 +//
3510 +// * NewProtocol: allowed values: TCP, UDP
3511 +//
3512 +// * NewInternalPort: allowed value range: minimum=1, maximum=65535
3513 +//
3514 +// * NewInternalClient:
3515 +//
3516 +// * NewEnabled:
3517 +//
3518 +// * NewPortMappingDescription:
3519 +//
3520 +// * NewLeaseDuration: allowed value range: minimum=0, maximum=604800
3521 +//
3522 +// Return values:
3523 +//
3524 +// * NewReservedPort:
3525 +func (client *WANIPConnection2) AddAnyPortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32) (NewReservedPort uint16, err error) {
3526 + // Request structure.
3527 + request := &struct {
3528 + NewRemoteHost string
3529 +
3530 + NewExternalPort string
3531 +
3532 + NewProtocol string
3533 +
3534 + NewInternalPort string
3535 +
3536 + NewInternalClient string
3537 +
3538 + NewEnabled string
3539 +
3540 + NewPortMappingDescription string
3541 +
3542 + NewLeaseDuration string
3543 + }{}
3544 + // BEGIN Marshal arguments into request.
3545 +
3546 + if request.NewRemoteHost, err = soap.MarshalString(NewRemoteHost); err != nil {
3547 + return
3548 + }
3549 + if request.NewExternalPort, err = soap.MarshalUi2(NewExternalPort); err != nil {
3550 + return
3551 + }
3552 + if request.NewProtocol, err = soap.MarshalString(NewProtocol); err != nil {
3553 + return
3554 + }
3555 + if request.NewInternalPort, err = soap.MarshalUi2(NewInternalPort); err != nil {
3556 + return
3557 + }
3558 + if request.NewInternalClient, err = soap.MarshalString(NewInternalClient); err != nil {
3559 + return
3560 + }
3561 + if request.NewEnabled, err = soap.MarshalBoolean(NewEnabled); err != nil {
3562 + return
3563 + }
3564 + if request.NewPortMappingDescription, err = soap.MarshalString(NewPortMappingDescription); err != nil {
3565 + return
3566 + }
3567 + if request.NewLeaseDuration, err = soap.MarshalUi4(NewLeaseDuration); err != nil {
3568 + return
3569 + }
3570 + // END Marshal arguments into request.
3571 +
3572 + // Response structure.
3573 + response := &struct {
3574 + NewReservedPort string
3575 + }{}
3576 +
3577 + // Perform the SOAP call.
3578 + if err = client.SOAPClient.PerformAction(URN_WANIPConnection_2, "AddAnyPortMapping", request, response); err != nil {
3579 + return
3580 + }
3581 +
3582 + // BEGIN Unmarshal arguments from response.
3583 +
3584 + if NewReservedPort, err = soap.UnmarshalUi2(response.NewReservedPort); err != nil {
3585 + return
3586 + }
3587 + // END Unmarshal arguments from response.
3588 + return
3589 +}
3590 +
3591 +// WANIPv6FirewallControl1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1". See
3592 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
3593 +// are provided for informational value.
3594 +type WANIPv6FirewallControl1 struct {
3595 + goupnp.ServiceClient
3596 +}
3597 +
3598 +// NewWANIPv6FirewallControl1Clients discovers instances of the service on the network,
3599 +// and returns clients to any that are found. errors will contain an error for
3600 +// any devices that replied but which could not be queried, and err will be set
3601 +// if the discovery process failed outright.
3602 +//
3603 +// This is a typical entry calling point into this package.
3604 +func NewWANIPv6FirewallControl1Clients() (clients []*WANIPv6FirewallControl1, errors []error, err error) {
3605 + var genericClients []goupnp.ServiceClient
3606 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANIPv6FirewallControl_1); err != nil {
3607 + return
3608 + }
3609 + clients = make([]*WANIPv6FirewallControl1, len(genericClients))
3610 + for i := range genericClients {
3611 + clients[i] = &WANIPv6FirewallControl1{genericClients[i]}
3612 + }
3613 + return
3614 +}
3615 +
3616 +//
3617 +//
3618 +// Return values:
3619 +//
3620 +// * FirewallEnabled:
3621 +//
3622 +// * InboundPinholeAllowed:
3623 +func (client *WANIPv6FirewallControl1) GetFirewallStatus() (FirewallEnabled bool, InboundPinholeAllowed bool, err error) {
3624 + // Request structure.
3625 + request := interface{}(nil)
3626 + // BEGIN Marshal arguments into request.
3627 +
3628 + // END Marshal arguments into request.
3629 +
3630 + // Response structure.
3631 + response := &struct {
3632 + FirewallEnabled string
3633 +
3634 + InboundPinholeAllowed string
3635 + }{}
3636 +
3637 + // Perform the SOAP call.
3638 + if err = client.SOAPClient.PerformAction(URN_WANIPv6FirewallControl_1, "GetFirewallStatus", request, response); err != nil {
3639 + return
3640 + }
3641 +
3642 + // BEGIN Unmarshal arguments from response.
3643 +
3644 + if FirewallEnabled, err = soap.UnmarshalBoolean(response.FirewallEnabled); err != nil {
3645 + return
3646 + }
3647 + if InboundPinholeAllowed, err = soap.UnmarshalBoolean(response.InboundPinholeAllowed); err != nil {
3648 + return
3649 + }
3650 + // END Unmarshal arguments from response.
3651 + return
3652 +}
3653 +
3654 +// Arguments:
3655 +//
3656 +// * RemoteHost:
3657 +//
3658 +// * RemotePort:
3659 +//
3660 +// * InternalClient:
3661 +//
3662 +// * InternalPort:
3663 +//
3664 +// * Protocol:
3665 +//
3666 +// Return values:
3667 +//
3668 +// * OutboundPinholeTimeout:
3669 +func (client *WANIPv6FirewallControl1) GetOutboundPinholeTimeout(RemoteHost string, RemotePort uint16, InternalClient string, InternalPort uint16, Protocol uint16) (OutboundPinholeTimeout uint32, err error) {
3670 + // Request structure.
3671 + request := &struct {
3672 + RemoteHost string
3673 +
3674 + RemotePort string
3675 +
3676 + InternalClient string
3677 +
3678 + InternalPort string
3679 +
3680 + Protocol string
3681 + }{}
3682 + // BEGIN Marshal arguments into request.
3683 +
3684 + if request.RemoteHost, err = soap.MarshalString(RemoteHost); err != nil {
3685 + return
3686 + }
3687 + if request.RemotePort, err = soap.MarshalUi2(RemotePort); err != nil {
3688 + return
3689 + }
3690 + if request.InternalClient, err = soap.MarshalString(InternalClient); err != nil {
3691 + return
3692 + }
3693 + if request.InternalPort, err = soap.MarshalUi2(InternalPort); err != nil {
3694 + return
3695 + }
3696 + if request.Protocol, err = soap.MarshalUi2(Protocol); err != nil {
3697 + return
3698 + }
3699 + // END Marshal arguments into request.
3700 +
3701 + // Response structure.
3702 + response := &struct {
3703 + OutboundPinholeTimeout string
3704 + }{}
3705 +
3706 + // Perform the SOAP call.
3707 + if err = client.SOAPClient.PerformAction(URN_WANIPv6FirewallControl_1, "GetOutboundPinholeTimeout", request, response); err != nil {
3708 + return
3709 + }
3710 +
3711 + // BEGIN Unmarshal arguments from response.
3712 +
3713 + if OutboundPinholeTimeout, err = soap.UnmarshalUi4(response.OutboundPinholeTimeout); err != nil {
3714 + return
3715 + }
3716 + // END Unmarshal arguments from response.
3717 + return
3718 +}
3719 +
3720 +// Arguments:
3721 +//
3722 +// * RemoteHost:
3723 +//
3724 +// * RemotePort:
3725 +//
3726 +// * InternalClient:
3727 +//
3728 +// * InternalPort:
3729 +//
3730 +// * Protocol:
3731 +//
3732 +// * LeaseTime: allowed value range: minimum=1, maximum=86400
3733 +//
3734 +// Return values:
3735 +//
3736 +// * UniqueID:
3737 +func (client *WANIPv6FirewallControl1) AddPinhole(RemoteHost string, RemotePort uint16, InternalClient string, InternalPort uint16, Protocol uint16, LeaseTime uint32) (UniqueID uint16, err error) {
3738 + // Request structure.
3739 + request := &struct {
3740 + RemoteHost string
3741 +
3742 + RemotePort string
3743 +
3744 + InternalClient string
3745 +
3746 + InternalPort string
3747 +
3748 + Protocol string
3749 +
3750 + LeaseTime string
3751 + }{}
3752 + // BEGIN Marshal arguments into request.
3753 +
3754 + if request.RemoteHost, err = soap.MarshalString(RemoteHost); err != nil {
3755 + return
3756 + }
3757 + if request.RemotePort, err = soap.MarshalUi2(RemotePort); err != nil {
3758 + return
3759 + }
3760 + if request.InternalClient, err = soap.MarshalString(InternalClient); err != nil {
3761 + return
3762 + }
3763 + if request.InternalPort, err = soap.MarshalUi2(InternalPort); err != nil {
3764 + return
3765 + }
3766 + if request.Protocol, err = soap.MarshalUi2(Protocol); err != nil {
3767 + return
3768 + }
3769 + if request.LeaseTime, err = soap.MarshalUi4(LeaseTime); err != nil {
3770 + return
3771 + }
3772 + // END Marshal arguments into request.
3773 +
3774 + // Response structure.
3775 + response := &struct {
3776 + UniqueID string
3777 + }{}
3778 +
3779 + // Perform the SOAP call.
3780 + if err = client.SOAPClient.PerformAction(URN_WANIPv6FirewallControl_1, "AddPinhole", request, response); err != nil {
3781 + return
3782 + }
3783 +
3784 + // BEGIN Unmarshal arguments from response.
3785 +
3786 + if UniqueID, err = soap.UnmarshalUi2(response.UniqueID); err != nil {
3787 + return
3788 + }
3789 + // END Unmarshal arguments from response.
3790 + return
3791 +}
3792 +
3793 +// Arguments:
3794 +//
3795 +// * UniqueID:
3796 +//
3797 +// * NewLeaseTime: allowed value range: minimum=1, maximum=86400
3798 +//
3799 +//
3800 +func (client *WANIPv6FirewallControl1) UpdatePinhole(UniqueID uint16, NewLeaseTime uint32) (err error) {
3801 + // Request structure.
3802 + request := &struct {
3803 + UniqueID string
3804 +
3805 + NewLeaseTime string
3806 + }{}
3807 + // BEGIN Marshal arguments into request.
3808 +
3809 + if request.UniqueID, err = soap.MarshalUi2(UniqueID); err != nil {
3810 + return
3811 + }
3812 + if request.NewLeaseTime, err = soap.MarshalUi4(NewLeaseTime); err != nil {
3813 + return
3814 + }
3815 + // END Marshal arguments into request.
3816 +
3817 + // Response structure.
3818 + response := interface{}(nil)
3819 +
3820 + // Perform the SOAP call.
3821 + if err = client.SOAPClient.PerformAction(URN_WANIPv6FirewallControl_1, "UpdatePinhole", request, response); err != nil {
3822 + return
3823 + }
3824 +
3825 + // BEGIN Unmarshal arguments from response.
3826 +
3827 + // END Unmarshal arguments from response.
3828 + return
3829 +}
3830 +
3831 +// Arguments:
3832 +//
3833 +// * UniqueID:
3834 +//
3835 +//
3836 +func (client *WANIPv6FirewallControl1) DeletePinhole(UniqueID uint16) (err error) {
3837 + // Request structure.
3838 + request := &struct {
3839 + UniqueID string
3840 + }{}
3841 + // BEGIN Marshal arguments into request.
3842 +
3843 + if request.UniqueID, err = soap.MarshalUi2(UniqueID); err != nil {
3844 + return
3845 + }
3846 + // END Marshal arguments into request.
3847 +
3848 + // Response structure.
3849 + response := interface{}(nil)
3850 +
3851 + // Perform the SOAP call.
3852 + if err = client.SOAPClient.PerformAction(URN_WANIPv6FirewallControl_1, "DeletePinhole", request, response); err != nil {
3853 + return
3854 + }
3855 +
3856 + // BEGIN Unmarshal arguments from response.
3857 +
3858 + // END Unmarshal arguments from response.
3859 + return
3860 +}
3861 +
3862 +// Arguments:
3863 +//
3864 +// * UniqueID:
3865 +//
3866 +// Return values:
3867 +//
3868 +// * PinholePackets:
3869 +func (client *WANIPv6FirewallControl1) GetPinholePackets(UniqueID uint16) (PinholePackets uint32, err error) {
3870 + // Request structure.
3871 + request := &struct {
3872 + UniqueID string
3873 + }{}
3874 + // BEGIN Marshal arguments into request.
3875 +
3876 + if request.UniqueID, err = soap.MarshalUi2(UniqueID); err != nil {
3877 + return
3878 + }
3879 + // END Marshal arguments into request.
3880 +
3881 + // Response structure.
3882 + response := &struct {
3883 + PinholePackets string
3884 + }{}
3885 +
3886 + // Perform the SOAP call.
3887 + if err = client.SOAPClient.PerformAction(URN_WANIPv6FirewallControl_1, "GetPinholePackets", request, response); err != nil {
3888 + return
3889 + }
3890 +
3891 + // BEGIN Unmarshal arguments from response.
3892 +
3893 + if PinholePackets, err = soap.UnmarshalUi4(response.PinholePackets); err != nil {
3894 + return
3895 + }
3896 + // END Unmarshal arguments from response.
3897 + return
3898 +}
3899 +
3900 +// Arguments:
3901 +//
3902 +// * UniqueID:
3903 +//
3904 +// Return values:
3905 +//
3906 +// * IsWorking:
3907 +func (client *WANIPv6FirewallControl1) CheckPinholeWorking(UniqueID uint16) (IsWorking bool, err error) {
3908 + // Request structure.
3909 + request := &struct {
3910 + UniqueID string
3911 + }{}
3912 + // BEGIN Marshal arguments into request.
3913 +
3914 + if request.UniqueID, err = soap.MarshalUi2(UniqueID); err != nil {
3915 + return
3916 + }
3917 + // END Marshal arguments into request.
3918 +
3919 + // Response structure.
3920 + response := &struct {
3921 + IsWorking string
3922 + }{}
3923 +
3924 + // Perform the SOAP call.
3925 + if err = client.SOAPClient.PerformAction(URN_WANIPv6FirewallControl_1, "CheckPinholeWorking", request, response); err != nil {
3926 + return
3927 + }
3928 +
3929 + // BEGIN Unmarshal arguments from response.
3930 +
3931 + if IsWorking, err = soap.UnmarshalBoolean(response.IsWorking); err != nil {
3932 + return
3933 + }
3934 + // END Unmarshal arguments from response.
3935 + return
3936 +}
3937 +
3938 +// WANPOTSLinkConfig1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANPOTSLinkConfig:1". See
3939 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
3940 +// are provided for informational value.
3941 +type WANPOTSLinkConfig1 struct {
3942 + goupnp.ServiceClient
3943 +}
3944 +
3945 +// NewWANPOTSLinkConfig1Clients discovers instances of the service on the network,
3946 +// and returns clients to any that are found. errors will contain an error for
3947 +// any devices that replied but which could not be queried, and err will be set
3948 +// if the discovery process failed outright.
3949 +//
3950 +// This is a typical entry calling point into this package.
3951 +func NewWANPOTSLinkConfig1Clients() (clients []*WANPOTSLinkConfig1, errors []error, err error) {
3952 + var genericClients []goupnp.ServiceClient
3953 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANPOTSLinkConfig_1); err != nil {
3954 + return
3955 + }
3956 + clients = make([]*WANPOTSLinkConfig1, len(genericClients))
3957 + for i := range genericClients {
3958 + clients[i] = &WANPOTSLinkConfig1{genericClients[i]}
3959 + }
3960 + return
3961 +}
3962 +
3963 +// Arguments:
3964 +//
3965 +// * NewISPPhoneNumber:
3966 +//
3967 +// * NewISPInfo:
3968 +//
3969 +// * NewLinkType: allowed values: PPP_Dialup
3970 +//
3971 +//
3972 +func (client *WANPOTSLinkConfig1) SetISPInfo(NewISPPhoneNumber string, NewISPInfo string, NewLinkType string) (err error) {
3973 + // Request structure.
3974 + request := &struct {
3975 + NewISPPhoneNumber string
3976 +
3977 + NewISPInfo string
3978 +
3979 + NewLinkType string
3980 + }{}
3981 + // BEGIN Marshal arguments into request.
3982 +
3983 + if request.NewISPPhoneNumber, err = soap.MarshalString(NewISPPhoneNumber); err != nil {
3984 + return
3985 + }
3986 + if request.NewISPInfo, err = soap.MarshalString(NewISPInfo); err != nil {
3987 + return
3988 + }
3989 + if request.NewLinkType, err = soap.MarshalString(NewLinkType); err != nil {
3990 + return
3991 + }
3992 + // END Marshal arguments into request.
3993 +
3994 + // Response structure.
3995 + response := interface{}(nil)
3996 +
3997 + // Perform the SOAP call.
3998 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "SetISPInfo", request, response); err != nil {
3999 + return
4000 + }
4001 +
4002 + // BEGIN Unmarshal arguments from response.
4003 +
4004 + // END Unmarshal arguments from response.
4005 + return
4006 +}
4007 +
4008 +// Arguments:
4009 +//
4010 +// * NewNumberOfRetries:
4011 +//
4012 +// * NewDelayBetweenRetries:
4013 +//
4014 +//
4015 +func (client *WANPOTSLinkConfig1) SetCallRetryInfo(NewNumberOfRetries uint32, NewDelayBetweenRetries uint32) (err error) {
4016 + // Request structure.
4017 + request := &struct {
4018 + NewNumberOfRetries string
4019 +
4020 + NewDelayBetweenRetries string
4021 + }{}
4022 + // BEGIN Marshal arguments into request.
4023 +
4024 + if request.NewNumberOfRetries, err = soap.MarshalUi4(NewNumberOfRetries); err != nil {
4025 + return
4026 + }
4027 + if request.NewDelayBetweenRetries, err = soap.MarshalUi4(NewDelayBetweenRetries); err != nil {
4028 + return
4029 + }
4030 + // END Marshal arguments into request.
4031 +
4032 + // Response structure.
4033 + response := interface{}(nil)
4034 +
4035 + // Perform the SOAP call.
4036 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "SetCallRetryInfo", request, response); err != nil {
4037 + return
4038 + }
4039 +
4040 + // BEGIN Unmarshal arguments from response.
4041 +
4042 + // END Unmarshal arguments from response.
4043 + return
4044 +}
4045 +
4046 +//
4047 +//
4048 +// Return values:
4049 +//
4050 +// * NewISPPhoneNumber:
4051 +//
4052 +// * NewISPInfo:
4053 +//
4054 +// * NewLinkType: allowed values: PPP_Dialup
4055 +func (client *WANPOTSLinkConfig1) GetISPInfo() (NewISPPhoneNumber string, NewISPInfo string, NewLinkType string, err error) {
4056 + // Request structure.
4057 + request := interface{}(nil)
4058 + // BEGIN Marshal arguments into request.
4059 +
4060 + // END Marshal arguments into request.
4061 +
4062 + // Response structure.
4063 + response := &struct {
4064 + NewISPPhoneNumber string
4065 +
4066 + NewISPInfo string
4067 +
4068 + NewLinkType string
4069 + }{}
4070 +
4071 + // Perform the SOAP call.
4072 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetISPInfo", request, response); err != nil {
4073 + return
4074 + }
4075 +
4076 + // BEGIN Unmarshal arguments from response.
4077 +
4078 + if NewISPPhoneNumber, err = soap.UnmarshalString(response.NewISPPhoneNumber); err != nil {
4079 + return
4080 + }
4081 + if NewISPInfo, err = soap.UnmarshalString(response.NewISPInfo); err != nil {
4082 + return
4083 + }
4084 + if NewLinkType, err = soap.UnmarshalString(response.NewLinkType); err != nil {
4085 + return
4086 + }
4087 + // END Unmarshal arguments from response.
4088 + return
4089 +}
4090 +
4091 +//
4092 +//
4093 +// Return values:
4094 +//
4095 +// * NewNumberOfRetries:
4096 +//
4097 +// * NewDelayBetweenRetries:
4098 +func (client *WANPOTSLinkConfig1) GetCallRetryInfo() (NewNumberOfRetries uint32, NewDelayBetweenRetries uint32, err error) {
4099 + // Request structure.
4100 + request := interface{}(nil)
4101 + // BEGIN Marshal arguments into request.
4102 +
4103 + // END Marshal arguments into request.
4104 +
4105 + // Response structure.
4106 + response := &struct {
4107 + NewNumberOfRetries string
4108 +
4109 + NewDelayBetweenRetries string
4110 + }{}
4111 +
4112 + // Perform the SOAP call.
4113 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetCallRetryInfo", request, response); err != nil {
4114 + return
4115 + }
4116 +
4117 + // BEGIN Unmarshal arguments from response.
4118 +
4119 + if NewNumberOfRetries, err = soap.UnmarshalUi4(response.NewNumberOfRetries); err != nil {
4120 + return
4121 + }
4122 + if NewDelayBetweenRetries, err = soap.UnmarshalUi4(response.NewDelayBetweenRetries); err != nil {
4123 + return
4124 + }
4125 + // END Unmarshal arguments from response.
4126 + return
4127 +}
4128 +
4129 +//
4130 +//
4131 +// Return values:
4132 +//
4133 +// * NewFclass:
4134 +func (client *WANPOTSLinkConfig1) GetFclass() (NewFclass string, err error) {
4135 + // Request structure.
4136 + request := interface{}(nil)
4137 + // BEGIN Marshal arguments into request.
4138 +
4139 + // END Marshal arguments into request.
4140 +
4141 + // Response structure.
4142 + response := &struct {
4143 + NewFclass string
4144 + }{}
4145 +
4146 + // Perform the SOAP call.
4147 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetFclass", request, response); err != nil {
4148 + return
4149 + }
4150 +
4151 + // BEGIN Unmarshal arguments from response.
4152 +
4153 + if NewFclass, err = soap.UnmarshalString(response.NewFclass); err != nil {
4154 + return
4155 + }
4156 + // END Unmarshal arguments from response.
4157 + return
4158 +}
4159 +
4160 +//
4161 +//
4162 +// Return values:
4163 +//
4164 +// * NewDataModulationSupported:
4165 +func (client *WANPOTSLinkConfig1) GetDataModulationSupported() (NewDataModulationSupported string, err error) {
4166 + // Request structure.
4167 + request := interface{}(nil)
4168 + // BEGIN Marshal arguments into request.
4169 +
4170 + // END Marshal arguments into request.
4171 +
4172 + // Response structure.
4173 + response := &struct {
4174 + NewDataModulationSupported string
4175 + }{}
4176 +
4177 + // Perform the SOAP call.
4178 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetDataModulationSupported", request, response); err != nil {
4179 + return
4180 + }
4181 +
4182 + // BEGIN Unmarshal arguments from response.
4183 +
4184 + if NewDataModulationSupported, err = soap.UnmarshalString(response.NewDataModulationSupported); err != nil {
4185 + return
4186 + }
4187 + // END Unmarshal arguments from response.
4188 + return
4189 +}
4190 +
4191 +//
4192 +//
4193 +// Return values:
4194 +//
4195 +// * NewDataProtocol:
4196 +func (client *WANPOTSLinkConfig1) GetDataProtocol() (NewDataProtocol string, err error) {
4197 + // Request structure.
4198 + request := interface{}(nil)
4199 + // BEGIN Marshal arguments into request.
4200 +
4201 + // END Marshal arguments into request.
4202 +
4203 + // Response structure.
4204 + response := &struct {
4205 + NewDataProtocol string
4206 + }{}
4207 +
4208 + // Perform the SOAP call.
4209 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetDataProtocol", request, response); err != nil {
4210 + return
4211 + }
4212 +
4213 + // BEGIN Unmarshal arguments from response.
4214 +
4215 + if NewDataProtocol, err = soap.UnmarshalString(response.NewDataProtocol); err != nil {
4216 + return
4217 + }
4218 + // END Unmarshal arguments from response.
4219 + return
4220 +}
4221 +
4222 +//
4223 +//
4224 +// Return values:
4225 +//
4226 +// * NewDataCompression:
4227 +func (client *WANPOTSLinkConfig1) GetDataCompression() (NewDataCompression string, err error) {
4228 + // Request structure.
4229 + request := interface{}(nil)
4230 + // BEGIN Marshal arguments into request.
4231 +
4232 + // END Marshal arguments into request.
4233 +
4234 + // Response structure.
4235 + response := &struct {
4236 + NewDataCompression string
4237 + }{}
4238 +
4239 + // Perform the SOAP call.
4240 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetDataCompression", request, response); err != nil {
4241 + return
4242 + }
4243 +
4244 + // BEGIN Unmarshal arguments from response.
4245 +
4246 + if NewDataCompression, err = soap.UnmarshalString(response.NewDataCompression); err != nil {
4247 + return
4248 + }
4249 + // END Unmarshal arguments from response.
4250 + return
4251 +}
4252 +
4253 +//
4254 +//
4255 +// Return values:
4256 +//
4257 +// * NewPlusVTRCommandSupported:
4258 +func (client *WANPOTSLinkConfig1) GetPlusVTRCommandSupported() (NewPlusVTRCommandSupported bool, err error) {
4259 + // Request structure.
4260 + request := interface{}(nil)
4261 + // BEGIN Marshal arguments into request.
4262 +
4263 + // END Marshal arguments into request.
4264 +
4265 + // Response structure.
4266 + response := &struct {
4267 + NewPlusVTRCommandSupported string
4268 + }{}
4269 +
4270 + // Perform the SOAP call.
4271 + if err = client.SOAPClient.PerformAction(URN_WANPOTSLinkConfig_1, "GetPlusVTRCommandSupported", request, response); err != nil {
4272 + return
4273 + }
4274 +
4275 + // BEGIN Unmarshal arguments from response.
4276 +
4277 + if NewPlusVTRCommandSupported, err = soap.UnmarshalBoolean(response.NewPlusVTRCommandSupported); err != nil {
4278 + return
4279 + }
4280 + // END Unmarshal arguments from response.
4281 + return
4282 +}
4283 +
4284 +// WANPPPConnection1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:WANPPPConnection:1". See
4285 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
4286 +// are provided for informational value.
4287 +type WANPPPConnection1 struct {
4288 + goupnp.ServiceClient
4289 +}
4290 +
4291 +// NewWANPPPConnection1Clients discovers instances of the service on the network,
4292 +// and returns clients to any that are found. errors will contain an error for
4293 +// any devices that replied but which could not be queried, and err will be set
4294 +// if the discovery process failed outright.
4295 +//
4296 +// This is a typical entry calling point into this package.
4297 +func NewWANPPPConnection1Clients() (clients []*WANPPPConnection1, errors []error, err error) {
4298 + var genericClients []goupnp.ServiceClient
4299 + if genericClients, errors, err = goupnp.NewServiceClients(URN_WANPPPConnection_1); err != nil {
4300 + return
4301 + }
4302 + clients = make([]*WANPPPConnection1, len(genericClients))
4303 + for i := range genericClients {
4304 + clients[i] = &WANPPPConnection1{genericClients[i]}
4305 + }
4306 + return
4307 +}
4308 +
4309 +// Arguments:
4310 +//
4311 +// * NewConnectionType:
4312 +//
4313 +//
4314 +func (client *WANPPPConnection1) SetConnectionType(NewConnectionType string) (err error) {
4315 + // Request structure.
4316 + request := &struct {
4317 + NewConnectionType string
4318 + }{}
4319 + // BEGIN Marshal arguments into request.
4320 +
4321 + if request.NewConnectionType, err = soap.MarshalString(NewConnectionType); err != nil {
4322 + return
4323 + }
4324 + // END Marshal arguments into request.
4325 +
4326 + // Response structure.
4327 + response := interface{}(nil)
4328 +
4329 + // Perform the SOAP call.
4330 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "SetConnectionType", request, response); err != nil {
4331 + return
4332 + }
4333 +
4334 + // BEGIN Unmarshal arguments from response.
4335 +
4336 + // END Unmarshal arguments from response.
4337 + return
4338 +}
4339 +
4340 +//
4341 +//
4342 +// Return values:
4343 +//
4344 +// * NewConnectionType:
4345 +//
4346 +// * NewPossibleConnectionTypes: allowed values: Unconfigured, IP_Routed, DHCP_Spoofed, PPPoE_Bridged, PPTP_Relay, L2TP_Relay, PPPoE_Relay
4347 +func (client *WANPPPConnection1) GetConnectionTypeInfo() (NewConnectionType string, NewPossibleConnectionTypes string, err error) {
4348 + // Request structure.
4349 + request := interface{}(nil)
4350 + // BEGIN Marshal arguments into request.
4351 +
4352 + // END Marshal arguments into request.
4353 +
4354 + // Response structure.
4355 + response := &struct {
4356 + NewConnectionType string
4357 +
4358 + NewPossibleConnectionTypes string
4359 + }{}
4360 +
4361 + // Perform the SOAP call.
4362 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetConnectionTypeInfo", request, response); err != nil {
4363 + return
4364 + }
4365 +
4366 + // BEGIN Unmarshal arguments from response.
4367 +
4368 + if NewConnectionType, err = soap.UnmarshalString(response.NewConnectionType); err != nil {
4369 + return
4370 + }
4371 + if NewPossibleConnectionTypes, err = soap.UnmarshalString(response.NewPossibleConnectionTypes); err != nil {
4372 + return
4373 + }
4374 + // END Unmarshal arguments from response.
4375 + return
4376 +}
4377 +
4378 +// Arguments:
4379 +//
4380 +// * NewUserName:
4381 +//
4382 +// * NewPassword:
4383 +//
4384 +//
4385 +func (client *WANPPPConnection1) ConfigureConnection(NewUserName string, NewPassword string) (err error) {
4386 + // Request structure.
4387 + request := &struct {
4388 + NewUserName string
4389 +
4390 + NewPassword string
4391 + }{}
4392 + // BEGIN Marshal arguments into request.
4393 +
4394 + if request.NewUserName, err = soap.MarshalString(NewUserName); err != nil {
4395 + return
4396 + }
4397 + if request.NewPassword, err = soap.MarshalString(NewPassword); err != nil {
4398 + return
4399 + }
4400 + // END Marshal arguments into request.
4401 +
4402 + // Response structure.
4403 + response := interface{}(nil)
4404 +
4405 + // Perform the SOAP call.
4406 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "ConfigureConnection", request, response); err != nil {
4407 + return
4408 + }
4409 +
4410 + // BEGIN Unmarshal arguments from response.
4411 +
4412 + // END Unmarshal arguments from response.
4413 + return
4414 +}
4415 +
4416 +//
4417 +//
4418 +//
4419 +func (client *WANPPPConnection1) RequestConnection() (err error) {
4420 + // Request structure.
4421 + request := interface{}(nil)
4422 + // BEGIN Marshal arguments into request.
4423 +
4424 + // END Marshal arguments into request.
4425 +
4426 + // Response structure.
4427 + response := interface{}(nil)
4428 +
4429 + // Perform the SOAP call.
4430 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "RequestConnection", request, response); err != nil {
4431 + return
4432 + }
4433 +
4434 + // BEGIN Unmarshal arguments from response.
4435 +
4436 + // END Unmarshal arguments from response.
4437 + return
4438 +}
4439 +
4440 +//
4441 +//
4442 +//
4443 +func (client *WANPPPConnection1) RequestTermination() (err error) {
4444 + // Request structure.
4445 + request := interface{}(nil)
4446 + // BEGIN Marshal arguments into request.
4447 +
4448 + // END Marshal arguments into request.
4449 +
4450 + // Response structure.
4451 + response := interface{}(nil)
4452 +
4453 + // Perform the SOAP call.
4454 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "RequestTermination", request, response); err != nil {
4455 + return
4456 + }
4457 +
4458 + // BEGIN Unmarshal arguments from response.
4459 +
4460 + // END Unmarshal arguments from response.
4461 + return
4462 +}
4463 +
4464 +//
4465 +//
4466 +//
4467 +func (client *WANPPPConnection1) ForceTermination() (err error) {
4468 + // Request structure.
4469 + request := interface{}(nil)
4470 + // BEGIN Marshal arguments into request.
4471 +
4472 + // END Marshal arguments into request.
4473 +
4474 + // Response structure.
4475 + response := interface{}(nil)
4476 +
4477 + // Perform the SOAP call.
4478 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "ForceTermination", request, response); err != nil {
4479 + return
4480 + }
4481 +
4482 + // BEGIN Unmarshal arguments from response.
4483 +
4484 + // END Unmarshal arguments from response.
4485 + return
4486 +}
4487 +
4488 +// Arguments:
4489 +//
4490 +// * NewAutoDisconnectTime:
4491 +//
4492 +//
4493 +func (client *WANPPPConnection1) SetAutoDisconnectTime(NewAutoDisconnectTime uint32) (err error) {
4494 + // Request structure.
4495 + request := &struct {
4496 + NewAutoDisconnectTime string
4497 + }{}
4498 + // BEGIN Marshal arguments into request.
4499 +
4500 + if request.NewAutoDisconnectTime, err = soap.MarshalUi4(NewAutoDisconnectTime); err != nil {
4501 + return
4502 + }
4503 + // END Marshal arguments into request.
4504 +
4505 + // Response structure.
4506 + response := interface{}(nil)
4507 +
4508 + // Perform the SOAP call.
4509 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "SetAutoDisconnectTime", request, response); err != nil {
4510 + return
4511 + }
4512 +
4513 + // BEGIN Unmarshal arguments from response.
4514 +
4515 + // END Unmarshal arguments from response.
4516 + return
4517 +}
4518 +
4519 +// Arguments:
4520 +//
4521 +// * NewIdleDisconnectTime:
4522 +//
4523 +//
4524 +func (client *WANPPPConnection1) SetIdleDisconnectTime(NewIdleDisconnectTime uint32) (err error) {
4525 + // Request structure.
4526 + request := &struct {
4527 + NewIdleDisconnectTime string
4528 + }{}
4529 + // BEGIN Marshal arguments into request.
4530 +
4531 + if request.NewIdleDisconnectTime, err = soap.MarshalUi4(NewIdleDisconnectTime); err != nil {
4532 + return
4533 + }
4534 + // END Marshal arguments into request.
4535 +
4536 + // Response structure.
4537 + response := interface{}(nil)
4538 +
4539 + // Perform the SOAP call.
4540 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "SetIdleDisconnectTime", request, response); err != nil {
4541 + return
4542 + }
4543 +
4544 + // BEGIN Unmarshal arguments from response.
4545 +
4546 + // END Unmarshal arguments from response.
4547 + return
4548 +}
4549 +
4550 +// Arguments:
4551 +//
4552 +// * NewWarnDisconnectDelay:
4553 +//
4554 +//
4555 +func (client *WANPPPConnection1) SetWarnDisconnectDelay(NewWarnDisconnectDelay uint32) (err error) {
4556 + // Request structure.
4557 + request := &struct {
4558 + NewWarnDisconnectDelay string
4559 + }{}
4560 + // BEGIN Marshal arguments into request.
4561 +
4562 + if request.NewWarnDisconnectDelay, err = soap.MarshalUi4(NewWarnDisconnectDelay); err != nil {
4563 + return
4564 + }
4565 + // END Marshal arguments into request.
4566 +
4567 + // Response structure.
4568 + response := interface{}(nil)
4569 +
4570 + // Perform the SOAP call.
4571 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "SetWarnDisconnectDelay", request, response); err != nil {
4572 + return
4573 + }
4574 +
4575 + // BEGIN Unmarshal arguments from response.
4576 +
4577 + // END Unmarshal arguments from response.
4578 + return
4579 +}
4580 +
4581 +//
4582 +//
4583 +// Return values:
4584 +//
4585 +// * NewConnectionStatus: allowed values: Unconfigured, Connected, Disconnected
4586 +//
4587 +// * NewLastConnectionError: allowed values: ERROR_NONE
4588 +//
4589 +// * NewUptime:
4590 +func (client *WANPPPConnection1) GetStatusInfo() (NewConnectionStatus string, NewLastConnectionError string, NewUptime uint32, err error) {
4591 + // Request structure.
4592 + request := interface{}(nil)
4593 + // BEGIN Marshal arguments into request.
4594 +
4595 + // END Marshal arguments into request.
4596 +
4597 + // Response structure.
4598 + response := &struct {
4599 + NewConnectionStatus string
4600 +
4601 + NewLastConnectionError string
4602 +
4603 + NewUptime string
4604 + }{}
4605 +
4606 + // Perform the SOAP call.
4607 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetStatusInfo", request, response); err != nil {
4608 + return
4609 + }
4610 +
4611 + // BEGIN Unmarshal arguments from response.
4612 +
4613 + if NewConnectionStatus, err = soap.UnmarshalString(response.NewConnectionStatus); err != nil {
4614 + return
4615 + }
4616 + if NewLastConnectionError, err = soap.UnmarshalString(response.NewLastConnectionError); err != nil {
4617 + return
4618 + }
4619 + if NewUptime, err = soap.UnmarshalUi4(response.NewUptime); err != nil {
4620 + return
4621 + }
4622 + // END Unmarshal arguments from response.
4623 + return
4624 +}
4625 +
4626 +//
4627 +//
4628 +// Return values:
4629 +//
4630 +// * NewUpstreamMaxBitRate:
4631 +//
4632 +// * NewDownstreamMaxBitRate:
4633 +func (client *WANPPPConnection1) GetLinkLayerMaxBitRates() (NewUpstreamMaxBitRate uint32, NewDownstreamMaxBitRate uint32, err error) {
4634 + // Request structure.
4635 + request := interface{}(nil)
4636 + // BEGIN Marshal arguments into request.
4637 +
4638 + // END Marshal arguments into request.
4639 +
4640 + // Response structure.
4641 + response := &struct {
4642 + NewUpstreamMaxBitRate string
4643 +
4644 + NewDownstreamMaxBitRate string
4645 + }{}
4646 +
4647 + // Perform the SOAP call.
4648 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetLinkLayerMaxBitRates", request, response); err != nil {
4649 + return
4650 + }
4651 +
4652 + // BEGIN Unmarshal arguments from response.
4653 +
4654 + if NewUpstreamMaxBitRate, err = soap.UnmarshalUi4(response.NewUpstreamMaxBitRate); err != nil {
4655 + return
4656 + }
4657 + if NewDownstreamMaxBitRate, err = soap.UnmarshalUi4(response.NewDownstreamMaxBitRate); err != nil {
4658 + return
4659 + }
4660 + // END Unmarshal arguments from response.
4661 + return
4662 +}
4663 +
4664 +//
4665 +//
4666 +// Return values:
4667 +//
4668 +// * NewPPPEncryptionProtocol:
4669 +func (client *WANPPPConnection1) GetPPPEncryptionProtocol() (NewPPPEncryptionProtocol string, err error) {
4670 + // Request structure.
4671 + request := interface{}(nil)
4672 + // BEGIN Marshal arguments into request.
4673 +
4674 + // END Marshal arguments into request.
4675 +
4676 + // Response structure.
4677 + response := &struct {
4678 + NewPPPEncryptionProtocol string
4679 + }{}
4680 +
4681 + // Perform the SOAP call.
4682 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetPPPEncryptionProtocol", request, response); err != nil {
4683 + return
4684 + }
4685 +
4686 + // BEGIN Unmarshal arguments from response.
4687 +
4688 + if NewPPPEncryptionProtocol, err = soap.UnmarshalString(response.NewPPPEncryptionProtocol); err != nil {
4689 + return
4690 + }
4691 + // END Unmarshal arguments from response.
4692 + return
4693 +}
4694 +
4695 +//
4696 +//
4697 +// Return values:
4698 +//
4699 +// * NewPPPCompressionProtocol:
4700 +func (client *WANPPPConnection1) GetPPPCompressionProtocol() (NewPPPCompressionProtocol string, err error) {
4701 + // Request structure.
4702 + request := interface{}(nil)
4703 + // BEGIN Marshal arguments into request.
4704 +
4705 + // END Marshal arguments into request.
4706 +
4707 + // Response structure.
4708 + response := &struct {
4709 + NewPPPCompressionProtocol string
4710 + }{}
4711 +
4712 + // Perform the SOAP call.
4713 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetPPPCompressionProtocol", request, response); err != nil {
4714 + return
4715 + }
4716 +
4717 + // BEGIN Unmarshal arguments from response.
4718 +
4719 + if NewPPPCompressionProtocol, err = soap.UnmarshalString(response.NewPPPCompressionProtocol); err != nil {
4720 + return
4721 + }
4722 + // END Unmarshal arguments from response.
4723 + return
4724 +}
4725 +
4726 +//
4727 +//
4728 +// Return values:
4729 +//
4730 +// * NewPPPAuthenticationProtocol:
4731 +func (client *WANPPPConnection1) GetPPPAuthenticationProtocol() (NewPPPAuthenticationProtocol string, err error) {
4732 + // Request structure.
4733 + request := interface{}(nil)
4734 + // BEGIN Marshal arguments into request.
4735 +
4736 + // END Marshal arguments into request.
4737 +
4738 + // Response structure.
4739 + response := &struct {
4740 + NewPPPAuthenticationProtocol string
4741 + }{}
4742 +
4743 + // Perform the SOAP call.
4744 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetPPPAuthenticationProtocol", request, response); err != nil {
4745 + return
4746 + }
4747 +
4748 + // BEGIN Unmarshal arguments from response.
4749 +
4750 + if NewPPPAuthenticationProtocol, err = soap.UnmarshalString(response.NewPPPAuthenticationProtocol); err != nil {
4751 + return
4752 + }
4753 + // END Unmarshal arguments from response.
4754 + return
4755 +}
4756 +
4757 +//
4758 +//
4759 +// Return values:
4760 +//
4761 +// * NewUserName:
4762 +func (client *WANPPPConnection1) GetUserName() (NewUserName string, err error) {
4763 + // Request structure.
4764 + request := interface{}(nil)
4765 + // BEGIN Marshal arguments into request.
4766 +
4767 + // END Marshal arguments into request.
4768 +
4769 + // Response structure.
4770 + response := &struct {
4771 + NewUserName string
4772 + }{}
4773 +
4774 + // Perform the SOAP call.
4775 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetUserName", request, response); err != nil {
4776 + return
4777 + }
4778 +
4779 + // BEGIN Unmarshal arguments from response.
4780 +
4781 + if NewUserName, err = soap.UnmarshalString(response.NewUserName); err != nil {
4782 + return
4783 + }
4784 + // END Unmarshal arguments from response.
4785 + return
4786 +}
4787 +
4788 +//
4789 +//
4790 +// Return values:
4791 +//
4792 +// * NewPassword:
4793 +func (client *WANPPPConnection1) GetPassword() (NewPassword string, err error) {
4794 + // Request structure.
4795 + request := interface{}(nil)
4796 + // BEGIN Marshal arguments into request.
4797 +
4798 + // END Marshal arguments into request.
4799 +
4800 + // Response structure.
4801 + response := &struct {
4802 + NewPassword string
4803 + }{}
4804 +
4805 + // Perform the SOAP call.
4806 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetPassword", request, response); err != nil {
4807 + return
4808 + }
4809 +
4810 + // BEGIN Unmarshal arguments from response.
4811 +
4812 + if NewPassword, err = soap.UnmarshalString(response.NewPassword); err != nil {
4813 + return
4814 + }
4815 + // END Unmarshal arguments from response.
4816 + return
4817 +}
4818 +
4819 +//
4820 +//
4821 +// Return values:
4822 +//
4823 +// * NewAutoDisconnectTime:
4824 +func (client *WANPPPConnection1) GetAutoDisconnectTime() (NewAutoDisconnectTime uint32, err error) {
4825 + // Request structure.
4826 + request := interface{}(nil)
4827 + // BEGIN Marshal arguments into request.
4828 +
4829 + // END Marshal arguments into request.
4830 +
4831 + // Response structure.
4832 + response := &struct {
4833 + NewAutoDisconnectTime string
4834 + }{}
4835 +
4836 + // Perform the SOAP call.
4837 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetAutoDisconnectTime", request, response); err != nil {
4838 + return
4839 + }
4840 +
4841 + // BEGIN Unmarshal arguments from response.
4842 +
4843 + if NewAutoDisconnectTime, err = soap.UnmarshalUi4(response.NewAutoDisconnectTime); err != nil {
4844 + return
4845 + }
4846 + // END Unmarshal arguments from response.
4847 + return
4848 +}
4849 +
4850 +//
4851 +//
4852 +// Return values:
4853 +//
4854 +// * NewIdleDisconnectTime:
4855 +func (client *WANPPPConnection1) GetIdleDisconnectTime() (NewIdleDisconnectTime uint32, err error) {
4856 + // Request structure.
4857 + request := interface{}(nil)
4858 + // BEGIN Marshal arguments into request.
4859 +
4860 + // END Marshal arguments into request.
4861 +
4862 + // Response structure.
4863 + response := &struct {
4864 + NewIdleDisconnectTime string
4865 + }{}
4866 +
4867 + // Perform the SOAP call.
4868 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetIdleDisconnectTime", request, response); err != nil {
4869 + return
4870 + }
4871 +
4872 + // BEGIN Unmarshal arguments from response.
4873 +
4874 + if NewIdleDisconnectTime, err = soap.UnmarshalUi4(response.NewIdleDisconnectTime); err != nil {
4875 + return
4876 + }
4877 + // END Unmarshal arguments from response.
4878 + return
4879 +}
4880 +
4881 +//
4882 +//
4883 +// Return values:
4884 +//
4885 +// * NewWarnDisconnectDelay:
4886 +func (client *WANPPPConnection1) GetWarnDisconnectDelay() (NewWarnDisconnectDelay uint32, err error) {
4887 + // Request structure.
4888 + request := interface{}(nil)
4889 + // BEGIN Marshal arguments into request.
4890 +
4891 + // END Marshal arguments into request.
4892 +
4893 + // Response structure.
4894 + response := &struct {
4895 + NewWarnDisconnectDelay string
4896 + }{}
4897 +
4898 + // Perform the SOAP call.
4899 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetWarnDisconnectDelay", request, response); err != nil {
4900 + return
4901 + }
4902 +
4903 + // BEGIN Unmarshal arguments from response.
4904 +
4905 + if NewWarnDisconnectDelay, err = soap.UnmarshalUi4(response.NewWarnDisconnectDelay); err != nil {
4906 + return
4907 + }
4908 + // END Unmarshal arguments from response.
4909 + return
4910 +}
4911 +
4912 +//
4913 +//
4914 +// Return values:
4915 +//
4916 +// * NewRSIPAvailable:
4917 +//
4918 +// * NewNATEnabled:
4919 +func (client *WANPPPConnection1) GetNATRSIPStatus() (NewRSIPAvailable bool, NewNATEnabled bool, err error) {
4920 + // Request structure.
4921 + request := interface{}(nil)
4922 + // BEGIN Marshal arguments into request.
4923 +
4924 + // END Marshal arguments into request.
4925 +
4926 + // Response structure.
4927 + response := &struct {
4928 + NewRSIPAvailable string
4929 +
4930 + NewNATEnabled string
4931 + }{}
4932 +
4933 + // Perform the SOAP call.
4934 + if err = client.SOAPClient.PerformAction(URN_WANPPPConnection_1, "GetNATRSIPStatus", request, response); err != nil {
4935 + return
4936 + }
4937 +
4938 + // BEGIN Unmarshal arguments from response.
4939 +
4940 + if NewRSIPAvailable, err = soap.UnmarshalBoolean(response.NewRSIPAvailable); err != nil {
4941 + return
4942 + }
4943 + if NewNATEnabled, err = soap.UnmarshalBoolean(response.NewNATEnabled); err != nil {
4944 + return
4945 + }
4946 + // END Unmarshal arguments from response.
4947 + return
4948 +}
4949 +
4950 +// Arguments:
4951 +//
4952 +// * NewPortMappingIndex:
4953 +//
4954 +// Return values:
4955 +//
4956 +// * NewRemoteHost:
4957 +//
4958 +// * NewExternalPort:
4959 +//
4960 +// * NewProtocol: allowed values: TCP, UDP
4961 +//
4962 +// * NewInternalPort:
4963 +//
4964 +// * NewInternalClient:
4965 +//
4966 +// * NewEnabled:
4967 +//
4968 +// * NewPortMappingDescription:
4969 +//
4970 +// * NewLeaseDuration:
4971 +func (client *WANPPPConnection1) GetGenericPortMappingEntry(NewPortMappingIndex uint16) (NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
4972 + // Request structure.
4973 + request := &struct {
4974 + NewPortMappingIndex string
4975 + }{}
4976 + // BEGIN Marshal arguments into request.
4977 +
4978 + if request.NewPortMappingIndex, err = soap.MarshalUi2(NewPortMappingIndex); err != nil {
4979 + return
4980 + }
4981 + // END Marshal arguments into request.
4982 +
4983 + // Response structure.
4984 + response := &struct {
4985 + NewRemoteHost string
4986 +
4987 + NewExternalPort string
4988 +
4989 + NewProtocol string
4990 +
4991 + NewInternalPort string
4992 +
4993 + NewInternalClient string
4994 +
4995 + NewEnabled string
4996 +
4997 + NewPortMappingDescription string
4998 +
4999 + NewLeaseDuration string

This file is too large to show in full.

Godeps/_workspace/src/github.com/huin/goupnp/device.go new
+184
@@ -0,0 +1,184 @@
1 +// This file contains XML structures for communicating with UPnP devices.
2 +
3 +package goupnp
4 +
5 +import (
6 + "encoding/xml"
7 + "errors"
8 + "fmt"
9 + "net/url"
10 +
11 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/scpd"
12 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/soap"
13 +)
14 +
15 +const (
16 + DeviceXMLNamespace = "urn:schemas-upnp-org:device-1-0"
17 +)
18 +
19 +// RootDevice is the device description as described by section 2.3 "Device
20 +// description" in
21 +// http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf
22 +type RootDevice struct {
23 + XMLName xml.Name `xml:"root"`
24 + SpecVersion SpecVersion `xml:"specVersion"`
25 + URLBase url.URL `xml:"-"`
26 + URLBaseStr string `xml:"URLBase"`
27 + Device Device `xml:"device"`
28 +}
29 +
30 +// SetURLBase sets the URLBase for the RootDevice and its underlying components.
31 +func (root *RootDevice) SetURLBase(urlBase *url.URL) {
32 + root.URLBase = *urlBase
33 + root.URLBaseStr = urlBase.String()
34 + root.Device.SetURLBase(urlBase)
35 +}
36 +
37 +// SpecVersion is part of a RootDevice, describes the version of the
38 +// specification that the data adheres to.
39 +type SpecVersion struct {
40 + Major int32 `xml:"major"`
41 + Minor int32 `xml:"minor"`
42 +}
43 +
44 +// Device is a UPnP device. It can have child devices.
45 +type Device struct {
46 + DeviceType string `xml:"deviceType"`
47 + FriendlyName string `xml:"friendlyName"`
48 + Manufacturer string `xml:"manufacturer"`
49 + ManufacturerURL URLField `xml:"manufacturerURL"`
50 + ModelDescription string `xml:"modelDescription"`
51 + ModelName string `xml:"modelName"`
52 + ModelNumber string `xml:"modelNumber"`
53 + ModelURL URLField `xml:"modelURL"`
54 + SerialNumber string `xml:"serialNumber"`
55 + UDN string `xml:"UDN"`
56 + UPC string `xml:"UPC,omitempty"`
57 + Icons []Icon `xml:"iconList>icon,omitempty"`
58 + Services []Service `xml:"serviceList>service,omitempty"`
59 + Devices []Device `xml:"deviceList>device,omitempty"`
60 +
61 + // Extra observed elements:
62 + PresentationURL URLField `xml:"presentationURL"`
63 +}
64 +
65 +// VisitDevices calls visitor for the device, and all its descendent devices.
66 +func (device *Device) VisitDevices(visitor func(*Device)) {
67 + visitor(device)
68 + for i := range device.Devices {
69 + device.Devices[i].VisitDevices(visitor)
70 + }
71 +}
72 +
73 +// VisitServices calls visitor for all Services under the device and all its
74 +// descendent devices.
75 +func (device *Device) VisitServices(visitor func(*Service)) {
76 + device.VisitDevices(func(d *Device) {
77 + for i := range d.Services {
78 + visitor(&d.Services[i])
79 + }
80 + })
81 +}
82 +
83 +// FindService finds all (if any) Services under the device and its descendents
84 +// that have the given ServiceType.
85 +func (device *Device) FindService(serviceType string) []*Service {
86 + var services []*Service
87 + device.VisitServices(func(s *Service) {
88 + if s.ServiceType == serviceType {
89 + services = append(services, s)
90 + }
91 + })
92 + return services
93 +}
94 +
95 +// SetURLBase sets the URLBase for the Device and its underlying components.
96 +func (device *Device) SetURLBase(urlBase *url.URL) {
97 + device.ManufacturerURL.SetURLBase(urlBase)
98 + device.ModelURL.SetURLBase(urlBase)
99 + device.PresentationURL.SetURLBase(urlBase)
100 + for i := range device.Icons {
101 + device.Icons[i].SetURLBase(urlBase)
102 + }
103 + for i := range device.Services {
104 + device.Services[i].SetURLBase(urlBase)
105 + }
106 + for i := range device.Devices {
107 + device.Devices[i].SetURLBase(urlBase)
108 + }
109 +}
110 +
111 +func (device *Device) String() string {
112 + return fmt.Sprintf("Device ID %s : %s (%s)", device.UDN, device.DeviceType, device.FriendlyName)
113 +}
114 +
115 +// Icon is a representative image that a device might include in its
116 +// description.
117 +type Icon struct {
118 + Mimetype string `xml:"mimetype"`
119 + Width int32 `xml:"width"`
120 + Height int32 `xml:"height"`
121 + Depth int32 `xml:"depth"`
122 + URL URLField `xml:"url"`
123 +}
124 +
125 +// SetURLBase sets the URLBase for the Icon.
126 +func (icon *Icon) SetURLBase(url *url.URL) {
127 + icon.URL.SetURLBase(url)
128 +}
129 +
130 +// Service is a service provided by a UPnP Device.
131 +type Service struct {
132 + ServiceType string `xml:"serviceType"`
133 + ServiceId string `xml:"serviceId"`
134 + SCPDURL URLField `xml:"SCPDURL"`
135 + ControlURL URLField `xml:"controlURL"`
136 + EventSubURL URLField `xml:"eventSubURL"`
137 +}
138 +
139 +// SetURLBase sets the URLBase for the Service.
140 +func (srv *Service) SetURLBase(urlBase *url.URL) {
141 + srv.SCPDURL.SetURLBase(urlBase)
142 + srv.ControlURL.SetURLBase(urlBase)
143 + srv.EventSubURL.SetURLBase(urlBase)
144 +}
145 +
146 +func (srv *Service) String() string {
147 + return fmt.Sprintf("Service ID %s : %s", srv.ServiceId, srv.ServiceType)
148 +}
149 +
150 +// RequestSCDP requests the SCPD (soap actions and state variables description)
151 +// for the service.
152 +func (srv *Service) RequestSCDP() (*scpd.SCPD, error) {
153 + if !srv.SCPDURL.Ok {
154 + return nil, errors.New("bad/missing SCPD URL, or no URLBase has been set")
155 + }
156 + s := new(scpd.SCPD)
157 + if err := requestXml(srv.SCPDURL.URL.String(), scpd.SCPDXMLNamespace, s); err != nil {
158 + return nil, err
159 + }
160 + return s, nil
161 +}
162 +
163 +func (srv *Service) NewSOAPClient() *soap.SOAPClient {
164 + return soap.NewSOAPClient(srv.ControlURL.URL)
165 +}
166 +
167 +// URLField is a URL that is part of a device description.
168 +type URLField struct {
169 + URL url.URL `xml:"-"`
170 + Ok bool `xml:"-"`
171 + Str string `xml:",chardata"`
172 +}
173 +
174 +func (uf *URLField) SetURLBase(urlBase *url.URL) {
175 + refUrl, err := url.Parse(uf.Str)
176 + if err != nil {
177 + uf.URL = url.URL{}
178 + uf.Ok = false
179 + return
180 + }
181 +
182 + uf.URL = *urlBase.ResolveReference(refUrl)
183 + uf.Ok = true
184 +}
Godeps/_workspace/src/github.com/huin/goupnp/example/example.go new
+6
@@ -0,0 +1,6 @@
1 +// Serves as examples of using the goupnp library.
2 +//
3 +// To run examples and see the output for your local network, run the following
4 +// command (specifically including the -v flag):
5 +// go test -v github.com/huin/goupnp/example
6 +package example
Godeps/_workspace/src/github.com/huin/goupnp/example/example_test.go new
+62
@@ -0,0 +1,62 @@
1 +package example_test
2 +
3 +import (
4 + "fmt"
5 + "os"
6 +
7 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp"
8 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway1"
9 +)
10 +
11 +// Use discovered WANPPPConnection1 services to find external IP addresses.
12 +func Example_WANPPPConnection1_GetExternalIPAddress() {
13 + clients, errors, err := internetgateway1.NewWANPPPConnection1Clients()
14 + extIPClients := make([]GetExternalIPAddresser, len(clients))
15 + for i, client := range clients {
16 + extIPClients[i] = client
17 + }
18 + DisplayExternalIPResults(extIPClients, errors, err)
19 + // Output:
20 +}
21 +
22 +// Use discovered WANIPConnection services to find external IP addresses.
23 +func Example_WANIPConnection_GetExternalIPAddress() {
24 + clients, errors, err := internetgateway1.NewWANIPConnection1Clients()
25 + extIPClients := make([]GetExternalIPAddresser, len(clients))
26 + for i, client := range clients {
27 + extIPClients[i] = client
28 + }
29 + DisplayExternalIPResults(extIPClients, errors, err)
30 + // Output:
31 +}
32 +
33 +type GetExternalIPAddresser interface {
34 + GetExternalIPAddress() (NewExternalIPAddress string, err error)
35 + GetServiceClient() *goupnp.ServiceClient
36 +}
37 +
38 +func DisplayExternalIPResults(clients []GetExternalIPAddresser, errors []error, err error) {
39 + if err != nil {
40 + fmt.Fprintln(os.Stderr, "Error discovering service with UPnP: ", err)
41 + return
42 + }
43 +
44 + if len(errors) > 0 {
45 + fmt.Fprintf(os.Stderr, "Error discovering %d services:\n", len(errors))
46 + for _, err := range errors {
47 + fmt.Println(" ", err)
48 + }
49 + }
50 +
51 + fmt.Fprintf(os.Stderr, "Successfully discovered %d services:\n", len(clients))
52 + for _, client := range clients {
53 + device := &client.GetServiceClient().RootDevice.Device
54 +
55 + fmt.Fprintln(os.Stderr, " Device:", device.FriendlyName)
56 + if addr, err := client.GetExternalIPAddress(); err != nil {
57 + fmt.Fprintf(os.Stderr, " Failed to get external IP address: %v\n", err)
58 + } else {
59 + fmt.Fprintf(os.Stderr, " External IP address: %v\n", addr)
60 + }
61 + }
62 +}
Godeps/_workspace/src/github.com/huin/goupnp/gotasks/specgen_task.go new
+539
@@ -0,0 +1,539 @@
1 +// +build gotask
2 +
3 +package gotasks
4 +
5 +import (
6 + "archive/zip"
7 + "bytes"
8 + "encoding/xml"
9 + "fmt"
10 + "io"
11 + "io/ioutil"
12 + "log"
13 + "os"
14 + "path"
15 + "path/filepath"
16 + "regexp"
17 + "strings"
18 + "text/template"
19 +
20 + "github.com/huin/goutil/codegen"
21 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp"
22 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/scpd"
23 + "github.com/jingweno/gotask/tasking"
24 +)
25 +
26 +var (
27 + deviceURNPrefix = "urn:schemas-upnp-org:device:"
28 + serviceURNPrefix = "urn:schemas-upnp-org:service:"
29 +)
30 +
31 +// NAME
32 +// specgen - generates Go code from the UPnP specification files.
33 +//
34 +// DESCRIPTION
35 +// The specification is available for download from:
36 +//
37 +// OPTIONS
38 +// -s, --spec_filename=<upnpresources.zip>
39 +// Path to the specification file, available from http://upnp.org/resources/upnpresources.zip
40 +// -o, --out_dir=<output directory>
41 +// Path to the output directory. This is is where the DCP source files will be placed. Should normally correspond to the directory for github.com/huin/goupnp/dcps
42 +// --nogofmt
43 +// Disable passing the output through gofmt. Do this if debugging code output problems and needing to see the generated code prior to being passed through gofmt.
44 +func TaskSpecgen(t *tasking.T) {
45 + specFilename := t.Flags.String("spec-filename")
46 + if specFilename == "" {
47 + specFilename = t.Flags.String("s")
48 + }
49 + if specFilename == "" {
50 + t.Fatal("--spec_filename is required")
51 + }
52 + outDir := t.Flags.String("out-dir")
53 + if outDir == "" {
54 + outDir = t.Flags.String("o")
55 + }
56 + if outDir == "" {
57 + log.Fatal("--out_dir is required")
58 + }
59 + useGofmt := !t.Flags.Bool("nogofmt")
60 +
61 + specArchive, err := openZipfile(specFilename)
62 + if err != nil {
63 + t.Fatalf("Error opening spec file: %v", err)
64 + }
65 + defer specArchive.Close()
66 +
67 + dcpCol := newDcpsCollection()
68 + for _, f := range globFiles("standardizeddcps/*/*.zip", specArchive.Reader) {
69 + dirName := strings.TrimPrefix(f.Name, "standardizeddcps/")
70 + slashIndex := strings.Index(dirName, "/")
71 + if slashIndex == -1 {
72 + // Should not happen.
73 + t.Logf("Could not find / in %q", dirName)
74 + return
75 + }
76 + dirName = dirName[:slashIndex]
77 +
78 + dcp := dcpCol.dcpForDir(dirName)
79 + if dcp == nil {
80 + t.Logf("No alias defined for directory %q: skipping %s\n", dirName, f.Name)
81 + continue
82 + } else {
83 + t.Logf("Alias found for directory %q: processing %s\n", dirName, f.Name)
84 + }
85 +
86 + dcp.processZipFile(f)
87 + }
88 +
89 + for _, dcp := range dcpCol.dcpByAlias {
90 + if err := dcp.writePackage(outDir, useGofmt); err != nil {
91 + log.Printf("Error writing package %q: %v", dcp.Metadata.Name, err)
92 + }
93 + }
94 +}
95 +
96 +// DCP contains extra metadata to use when generating DCP source files.
97 +type DCPMetadata struct {
98 + Name string // What to name the Go DCP package.
99 + OfficialName string // Official name for the DCP.
100 + DocURL string // Optional - URL for futher documentation about the DCP.
101 +}
102 +
103 +var dcpMetadataByDir = map[string]DCPMetadata{
104 + "Internet Gateway_1": {
105 + Name: "internetgateway1",
106 + OfficialName: "Internet Gateway Device v1",
107 + DocURL: "http://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v1-Device.pdf",
108 + },
109 + "Internet Gateway_2": {
110 + Name: "internetgateway2",
111 + OfficialName: "Internet Gateway Device v2",
112 + DocURL: "http://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v2-Device.pdf",
113 + },
114 +}
115 +
116 +type dcpCollection struct {
117 + dcpByAlias map[string]*DCP
118 +}
119 +
120 +func newDcpsCollection() *dcpCollection {
121 + c := &dcpCollection{
122 + dcpByAlias: make(map[string]*DCP),
123 + }
124 + for _, metadata := range dcpMetadataByDir {
125 + c.dcpByAlias[metadata.Name] = newDCP(metadata)
126 + }
127 + return c
128 +}
129 +
130 +func (c *dcpCollection) dcpForDir(dirName string) *DCP {
131 + metadata, ok := dcpMetadataByDir[dirName]
132 + if !ok {
133 + return nil
134 + }
135 + return c.dcpByAlias[metadata.Name]
136 +}
137 +
138 +// DCP collects together information about a UPnP Device Control Protocol.
139 +type DCP struct {
140 + Metadata DCPMetadata
141 + DeviceTypes map[string]*URNParts
142 + ServiceTypes map[string]*URNParts
143 + Services []SCPDWithURN
144 +}
145 +
146 +func newDCP(metadata DCPMetadata) *DCP {
147 + return &DCP{
148 + Metadata: metadata,
149 + DeviceTypes: make(map[string]*URNParts),
150 + ServiceTypes: make(map[string]*URNParts),
151 + }
152 +}
153 +
154 +func (dcp *DCP) processZipFile(file *zip.File) {
155 + archive, err := openChildZip(file)
156 + if err != nil {
157 + log.Println("Error reading child zip file:", err)
158 + return
159 + }
160 + for _, deviceFile := range globFiles("*/device/*.xml", archive) {
161 + dcp.processDeviceFile(deviceFile)
162 + }
163 + for _, scpdFile := range globFiles("*/service/*.xml", archive) {
164 + dcp.processSCPDFile(scpdFile)
165 + }
166 +}
167 +
168 +func (dcp *DCP) processDeviceFile(file *zip.File) {
169 + var device goupnp.Device
170 + if err := unmarshalXmlFile(file, &device); err != nil {
171 + log.Printf("Error decoding device XML from file %q: %v", file.Name, err)
172 + return
173 + }
174 + device.VisitDevices(func(d *goupnp.Device) {
175 + t := strings.TrimSpace(d.DeviceType)
176 + if t != "" {
177 + u, err := extractURNParts(t, deviceURNPrefix)
178 + if err != nil {
179 + log.Println(err)
180 + return
181 + }
182 + dcp.DeviceTypes[t] = u
183 + }
184 + })
185 + device.VisitServices(func(s *goupnp.Service) {
186 + u, err := extractURNParts(s.ServiceType, serviceURNPrefix)
187 + if err != nil {
188 + log.Println(err)
189 + return
190 + }
191 + dcp.ServiceTypes[s.ServiceType] = u
192 + })
193 +}
194 +
195 +func (dcp *DCP) writePackage(outDir string, useGofmt bool) error {
196 + packageDirname := filepath.Join(outDir, dcp.Metadata.Name)
197 + err := os.MkdirAll(packageDirname, os.ModePerm)
198 + if err != nil && !os.IsExist(err) {
199 + return err
200 + }
201 + packageFilename := filepath.Join(packageDirname, dcp.Metadata.Name+".go")
202 + packageFile, err := os.Create(packageFilename)
203 + if err != nil {
204 + return err
205 + }
206 + var output io.WriteCloser = packageFile
207 + if useGofmt {
208 + if output, err = codegen.NewGofmtWriteCloser(output); err != nil {
209 + packageFile.Close()
210 + return err
211 + }
212 + }
213 + if err = packageTmpl.Execute(output, dcp); err != nil {
214 + output.Close()
215 + return err
216 + }
217 + return output.Close()
218 +}
219 +
220 +func (dcp *DCP) processSCPDFile(file *zip.File) {
221 + scpd := new(scpd.SCPD)
222 + if err := unmarshalXmlFile(file, scpd); err != nil {
223 + log.Printf("Error decoding SCPD XML from file %q: %v", file.Name, err)
224 + return
225 + }
226 + scpd.Clean()
227 + urnParts, err := urnPartsFromSCPDFilename(file.Name)
228 + if err != nil {
229 + log.Printf("Could not recognize SCPD filename %q: %v", file.Name, err)
230 + return
231 + }
232 + dcp.Services = append(dcp.Services, SCPDWithURN{
233 + URNParts: urnParts,
234 + SCPD: scpd,
235 + })
236 +}
237 +
238 +type SCPDWithURN struct {
239 + *URNParts
240 + SCPD *scpd.SCPD
241 +}
242 +
243 +func (s *SCPDWithURN) WrapArgument(arg scpd.Argument) (*argumentWrapper, error) {
244 + relVar := s.SCPD.GetStateVariable(arg.RelatedStateVariable)
245 + if relVar == nil {
246 + return nil, fmt.Errorf("no such state variable: %q, for argument %q", arg.RelatedStateVariable, arg.Name)
247 + }
248 + cnv, ok := typeConvs[relVar.DataType.Name]
249 + if !ok {
250 + return nil, fmt.Errorf("unknown data type: %q, for state variable %q, for argument %q", relVar.DataType.Type, arg.RelatedStateVariable, arg.Name)
251 + }
252 + return &argumentWrapper{
253 + Argument: arg,
254 + relVar: relVar,
255 + conv: cnv,
256 + }, nil
257 +}
258 +
259 +type argumentWrapper struct {
260 + scpd.Argument
261 + relVar *scpd.StateVariable
262 + conv conv
263 +}
264 +
265 +func (arg *argumentWrapper) AsParameter() string {
266 + return fmt.Sprintf("%s %s", arg.Name, arg.conv.ExtType)
267 +}
268 +
269 +func (arg *argumentWrapper) Document() string {
270 + relVar := arg.relVar
271 + if rng := relVar.AllowedValueRange; rng != nil {
272 + var parts []string
273 + if rng.Minimum != "" {
274 + parts = append(parts, fmt.Sprintf("minimum=%s", rng.Minimum))
275 + }
276 + if rng.Maximum != "" {
277 + parts = append(parts, fmt.Sprintf("maximum=%s", rng.Maximum))
278 + }
279 + if rng.Step != "" {
280 + parts = append(parts, fmt.Sprintf("step=%s", rng.Step))
281 + }
282 + return "allowed value range: " + strings.Join(parts, ", ")
283 + }
284 + if len(relVar.AllowedValues) != 0 {
285 + return "allowed values: " + strings.Join(relVar.AllowedValues, ", ")
286 + }
287 + return ""
288 +}
289 +
290 +func (arg *argumentWrapper) Marshal() string {
291 + return fmt.Sprintf("soap.Marshal%s(%s)", arg.conv.FuncSuffix, arg.Name)
292 +}
293 +
294 +func (arg *argumentWrapper) Unmarshal(objVar string) string {
295 + return fmt.Sprintf("soap.Unmarshal%s(%s.%s)", arg.conv.FuncSuffix, objVar, arg.Name)
296 +}
297 +
298 +type conv struct {
299 + FuncSuffix string
300 + ExtType string
301 +}
302 +
303 +// typeConvs maps from a SOAP type (e.g "fixed.14.4") to the function name
304 +// suffix inside the soap module (e.g "Fixed14_4") and the Go type.
305 +var typeConvs = map[string]conv{
306 + "ui1": conv{"Ui1", "uint8"},
307 + "ui2": conv{"Ui2", "uint16"},
308 + "ui4": conv{"Ui4", "uint32"},
309 + "i1": conv{"I1", "int8"},
310 + "i2": conv{"I2", "int16"},
311 + "i4": conv{"I4", "int32"},
312 + "int": conv{"Int", "int64"},
313 + "r4": conv{"R4", "float32"},
314 + "r8": conv{"R8", "float64"},
315 + "number": conv{"R8", "float64"}, // Alias for r8.
316 + "fixed.14.4": conv{"Fixed14_4", "float64"},
317 + "float": conv{"R8", "float64"},
318 + "char": conv{"Char", "rune"},
319 + "string": conv{"String", "string"},
320 + "date": conv{"Date", "time.Time"},
321 + "dateTime": conv{"DateTime", "time.Time"},
322 + "dateTime.tz": conv{"DateTimeTz", "time.Time"},
323 + "time": conv{"TimeOfDay", "soap.TimeOfDay"},
324 + "time.tz": conv{"TimeOfDayTz", "soap.TimeOfDay"},
325 + "boolean": conv{"Boolean", "bool"},
326 + "bin.base64": conv{"BinBase64", "[]byte"},
327 + "bin.hex": conv{"BinHex", "[]byte"},
328 +}
329 +
330 +type closeableZipReader struct {
331 + io.Closer
332 + *zip.Reader
333 +}
334 +
335 +func openZipfile(filename string) (*closeableZipReader, error) {
336 + file, err := os.Open(filename)
337 + if err != nil {
338 + return nil, err
339 + }
340 + fi, err := file.Stat()
341 + if err != nil {
342 + return nil, err
343 + }
344 + archive, err := zip.NewReader(file, fi.Size())
345 + if err != nil {
346 + return nil, err
347 + }
348 + return &closeableZipReader{
349 + Closer: file,
350 + Reader: archive,
351 + }, nil
352 +}
353 +
354 +// openChildZip opens a zip file within another zip file.
355 +func openChildZip(file *zip.File) (*zip.Reader, error) {
356 + zipFile, err := file.Open()
357 + if err != nil {
358 + return nil, err
359 + }
360 + defer zipFile.Close()
361 +
362 + zipBytes, err := ioutil.ReadAll(zipFile)
363 + if err != nil {
364 + return nil, err
365 + }
366 +
367 + return zip.NewReader(bytes.NewReader(zipBytes), int64(len(zipBytes)))
368 +}
369 +
370 +func globFiles(pattern string, archive *zip.Reader) []*zip.File {
371 + var files []*zip.File
372 + for _, f := range archive.File {
373 + if matched, err := path.Match(pattern, f.Name); err != nil {
374 + // This shouldn't happen - all patterns are hard-coded, errors in them
375 + // are a programming error.
376 + panic(err)
377 + } else if matched {
378 + files = append(files, f)
379 + }
380 + }
381 + return files
382 +}
383 +
384 +func unmarshalXmlFile(file *zip.File, data interface{}) error {
385 + r, err := file.Open()
386 + if err != nil {
387 + return err
388 + }
389 + decoder := xml.NewDecoder(r)
390 + r.Close()
391 + return decoder.Decode(data)
392 +}
393 +
394 +type URNParts struct {
395 + URN string
396 + Name string
397 + Version string
398 +}
399 +
400 +func (u *URNParts) Const() string {
401 + return fmt.Sprintf("URN_%s_%s", u.Name, u.Version)
402 +}
403 +
404 +// extractURNParts extracts the name and version from a URN string.
405 +func extractURNParts(urn, expectedPrefix string) (*URNParts, error) {
406 + if !strings.HasPrefix(urn, expectedPrefix) {
407 + return nil, fmt.Errorf("%q does not have expected prefix %q", urn, expectedPrefix)
408 + }
409 + parts := strings.SplitN(strings.TrimPrefix(urn, expectedPrefix), ":", 2)
410 + if len(parts) != 2 {
411 + return nil, fmt.Errorf("%q does not have a name and version", urn)
412 + }
413 + name, version := parts[0], parts[1]
414 + return &URNParts{urn, name, version}, nil
415 +}
416 +
417 +var scpdFilenameRe = regexp.MustCompile(
418 + `.*/([a-zA-Z0-9]+)([0-9]+)\.xml`)
419 +
420 +func urnPartsFromSCPDFilename(filename string) (*URNParts, error) {
421 + parts := scpdFilenameRe.FindStringSubmatch(filename)
422 + if len(parts) != 3 {
423 + return nil, fmt.Errorf("SCPD filename %q does not have expected number of parts", filename)
424 + }
425 + name, version := parts[1], parts[2]
426 + return &URNParts{
427 + URN: serviceURNPrefix + name + ":" + version,
428 + Name: name,
429 + Version: version,
430 + }, nil
431 +}
432 +
433 +var packageTmpl = template.Must(template.New("package").Parse(`{{$name := .Metadata.Name}}
434 +// Client for UPnP Device Control Protocol {{.Metadata.OfficialName}}.
435 +// {{if .Metadata.DocURL}}
436 +// This DCP is documented in detail at: {{.Metadata.DocURL}}{{end}}
437 +//
438 +// Typically, use one of the New* functions to discover services on the local
439 +// network.
440 +package {{$name}}
441 +
442 +// Generated file - do not edit by hand. See README.md
443 +
444 +
445 +import (
446 + "time"
447 +
448 + "github.com/huin/goupnp"
449 + "github.com/huin/goupnp/soap"
450 +)
451 +
452 +// Hack to avoid Go complaining if time isn't used.
453 +var _ time.Time
454 +
455 +// Device URNs:
456 +const ({{range .DeviceTypes}}
457 + {{.Const}} = "{{.URN}}"{{end}}
458 +)
459 +
460 +// Service URNs:
461 +const ({{range .ServiceTypes}}
462 + {{.Const}} = "{{.URN}}"{{end}}
463 +)
464 +
465 +{{range .Services}}
466 +{{$srv := .}}
467 +{{$srvIdent := printf "%s%s" .Name .Version}}
468 +
469 +// {{$srvIdent}} is a client for UPnP SOAP service with URN "{{.URN}}". See
470 +// goupnp.ServiceClient, which contains RootDevice and Service attributes which
471 +// are provided for informational value.
472 +type {{$srvIdent}} struct {
473 + goupnp.ServiceClient
474 +}
475 +
476 +// New{{$srvIdent}}Clients discovers instances of the service on the network,
477 +// and returns clients to any that are found. errors will contain an error for
478 +// any devices that replied but which could not be queried, and err will be set
479 +// if the discovery process failed outright.
480 +//
481 +// This is a typical entry calling point into this package.
482 +func New{{$srvIdent}}Clients() (clients []*{{$srvIdent}}, errors []error, err error) {
483 + var genericClients []goupnp.ServiceClient
484 + if genericClients, errors, err = goupnp.NewServiceClients({{$srv.Const}}); err != nil {
485 + return
486 + }
487 + clients = make([]*{{$srvIdent}}, len(genericClients))
488 + for i := range genericClients {
489 + clients[i] = &{{$srvIdent}}{genericClients[i]}
490 + }
491 + return
492 +}
493 +
494 +{{range .SCPD.Actions}}{{/* loops over *SCPDWithURN values */}}
495 +
496 +{{$inargs := .InputArguments}}{{$outargs := .OutputArguments}}
497 +// {{if $inargs}}Arguments:{{range $inargs}}{{$argWrap := $srv.WrapArgument .}}
498 +//
499 +// * {{.Name}}: {{$argWrap.Document}}{{end}}{{end}}
500 +//
501 +// {{if $outargs}}Return values:{{range $outargs}}{{$argWrap := $srv.WrapArgument .}}
502 +//
503 +// * {{.Name}}: {{$argWrap.Document}}{{end}}{{end}}
504 +func (client *{{$srvIdent}}) {{.Name}}({{range $inargs}}{{/*
505 +*/}}{{$argWrap := $srv.WrapArgument .}}{{$argWrap.AsParameter}}, {{end}}{{/*
506 +*/}}) ({{range $outargs}}{{/*
507 +*/}}{{$argWrap := $srv.WrapArgument .}}{{$argWrap.AsParameter}}, {{end}} err error) {
508 + // Request structure.
509 + request := {{if $inargs}}&{{template "argstruct" $inargs}}{{"{}"}}{{else}}{{"interface{}(nil)"}}{{end}}
510 + // BEGIN Marshal arguments into request.
511 +{{range $inargs}}{{$argWrap := $srv.WrapArgument .}}
512 + if request.{{.Name}}, err = {{$argWrap.Marshal}}; err != nil {
513 + return
514 + }{{end}}
515 + // END Marshal arguments into request.
516 +
517 + // Response structure.
518 + response := {{if $outargs}}&{{template "argstruct" $outargs}}{{"{}"}}{{else}}{{"interface{}(nil)"}}{{end}}
519 +
520 + // Perform the SOAP call.
521 + if err = client.SOAPClient.PerformAction({{$srv.URNParts.Const}}, "{{.Name}}", request, response); err != nil {
522 + return
523 + }
524 +
525 + // BEGIN Unmarshal arguments from response.
526 +{{range $outargs}}{{$argWrap := $srv.WrapArgument .}}
527 + if {{.Name}}, err = {{$argWrap.Unmarshal "response"}}; err != nil {
528 + return
529 + }{{end}}
530 + // END Unmarshal arguments from response.
531 + return
532 +}
533 +{{end}}{{/* range .SCPD.Actions */}}
534 +{{end}}{{/* range .Services */}}
535 +
536 +{{define "argstruct"}}struct {{"{"}}{{range .}}
537 +{{.Name}} string
538 +{{end}}{{"}"}}{{end}}
539 +`))
Godeps/_workspace/src/github.com/huin/goupnp/goupnp.go new
+109
@@ -0,0 +1,109 @@
1 +// goupnp is an implementation of a client for various UPnP services.
2 +//
3 +// For most uses, it is recommended to use the code-generated packages under
4 +// github.com/huin/goupnp/dcps. Example use is shown at
5 +// http://godoc.org/github.com/huin/goupnp/example
6 +//
7 +// A commonly used client is internetgateway1.WANPPPConnection1:
8 +// http://godoc.org/github.com/huin/goupnp/dcps/internetgateway1#WANPPPConnection1
9 +//
10 +// Currently only a couple of schemas have code generated for them from the
11 +// UPnP example XML specifications. Not all methods will work on these clients,
12 +// because the generated stubs contain the full set of specified methods from
13 +// the XML specifications, and the discovered services will likely support a
14 +// subset of those methods.
15 +package goupnp
16 +
17 +import (
18 + "encoding/xml"
19 + "fmt"
20 + "net/http"
21 + "net/url"
22 +
23 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/httpu"
24 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/ssdp"
25 +)
26 +
27 +// ContextError is an error that wraps an error with some context information.
28 +type ContextError struct {
29 + Context string
30 + Err error
31 +}
32 +
33 +func (err ContextError) Error() string {
34 + return fmt.Sprintf("%s: %v", err.Context, err.Err)
35 +}
36 +
37 +// MaybeRootDevice contains either a RootDevice or an error.
38 +type MaybeRootDevice struct {
39 + Root *RootDevice
40 + Err error
41 +}
42 +
43 +// DiscoverDevices attempts to find targets of the given type. This is
44 +// typically the entry-point for this package. searchTarget is typically a URN
45 +// in the form "urn:schemas-upnp-org:device:..." or
46 +// "urn:schemas-upnp-org:service:...". A single error is returned for errors
47 +// while attempting to send the query. An error or RootDevice is returned for
48 +// each discovered RootDevice.
49 +func DiscoverDevices(searchTarget string) ([]MaybeRootDevice, error) {
50 + httpu, err := httpu.NewHTTPUClient()
51 + if err != nil {
52 + return nil, err
53 + }
54 + defer httpu.Close()
55 + responses, err := ssdp.SSDPRawSearch(httpu, string(searchTarget), 2, 3)
56 + if err != nil {
57 + return nil, err
58 + }
59 +
60 + results := make([]MaybeRootDevice, len(responses))
61 + for i, response := range responses {
62 + maybe := &results[i]
63 + loc, err := response.Location()
64 + if err != nil {
65 +
66 + maybe.Err = ContextError{"unexpected bad location from search", err}
67 + continue
68 + }
69 + locStr := loc.String()
70 + root := new(RootDevice)
71 + if err := requestXml(locStr, DeviceXMLNamespace, root); err != nil {
72 + maybe.Err = ContextError{fmt.Sprintf("error requesting root device details from %q", locStr), err}
73 + continue
74 + }
75 + var urlBaseStr string
76 + if root.URLBaseStr != "" {
77 + urlBaseStr = root.URLBaseStr
78 + } else {
79 + urlBaseStr = locStr
80 + }
81 + urlBase, err := url.Parse(urlBaseStr)
82 + if err != nil {
83 + maybe.Err = ContextError{fmt.Sprintf("error parsing location URL %q", locStr), err}
84 + continue
85 + }
86 + root.SetURLBase(urlBase)
87 + maybe.Root = root
88 + }
89 +
90 + return results, nil
91 +}
92 +
93 +func requestXml(url string, defaultSpace string, doc interface{}) error {
94 + resp, err := http.Get(url)
95 + if err != nil {
96 + return err
97 + }
98 + defer resp.Body.Close()
99 +
100 + if resp.StatusCode != 200 {
101 + return fmt.Errorf("goupnp: got response status %s from %q",
102 + resp.Status, url)
103 + }
104 +
105 + decoder := xml.NewDecoder(resp.Body)
106 + decoder.DefaultSpace = defaultSpace
107 +
108 + return decoder.Decode(doc)
109 +}
Godeps/_workspace/src/github.com/huin/goupnp/httpu/httpu.go new
+117
@@ -0,0 +1,117 @@
1 +package httpu
2 +
3 +import (
4 + "bufio"
5 + "bytes"
6 + "fmt"
7 + "log"
8 + "net"
9 + "net/http"
10 + "sync"
11 + "time"
12 +)
13 +
14 +// HTTPUClient is a client for dealing with HTTPU (HTTP over UDP). Its typical
15 +// function is for HTTPMU, and particularly SSDP.
16 +type HTTPUClient struct {
17 + connLock sync.Mutex // Protects use of conn.
18 + conn net.PacketConn
19 +}
20 +
21 +// NewHTTPUClient creates a new HTTPUClient, opening up a new UDP socket for the
22 +// purpose.
23 +func NewHTTPUClient() (*HTTPUClient, error) {
24 + conn, err := net.ListenPacket("udp", ":0")
25 + if err != nil {
26 + return nil, err
27 + }
28 + return &HTTPUClient{conn: conn}, nil
29 +}
30 +
31 +// Close shuts down the client. The client will no longer be useful following
32 +// this.
33 +func (httpu *HTTPUClient) Close() error {
34 + httpu.connLock.Lock()
35 + defer httpu.connLock.Unlock()
36 + return httpu.conn.Close()
37 +}
38 +
39 +// Do performs a request. The timeout is how long to wait for before returning
40 +// the responses that were received. An error is only returned for failing to
41 +// send the request. Failures in receipt simply do not add to the resulting
42 +// responses.
43 +//
44 +// Note that at present only one concurrent connection will happen per
45 +// HTTPUClient.
46 +func (httpu *HTTPUClient) Do(req *http.Request, timeout time.Duration, numSends int) ([]*http.Response, error) {
47 + httpu.connLock.Lock()
48 + defer httpu.connLock.Unlock()
49 +
50 + // Create the request. This is a subset of what http.Request.Write does
51 + // deliberately to avoid creating extra fields which may confuse some
52 + // devices.
53 + var requestBuf bytes.Buffer
54 + method := req.Method
55 + if method == "" {
56 + method = "GET"
57 + }
58 + if _, err := fmt.Fprintf(&requestBuf, "%s %s HTTP/1.1\r\n", method, req.URL.RequestURI()); err != nil {
59 + return nil, err
60 + }
61 + if err := req.Header.Write(&requestBuf); err != nil {
62 + return nil, err
63 + }
64 + if _, err := requestBuf.Write([]byte{'\r', '\n'}); err != nil {
65 + return nil, err
66 + }
67 +
68 + destAddr, err := net.ResolveUDPAddr("udp", req.Host)
69 + if err != nil {
70 + return nil, err
71 + }
72 + if err = httpu.conn.SetDeadline(time.Now().Add(timeout)); err != nil {
73 + return nil, err
74 + }
75 +
76 + // Send request.
77 + for i := 0; i < numSends; i++ {
78 + if n, err := httpu.conn.WriteTo(requestBuf.Bytes(), destAddr); err != nil {
79 + return nil, err
80 + } else if n < len(requestBuf.Bytes()) {
81 + return nil, fmt.Errorf("httpu: wrote %d bytes rather than full %d in request",
82 + n, len(requestBuf.Bytes()))
83 + }
84 + time.Sleep(5 * time.Millisecond)
85 + }
86 +
87 + // Await responses until timeout.
88 + var responses []*http.Response
89 + responseBytes := make([]byte, 2048)
90 + for {
91 + // 2048 bytes should be sufficient for most networks.
92 + n, _, err := httpu.conn.ReadFrom(responseBytes)
93 + if err != nil {
94 + if err, ok := err.(net.Error); ok {
95 + if err.Timeout() {
96 + break
97 + }
98 + if err.Temporary() {
99 + // Sleep in case this is a persistent error to avoid pegging CPU until deadline.
100 + time.Sleep(10 * time.Millisecond)
101 + continue
102 + }
103 + }
104 + return nil, err
105 + }
106 +
107 + // Parse response.
108 + response, err := http.ReadResponse(bufio.NewReader(bytes.NewBuffer(responseBytes[:n])), req)
109 + if err != nil {
110 + log.Print("httpu: error while parsing response: %v", err)
111 + continue
112 + }
113 +
114 + responses = append(responses, response)
115 + }
116 + return responses, err
117 +}
Godeps/_workspace/src/github.com/huin/goupnp/httpu/serve.go new
+108
@@ -0,0 +1,108 @@
1 +package httpu
2 +
3 +import (
4 + "bufio"
5 + "bytes"
6 + "log"
7 + "net"
8 + "net/http"
9 + "regexp"
10 +)
11 +
12 +const (
13 + DefaultMaxMessageBytes = 2048
14 +)
15 +
16 +var (
17 + trailingWhitespaceRx = regexp.MustCompile(" +\r\n")
18 + crlf = []byte("\r\n")
19 +)
20 +
21 +// Handler is the interface by which received HTTPU messages are passed to
22 +// handling code.
23 +type Handler interface {
24 + // ServeMessage is called for each HTTPU message received. peerAddr contains
25 + // the address that the message was received from.
26 + ServeMessage(r *http.Request)
27 +}
28 +
29 +// HandlerFunc is a function-to-Handler adapter.
30 +type HandlerFunc func(r *http.Request)
31 +
32 +func (f HandlerFunc) ServeMessage(r *http.Request) {
33 + f(r)
34 +}
35 +
36 +// A Server defines parameters for running an HTTPU server.
37 +type Server struct {
38 + Addr string // UDP address to listen on
39 + Multicast bool // Should listen for multicast?
40 + Interface *net.Interface // Network interface to listen on for multicast, nil for default multicast interface
41 + Handler Handler // handler to invoke
42 + MaxMessageBytes int // maximum number of bytes to read from a packet, DefaultMaxMessageBytes if 0
43 +}
44 +
45 +// ListenAndServe listens on the UDP network address srv.Addr. If srv.Multicast
46 +// is true, then a multicast UDP listener will be used on srv.Interface (or
47 +// default interface if nil).
48 +func (srv *Server) ListenAndServe() error {
49 + var err error
50 +
51 + var addr *net.UDPAddr
52 + if addr, err = net.ResolveUDPAddr("udp", srv.Addr); err != nil {
53 + log.Fatal(err)
54 + }
55 +
56 + var conn net.PacketConn
57 + if srv.Multicast {
58 + if conn, err = net.ListenMulticastUDP("udp", srv.Interface, addr); err != nil {
59 + return err
60 + }
61 + } else {
62 + if conn, err = net.ListenUDP("udp", addr); err != nil {
63 + return err
64 + }
65 + }
66 +
67 + return srv.Serve(conn)
68 +}
69 +
70 +// Serve messages received on the given packet listener to the srv.Handler.
71 +func (srv *Server) Serve(l net.PacketConn) error {
72 + maxMessageBytes := DefaultMaxMessageBytes
73 + if srv.MaxMessageBytes != 0 {
74 + maxMessageBytes = srv.MaxMessageBytes
75 + }
76 + for {
77 + buf := make([]byte, maxMessageBytes)
78 + n, peerAddr, err := l.ReadFrom(buf)
79 + if err != nil {
80 + return err
81 + }
82 + buf = buf[:n]
83 +
84 + go func(buf []byte, peerAddr net.Addr) {
85 + // At least one router's UPnP implementation has added a trailing space
86 + // after "HTTP/1.1" - trim it.
87 + buf = trailingWhitespaceRx.ReplaceAllLiteral(buf, crlf)
88 +
89 + req, err := http.ReadRequest(bufio.NewReader(bytes.NewBuffer(buf)))
90 + if err != nil {
91 + log.Printf("httpu: Failed to parse request: %v", err)
92 + return
93 + }
94 + req.RemoteAddr = peerAddr.String()
95 + srv.Handler.ServeMessage(req)
96 + // No need to call req.Body.Close - underlying reader is bytes.Buffer.
97 + }(buf, peerAddr)
98 + }
99 +}
100 +
101 +// Serve messages received on the given packet listener to the given handler.
102 +func Serve(l net.PacketConn, handler Handler) error {
103 + srv := Server{
104 + Handler: handler,
105 + MaxMessageBytes: DefaultMaxMessageBytes,
106 + }
107 + return srv.Serve(l)
108 +}
Godeps/_workspace/src/github.com/huin/goupnp/scpd/scpd.go new
+167
@@ -0,0 +1,167 @@
1 +package scpd
2 +
3 +import (
4 + "encoding/xml"
5 + "strings"
6 +)
7 +
8 +const (
9 + SCPDXMLNamespace = "urn:schemas-upnp-org:service-1-0"
10 +)
11 +
12 +func cleanWhitespace(s *string) {
13 + *s = strings.TrimSpace(*s)
14 +}
15 +
16 +// SCPD is the service description as described by section 2.5 "Service
17 +// description" in
18 +// http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf
19 +type SCPD struct {
20 + XMLName xml.Name `xml:"scpd"`
21 + ConfigId string `xml:"configId,attr"`
22 + SpecVersion SpecVersion `xml:"specVersion"`
23 + Actions []Action `xml:"actionList>action"`
24 + StateVariables []StateVariable `xml:"serviceStateTable>stateVariable"`
25 +}
26 +
27 +// Clean attempts to remove stray whitespace etc. in the structure. It seems
28 +// unfortunately common for stray whitespace to be present in SCPD documents,
29 +// this method attempts to make it easy to clean them out.
30 +func (scpd *SCPD) Clean() {
31 + cleanWhitespace(&scpd.ConfigId)
32 + for i := range scpd.Actions {
33 + scpd.Actions[i].clean()
34 + }
35 + for i := range scpd.StateVariables {
36 + scpd.StateVariables[i].clean()
37 + }
38 +}
39 +
40 +func (scpd *SCPD) GetStateVariable(variable string) *StateVariable {
41 + for i := range scpd.StateVariables {
42 + v := &scpd.StateVariables[i]
43 + if v.Name == variable {
44 + return v
45 + }
46 + }
47 + return nil
48 +}
49 +
50 +func (scpd *SCPD) GetAction(action string) *Action {
51 + for i := range scpd.Actions {
52 + a := &scpd.Actions[i]
53 + if a.Name == action {
54 + return a
55 + }
56 + }
57 + return nil
58 +}
59 +
60 +// SpecVersion is part of a SCPD document, describes the version of the
61 +// specification that the data adheres to.
62 +type SpecVersion struct {
63 + Major int32 `xml:"major"`
64 + Minor int32 `xml:"minor"`
65 +}
66 +
67 +type Action struct {
68 + Name string `xml:"name"`
69 + Arguments []Argument `xml:"argumentList>argument"`
70 +}
71 +
72 +func (action *Action) clean() {
73 + cleanWhitespace(&action.Name)
74 + for i := range action.Arguments {
75 + action.Arguments[i].clean()
76 + }
77 +}
78 +
79 +func (action *Action) InputArguments() []*Argument {
80 + var result []*Argument
81 + for i := range action.Arguments {
82 + arg := &action.Arguments[i]
83 + if arg.IsInput() {
84 + result = append(result, arg)
85 + }
86 + }
87 + return result
88 +}
89 +
90 +func (action *Action) OutputArguments() []*Argument {
91 + var result []*Argument
92 + for i := range action.Arguments {
93 + arg := &action.Arguments[i]
94 + if arg.IsOutput() {
95 + result = append(result, arg)
96 + }
97 + }
98 + return result
99 +}
100 +
101 +type Argument struct {
102 + Name string `xml:"name"`
103 + Direction string `xml:"direction"` // in|out
104 + RelatedStateVariable string `xml:"relatedStateVariable"` // ?
105 + Retval string `xml:"retval"` // ?
106 +}
107 +
108 +func (arg *Argument) clean() {
109 + cleanWhitespace(&arg.Name)
110 + cleanWhitespace(&arg.Direction)
111 + cleanWhitespace(&arg.RelatedStateVariable)
112 + cleanWhitespace(&arg.Retval)
113 +}
114 +
115 +func (arg *Argument) IsInput() bool {
116 + return arg.Direction == "in"
117 +}
118 +
119 +func (arg *Argument) IsOutput() bool {
120 + return arg.Direction == "out"
121 +}
122 +
123 +type StateVariable struct {
124 + Name string `xml:"name"`
125 + SendEvents string `xml:"sendEvents,attr"` // yes|no
126 + Multicast string `xml:"multicast,attr"` // yes|no
127 + DataType DataType `xml:"dataType"`
128 + DefaultValue string `xml:"defaultValue"`
129 + AllowedValueRange *AllowedValueRange `xml:"allowedValueRange"`
130 + AllowedValues []string `xml:"allowedValueList>allowedValue"`
131 +}
132 +
133 +func (v *StateVariable) clean() {
134 + cleanWhitespace(&v.Name)
135 + cleanWhitespace(&v.SendEvents)
136 + cleanWhitespace(&v.Multicast)
137 + v.DataType.clean()
138 + cleanWhitespace(&v.DefaultValue)
139 + if v.AllowedValueRange != nil {
140 + v.AllowedValueRange.clean()
141 + }
142 + for i := range v.AllowedValues {
143 + cleanWhitespace(&v.AllowedValues[i])
144 + }
145 +}
146 +
147 +type AllowedValueRange struct {
148 + Minimum string `xml:"minimum"`
149 + Maximum string `xml:"maximum"`
150 + Step string `xml:"step"`
151 +}
152 +
153 +func (r *AllowedValueRange) clean() {
154 + cleanWhitespace(&r.Minimum)
155 + cleanWhitespace(&r.Maximum)
156 + cleanWhitespace(&r.Step)
157 +}
158 +
159 +type DataType struct {
160 + Name string `xml:",chardata"`
161 + Type string `xml:"type,attr"`
162 +}
163 +
164 +func (dt *DataType) clean() {
165 + cleanWhitespace(&dt.Name)
166 + cleanWhitespace(&dt.Type)
167 +}
Godeps/_workspace/src/github.com/huin/goupnp/service_client.go new
+56
@@ -0,0 +1,56 @@
1 +package goupnp
2 +
3 +import (
4 + "fmt"
5 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/soap"
6 +)
7 +
8 +// ServiceClient is a SOAP client, root device and the service for the SOAP
9 +// client rolled into one value. The root device and service are intended to be
10 +// informational.
11 +type ServiceClient struct {
12 + SOAPClient *soap.SOAPClient
13 + RootDevice *RootDevice
14 + Service *Service
15 +}
16 +
17 +func NewServiceClients(searchTarget string) (clients []ServiceClient, errors []error, err error) {
18 + var maybeRootDevices []MaybeRootDevice
19 + if maybeRootDevices, err = DiscoverDevices(searchTarget); err != nil {
20 + return
21 + }
22 +
23 + clients = make([]ServiceClient, 0, len(maybeRootDevices))
24 +
25 + for _, maybeRootDevice := range maybeRootDevices {
26 + if maybeRootDevice.Err != nil {
27 + errors = append(errors, maybeRootDevice.Err)
28 + continue
29 + }
30 +
31 + device := &maybeRootDevice.Root.Device
32 + srvs := device.FindService(searchTarget)
33 + if len(srvs) == 0 {
34 + errors = append(errors, fmt.Errorf("goupnp: service %q not found within device %q (UDN=%q)",
35 + searchTarget, device.FriendlyName, device.UDN))
36 + continue
37 + }
38 +
39 + for _, srv := range srvs {
40 + clients = append(clients, ServiceClient{
41 + SOAPClient: srv.NewSOAPClient(),
42 + RootDevice: maybeRootDevice.Root,
43 + Service: srv,
44 + })
45 + }
46 + }
47 +
48 + return
49 +}
50 +
51 +// GetServiceClient returns the ServiceClient itself. This is provided so that the
52 +// service client attributes can be accessed via an interface method on a
53 +// wrapping type.
54 +func (client *ServiceClient) GetServiceClient() *ServiceClient {
55 + return client
56 +}
Godeps/_workspace/src/github.com/huin/goupnp/soap/soap.go new
+157
@@ -0,0 +1,157 @@
1 +// Definition for the SOAP structure required for UPnP's SOAP usage.
2 +
3 +package soap
4 +
5 +import (
6 + "bytes"
7 + "encoding/xml"
8 + "fmt"
9 + "io/ioutil"
10 + "net/http"
11 + "net/url"
12 + "reflect"
13 +)
14 +
15 +const (
16 + soapEncodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
17 + soapPrefix = xml.Header + `<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body>`
18 + soapSuffix = `</s:Body></s:Envelope>`
19 +)
20 +
21 +type SOAPClient struct {
22 + EndpointURL url.URL
23 + HTTPClient http.Client
24 +}
25 +
26 +func NewSOAPClient(endpointURL url.URL) *SOAPClient {
27 + return &SOAPClient{
28 + EndpointURL: endpointURL,
29 + }
30 +}
31 +
32 +// PerformSOAPAction makes a SOAP request, with the given action.
33 +// inAction and outAction must both be pointers to structs with string fields
34 +// only.
35 +func (client *SOAPClient) PerformAction(actionNamespace, actionName string, inAction interface{}, outAction interface{}) error {
36 + requestBytes, err := encodeRequestAction(actionNamespace, actionName, inAction)
37 + if err != nil {
38 + return err
39 + }
40 +
41 + response, err := client.HTTPClient.Do(&http.Request{
42 + Method: "POST",
43 + URL: &client.EndpointURL,
44 + Header: http.Header{
45 + "SOAPACTION": []string{actionNamespace + "#" + actionName},
46 + "CONTENT-TYPE": []string{"text/xml; charset=\"utf-8\""},
47 + },
48 + Body: ioutil.NopCloser(bytes.NewBuffer(requestBytes)),
49 + // Set ContentLength to avoid chunked encoding - some servers might not support it.
50 + ContentLength: int64(len(requestBytes)),
51 + })
52 + if err != nil {
53 + return fmt.Errorf("goupnp: error performing SOAP HTTP request: %v", err)
54 + }
55 + defer response.Body.Close()
56 + if response.StatusCode != 200 {
57 + return fmt.Errorf("goupnp: SOAP request got HTTP %s", response.Status)
58 + }
59 +
60 + responseEnv := newSOAPEnvelope()
61 + decoder := xml.NewDecoder(response.Body)
62 + if err := decoder.Decode(responseEnv); err != nil {
63 + return fmt.Errorf("goupnp: error decoding response body: %v", err)
64 + }
65 +
66 + if responseEnv.Body.Fault != nil {
67 + return responseEnv.Body.Fault
68 + }
69 +
70 + if outAction != nil {
71 + if err := xml.Unmarshal(responseEnv.Body.RawAction, outAction); err != nil {
72 + return fmt.Errorf("goupnp: error unmarshalling out action: %v, %v", err, responseEnv.Body.RawAction)
73 + }
74 + }
75 +
76 + return nil
77 +}
78 +
79 +// newSOAPAction creates a soapEnvelope with the given action and arguments.
80 +func newSOAPEnvelope() *soapEnvelope {
81 + return &soapEnvelope{
82 + EncodingStyle: soapEncodingStyle,
83 + }
84 +}
85 +
86 +// encodeRequestAction is a hacky way to create an encoded SOAP envelope
87 +// containing the given action. Experiments with one router have shown that it
88 +// 500s for requests where the outer default xmlns is set to the SOAP
89 +// namespace, and then reassigning the default namespace within that to the
90 +// service namespace. Hand-coding the outer XML to work-around this.
91 +func encodeRequestAction(actionNamespace, actionName string, inAction interface{}) ([]byte, error) {
92 + requestBuf := new(bytes.Buffer)
93 + requestBuf.WriteString(soapPrefix)
94 + requestBuf.WriteString(`<u:`)
95 + xml.EscapeText(requestBuf, []byte(actionName))
96 + requestBuf.WriteString(` xmlns:u="`)
97 + xml.EscapeText(requestBuf, []byte(actionNamespace))
98 + requestBuf.WriteString(`">`)
99 + if inAction != nil {
100 + if err := encodeRequestArgs(requestBuf, inAction); err != nil {
101 + return nil, err
102 + }
103 + }
104 + requestBuf.WriteString(`</u:`)
105 + xml.EscapeText(requestBuf, []byte(actionName))
106 + requestBuf.WriteString(`>`)
107 + requestBuf.WriteString(soapSuffix)
108 + return requestBuf.Bytes(), nil
109 +}
110 +
111 +func encodeRequestArgs(w *bytes.Buffer, inAction interface{}) error {
112 + in := reflect.Indirect(reflect.ValueOf(inAction))
113 + if in.Kind() != reflect.Struct {
114 + return fmt.Errorf("goupnp: SOAP inAction is not a struct but of type %v", in.Type())
115 + }
116 + enc := xml.NewEncoder(w)
117 + nFields := in.NumField()
118 + inType := in.Type()
119 + for i := 0; i < nFields; i++ {
120 + field := inType.Field(i)
121 + argName := field.Name
122 + if nameOverride := field.Tag.Get("soap"); nameOverride != "" {
123 + argName = nameOverride
124 + }
125 + value := in.Field(i)
126 + if value.Kind() != reflect.String {
127 + return fmt.Errorf("goupnp: SOAP arg %q is not of type string, but of type %v", argName, value.Type())
128 + }
129 + if err := enc.EncodeElement(value.Interface(), xml.StartElement{xml.Name{"", argName}, nil}); err != nil {
130 + return fmt.Errorf("goupnp: error encoding SOAP arg %q: %v", argName, err)
131 + }
132 + }
133 + enc.Flush()
134 + return nil
135 +}
136 +
137 +type soapEnvelope struct {
138 + XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
139 + EncodingStyle string `xml:"http://schemas.xmlsoap.org/soap/envelope/ encodingStyle,attr"`
140 + Body soapBody `xml:"http://schemas.xmlsoap.org/soap/envelope/ Body"`
141 +}
142 +
143 +type soapBody struct {
144 + Fault *SOAPFaultError `xml:"Fault"`
145 + RawAction []byte `xml:",innerxml"`
146 +}
147 +
148 +// SOAPFaultError implements error, and contains SOAP fault information.
149 +type SOAPFaultError struct {
150 + FaultCode string `xml:"faultcode"`
151 + FaultString string `xml:"faultstring"`
152 + Detail string `xml:"detail"`
153 +}
154 +
155 +func (err *SOAPFaultError) Error() string {
156 + return fmt.Sprintf("SOAP fault: %s", err.FaultString)
157 +}
Godeps/_workspace/src/github.com/huin/goupnp/soap/soap_test.go new
+85
@@ -0,0 +1,85 @@
1 +package soap
2 +
3 +import (
4 + "bytes"
5 + "io/ioutil"
6 + "net/http"
7 + "net/url"
8 + "reflect"
9 + "testing"
10 +)
11 +
12 +type capturingRoundTripper struct {
13 + err error
14 + resp *http.Response
15 + capturedReq *http.Request
16 +}
17 +
18 +func (rt *capturingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
19 + rt.capturedReq = req
20 + return rt.resp, rt.err
21 +}
22 +
23 +func TestActionInputs(t *testing.T) {
24 + url, err := url.Parse("http://example.com/soap")
25 + if err != nil {
26 + t.Fatal(err)
27 + }
28 + rt := &capturingRoundTripper{
29 + err: nil,
30 + resp: &http.Response{
31 + StatusCode: 200,
32 + Body: ioutil.NopCloser(bytes.NewBufferString(`
33 + <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
34 + <s:Body>
35 + <u:myactionResponse xmlns:u="mynamespace">
36 + <A>valueA</A>
37 + <B>valueB</B>
38 + </u:myactionResponse>
39 + </s:Body>
40 + </s:Envelope>
41 + `)),
42 + },
43 + }
44 + client := SOAPClient{
45 + EndpointURL: *url,
46 + HTTPClient: http.Client{
47 + Transport: rt,
48 + },
49 + }
50 +
51 + type In struct {
52 + Foo string
53 + Bar string `soap:"bar"`
54 + }
55 + type Out struct {
56 + A string
57 + B string
58 + }
59 + in := In{"foo", "bar"}
60 + gotOut := Out{}
61 + err = client.PerformAction("mynamespace", "myaction", &in, &gotOut)
62 + if err != nil {
63 + t.Fatal(err)
64 + }
65 +
66 + wantBody := (soapPrefix +
67 + `<u:myaction xmlns:u="mynamespace">` +
68 + `<Foo>foo</Foo>` +
69 + `<bar>bar</bar>` +
70 + `</u:myaction>` +
71 + soapSuffix)
72 + body, err := ioutil.ReadAll(rt.capturedReq.Body)
73 + if err != nil {
74 + t.Fatal(err)
75 + }
76 + gotBody := string(body)
77 + if wantBody != gotBody {
78 + t.Errorf("Bad request body\nwant: %q\n got: %q", wantBody, gotBody)
79 + }
80 +
81 + wantOut := Out{"valueA", "valueB"}
82 + if !reflect.DeepEqual(wantOut, gotOut) {
83 + t.Errorf("Bad output\nwant: %+v\n got: %+v", wantOut, gotOut)
84 + }
85 +}
Godeps/_workspace/src/github.com/huin/goupnp/soap/types.go new
+508
@@ -0,0 +1,508 @@
1 +package soap
2 +
3 +import (
4 + "encoding/base64"
5 + "encoding/hex"
6 + "errors"
7 + "fmt"
8 + "regexp"
9 + "strconv"
10 + "strings"
11 + "time"
12 + "unicode/utf8"
13 +)
14 +
15 +var (
16 + // localLoc acts like time.Local for this package, but is faked out by the
17 + // unit tests to ensure that things stay constant (especially when running
18 + // this test in a place where local time is UTC which might mask bugs).
19 + localLoc = time.Local
20 +)
21 +
22 +func MarshalUi1(v uint8) (string, error) {
23 + return strconv.FormatUint(uint64(v), 10), nil
24 +}
25 +
26 +func UnmarshalUi1(s string) (uint8, error) {
27 + v, err := strconv.ParseUint(s, 10, 8)
28 + return uint8(v), err
29 +}
30 +
31 +func MarshalUi2(v uint16) (string, error) {
32 + return strconv.FormatUint(uint64(v), 10), nil
33 +}
34 +
35 +func UnmarshalUi2(s string) (uint16, error) {
36 + v, err := strconv.ParseUint(s, 10, 16)
37 + return uint16(v), err
38 +}
39 +
40 +func MarshalUi4(v uint32) (string, error) {
41 + return strconv.FormatUint(uint64(v), 10), nil
42 +}
43 +
44 +func UnmarshalUi4(s string) (uint32, error) {
45 + v, err := strconv.ParseUint(s, 10, 32)
46 + return uint32(v), err
47 +}
48 +
49 +func MarshalI1(v int8) (string, error) {
50 + return strconv.FormatInt(int64(v), 10), nil
51 +}
52 +
53 +func UnmarshalI1(s string) (int8, error) {
54 + v, err := strconv.ParseInt(s, 10, 8)
55 + return int8(v), err
56 +}
57 +
58 +func MarshalI2(v int16) (string, error) {
59 + return strconv.FormatInt(int64(v), 10), nil
60 +}
61 +
62 +func UnmarshalI2(s string) (int16, error) {
63 + v, err := strconv.ParseInt(s, 10, 16)
64 + return int16(v), err
65 +}
66 +
67 +func MarshalI4(v int32) (string, error) {
68 + return strconv.FormatInt(int64(v), 10), nil
69 +}
70 +
71 +func UnmarshalI4(s string) (int32, error) {
72 + v, err := strconv.ParseInt(s, 10, 32)
73 + return int32(v), err
74 +}
75 +
76 +func MarshalInt(v int64) (string, error) {
77 + return strconv.FormatInt(v, 10), nil
78 +}
79 +
80 +func UnmarshalInt(s string) (int64, error) {
81 + return strconv.ParseInt(s, 10, 64)
82 +}
83 +
84 +func MarshalR4(v float32) (string, error) {
85 + return strconv.FormatFloat(float64(v), 'G', -1, 32), nil
86 +}
87 +
88 +func UnmarshalR4(s string) (float32, error) {
89 + v, err := strconv.ParseFloat(s, 32)
90 + return float32(v), err
91 +}
92 +
93 +func MarshalR8(v float64) (string, error) {
94 + return strconv.FormatFloat(v, 'G', -1, 64), nil
95 +}
96 +
97 +func UnmarshalR8(s string) (float64, error) {
98 + v, err := strconv.ParseFloat(s, 64)
99 + return float64(v), err
100 +}
101 +
102 +// MarshalFixed14_4 marshals float64 to SOAP "fixed.14.4" type.
103 +func MarshalFixed14_4(v float64) (string, error) {
104 + if v >= 1e14 || v <= -1e14 {
105 + return "", fmt.Errorf("soap fixed14.4: value %v out of bounds", v)
106 + }
107 + return strconv.FormatFloat(v, 'f', 4, 64), nil
108 +}
109 +
110 +// UnmarshalFixed14_4 unmarshals float64 from SOAP "fixed.14.4" type.
111 +func UnmarshalFixed14_4(s string) (float64, error) {
112 + v, err := strconv.ParseFloat(s, 64)
113 + if err != nil {
114 + return 0, err
115 + }
116 + if v >= 1e14 || v <= -1e14 {
117 + return 0, fmt.Errorf("soap fixed14.4: value %q out of bounds", s)
118 + }
119 + return v, nil
120 +}
121 +
122 +// MarshalChar marshals rune to SOAP "char" type.
123 +func MarshalChar(v rune) (string, error) {
124 + if v == 0 {
125 + return "", errors.New("soap char: rune 0 is not allowed")
126 + }
127 + return string(v), nil
128 +}
129 +
130 +// UnmarshalChar unmarshals rune from SOAP "char" type.
131 +func UnmarshalChar(s string) (rune, error) {
132 + if len(s) == 0 {
133 + return 0, errors.New("soap char: got empty string")
134 + }
135 + r, n := utf8.DecodeRune([]byte(s))
136 + if n != len(s) {
137 + return 0, fmt.Errorf("soap char: value %q is not a single rune", s)
138 + }
139 + return r, nil
140 +}
141 +
142 +func MarshalString(v string) (string, error) {
143 + return v, nil
144 +}
145 +
146 +func UnmarshalString(v string) (string, error) {
147 + return v, nil
148 +}
149 +
150 +func parseInt(s string, err *error) int {
151 + v, parseErr := strconv.ParseInt(s, 10, 64)
152 + if parseErr != nil {
153 + *err = parseErr
154 + }
155 + return int(v)
156 +}
157 +
158 +var dateRegexps = []*regexp.Regexp{
159 + // yyyy[-mm[-dd]]
160 + regexp.MustCompile(`^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$`),
161 + // yyyy[mm[dd]]
162 + regexp.MustCompile(`^(\d{4})(?:(\d{2})(?:(\d{2}))?)?$`),
163 +}
164 +
165 +func parseDateParts(s string) (year, month, day int, err error) {
166 + var parts []string
167 + for _, re := range dateRegexps {
168 + parts = re.FindStringSubmatch(s)
169 + if parts != nil {
170 + break
171 + }
172 + }
173 + if parts == nil {
174 + err = fmt.Errorf("soap date: value %q is not in a recognized ISO8601 date format", s)
175 + return
176 + }
177 +
178 + year = parseInt(parts[1], &err)
179 + month = 1
180 + day = 1
181 + if len(parts[2]) != 0 {
182 + month = parseInt(parts[2], &err)
183 + if len(parts[3]) != 0 {
184 + day = parseInt(parts[3], &err)
185 + }
186 + }
187 +
188 + if err != nil {
189 + err = fmt.Errorf("soap date: %q: %v", s, err)
190 + }
191 +
192 + return
193 +}
194 +
195 +var timeRegexps = []*regexp.Regexp{
196 + // hh[:mm[:ss]]
197 + regexp.MustCompile(`^(\d{2})(?::(\d{2})(?::(\d{2}))?)?$`),
198 + // hh[mm[ss]]
199 + regexp.MustCompile(`^(\d{2})(?:(\d{2})(?:(\d{2}))?)?$`),
200 +}
201 +
202 +func parseTimeParts(s string) (hour, minute, second int, err error) {
203 + var parts []string
204 + for _, re := range timeRegexps {
205 + parts = re.FindStringSubmatch(s)
206 + if parts != nil {
207 + break
208 + }
209 + }
210 + if parts == nil {
211 + err = fmt.Errorf("soap time: value %q is not in ISO8601 time format", s)
212 + return
213 + }
214 +
215 + hour = parseInt(parts[1], &err)
216 + if len(parts[2]) != 0 {
217 + minute = parseInt(parts[2], &err)
218 + if len(parts[3]) != 0 {
219 + second = parseInt(parts[3], &err)
220 + }
221 + }
222 +
223 + if err != nil {
224 + err = fmt.Errorf("soap time: %q: %v", s, err)
225 + }
226 +
227 + return
228 +}
229 +
230 +// (+|-)hh[[:]mm]
231 +var timezoneRegexp = regexp.MustCompile(`^([+-])(\d{2})(?::?(\d{2}))?$`)
232 +
233 +func parseTimezone(s string) (offset int, err error) {
234 + if s == "Z" {
235 + return 0, nil
236 + }
237 + parts := timezoneRegexp.FindStringSubmatch(s)
238 + if parts == nil {
239 + err = fmt.Errorf("soap timezone: value %q is not in ISO8601 timezone format", s)
240 + return
241 + }
242 +
243 + offset = parseInt(parts[2], &err) * 3600
244 + if len(parts[3]) != 0 {
245 + offset += parseInt(parts[3], &err) * 60
246 + }
247 + if parts[1] == "-" {
248 + offset = -offset
249 + }
250 +
251 + if err != nil {
252 + err = fmt.Errorf("soap timezone: %q: %v", s, err)
253 + }
254 +
255 + return
256 +}
257 +
258 +var completeDateTimeZoneRegexp = regexp.MustCompile(`^([^T]+)(?:T([^-+Z]+)(.+)?)?$`)
259 +
260 +// splitCompleteDateTimeZone splits date, time and timezone apart from an
261 +// ISO8601 string. It does not ensure that the contents of each part are
262 +// correct, it merely splits on certain delimiters.
263 +// e.g "2010-09-08T12:15:10+0700" => "2010-09-08", "12:15:10", "+0700".
264 +// Timezone can only be present if time is also present.
265 +func splitCompleteDateTimeZone(s string) (dateStr, timeStr, zoneStr string, err error) {
266 + parts := completeDateTimeZoneRegexp.FindStringSubmatch(s)
267 + if parts == nil {
268 + err = fmt.Errorf("soap date/time/zone: value %q is not in ISO8601 datetime format", s)
269 + return
270 + }
271 + dateStr = parts[1]
272 + timeStr = parts[2]
273 + zoneStr = parts[3]
274 + return
275 +}
276 +
277 +// MarshalDate marshals time.Time to SOAP "date" type. Note that this converts
278 +// to local time, and discards the time-of-day components.
279 +func MarshalDate(v time.Time) (string, error) {
280 + return v.In(localLoc).Format("2006-01-02"), nil
281 +}
282 +
283 +var dateFmts = []string{"2006-01-02", "20060102"}
284 +
285 +// UnmarshalDate unmarshals time.Time from SOAP "date" type. This outputs the
286 +// date as midnight in the local time zone.
287 +func UnmarshalDate(s string) (time.Time, error) {
288 + year, month, day, err := parseDateParts(s)
289 + if err != nil {
290 + return time.Time{}, err
291 + }
292 + return time.Date(year, time.Month(month), day, 0, 0, 0, 0, localLoc), nil
293 +}
294 +
295 +// TimeOfDay is used in cases where SOAP "time" or "time.tz" is used.
296 +type TimeOfDay struct {
297 + // Duration of time since midnight.
298 + FromMidnight time.Duration
299 +
300 + // Set to true if Offset is specified. If false, then the timezone is
301 + // unspecified (and by ISO8601 - implies some "local" time).
302 + HasOffset bool
303 +
304 + // Offset is non-zero only if time.tz is used. It is otherwise ignored. If
305 + // non-zero, then it is regarded as a UTC offset in seconds. Note that the
306 + // sub-minutes is ignored by the marshal function.
307 + Offset int
308 +}
309 +
310 +// MarshalTimeOfDay marshals TimeOfDay to the "time" type.
311 +func MarshalTimeOfDay(v TimeOfDay) (string, error) {
312 + d := int64(v.FromMidnight / time.Second)
313 + hour := d / 3600
314 + d = d % 3600
315 + minute := d / 60
316 + second := d % 60
317 +
318 + return fmt.Sprintf("%02d:%02d:%02d", hour, minute, second), nil
319 +}
320 +
321 +// UnmarshalTimeOfDay unmarshals TimeOfDay from the "time" type.
322 +func UnmarshalTimeOfDay(s string) (TimeOfDay, error) {
323 + t, err := UnmarshalTimeOfDayTz(s)
324 + if err != nil {
325 + return TimeOfDay{}, err
326 + } else if t.HasOffset {
327 + return TimeOfDay{}, fmt.Errorf("soap time: value %q contains unexpected timezone")
328 + }
329 + return t, nil
330 +}
331 +
332 +// MarshalTimeOfDayTz marshals TimeOfDay to the "time.tz" type.
333 +func MarshalTimeOfDayTz(v TimeOfDay) (string, error) {
334 + d := int64(v.FromMidnight / time.Second)
335 + hour := d / 3600
336 + d = d % 3600
337 + minute := d / 60
338 + second := d % 60
339 +
340 + tz := ""
341 + if v.HasOffset {
342 + if v.Offset == 0 {
343 + tz = "Z"
344 + } else {
345 + offsetMins := v.Offset / 60
346 + sign := '+'
347 + if offsetMins < 1 {
348 + offsetMins = -offsetMins
349 + sign = '-'
350 + }
351 + tz = fmt.Sprintf("%c%02d:%02d", sign, offsetMins/60, offsetMins%60)
352 + }
353 + }
354 +
355 + return fmt.Sprintf("%02d:%02d:%02d%s", hour, minute, second, tz), nil
356 +}
357 +
358 +// UnmarshalTimeOfDayTz unmarshals TimeOfDay from the "time.tz" type.
359 +func UnmarshalTimeOfDayTz(s string) (tod TimeOfDay, err error) {
360 + zoneIndex := strings.IndexAny(s, "Z+-")
361 + var timePart string
362 + var hasOffset bool
363 + var offset int
364 + if zoneIndex == -1 {
365 + hasOffset = false
366 + timePart = s
367 + } else {
368 + hasOffset = true
369 + timePart = s[:zoneIndex]
370 + if offset, err = parseTimezone(s[zoneIndex:]); err != nil {
371 + return
372 + }
373 + }
374 +
375 + hour, minute, second, err := parseTimeParts(timePart)
376 + if err != nil {
377 + return
378 + }
379 +
380 + fromMidnight := time.Duration(hour*3600+minute*60+second) * time.Second
381 +
382 + // ISO8601 special case - values up to 24:00:00 are allowed, so using
383 + // strictly greater-than for the maximum value.
384 + if fromMidnight > 24*time.Hour || minute >= 60 || second >= 60 {
385 + return TimeOfDay{}, fmt.Errorf("soap time.tz: value %q has value(s) out of range", s)
386 + }
387 +
388 + return TimeOfDay{
389 + FromMidnight: time.Duration(hour*3600+minute*60+second) * time.Second,
390 + HasOffset: hasOffset,
391 + Offset: offset,
392 + }, nil
393 +}
394 +
395 +// MarshalDateTime marshals time.Time to SOAP "dateTime" type. Note that this
396 +// converts to local time.
397 +func MarshalDateTime(v time.Time) (string, error) {
398 + return v.In(localLoc).Format("2006-01-02T15:04:05"), nil
399 +}
400 +
401 +// UnmarshalDateTime unmarshals time.Time from the SOAP "dateTime" type. This
402 +// returns a value in the local timezone.
403 +func UnmarshalDateTime(s string) (result time.Time, err error) {
404 + dateStr, timeStr, zoneStr, err := splitCompleteDateTimeZone(s)
405 + if err != nil {
406 + return
407 + }
408 +
409 + if len(zoneStr) != 0 {
410 + err = fmt.Errorf("soap datetime: unexpected timezone in %q", s)
411 + return
412 + }
413 +
414 + year, month, day, err := parseDateParts(dateStr)
415 + if err != nil {
416 + return
417 + }
418 +
419 + var hour, minute, second int
420 + if len(timeStr) != 0 {
421 + hour, minute, second, err = parseTimeParts(timeStr)
422 + if err != nil {
423 + return
424 + }
425 + }
426 +
427 + result = time.Date(year, time.Month(month), day, hour, minute, second, 0, localLoc)
428 + return
429 +}
430 +
431 +// MarshalDateTimeTz marshals time.Time to SOAP "dateTime.tz" type.
432 +func MarshalDateTimeTz(v time.Time) (string, error) {
433 + return v.Format("2006-01-02T15:04:05-07:00"), nil
434 +}
435 +
436 +// UnmarshalDateTimeTz unmarshals time.Time from the SOAP "dateTime.tz" type.
437 +// This returns a value in the local timezone when the timezone is unspecified.
438 +func UnmarshalDateTimeTz(s string) (result time.Time, err error) {
439 + dateStr, timeStr, zoneStr, err := splitCompleteDateTimeZone(s)
440 + if err != nil {
441 + return
442 + }
443 +
444 + year, month, day, err := parseDateParts(dateStr)
445 + if err != nil {
446 + return
447 + }
448 +
449 + var hour, minute, second int
450 + var location *time.Location = localLoc
451 + if len(timeStr) != 0 {
452 + hour, minute, second, err = parseTimeParts(timeStr)
453 + if err != nil {
454 + return
455 + }
456 + if len(zoneStr) != 0 {
457 + var offset int
458 + offset, err = parseTimezone(zoneStr)
459 + if offset == 0 {
460 + location = time.UTC
461 + } else {
462 + location = time.FixedZone("", offset)
463 + }
464 + }
465 + }
466 +
467 + result = time.Date(year, time.Month(month), day, hour, minute, second, 0, location)
468 + return
469 +}
470 +
471 +// MarshalBoolean marshals bool to SOAP "boolean" type.
472 +func MarshalBoolean(v bool) (string, error) {
473 + if v {
474 + return "1", nil
475 + }
476 + return "0", nil
477 +}
478 +
479 +// UnmarshalBoolean unmarshals bool from the SOAP "boolean" type.
480 +func UnmarshalBoolean(s string) (bool, error) {
481 + switch s {
482 + case "0", "false", "no":
483 + return false, nil
484 + case "1", "true", "yes":
485 + return true, nil
486 + }
487 + return false, fmt.Errorf("soap boolean: %q is not a valid boolean value", s)
488 +}
489 +
490 +// MarshalBinBase64 marshals []byte to SOAP "bin.base64" type.
491 +func MarshalBinBase64(v []byte) (string, error) {
492 + return base64.StdEncoding.EncodeToString(v), nil
493 +}
494 +
495 +// UnmarshalBinBase64 unmarshals []byte from the SOAP "bin.base64" type.
496 +func UnmarshalBinBase64(s string) ([]byte, error) {
497 + return base64.StdEncoding.DecodeString(s)
498 +}
499 +
500 +// MarshalBinHex marshals []byte to SOAP "bin.hex" type.
501 +func MarshalBinHex(v []byte) (string, error) {
502 + return hex.EncodeToString(v), nil
503 +}
504 +
505 +// UnmarshalBinHex unmarshals []byte from the SOAP "bin.hex" type.
506 +func UnmarshalBinHex(s string) ([]byte, error) {
507 + return hex.DecodeString(s)
508 +}
Godeps/_workspace/src/github.com/huin/goupnp/soap/types_test.go new
+481
@@ -0,0 +1,481 @@
1 +package soap
2 +
3 +import (
4 + "bytes"
5 + "math"
6 + "testing"
7 + "time"
8 +)
9 +
10 +type convTest interface {
11 + Marshal() (string, error)
12 + Unmarshal(string) (interface{}, error)
13 + Equal(result interface{}) bool
14 +}
15 +
16 +// duper is an interface that convTest values may optionally also implement to
17 +// generate another convTest for a value in an otherwise identical testCase.
18 +type duper interface {
19 + Dupe(tag string) []convTest
20 +}
21 +
22 +type testCase struct {
23 + value convTest
24 + str string
25 + wantMarshalErr bool
26 + wantUnmarshalErr bool
27 + noMarshal bool
28 + noUnMarshal bool
29 + tag string
30 +}
31 +
32 +type Ui1Test uint8
33 +
34 +func (v Ui1Test) Marshal() (string, error) {
35 + return MarshalUi1(uint8(v))
36 +}
37 +func (v Ui1Test) Unmarshal(s string) (interface{}, error) {
38 + return UnmarshalUi1(s)
39 +}
40 +func (v Ui1Test) Equal(result interface{}) bool {
41 + return uint8(v) == result.(uint8)
42 +}
43 +func (v Ui1Test) Dupe(tag string) []convTest {
44 + if tag == "dupe" {
45 + return []convTest{
46 + Ui2Test(v),
47 + Ui4Test(v),
48 + }
49 + }
50 + return nil
51 +}
52 +
53 +type Ui2Test uint16
54 +
55 +func (v Ui2Test) Marshal() (string, error) {
56 + return MarshalUi2(uint16(v))
57 +}
58 +func (v Ui2Test) Unmarshal(s string) (interface{}, error) {
59 + return UnmarshalUi2(s)
60 +}
61 +func (v Ui2Test) Equal(result interface{}) bool {
62 + return uint16(v) == result.(uint16)
63 +}
64 +
65 +type Ui4Test uint32
66 +
67 +func (v Ui4Test) Marshal() (string, error) {
68 + return MarshalUi4(uint32(v))
69 +}
70 +func (v Ui4Test) Unmarshal(s string) (interface{}, error) {
71 + return UnmarshalUi4(s)
72 +}
73 +func (v Ui4Test) Equal(result interface{}) bool {
74 + return uint32(v) == result.(uint32)
75 +}
76 +
77 +type I1Test int8
78 +
79 +func (v I1Test) Marshal() (string, error) {
80 + return MarshalI1(int8(v))
81 +}
82 +func (v I1Test) Unmarshal(s string) (interface{}, error) {
83 + return UnmarshalI1(s)
84 +}
85 +func (v I1Test) Equal(result interface{}) bool {
86 + return int8(v) == result.(int8)
87 +}
88 +func (v I1Test) Dupe(tag string) []convTest {
89 + if tag == "dupe" {
90 + return []convTest{
91 + I2Test(v),
92 + I4Test(v),
93 + }
94 + }
95 + return nil
96 +}
97 +
98 +type I2Test int16
99 +
100 +func (v I2Test) Marshal() (string, error) {
101 + return MarshalI2(int16(v))
102 +}
103 +func (v I2Test) Unmarshal(s string) (interface{}, error) {
104 + return UnmarshalI2(s)
105 +}
106 +func (v I2Test) Equal(result interface{}) bool {
107 + return int16(v) == result.(int16)
108 +}
109 +
110 +type I4Test int32
111 +
112 +func (v I4Test) Marshal() (string, error) {
113 + return MarshalI4(int32(v))
114 +}
115 +func (v I4Test) Unmarshal(s string) (interface{}, error) {
116 + return UnmarshalI4(s)
117 +}
118 +func (v I4Test) Equal(result interface{}) bool {
119 + return int32(v) == result.(int32)
120 +}
121 +
122 +type IntTest int64
123 +
124 +func (v IntTest) Marshal() (string, error) {
125 + return MarshalInt(int64(v))
126 +}
127 +func (v IntTest) Unmarshal(s string) (interface{}, error) {
128 + return UnmarshalInt(s)
129 +}
130 +func (v IntTest) Equal(result interface{}) bool {
131 + return int64(v) == result.(int64)
132 +}
133 +
134 +type Fixed14_4Test float64
135 +
136 +func (v Fixed14_4Test) Marshal() (string, error) {
137 + return MarshalFixed14_4(float64(v))
138 +}
139 +func (v Fixed14_4Test) Unmarshal(s string) (interface{}, error) {
140 + return UnmarshalFixed14_4(s)
141 +}
142 +func (v Fixed14_4Test) Equal(result interface{}) bool {
143 + return math.Abs(float64(v)-result.(float64)) < 0.001
144 +}
145 +
146 +type CharTest rune
147 +
148 +func (v CharTest) Marshal() (string, error) {
149 + return MarshalChar(rune(v))
150 +}
151 +func (v CharTest) Unmarshal(s string) (interface{}, error) {
152 + return UnmarshalChar(s)
153 +}
154 +func (v CharTest) Equal(result interface{}) bool {
155 + return rune(v) == result.(rune)
156 +}
157 +
158 +type DateTest struct{ time.Time }
159 +
160 +func (v DateTest) Marshal() (string, error) {
161 + return MarshalDate(time.Time(v.Time))
162 +}
163 +func (v DateTest) Unmarshal(s string) (interface{}, error) {
164 + return UnmarshalDate(s)
165 +}
166 +func (v DateTest) Equal(result interface{}) bool {
167 + return v.Time.Equal(result.(time.Time))
168 +}
169 +func (v DateTest) Dupe(tag string) []convTest {
170 + if tag != "no:dateTime" {
171 + return []convTest{DateTimeTest{v.Time}}
172 + }
173 + return nil
174 +}
175 +
176 +type TimeOfDayTest struct {
177 + TimeOfDay
178 +}
179 +
180 +func (v TimeOfDayTest) Marshal() (string, error) {
181 + return MarshalTimeOfDay(v.TimeOfDay)
182 +}
183 +func (v TimeOfDayTest) Unmarshal(s string) (interface{}, error) {
184 + return UnmarshalTimeOfDay(s)
185 +}
186 +func (v TimeOfDayTest) Equal(result interface{}) bool {
187 + return v.TimeOfDay == result.(TimeOfDay)
188 +}
189 +func (v TimeOfDayTest) Dupe(tag string) []convTest {
190 + if tag != "no:time.tz" {
191 + return []convTest{TimeOfDayTzTest{v.TimeOfDay}}
192 + }
193 + return nil
194 +}
195 +
196 +type TimeOfDayTzTest struct {
197 + TimeOfDay
198 +}
199 +
200 +func (v TimeOfDayTzTest) Marshal() (string, error) {
201 + return MarshalTimeOfDayTz(v.TimeOfDay)
202 +}
203 +func (v TimeOfDayTzTest) Unmarshal(s string) (interface{}, error) {
204 + return UnmarshalTimeOfDayTz(s)
205 +}
206 +func (v TimeOfDayTzTest) Equal(result interface{}) bool {
207 + return v.TimeOfDay == result.(TimeOfDay)
208 +}
209 +
210 +type DateTimeTest struct{ time.Time }
211 +
212 +func (v DateTimeTest) Marshal() (string, error) {
213 + return MarshalDateTime(time.Time(v.Time))
214 +}
215 +func (v DateTimeTest) Unmarshal(s string) (interface{}, error) {
216 + return UnmarshalDateTime(s)
217 +}
218 +func (v DateTimeTest) Equal(result interface{}) bool {
219 + return v.Time.Equal(result.(time.Time))
220 +}
221 +func (v DateTimeTest) Dupe(tag string) []convTest {
222 + if tag != "no:dateTime.tz" {
223 + return []convTest{DateTimeTzTest{v.Time}}
224 + }
225 + return nil
226 +}
227 +
228 +type DateTimeTzTest struct{ time.Time }
229 +
230 +func (v DateTimeTzTest) Marshal() (string, error) {
231 + return MarshalDateTimeTz(time.Time(v.Time))
232 +}
233 +func (v DateTimeTzTest) Unmarshal(s string) (interface{}, error) {
234 + return UnmarshalDateTimeTz(s)
235 +}
236 +func (v DateTimeTzTest) Equal(result interface{}) bool {
237 + return v.Time.Equal(result.(time.Time))
238 +}
239 +
240 +type BooleanTest bool
241 +
242 +func (v BooleanTest) Marshal() (string, error) {
243 + return MarshalBoolean(bool(v))
244 +}
245 +func (v BooleanTest) Unmarshal(s string) (interface{}, error) {
246 + return UnmarshalBoolean(s)
247 +}
248 +func (v BooleanTest) Equal(result interface{}) bool {
249 + return bool(v) == result.(bool)
250 +}
251 +
252 +type BinBase64Test []byte
253 +
254 +func (v BinBase64Test) Marshal() (string, error) {
255 + return MarshalBinBase64([]byte(v))
256 +}
257 +func (v BinBase64Test) Unmarshal(s string) (interface{}, error) {
258 + return UnmarshalBinBase64(s)
259 +}
260 +func (v BinBase64Test) Equal(result interface{}) bool {
261 + return bytes.Equal([]byte(v), result.([]byte))
262 +}
263 +
264 +type BinHexTest []byte
265 +
266 +func (v BinHexTest) Marshal() (string, error) {
267 + return MarshalBinHex([]byte(v))
268 +}
269 +func (v BinHexTest) Unmarshal(s string) (interface{}, error) {
270 + return UnmarshalBinHex(s)
271 +}
272 +func (v BinHexTest) Equal(result interface{}) bool {
273 + return bytes.Equal([]byte(v), result.([]byte))
274 +}
275 +
276 +func Test(t *testing.T) {
277 + const time010203 time.Duration = (1*3600 + 2*60 + 3) * time.Second
278 + const time0102 time.Duration = (1*3600 + 2*60) * time.Second
279 + const time01 time.Duration = (1 * 3600) * time.Second
280 + const time235959 time.Duration = (23*3600 + 59*60 + 59) * time.Second
281 +
282 + // Fake out the local time for the implementation.
283 + localLoc = time.FixedZone("Fake/Local", 6*3600)
284 + defer func() {
285 + localLoc = time.Local
286 + }()
287 +
288 + tests := []testCase{
289 + // ui1
290 + {str: "", value: Ui1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
291 + {str: " ", value: Ui1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
292 + {str: "abc", value: Ui1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
293 + {str: "-1", value: Ui1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
294 + {str: "0", value: Ui1Test(0), tag: "dupe"},
295 + {str: "1", value: Ui1Test(1), tag: "dupe"},
296 + {str: "255", value: Ui1Test(255), tag: "dupe"},
297 + {str: "256", value: Ui1Test(0), wantUnmarshalErr: true, noMarshal: true},
298 +
299 + // ui2
300 + {str: "65535", value: Ui2Test(65535)},
301 + {str: "65536", value: Ui2Test(0), wantUnmarshalErr: true, noMarshal: true},
302 +
303 + // ui4
304 + {str: "4294967295", value: Ui4Test(4294967295)},
305 + {str: "4294967296", value: Ui4Test(0), wantUnmarshalErr: true, noMarshal: true},
306 +
307 + // i1
308 + {str: "", value: I1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
309 + {str: " ", value: I1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
310 + {str: "abc", value: I1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
311 + {str: "0", value: I1Test(0), tag: "dupe"},
312 + {str: "-1", value: I1Test(-1), tag: "dupe"},
313 + {str: "127", value: I1Test(127), tag: "dupe"},
314 + {str: "-128", value: I1Test(-128), tag: "dupe"},
315 + {str: "128", value: I1Test(0), wantUnmarshalErr: true, noMarshal: true},
316 + {str: "-129", value: I1Test(0), wantUnmarshalErr: true, noMarshal: true},
317 +
318 + // i2
319 + {str: "32767", value: I2Test(32767)},
320 + {str: "-32768", value: I2Test(-32768)},
321 + {str: "32768", value: I2Test(0), wantUnmarshalErr: true, noMarshal: true},
322 + {str: "-32769", value: I2Test(0), wantUnmarshalErr: true, noMarshal: true},
323 +
324 + // i4
325 + {str: "2147483647", value: I4Test(2147483647)},
326 + {str: "-2147483648", value: I4Test(-2147483648)},
327 + {str: "2147483648", value: I4Test(0), wantUnmarshalErr: true, noMarshal: true},
328 + {str: "-2147483649", value: I4Test(0), wantUnmarshalErr: true, noMarshal: true},
329 +
330 + // int
331 + {str: "9223372036854775807", value: IntTest(9223372036854775807)},
332 + {str: "-9223372036854775808", value: IntTest(-9223372036854775808)},
333 + {str: "9223372036854775808", value: IntTest(0), wantUnmarshalErr: true, noMarshal: true},
334 + {str: "-9223372036854775809", value: IntTest(0), wantUnmarshalErr: true, noMarshal: true},
335 +
336 + // fixed.14.4
337 + {str: "0.0000", value: Fixed14_4Test(0)},
338 + {str: "1.0000", value: Fixed14_4Test(1)},
339 + {str: "1.2346", value: Fixed14_4Test(1.23456)},
340 + {str: "-1.0000", value: Fixed14_4Test(-1)},
341 + {str: "-1.2346", value: Fixed14_4Test(-1.23456)},
342 + {str: "10000000000000.0000", value: Fixed14_4Test(1e13)},
343 + {str: "100000000000000.0000", value: Fixed14_4Test(1e14), wantMarshalErr: true, wantUnmarshalErr: true},
344 + {str: "-10000000000000.0000", value: Fixed14_4Test(-1e13)},
345 + {str: "-100000000000000.0000", value: Fixed14_4Test(-1e14), wantMarshalErr: true, wantUnmarshalErr: true},
346 +
347 + // char
348 + {str: "a", value: CharTest('a')},
349 + {str: "z", value: CharTest('z')},
350 + {str: "\u1234", value: CharTest(0x1234)},
351 + {str: "aa", value: CharTest(0), wantMarshalErr: true, wantUnmarshalErr: true},
352 + {str: "", value: CharTest(0), wantMarshalErr: true, wantUnmarshalErr: true},
353 +
354 + // date
355 + {str: "2013-10-08", value: DateTest{time.Date(2013, 10, 8, 0, 0, 0, 0, localLoc)}, tag: "no:dateTime"},
356 + {str: "20131008", value: DateTest{time.Date(2013, 10, 8, 0, 0, 0, 0, localLoc)}, noMarshal: true, tag: "no:dateTime"},
357 + {str: "2013-10-08T10:30:50", value: DateTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime"},
358 + {str: "2013-10-08T10:30:50Z", value: DateTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime"},
359 + {str: "", value: DateTest{}, wantMarshalErr: true, wantUnmarshalErr: true, noMarshal: true},
360 + {str: "-1", value: DateTest{}, wantUnmarshalErr: true, noMarshal: true},
361 +
362 + // time
363 + {str: "00:00:00", value: TimeOfDayTest{TimeOfDay{FromMidnight: 0}}},
364 + {str: "000000", value: TimeOfDayTest{TimeOfDay{FromMidnight: 0}}, noMarshal: true},
365 + {str: "24:00:00", value: TimeOfDayTest{TimeOfDay{FromMidnight: 24 * time.Hour}}, noMarshal: true}, // ISO8601 special case
366 + {str: "24:01:00", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true},
367 + {str: "24:00:01", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true},
368 + {str: "25:00:00", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true},
369 + {str: "00:60:00", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true},
370 + {str: "00:00:60", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true},
371 + {str: "01:02:03", value: TimeOfDayTest{TimeOfDay{FromMidnight: time010203}}},
372 + {str: "010203", value: TimeOfDayTest{TimeOfDay{FromMidnight: time010203}}, noMarshal: true},
373 + {str: "23:59:59", value: TimeOfDayTest{TimeOfDay{FromMidnight: time235959}}},
374 + {str: "235959", value: TimeOfDayTest{TimeOfDay{FromMidnight: time235959}}, noMarshal: true},
375 + {str: "01:02", value: TimeOfDayTest{TimeOfDay{FromMidnight: time0102}}, noMarshal: true},
376 + {str: "0102", value: TimeOfDayTest{TimeOfDay{FromMidnight: time0102}}, noMarshal: true},
377 + {str: "01", value: TimeOfDayTest{TimeOfDay{FromMidnight: time01}}, noMarshal: true},
378 + {str: "foo 01:02:03", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
379 + {str: "foo\n01:02:03", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
380 + {str: "01:02:03 foo", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
381 + {str: "01:02:03\nfoo", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
382 + {str: "01:02:03Z", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
383 + {str: "01:02:03+01", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
384 + {str: "01:02:03+01:23", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
385 + {str: "01:02:03+0123", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
386 + {str: "01:02:03-01", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
387 + {str: "01:02:03-01:23", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
388 + {str: "01:02:03-0123", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
389 +
390 + // time.tz
391 + {str: "24:00:01", value: TimeOfDayTzTest{}, wantUnmarshalErr: true, noMarshal: true},
392 + {str: "01Z", value: TimeOfDayTzTest{TimeOfDay{time01, true, 0}}, noMarshal: true},
393 + {str: "01:02:03Z", value: TimeOfDayTzTest{TimeOfDay{time010203, true, 0}}},
394 + {str: "01+01", value: TimeOfDayTzTest{TimeOfDay{time01, true, 3600}}, noMarshal: true},
395 + {str: "01:02:03+01", value: TimeOfDayTzTest{TimeOfDay{time010203, true, 3600}}, noMarshal: true},
396 + {str: "01:02:03+01:23", value: TimeOfDayTzTest{TimeOfDay{time010203, true, 3600 + 23*60}}},
397 + {str: "01:02:03+0123", value: TimeOfDayTzTest{TimeOfDay{time010203, true, 3600 + 23*60}}, noMarshal: true},
398 + {str: "01:02:03-01", value: TimeOfDayTzTest{TimeOfDay{time010203, true, -3600}}, noMarshal: true},
399 + {str: "01:02:03-01:23", value: TimeOfDayTzTest{TimeOfDay{time010203, true, -(3600 + 23*60)}}},
400 + {str: "01:02:03-0123", value: TimeOfDayTzTest{TimeOfDay{time010203, true, -(3600 + 23*60)}}, noMarshal: true},
401 +
402 + // dateTime
403 + {str: "2013-10-08T00:00:00", value: DateTimeTest{time.Date(2013, 10, 8, 0, 0, 0, 0, localLoc)}, tag: "no:dateTime.tz"},
404 + {str: "20131008", value: DateTimeTest{time.Date(2013, 10, 8, 0, 0, 0, 0, localLoc)}, noMarshal: true},
405 + {str: "2013-10-08T10:30:50", value: DateTimeTest{time.Date(2013, 10, 8, 10, 30, 50, 0, localLoc)}, tag: "no:dateTime.tz"},
406 + {str: "2013-10-08T10:30:50T", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true},
407 + {str: "2013-10-08T10:30:50+01", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime.tz"},
408 + {str: "2013-10-08T10:30:50+01:23", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime.tz"},
409 + {str: "2013-10-08T10:30:50+0123", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime.tz"},
410 + {str: "2013-10-08T10:30:50-01", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime.tz"},
411 + {str: "2013-10-08T10:30:50-01:23", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime.tz"},
412 + {str: "2013-10-08T10:30:50-0123", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime.tz"},
413 +
414 + // dateTime.tz
415 + {str: "2013-10-08T10:30:50", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, localLoc)}, noMarshal: true},
416 + {str: "2013-10-08T10:30:50+01", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, time.FixedZone("+01:00", 3600))}, noMarshal: true},
417 + {str: "2013-10-08T10:30:50+01:23", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, time.FixedZone("+01:23", 3600+23*60))}},
418 + {str: "2013-10-08T10:30:50+0123", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, time.FixedZone("+01:23", 3600+23*60))}, noMarshal: true},
419 + {str: "2013-10-08T10:30:50-01", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, time.FixedZone("-01:00", -3600))}, noMarshal: true},
420 + {str: "2013-10-08T10:30:50-01:23", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, time.FixedZone("-01:23", -(3600+23*60)))}},
421 + {str: "2013-10-08T10:30:50-0123", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, time.FixedZone("-01:23", -(3600+23*60)))}, noMarshal: true},
422 +
423 + // boolean
424 + {str: "0", value: BooleanTest(false)},
425 + {str: "1", value: BooleanTest(true)},
426 + {str: "false", value: BooleanTest(false), noMarshal: true},
427 + {str: "true", value: BooleanTest(true), noMarshal: true},
428 + {str: "no", value: BooleanTest(false), noMarshal: true},
429 + {str: "yes", value: BooleanTest(true), noMarshal: true},
430 + {str: "", value: BooleanTest(false), noMarshal: true, wantUnmarshalErr: true},
431 + {str: "other", value: BooleanTest(false), noMarshal: true, wantUnmarshalErr: true},
432 + {str: "2", value: BooleanTest(false), noMarshal: true, wantUnmarshalErr: true},
433 + {str: "-1", value: BooleanTest(false), noMarshal: true, wantUnmarshalErr: true},
434 +
435 + // bin.base64
436 + {str: "", value: BinBase64Test{}},
437 + {str: "YQ==", value: BinBase64Test("a")},
438 + {str: "TG9uZ2VyIFN0cmluZy4=", value: BinBase64Test("Longer String.")},
439 + {str: "TG9uZ2VyIEFsaWduZWQu", value: BinBase64Test("Longer Aligned.")},
440 +
441 + // bin.hex
442 + {str: "", value: BinHexTest{}},
443 + {str: "61", value: BinHexTest("a")},
444 + {str: "4c6f6e67657220537472696e672e", value: BinHexTest("Longer String.")},
445 + {str: "4C6F6E67657220537472696E672E", value: BinHexTest("Longer String."), noMarshal: true},
446 + }
447 +
448 + // Generate extra test cases from convTests that implement duper.
449 + var extras []testCase
450 + for i := range tests {
451 + if duper, ok := tests[i].value.(duper); ok {
452 + dupes := duper.Dupe(tests[i].tag)
453 + for _, duped := range dupes {
454 + dupedCase := testCase(tests[i])
455 + dupedCase.value = duped
456 + extras = append(extras, dupedCase)
457 + }
458 + }
459 + }
460 + tests = append(tests, extras...)
461 +
462 + for _, test := range tests {
463 + if test.noMarshal {
464 + } else if resultStr, err := test.value.Marshal(); err != nil && !test.wantMarshalErr {
465 + t.Errorf("For %T marshal %v, want %q, got error: %v", test.value, test.value, test.str, err)
466 + } else if err == nil && test.wantMarshalErr {
467 + t.Errorf("For %T marshal %v, want error, got %q", test.value, test.value, resultStr)
468 + } else if err == nil && resultStr != test.str {
469 + t.Errorf("For %T marshal %v, want %q, got %q", test.value, test.value, test.str, resultStr)
470 + }
471 +
472 + if test.noUnMarshal {
473 + } else if resultValue, err := test.value.Unmarshal(test.str); err != nil && !test.wantUnmarshalErr {
474 + t.Errorf("For %T unmarshal %q, want %v, got error: %v", test.value, test.str, test.value, err)
475 + } else if err == nil && test.wantUnmarshalErr {
476 + t.Errorf("For %T unmarshal %q, want error, got %v", test.value, test.str, resultValue)
477 + } else if err == nil && !test.value.Equal(resultValue) {
478 + t.Errorf("For %T unmarshal %q, want %v, got %v", test.value, test.str, test.value, resultValue)
479 + }
480 + }
481 +}
Godeps/_workspace/src/github.com/huin/goupnp/ssdp/registry.go new
+202
@@ -0,0 +1,202 @@
1 +package ssdp
2 +
3 +import (
4 + "fmt"
5 + "log"
6 + "net/http"
7 + "net/url"
8 + "regexp"
9 + "strconv"
10 + "sync"
11 + "time"
12 +
13 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/httpu"
14 +)
15 +
16 +const (
17 + maxExpiryTimeSeconds = 24 * 60 * 60
18 +)
19 +
20 +var (
21 + maxAgeRx = regexp.MustCompile("max-age=([0-9]+)")
22 +)
23 +
24 +type Entry struct {
25 + // The address that the entry data was actually received from.
26 + RemoteAddr string
27 + // Unique Service Name. Identifies a unique instance of a device or service.
28 + USN string
29 + // Notfication Type. The type of device or service being announced.
30 + NT string
31 + // Server's self-identifying string.
32 + Server string
33 + Host string
34 + // Location of the UPnP root device description.
35 + Location *url.URL
36 +
37 + // Despite BOOTID,CONFIGID being required fields, apparently they are not
38 + // always set by devices. Set to -1 if not present.
39 +
40 + BootID int32
41 + ConfigID int32
42 +
43 + SearchPort uint16
44 +
45 + // When the last update was received for this entry identified by this USN.
46 + LastUpdate time.Time
47 + // When the last update's cached values are advised to expire.
48 + CacheExpiry time.Time
49 +}
50 +
51 +func newEntryFromRequest(r *http.Request) (*Entry, error) {
52 + now := time.Now()
53 + expiryDuration, err := parseCacheControlMaxAge(r.Header.Get("CACHE-CONTROL"))
54 + if err != nil {
55 + return nil, fmt.Errorf("ssdp: error parsing CACHE-CONTROL max age: %v", err)
56 + }
57 +
58 + loc, err := url.Parse(r.Header.Get("LOCATION"))
59 + if err != nil {
60 + return nil, fmt.Errorf("ssdp: error parsing entry Location URL: %v", err)
61 + }
62 +
63 + bootID, err := parseUpnpIntHeader(r.Header, "BOOTID.UPNP.ORG", -1)
64 + if err != nil {
65 + return nil, err
66 + }
67 + configID, err := parseUpnpIntHeader(r.Header, "CONFIGID.UPNP.ORG", -1)
68 + if err != nil {
69 + return nil, err
70 + }
71 + searchPort, err := parseUpnpIntHeader(r.Header, "SEARCHPORT.UPNP.ORG", ssdpSearchPort)
72 + if err != nil {
73 + return nil, err
74 + }
75 +
76 + if searchPort < 1 || searchPort > 65535 {
77 + return nil, fmt.Errorf("ssdp: search port %d is out of range", searchPort)
78 + }
79 +
80 + return &Entry{
81 + RemoteAddr: r.RemoteAddr,
82 + USN: r.Header.Get("USN"),
83 + NT: r.Header.Get("NT"),
84 + Server: r.Header.Get("SERVER"),
85 + Host: r.Header.Get("HOST"),
86 + Location: loc,
87 + BootID: bootID,
88 + ConfigID: configID,
89 + SearchPort: uint16(searchPort),
90 + LastUpdate: now,
91 + CacheExpiry: now.Add(expiryDuration),
92 + }, nil
93 +}
94 +
95 +func parseCacheControlMaxAge(cc string) (time.Duration, error) {
96 + matches := maxAgeRx.FindStringSubmatch(cc)
97 + if len(matches) != 2 {
98 + return 0, fmt.Errorf("did not find exactly one max-age in cache control header: %q", cc)
99 + }
100 + expirySeconds, err := strconv.ParseInt(matches[1], 10, 16)
101 + if err != nil {
102 + return 0, err
103 + }
104 + if expirySeconds < 1 || expirySeconds > maxExpiryTimeSeconds {
105 + return 0, fmt.Errorf("rejecting bad expiry time of %d seconds", expirySeconds)
106 + }
107 + return time.Duration(expirySeconds) * time.Second, nil
108 +}
109 +
110 +// parseUpnpIntHeader is intended to parse the
111 +// {BOOT,CONFIGID,SEARCHPORT}.UPNP.ORG header fields. It returns the def if
112 +// the head is empty or missing.
113 +func parseUpnpIntHeader(headers http.Header, headerName string, def int32) (int32, error) {
114 + s := headers.Get(headerName)
115 + if s == "" {
116 + return def, nil
117 + }
118 + v, err := strconv.ParseInt(s, 10, 32)
119 + if err != nil {
120 + return 0, fmt.Errorf("ssdp: could not parse header %s: %v", headerName, err)
121 + }
122 + return int32(v), nil
123 +}
124 +
125 +var _ httpu.Handler = new(Registry)
126 +
127 +// Registry maintains knowledge of discovered devices and services.
128 +type Registry struct {
129 + lock sync.Mutex
130 + byUSN map[string]*Entry
131 +}
132 +
133 +func NewRegistry() *Registry {
134 + return &Registry{
135 + byUSN: make(map[string]*Entry),
136 + }
137 +}
138 +
139 +// ServeMessage implements httpu.Handler, and uses SSDP NOTIFY requests to
140 +// maintain the registry of devices and services.
141 +func (reg *Registry) ServeMessage(r *http.Request) {
142 + if r.Method != methodNotify {
143 + return
144 + }
145 +
146 + nts := r.Header.Get("nts")
147 +
148 + var err error
149 + switch nts {
150 + case ntsAlive:
151 + err = reg.handleNTSAlive(r)
152 + case ntsUpdate:
153 + err = reg.handleNTSUpdate(r)
154 + case ntsByebye:
155 + err = reg.handleNTSByebye(r)
156 + default:
157 + err = fmt.Errorf("unknown NTS value: %q", nts)
158 + }
159 + log.Printf("In %s request from %s: %v", nts, r.RemoteAddr, err)
160 +}
161 +
162 +func (reg *Registry) handleNTSAlive(r *http.Request) error {
163 + entry, err := newEntryFromRequest(r)
164 + if err != nil {
165 + return err
166 + }
167 +
168 + reg.lock.Lock()
169 + defer reg.lock.Unlock()
170 +
171 + reg.byUSN[entry.USN] = entry
172 +
173 + return nil
174 +}
175 +
176 +func (reg *Registry) handleNTSUpdate(r *http.Request) error {
177 + entry, err := newEntryFromRequest(r)
178 + if err != nil {
179 + return err
180 + }
181 + nextBootID, err := parseUpnpIntHeader(r.Header, "NEXTBOOTID.UPNP.ORG", -1)
182 + if err != nil {
183 + return err
184 + }
185 + entry.BootID = nextBootID
186 +
187 + reg.lock.Lock()
188 + defer reg.lock.Unlock()
189 +
190 + reg.byUSN[entry.USN] = entry
191 +
192 + return nil
193 +}
194 +
195 +func (reg *Registry) handleNTSByebye(r *http.Request) error {
196 + reg.lock.Lock()
197 + defer reg.lock.Unlock()
198 +
199 + delete(reg.byUSN, r.Header.Get("USN"))
200 +
201 + return nil
202 +}
Godeps/_workspace/src/github.com/huin/goupnp/ssdp/ssdp.go new
+83
@@ -0,0 +1,83 @@
1 +package ssdp
2 +
3 +import (
4 + "errors"
5 + "log"
6 + "net/http"
7 + "net/url"
8 + "strconv"
9 + "time"
10 +
11 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/huin/goupnp/httpu"
12 +)
13 +
14 +const (
15 + ssdpDiscover = `"ssdp:discover"`
16 + ntsAlive = `ssdp:alive`
17 + ntsByebye = `ssdp:byebye`
18 + ntsUpdate = `ssdp:update`
19 + ssdpUDP4Addr = "239.255.255.250:1900"
20 + ssdpSearchPort = 1900
21 + methodSearch = "M-SEARCH"
22 + methodNotify = "NOTIFY"
23 +)
24 +
25 +// SSDPRawSearch performs a fairly raw SSDP search request, and returns the
26 +// unique response(s) that it receives. Each response has the requested
27 +// searchTarget, a USN, and a valid location. maxWaitSeconds states how long to
28 +// wait for responses in seconds, and must be a minimum of 1 (the
29 +// implementation waits an additional 100ms for responses to arrive), 2 is a
30 +// reasonable value for this. numSends is the number of requests to send - 3 is
31 +// a reasonable value for this.
32 +func SSDPRawSearch(httpu *httpu.HTTPUClient, searchTarget string, maxWaitSeconds int, numSends int) ([]*http.Response, error) {
33 + if maxWaitSeconds < 1 {
34 + return nil, errors.New("ssdp: maxWaitSeconds must be >= 1")
35 + }
36 +
37 + seenUsns := make(map[string]bool)
38 + var responses []*http.Response
39 + req := http.Request{
40 + Method: methodSearch,
41 + // TODO: Support both IPv4 and IPv6.
42 + Host: ssdpUDP4Addr,
43 + URL: &url.URL{Opaque: "*"},
44 + Header: http.Header{
45 + // Putting headers in here avoids them being title-cased.
46 + // (The UPnP discovery protocol uses case-sensitive headers)
47 + "HOST": []string{ssdpUDP4Addr},
48 + "MX": []string{strconv.FormatInt(int64(maxWaitSeconds), 10)},
49 + "MAN": []string{ssdpDiscover},
50 + "ST": []string{searchTarget},
51 + },
52 + }
53 + allResponses, err := httpu.Do(&req, time.Duration(maxWaitSeconds)*time.Second+100*time.Millisecond, numSends)
54 + if err != nil {
55 + return nil, err
56 + }
57 + for _, response := range allResponses {
58 + if response.StatusCode != 200 {
59 + log.Printf("ssdp: got response status code %q in search response", response.Status)
60 + continue
61 + }
62 + if st := response.Header.Get("ST"); st != searchTarget {
63 + log.Printf("ssdp: got unexpected search target result %q", st)
64 + continue
65 + }
66 + location, err := response.Location()
67 + if err != nil {
68 + log.Printf("ssdp: no usable location in search response (discarding): %v", err)
69 + continue
70 + }
71 + usn := response.Header.Get("USN")
72 + if usn == "" {
73 + log.Printf("ssdp: empty/missing USN in search response (using location instead): %v", err)
74 + usn = location.String()
75 + }
76 + if _, alreadySeen := seenUsns[usn]; !alreadySeen {
77 + seenUsns[usn] = true
78 + responses = append(responses, response)
79 + }
80 + }
81 +
82 + return responses, nil
83 +}
Godeps/_workspace/src/github.com/jackpal/go-nat-pmp/LICENSE new
+13
@@ -0,0 +1,13 @@
1 + Copyright 2013 John Howard Palevich
2 +
3 + Licensed under the Apache License, Version 2.0 (the "License");
4 + you may not use this file except in compliance with the License.
5 + You may obtain a copy of the License at
6 +
7 + http://www.apache.org/licenses/LICENSE-2.0
8 +
9 + Unless required by applicable law or agreed to in writing, software
10 + distributed under the License is distributed on an "AS IS" BASIS,
11 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 + See the License for the specific language governing permissions and
13 + limitations under the License.
Godeps/_workspace/src/github.com/jackpal/go-nat-pmp/README.md new
+48
@@ -0,0 +1,48 @@
1 +go-nat-pmp
2 +==========
3 +
4 +A Go language client for the NAT-PMP internet protocol for port mapping and discovering the external
5 +IP address of a firewall.
6 +
7 +NAT-PMP is supported by Apple brand routers and open source routers like Tomato and DD-WRT.
8 +
9 +See http://tools.ietf.org/html/draft-cheshire-nat-pmp-03
10 +
11 +Get the package
12 +---------------
13 +
14 + go get -u github.com/jackpal/go-nat-pmp
15 +
16 +Usage
17 +-----
18 +
19 + import natpmp "github.com/jackpal/go-nat-pmp"
20 +
21 + client := natpmp.NewClient(gatewayIP)
22 + response, err := client.GetExternalAddress()
23 + if err != nil {
24 + return
25 + }
26 + print("External IP address:", response.ExternalIPAddress)
27 +
28 +Notes
29 +-----
30 +
31 +There doesn't seem to be an easy way to programmatically determine the address of the default gateway.
32 +(Linux and OSX have a "routes" kernel API that can be examined to get this information, but there is
33 +no Go package for getting this information.)
34 +
35 +Clients
36 +-------
37 +
38 +This library is used in the Taipei Torrent BitTorrent client http://github.com/jackpal/Taipei-Torrent
39 +
40 +Complete documentation
41 +----------------------
42 +
43 + http://godoc.org/github.com/jackpal/go-nat-pmp
44 +
45 +License
46 +-------
47 +
48 +This project is licensed under the Apache License 2.0.
Godeps/_workspace/src/github.com/jackpal/go-nat-pmp/natpmp.go new
+184
@@ -0,0 +1,184 @@
1 +package natpmp
2 +
3 +import (
4 + "fmt"
5 + "log"
6 + "net"
7 + "time"
8 +)
9 +
10 +// Implement the NAT-PMP protocol, typically supported by Apple routers and open source
11 +// routers such as DD-WRT and Tomato.
12 +//
13 +// See http://tools.ietf.org/html/draft-cheshire-nat-pmp-03
14 +//
15 +// Usage:
16 +//
17 +// client := natpmp.NewClient(gatewayIP)
18 +// response, err := client.GetExternalAddress()
19 +
20 +const nAT_PMP_PORT = 5351
21 +
22 +const nAT_TRIES = 9
23 +
24 +const nAT_INITIAL_MS = 250
25 +
26 +// The recommended mapping lifetime for AddPortMapping
27 +const RECOMMENDED_MAPPING_LIFETIME_SECONDS = 3600
28 +
29 +// Client is a NAT-PMP protocol client.
30 +type Client struct {
31 + gateway net.IP
32 +}
33 +
34 +// Create a NAT-PMP client for the NAT-PMP server at the gateway.
35 +func NewClient(gateway net.IP) (nat *Client) {
36 + return &Client{gateway}
37 +}
38 +
39 +// Results of the NAT-PMP GetExternalAddress operation
40 +type GetExternalAddressResult struct {
41 + SecondsSinceStartOfEpoc uint32
42 + ExternalIPAddress [4]byte
43 +}
44 +
45 +// Get the external address of the router.
46 +func (n *Client) GetExternalAddress() (result *GetExternalAddressResult, err error) {
47 + msg := make([]byte, 2)
48 + msg[0] = 0 // Version 0
49 + msg[1] = 0 // OP Code 0
50 + response, err := n.rpc(msg, 12)
51 + if err != nil {
52 + return
53 + }
54 + result = &GetExternalAddressResult{}
55 + result.SecondsSinceStartOfEpoc = readNetworkOrderUint32(response[4:8])
56 + copy(result.ExternalIPAddress[:], response[8:12])
57 + return
58 +}
59 +
60 +// Results of the NAT-PMP AddPortMapping operation
61 +type AddPortMappingResult struct {
62 + SecondsSinceStartOfEpoc uint32
63 + InternalPort uint16
64 + MappedExternalPort uint16
65 + PortMappingLifetimeInSeconds uint32
66 +}
67 +
68 +// Add (or delete) a port mapping. To delete a mapping, set the requestedExternalPort and lifetime to 0
69 +func (n *Client) AddPortMapping(protocol string, internalPort, requestedExternalPort int, lifetime int) (result *AddPortMappingResult, err error) {
70 + var opcode byte
71 + if protocol == "udp" {
72 + opcode = 1
73 + } else if protocol == "tcp" {
74 + opcode = 2
75 + } else {
76 + err = fmt.Errorf("unknown protocol %v", protocol)
77 + return
78 + }
79 + msg := make([]byte, 12)
80 + msg[0] = 0 // Version 0
81 + msg[1] = opcode
82 + writeNetworkOrderUint16(msg[4:6], uint16(internalPort))
83 + writeNetworkOrderUint16(msg[6:8], uint16(requestedExternalPort))
84 + writeNetworkOrderUint32(msg[8:12], uint32(lifetime))
85 + response, err := n.rpc(msg, 16)
86 + if err != nil {
87 + return
88 + }
89 + result = &AddPortMappingResult{}
90 + result.SecondsSinceStartOfEpoc = readNetworkOrderUint32(response[4:8])
91 + result.InternalPort = readNetworkOrderUint16(response[8:10])
92 + result.MappedExternalPort = readNetworkOrderUint16(response[10:12])
93 + result.PortMappingLifetimeInSeconds = readNetworkOrderUint32(response[12:16])
94 + return
95 +}
96 +
97 +func (n *Client) rpc(msg []byte, resultSize int) (result []byte, err error) {
98 + var server net.UDPAddr
99 + server.IP = n.gateway
100 + server.Port = nAT_PMP_PORT
101 + conn, err := net.DialUDP("udp", nil, &server)
102 + if err != nil {
103 + return
104 + }
105 + defer conn.Close()
106 +
107 + result = make([]byte, resultSize)
108 +
109 + needNewDeadline := true
110 +
111 + var tries uint
112 + for tries = 0; tries < nAT_TRIES; {
113 + if needNewDeadline {
114 + err = conn.SetDeadline(time.Now().Add((nAT_INITIAL_MS << tries) * time.Millisecond))
115 + if err != nil {
116 + return
117 + }
118 + needNewDeadline = false
119 + }
120 + _, err = conn.Write(msg)
121 + if err != nil {
122 + return
123 + }
124 + var bytesRead int
125 + var remoteAddr *net.UDPAddr
126 + bytesRead, remoteAddr, err = conn.ReadFromUDP(result)
127 + if err != nil {
128 + if err.(net.Error).Timeout() {
129 + tries++
130 + needNewDeadline = true
131 + continue
132 + }
133 + return
134 + }
135 + if !remoteAddr.IP.Equal(n.gateway) {
136 + log.Printf("Ignoring packet because IPs differ:", remoteAddr, n.gateway)
137 + // Ignore this packet.
138 + // Continue without increasing retransmission timeout or deadline.
139 + continue
140 + }
141 + if bytesRead != resultSize {
142 + err = fmt.Errorf("unexpected result size %d, expected %d", bytesRead, resultSize)
143 + return
144 + }
145 + if result[0] != 0 {
146 + err = fmt.Errorf("unknown protocol version %d", result[0])
147 + return
148 + }
149 + expectedOp := msg[1] | 0x80
150 + if result[1] != expectedOp {
151 + err = fmt.Errorf("Unexpected opcode %d. Expected %d", result[1], expectedOp)
152 + return
153 + }
154 + resultCode := readNetworkOrderUint16(result[2:4])
155 + if resultCode != 0 {
156 + err = fmt.Errorf("Non-zero result code %d", resultCode)
157 + return
158 + }
159 + // If we got here the RPC is good.
160 + return
161 + }
162 + err = fmt.Errorf("Timed out trying to contact gateway")
163 + return
164 +}
165 +
166 +func writeNetworkOrderUint16(buf []byte, d uint16) {
167 + buf[0] = byte(d >> 8)
168 + buf[1] = byte(d)
169 +}
170 +
171 +func writeNetworkOrderUint32(buf []byte, d uint32) {
172 + buf[0] = byte(d >> 24)
173 + buf[1] = byte(d >> 16)
174 + buf[2] = byte(d >> 8)
175 + buf[3] = byte(d)
176 +}
177 +
178 +func readNetworkOrderUint16(buf []byte) uint16 {
179 + return (uint16(buf[0]) << 8) | uint16(buf[1])
180 +}
181 +
182 +func readNetworkOrderUint32(buf []byte) uint32 {
183 + return (uint32(buf[0]) << 24) | (uint32(buf[1]) << 16) | (uint32(buf[2]) << 8) | uint32(buf[3])
184 +}