OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [net/] [sock_bsd.go] - Blame information for rev 748

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2009 The Go Authors.  All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
// +build darwin freebsd netbsd openbsd
6
 
7
// Sockets for BSD variants
8
 
9
package net
10
 
11
import (
12
        "runtime"
13
        "syscall"
14
)
15
 
16
func maxListenerBacklog() int {
17
        var (
18
                n   uint32
19
                err error
20
        )
21
        switch runtime.GOOS {
22
        case "darwin", "freebsd":
23
                n, err = syscall.SysctlUint32("kern.ipc.somaxconn")
24
        case "netbsd":
25
                // NOTE: NetBSD has no somaxconn-like kernel state so far
26
        case "openbsd":
27
                n, err = syscall.SysctlUint32("kern.somaxconn")
28
        }
29
        if n == 0 || err != nil {
30
                return syscall.SOMAXCONN
31
        }
32
        return int(n)
33
}
34
 
35
func listenerSockaddr(s, f int, la syscall.Sockaddr, toAddr func(syscall.Sockaddr) Addr) (syscall.Sockaddr, error) {
36
        a := toAddr(la)
37
        if a == nil {
38
                return la, nil
39
        }
40
        switch v := a.(type) {
41
        case *UDPAddr:
42
                if v.IP.IsMulticast() {
43
                        err := setDefaultMulticastSockopts(s)
44
                        if err != nil {
45
                                return nil, err
46
                        }
47
                        switch f {
48
                        case syscall.AF_INET:
49
                                v.IP = IPv4zero
50
                        case syscall.AF_INET6:
51
                                v.IP = IPv6unspecified
52
                        }
53
                        return v.sockaddr(f)
54
                }
55
        }
56
        return la, nil
57
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.