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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [syscall/] [socket_bsd.go] - Blame information for rev 801

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

Line No. Rev Author Line
1 747 jeremybenn
// socket_bsd.go -- Socket handling specific to *BSD based systems.
2
 
3
// Copyright 2010 The Go Authors. All rights reserved.
4
// Use of this source code is governed by a BSD-style
5
// license that can be found in the LICENSE file.
6
 
7
package syscall
8
 
9
const SizeofSockaddrInet4 = 16
10
const SizeofSockaddrInet6 = 28
11
const SizeofSockaddrUnix = 110
12
 
13
type RawSockaddrInet4 struct {
14
        Len uint8;
15
        Family uint8;
16
        Port uint16;
17
        Addr [4]byte /* in_addr */;
18
        Zero [8]uint8;
19
}
20
 
21
func (sa *RawSockaddrInet4) setLen() Socklen_t {
22
        sa.Len = SizeofSockaddrInet4
23
        return SizeofSockaddrInet4
24
}
25
 
26
type RawSockaddrInet6 struct {
27
        Len uint8;
28
        Family uint8;
29
        Port uint16;
30
        Flowinfo uint32;
31
        Addr [16]byte /* in6_addr */;
32
        Scope_id uint32;
33
}
34
 
35
func (sa *RawSockaddrInet6) setLen() Socklen_t {
36
        sa.Len = SizeofSockaddrInet6
37
        return SizeofSockaddrInet6
38
}
39
 
40
type RawSockaddrUnix struct {
41
        Len uint8;
42
        Family uint8;
43
        Path [108]int8;
44
}
45
 
46
func (sa *RawSockaddrUnix) setLen(n int) {
47
        sa.Len = uint8(3 + n) // 2 for Family, Len; 1 for NUL.
48
}
49
 
50
func (sa *RawSockaddrUnix) getLen() (int, error) {
51
        if sa.Len < 3 || sa.Len > SizeofSockaddrUnix {
52
                return 0, EINVAL
53
        }
54
        n := int(sa.Len) - 3 // subtract leading Family, Len, terminating NUL.
55
        for i := 0; i < n; i++ {
56
                if sa.Path[i] == 0 {
57
                        // found early NUL; assume Len is overestimating.
58
                        n = i
59
                        break
60
                }
61
        }
62
        return n, nil
63
}
64
 
65
type RawSockaddr struct {
66
        Len uint8;
67
        Family uint8;
68
        Data [14]int8;
69
}
70
 
71
// BindToDevice binds the socket associated with fd to device.
72
func BindToDevice(fd int, device string) (err error) {
73
        return ENOSYS
74
}
75
 
76
func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) {
77
        return nil, EAFNOSUPPORT
78
}

powered by: WebSVN 2.1.0

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