1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:44:40 -07:00

syscall: add IPv6 scope zone ID support

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4515124
This commit is contained in:
Mikio Hara 2011-05-22 10:09:07 -07:00 committed by Brad Fitzpatrick
parent 8c6dc5fea5
commit 12104807de
3 changed files with 15 additions and 8 deletions

View File

@ -191,9 +191,10 @@ func (sa *SockaddrInet4) sockaddr() (uintptr, _Socklen, int) {
}
type SockaddrInet6 struct {
Port int
Addr [16]byte
raw RawSockaddrInet6
Port int
ZoneId uint32
Addr [16]byte
raw RawSockaddrInet6
}
func (sa *SockaddrInet6) sockaddr() (uintptr, _Socklen, int) {
@ -205,6 +206,7 @@ func (sa *SockaddrInet6) sockaddr() (uintptr, _Socklen, int) {
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
p[0] = byte(sa.Port >> 8)
p[1] = byte(sa.Port)
sa.raw.Scope_id = sa.ZoneId
for i := 0; i < len(sa.Addr); i++ {
sa.raw.Addr[i] = sa.Addr[i]
}
@ -297,6 +299,7 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, int) {
sa := new(SockaddrInet6)
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
sa.Port = int(p[0])<<8 + int(p[1])
sa.ZoneId = pp.Scope_id
for i := 0; i < len(sa.Addr); i++ {
sa.Addr[i] = pp.Addr[i]
}

View File

@ -219,9 +219,10 @@ func (sa *SockaddrInet4) sockaddr() (uintptr, _Socklen, int) {
}
type SockaddrInet6 struct {
Port int
Addr [16]byte
raw RawSockaddrInet6
Port int
ZoneId uint32
Addr [16]byte
raw RawSockaddrInet6
}
func (sa *SockaddrInet6) sockaddr() (uintptr, _Socklen, int) {
@ -232,6 +233,7 @@ func (sa *SockaddrInet6) sockaddr() (uintptr, _Socklen, int) {
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
p[0] = byte(sa.Port >> 8)
p[1] = byte(sa.Port)
sa.raw.Scope_id = sa.ZoneId
for i := 0; i < len(sa.Addr); i++ {
sa.raw.Addr[i] = sa.Addr[i]
}
@ -370,6 +372,7 @@ func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, int) {
sa := new(SockaddrInet6)
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
sa.Port = int(p[0])<<8 + int(p[1])
sa.ZoneId = pp.Scope_id
for i := 0; i < len(sa.Addr); i++ {
sa.Addr[i] = pp.Addr[i]
}

View File

@ -536,8 +536,9 @@ func (sa *SockaddrInet4) sockaddr() (uintptr, int32, int) {
}
type SockaddrInet6 struct {
Port int
Addr [16]byte
Port int
ZoneId uint32
Addr [16]byte
}
func (sa *SockaddrInet6) sockaddr() (uintptr, int32, int) {