if n > 0 {
sl += Socklen_t(n) + 1
}
- if sa.raw.Path[0] == '@' {
- sa.raw.Path[0] = 0
- // Don't count trailing NUL for abstract address.
- sl--
- }
+ sl = sa.raw.adjustAbstract(sl)
// length is family (uint16), name, NUL.
return (*RawSockaddrAny)(unsafe.Pointer(&sa.raw)), sl, nil
const SizeofSockaddrUnix = 110
type RawSockaddrInet4 struct {
- Len uint8;
- Family uint8;
- Port uint16;
- Addr [4]byte /* in_addr */;
- Zero [8]uint8;
+ Len uint8
+ Family uint8
+ Port uint16
+ Addr [4]byte /* in_addr */
+ Zero [8]uint8
}
func (sa *RawSockaddrInet4) setLen() Socklen_t {
}
type RawSockaddrInet6 struct {
- Len uint8;
- Family uint8;
- Port uint16;
- Flowinfo uint32;
- Addr [16]byte /* in6_addr */;
- Scope_id uint32;
+ Len uint8
+ Family uint8
+ Port uint16
+ Flowinfo uint32
+ Addr [16]byte /* in6_addr */
+ Scope_id uint32
}
func (sa *RawSockaddrInet6) setLen() Socklen_t {
}
type RawSockaddrUnix struct {
- Len uint8;
- Family uint8;
- Path [108]int8;
+ Len uint8
+ Family uint8
+ Path [108]int8
}
func (sa *RawSockaddrUnix) setLen(n int) {
return n, nil
}
+func (sa *RawSockaddrUnix) adjustAbstract(sl Socklen_t) Socklen_t {
+ return sl
+}
+
type RawSockaddr struct {
- Len uint8;
- Family uint8;
- Data [14]int8;
+ Len uint8
+ Family uint8
+ Data [14]int8
}
// BindToDevice binds the socket associated with fd to device.
type RawSockaddrInet4 struct {
Family uint16
- Port uint16
- Addr [4]byte /* in_addr */
- Zero [8]uint8
+ Port uint16
+ Addr [4]byte /* in_addr */
+ Zero [8]uint8
}
func (sa *RawSockaddrInet4) setLen() Socklen_t {
}
type RawSockaddrInet6 struct {
- Family uint16
- Port uint16
+ Family uint16
+ Port uint16
Flowinfo uint32
- Addr [16]byte /* in6_addr */
+ Addr [16]byte /* in6_addr */
Scope_id uint32
- Src_id uint32
+ Src_id uint32
}
func (sa *RawSockaddrInet6) setLen() Socklen_t {
type RawSockaddrUnix struct {
Family uint16
- Path [108]int8
+ Path [108]int8
}
func (sa *RawSockaddrUnix) setLen(int) {
}
func (sa *RawSockaddrUnix) getLen() (int, error) {
- if sa.Path[0] == 0 {
- // "Abstract" Unix domain socket.
- // Rewrite leading NUL as @ for textual display.
- // (This is the standard convention.)
- // Not friendly to overwrite in place,
- // but the callers below don't care.
- sa.Path[0] = '@'
- }
-
- // Assume path ends at NUL.
- // This is not technically the GNU/Linux semantics for
- // abstract Unix domain sockets--they are supposed
- // to be uninterpreted fixed-size binary blobs--but
- // everyone uses this convention.
n := 0
- for n < len(sa.Path) - 3 && sa.Path[n] != 0 {
+ for n < len(sa.Path) && sa.Path[n] != 0 {
n++
}
-
return n, nil
}
+func (sa *RawSockaddrUnix) adjustAbstract(sl Socklen_t) Socklen_t {
+ return sl
+}
+
type RawSockaddr struct {
Family uint16
- Data [14]int8
+ Data [14]int8
}
// BindToDevice binds the socket associated with fd to device.