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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2011 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
// IP-level socket options for OpenBSD
6
 
7
package net
8
 
9
import (
10
        "os"
11
        "syscall"
12
)
13
 
14
func ipv4MulticastInterface(fd *netFD) (*Interface, error) {
15
        fd.incref()
16
        defer fd.decref()
17
        a, err := syscall.GetsockoptInet4Addr(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF)
18
        if err != nil {
19
                return nil, os.NewSyscallError("getsockopt", err)
20
        }
21
        return ipv4AddrToInterface(IPv4(a[0], a[1], a[2], a[3]))
22
}
23
 
24
func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error {
25
        ip, err := interfaceToIPv4Addr(ifi)
26
        if err != nil {
27
                return os.NewSyscallError("setsockopt", err)
28
        }
29
        var x [4]byte
30
        copy(x[:], ip.To4())
31
        fd.incref()
32
        defer fd.decref()
33
        err = syscall.SetsockoptInet4Addr(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, x)
34
        if err != nil {
35
                return os.NewSyscallError("setsockopt", err)
36
        }
37
        return nil
38
}
39
 
40
func ipv4MulticastLoopback(fd *netFD) (bool, error) {
41
        fd.incref()
42
        defer fd.decref()
43
        v, err := syscall.GetsockoptByte(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP)
44
        if err != nil {
45
                return false, os.NewSyscallError("getsockopt", err)
46
        }
47
        return v == 1, nil
48
}
49
 
50
func setIPv4MulticastLoopback(fd *netFD, v bool) error {
51
        fd.incref()
52
        defer fd.decref()
53
        err := syscall.SetsockoptByte(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP, byte(boolint(v)))
54
        if err != nil {
55
                return os.NewSyscallError("setsockopt", err)
56
        }
57
        return nil
58
}
59
 
60
func ipv4ReceiveInterface(fd *netFD) (bool, error) {
61
        fd.incref()
62
        defer fd.decref()
63
        v, err := syscall.GetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_RECVIF)
64
        if err != nil {
65
                return false, os.NewSyscallError("getsockopt", err)
66
        }
67
        return v == 1, nil
68
}
69
 
70
func setIPv4ReceiveInterface(fd *netFD, v bool) error {
71
        fd.incref()
72
        defer fd.decref()
73
        err := syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_RECVIF, boolint(v))
74
        if err != nil {
75
                return os.NewSyscallError("setsockopt", err)
76
        }
77
        return nil
78
}

powered by: WebSVN 2.1.0

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