1 // Copyright 2012 Google, Inc. All rights reserved.
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the LICENSE file in the root of the source
14 "golang.org/x/sys/unix"
17 // setsockopt provides access to the setsockopt syscall.
18 func setsockopt(fd, level, name int, val unsafe.Pointer, vallen uintptr) error {
19 _, _, errno := unix.Syscall6(
35 // getsockopt provides access to the getsockopt syscall.
36 func getsockopt(fd, level, name int, val unsafe.Pointer, vallen uintptr) error {
37 _, _, errno := unix.Syscall6(
53 // htons converts a short (uint16) from host-to-network byte order.
54 // Thanks to mikioh for this neat trick:
55 // https://github.com/mikioh/-stdyng/blob/master/afpacket.go
56 func htons(i uint16) uint16 {
57 return (i<<8)&0xff00 | i>>8