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