Commit 534e1870 authored by Mikio Hara's avatar Mikio Hara

ipv4: don't refer to cgo-generated union field

The size of sockaddr_storage is fixed for interoperability on each
platform. There is no need to depend on changable cgo-generated
offset values.

Change-Id: I7469fe330d49867bbdbdfae128834140244925ec
Reviewed-on: https://go-review.googlesource.com/30177
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent a7769702
......@@ -78,18 +78,18 @@ func (pi *sysInetPktinfo) setIfindex(i int) {
}
func (gr *sysGroupReq) setGroup(grp net.IP) {
sa := (*sysSockaddrInet)(unsafe.Pointer(&gr.Pad_cgo_0[0]))
sa := (*sysSockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gr)) + 4))
sa.Len = sysSizeofSockaddrInet
sa.Family = syscall.AF_INET
copy(sa.Addr[:], grp)
}
func (gsr *sysGroupSourceReq) setSourceGroup(grp, src net.IP) {
sa := (*sysSockaddrInet)(unsafe.Pointer(&gsr.Pad_cgo_0[0]))
sa := (*sysSockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 4))
sa.Len = sysSizeofSockaddrInet
sa.Family = syscall.AF_INET
copy(sa.Addr[:], grp)
sa = (*sysSockaddrInet)(unsafe.Pointer(&gsr.Pad_cgo_1[0]))
sa = (*sysSockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 132))
sa.Len = sysSizeofSockaddrInet
sa.Family = syscall.AF_INET
copy(sa.Addr[:], src)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment