~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to src/pkg/net/ipsock.go

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
// boolean value is true, kernel supports IPv6 IPv4-mapping.
27
27
func probeIPv6Stack() (supportsIPv6, supportsIPv4map bool) {
28
28
        var probes = []struct {
29
 
                s  int
30
29
                la TCPAddr
31
30
                ok bool
32
31
        }{
33
32
                // IPv6 communication capability
34
 
                {-1, TCPAddr{IP: ParseIP("::1")}, false},
 
33
                {TCPAddr{IP: ParseIP("::1")}, false},
35
34
                // IPv6 IPv4-mapped address communication capability
36
 
                {-1, TCPAddr{IP: IPv4(127, 0, 0, 1)}, false},
 
35
                {TCPAddr{IP: IPv4(127, 0, 0, 1)}, false},
37
36
        }
38
 
        var errno int
39
37
 
40
38
        for i := range probes {
41
 
                probes[i].s, errno = syscall.Socket(syscall.AF_INET6, syscall.SOCK_STREAM, syscall.IPPROTO_TCP)
 
39
                s, errno := syscall.Socket(syscall.AF_INET6, syscall.SOCK_STREAM, syscall.IPPROTO_TCP)
42
40
                if errno != 0 {
43
41
                        continue
44
42
                }
45
 
                defer closesocket(probes[i].s)
 
43
                defer closesocket(s)
46
44
                sa, err := probes[i].la.toAddr().sockaddr(syscall.AF_INET6)
47
45
                if err != nil {
48
46
                        continue
49
47
                }
50
 
                errno = syscall.Bind(probes[i].s, sa)
 
48
                errno = syscall.Bind(s, sa)
51
49
                if errno != 0 {
52
50
                        continue
53
51
                }
270
268
 
271
269
// Convert "host:port" into IP address and port.
272
270
func hostPortToIP(net, hostport string) (ip IP, iport int, err os.Error) {
 
271
        var (
 
272
                addr IP
 
273
                p, i int
 
274
                ok   bool
 
275
        )
273
276
        host, port, err := SplitHostPort(hostport)
274
277
        if err != nil {
275
278
                goto Error
276
279
        }
277
280
 
278
 
        var addr IP
279
281
        if host != "" {
280
282
                // Try as an IP address.
281
283
                addr = ParseIP(host)
302
304
                }
303
305
        }
304
306
 
305
 
        p, i, ok := dtoi(port, 0)
 
307
        p, i, ok = dtoi(port, 0)
306
308
        if !ok || i != len(port) {
307
309
                p, err = LookupPort(net, port)
308
310
                if err != nil {