Source file
src/net/cgo_sockold.go
1
2
3
4
5
6
7 package net
8
9
15 import "C"
16
17 import (
18 "syscall"
19 "unsafe"
20 )
21
22 func cgoSockaddrInet4(ip IP) *C.struct_sockaddr {
23 sa := syscall.RawSockaddrInet4{Len: syscall.SizeofSockaddrInet4, Family: syscall.AF_INET}
24 copy(sa.Addr[:], ip)
25 return (*C.struct_sockaddr)(unsafe.Pointer(&sa))
26 }
27
28 func cgoSockaddrInet6(ip IP, zone int) *C.struct_sockaddr {
29 sa := syscall.RawSockaddrInet6{Len: syscall.SizeofSockaddrInet6, Family: syscall.AF_INET6, Scope_id: uint32(zone)}
30 copy(sa.Addr[:], ip)
31 return (*C.struct_sockaddr)(unsafe.Pointer(&sa))
32 }
33
View as plain text