mirror of
https://github.com/golang/net.git
synced 2026-03-31 18:37:08 +09:00
Change-Id: Idb2a2eb354c2835e6cae7e269730c599abb1c8d7 Reviewed-on: https://go-review.googlesource.com/27735 Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
32 lines
830 B
Go
32 lines
830 B
Go
// Copyright 2009 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package ipv6
|
|
|
|
import (
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
const (
|
|
sysGETSOCKOPT = 0xf
|
|
sysSETSOCKOPT = 0xe
|
|
)
|
|
|
|
func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno)
|
|
|
|
func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error {
|
|
if _, errno := socketcall(sysGETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 {
|
|
return error(errno)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error {
|
|
if _, errno := socketcall(sysSETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 {
|
|
return error(errno)
|
|
}
|
|
return nil
|
|
}
|