diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2013-03-04 21:27:36 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2013-03-04 21:27:36 +0100 |
commit | 04b08da9af0c450d645ab7389d1467308cfc2db8 (patch) | |
tree | db247935fa4f2f94408edc3acd5d0d4f997aa0d8 /src/pkg/net/sock_unix.go | |
parent | 917c5fb8ec48e22459d77e3849e6d388f93d3260 (diff) | |
download | golang-upstream/1.1_hg20130304.tar.gz |
Imported Upstream version 1.1~hg20130304upstream/1.1_hg20130304
Diffstat (limited to 'src/pkg/net/sock_unix.go')
-rw-r--r-- | src/pkg/net/sock_unix.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/pkg/net/sock_unix.go b/src/pkg/net/sock_unix.go new file mode 100644 index 000000000..b0d6d4900 --- /dev/null +++ b/src/pkg/net/sock_unix.go @@ -0,0 +1,36 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin freebsd linux netbsd openbsd + +package net + +import "syscall" + +func listenerSockaddr(s, f int, la syscall.Sockaddr, toAddr func(syscall.Sockaddr) Addr) (syscall.Sockaddr, error) { + a := toAddr(la) + if a == nil { + return la, nil + } + switch a := a.(type) { + case *TCPAddr, *UnixAddr: + if err := setDefaultListenerSockopts(s); err != nil { + return nil, err + } + case *UDPAddr: + if a.IP.IsMulticast() { + if err := setDefaultMulticastSockopts(s); err != nil { + return nil, err + } + switch f { + case syscall.AF_INET: + a.IP = IPv4zero + case syscall.AF_INET6: + a.IP = IPv6unspecified + } + return a.sockaddr(f) + } + } + return la, nil +} |