Mikio Hara | 99f5f79 | 2015-01-28 20:08:41 +0900 | [diff] [blame] | 1 | // Copyright 2015 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // +build cgo,!netgo |
Mikio Hara | 24db235 | 2015-06-18 09:38:04 +0900 | [diff] [blame] | 6 | // +build darwin linux,!android netbsd solaris |
Mikio Hara | 99f5f79 | 2015-01-28 20:08:41 +0900 | [diff] [blame] | 7 | |
| 8 | package net |
| 9 | |
| 10 | /* |
| 11 | #include <sys/types.h> |
| 12 | #include <sys/socket.h> |
| 13 | |
| 14 | #include <netdb.h> |
| 15 | */ |
| 16 | import "C" |
| 17 | |
| 18 | import "unsafe" |
| 19 | |
| 20 | func cgoNameinfoPTR(b []byte, sa *C.struct_sockaddr, salen C.socklen_t) (int, error) { |
| 21 | gerrno, err := C.getnameinfo(sa, salen, (*C.char)(unsafe.Pointer(&b[0])), C.socklen_t(len(b)), nil, 0, C.NI_NAMEREQD) |
| 22 | return int(gerrno), err |
| 23 | } |