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

Subversion Repositories openrisc

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

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 FreeBSD
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
        mreq, err := syscall.GetsockoptIPMreqn(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF)
18
        if err != nil {
19
                return nil, os.NewSyscallError("getsockopt", err)
20
        }
21
        if int(mreq.Ifindex) == 0 {
22
                return nil, nil
23
        }
24
        return InterfaceByIndex(int(mreq.Ifindex))
25
}
26
 
27
func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error {
28
        var v int32
29
        if ifi != nil {
30
                v = int32(ifi.Index)
31
        }
32
        mreq := &syscall.IPMreqn{Ifindex: v}
33
        fd.incref()
34
        defer fd.decref()
35
        err := syscall.SetsockoptIPMreqn(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, mreq)
36
        if err != nil {
37
                return os.NewSyscallError("setsockopt", err)
38
        }
39
        return nil
40
}
41
 
42
func ipv4MulticastLoopback(fd *netFD) (bool, error) {
43
        fd.incref()
44
        defer fd.decref()
45
        v, err := syscall.GetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP)
46
        if err != nil {
47
                return false, os.NewSyscallError("getsockopt", err)
48
        }
49
        return v == 1, nil
50
}
51
 
52
func setIPv4MulticastLoopback(fd *netFD, v bool) error {
53
        fd.incref()
54
        defer fd.decref()
55
        err := syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP, boolint(v))
56
        if err != nil {
57
                return os.NewSyscallError("setsockopt", err)
58
        }
59
        return nil
60
}
61
 
62
func ipv4ReceiveInterface(fd *netFD) (bool, error) {
63
        fd.incref()
64
        defer fd.decref()
65
        v, err := syscall.GetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_RECVIF)
66
        if err != nil {
67
                return false, os.NewSyscallError("getsockopt", err)
68
        }
69
        return v == 1, nil
70
}
71
 
72
func setIPv4ReceiveInterface(fd *netFD, v bool) error {
73
        fd.incref()
74
        defer fd.decref()
75
        err := syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_RECVIF, boolint(v))
76
        if err != nil {
77
                return os.NewSyscallError("setsockopt", err)
78
        }
79
        return nil
80
}

powered by: WebSVN 2.1.0

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