OSDN Git Service

PR c/21659
[pf3gnuchains/gcc-fork.git] / libgo / syscalls / socket_solaris.go
1 // socket_solaris.go -- Socket handling specific to Solaris.
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 = 32
11 const SizeofSockaddrUnix = 110
12
13 type RawSockaddrInet4 struct {
14         Family uint16
15         Port uint16
16         Addr [4]byte /* in_addr */
17         Zero [8]uint8
18 }
19
20 func (sa *RawSockaddrInet4) setLen() Socklen_t {
21         return SizeofSockaddrInet4
22 }
23
24 type RawSockaddrInet6 struct {
25         Family uint16
26         Port uint16
27         Flowinfo uint32
28         Addr [16]byte /* in6_addr */
29         Scope_id uint32
30         Src_id uint32
31 }
32
33 func (sa *RawSockaddrInet6) setLen() Socklen_t {
34         return SizeofSockaddrInet6
35 }
36
37 type RawSockaddrUnix struct {
38         Family uint16
39         Path [108]int8
40 }
41
42 func (sa *RawSockaddrUnix) setLen(int) {
43 }
44
45 func (sa *RawSockaddrUnix) getLen() (int, int) {
46         if sa.Path[0] == 0 {
47                 // "Abstract" Unix domain socket.
48                 // Rewrite leading NUL as @ for textual display.
49                 // (This is the standard convention.)
50                 // Not friendly to overwrite in place,
51                 // but the callers below don't care.
52                 sa.Path[0] = '@'
53         }
54
55         // Assume path ends at NUL.
56         // This is not technically the Linux semantics for
57         // abstract Unix domain sockets--they are supposed
58         // to be uninterpreted fixed-size binary blobs--but
59         // everyone uses this convention.
60         n := 0
61         for n < len(sa.Path) - 3 && sa.Path[n] != 0 {
62                 n++
63         }
64
65         return n, 0
66 }
67
68 type RawSockaddr struct {
69         Family uint16
70         Data [14]int8
71 }
72
73 // BindToDevice binds the socket associated with fd to device.
74 func BindToDevice(fd int, device string) (errno int) {
75         return ENOSYS
76 }