Source file
src/net/cgo_unix_cgo.go
1
2
3
4
5
6
7 package net
8
9
35 import "C"
36 import "unsafe"
37
38 const (
39 _C_AF_INET = C.AF_INET
40 _C_AF_INET6 = C.AF_INET6
41 _C_AF_UNSPEC = C.AF_UNSPEC
42 _C_EAI_ADDRFAMILY = C.EAI_ADDRFAMILY
43 _C_EAI_AGAIN = C.EAI_AGAIN
44 _C_EAI_NODATA = C.EAI_NODATA
45 _C_EAI_NONAME = C.EAI_NONAME
46 _C_EAI_SERVICE = C.EAI_SERVICE
47 _C_EAI_OVERFLOW = C.EAI_OVERFLOW
48 _C_EAI_SYSTEM = C.EAI_SYSTEM
49 _C_IPPROTO_TCP = C.IPPROTO_TCP
50 _C_IPPROTO_UDP = C.IPPROTO_UDP
51 _C_SOCK_DGRAM = C.SOCK_DGRAM
52 _C_SOCK_STREAM = C.SOCK_STREAM
53 )
54
55 type (
56 _C_char = C.char
57 _C_uchar = C.uchar
58 _C_int = C.int
59 _C_uint = C.uint
60 _C_socklen_t = C.socklen_t
61 _C_struct_addrinfo = C.struct_addrinfo
62 _C_struct_sockaddr = C.struct_sockaddr
63 )
64
65 func _C_malloc(n uintptr) unsafe.Pointer { return C.malloc(C.size_t(n)) }
66 func _C_free(p unsafe.Pointer) { C.free(p) }
67
68 func _C_ai_addr(ai *_C_struct_addrinfo) **_C_struct_sockaddr { return &ai.ai_addr }
69 func _C_ai_family(ai *_C_struct_addrinfo) *_C_int { return &ai.ai_family }
70 func _C_ai_flags(ai *_C_struct_addrinfo) *_C_int { return &ai.ai_flags }
71 func _C_ai_next(ai *_C_struct_addrinfo) **_C_struct_addrinfo { return &ai.ai_next }
72 func _C_ai_protocol(ai *_C_struct_addrinfo) *_C_int { return &ai.ai_protocol }
73 func _C_ai_socktype(ai *_C_struct_addrinfo) *_C_int { return &ai.ai_socktype }
74
75 func _C_freeaddrinfo(ai *_C_struct_addrinfo) {
76 C.freeaddrinfo(ai)
77 }
78
79 func _C_gai_strerror(eai _C_int) string {
80 return C.GoString(C.gai_strerror(eai))
81 }
82
83 func _C_getaddrinfo(hostname, servname *_C_char, hints *_C_struct_addrinfo, res **_C_struct_addrinfo) (int, error) {
84 x, err := C.getaddrinfo(hostname, servname, hints, res)
85 return int(x), err
86 }
87
View as plain text