mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2024-12-03 01:20:17 +01:00
cb6e5cb0c7
* use dep for vendoring * lets encrypt * moved web to transfer.sh-web repo * single command install * added first tests
40 lines
1 KiB
Go
40 lines
1 KiB
Go
// Copyright 2012 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.
|
|
|
|
// +build darwin dragonfly freebsd netbsd openbsd
|
|
|
|
package ipv4
|
|
|
|
import (
|
|
"net"
|
|
"syscall"
|
|
"unsafe"
|
|
|
|
"golang.org/x/net/internal/iana"
|
|
)
|
|
|
|
func marshalDst(b []byte, cm *ControlMessage) []byte {
|
|
m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
|
|
m.Level = iana.ProtocolIP
|
|
m.Type = sysIP_RECVDSTADDR
|
|
m.SetLen(syscall.CmsgLen(net.IPv4len))
|
|
return b[syscall.CmsgSpace(net.IPv4len):]
|
|
}
|
|
|
|
func parseDst(cm *ControlMessage, b []byte) {
|
|
cm.Dst = b[:net.IPv4len]
|
|
}
|
|
|
|
func marshalInterface(b []byte, cm *ControlMessage) []byte {
|
|
m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
|
|
m.Level = iana.ProtocolIP
|
|
m.Type = sysIP_RECVIF
|
|
m.SetLen(syscall.CmsgLen(syscall.SizeofSockaddrDatalink))
|
|
return b[syscall.CmsgSpace(syscall.SizeofSockaddrDatalink):]
|
|
}
|
|
|
|
func parseInterface(cm *ControlMessage, b []byte) {
|
|
sadl := (*syscall.SockaddrDatalink)(unsafe.Pointer(&b[0]))
|
|
cm.IfIndex = int(sadl.Index)
|
|
}
|