<commit_before>// Copyright 2016 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build freebsd openbsd

package tcp

import (
	"encoding/binary"
	"net"
	"os"
	"syscall"
	"unsafe"
)

func originalDst(_ uintptr, la, ra *net.TCPAddr) (net.Addr, error) {
	f, err := os.Open("/dev/pf")
	if err != nil {
		return nil, err
	}
	defer f.Close()
	fd := f.Fd()
	b := make([]byte, sizeofPfiocNatlook)
	nl := (*pfiocNatlook)(unsafe.Pointer(&b[0]))
	if ra.IP.To4() != nil {
		copy(nl.Saddr[:net.IPv4len], ra.IP.To4())
		copy(nl.Daddr[:net.IPv4len], la.IP.To4())
		nl.Af = sysAF_INET
	}
	if ra.IP.To16() != nil && ra.IP.To4() == nil {
		copy(nl.Saddr[:], ra.IP)
		copy(nl.Daddr[:], la.IP)
		nl.Af = sysAF_INET6
	}
	binary.BigEndian.PutUint16((*[2]byte)(unsafe.Pointer(&nl.Sport))[:], uint16(ra.Port))
	binary.BigEndian.PutUint16((*[2]byte)(unsafe.Pointer(&nl.Dport))[:], uint16(la.Port))
	nl.Proto = ianaProtocolTCP
	for _, dir := range []byte{sysPF_OUT, sysPF_IN} {
		nl.Direction = dir
		err = ioctl(fd, sysDIOCNATLOOK, b)
		if err == nil || err != syscall.ENOENT {
			break
		}
	}
	if err != nil {
		return nil, err
	}
	od := new(net.TCPAddr)
	od.Port = int(binary.BigEndian.Uint16((*[2]byte)(unsafe.Pointer(&nl.Rdport))[:]))<commit_msg>tcp: fix build on 32-bit machines<commit_after>// Copyright 2016 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build freebsd openbsd

package tcp

import (
	"encoding/binary"
	"net"
	"os"
	"syscall"
	"unsafe"
)

func originalDst(_ uintptr, la, ra *net.TCPAddr) (net.Addr, error) {
	f, err := os.Open("/dev/pf")
	if err != nil {
		return nil, err
	}
	defer f.Close()
	fd := f.Fd()
	b := make([]byte, sizeofPfiocNatlook)
	nl := (*pfiocNatlook)(unsafe.Pointer(&b[0]))
	if ra.IP.To4() != nil {
		copy(nl.Saddr[:net.IPv4len], ra.IP.To4())
		copy(nl.Daddr[:net.IPv4len], la.IP.To4())
		nl.Af = sysAF_INET
	}
	if ra.IP.To16() != nil && ra.IP.To4() == nil {
		copy(nl.Saddr[:], ra.IP)
		copy(nl.Daddr[:], la.IP)
		nl.Af = sysAF_INET6
	}
	binary.BigEndian.PutUint16((*[2]byte)(unsafe.Pointer(&nl.Sport))[:], uint16(ra.Port))
	binary.BigEndian.PutUint16((*[2]byte)(unsafe.Pointer(&nl.Dport))[:], uint16(la.Port))
	nl.Proto = ianaProtocolTCP
	ioc := uintptr(sysDIOCNATLOOK)
	for _, dir := range []byte{sysPF_OUT, sysPF_IN} {
		nl.Direction = dir
		err = ioctl(fd, int(ioc), b)
		if err == nil || err != syscall.ENOENT {
			break
		}
	}
	if err != nil {
		return nil, err
	}
	od := new(net.TCPAddr)
	od.Port = int(binary.BigEndian.Uint16((*[2]byte)(unsafe.Pointer(&nl.Rdport))[:]))
{'fraction_non_alphanumeric': 0.19730941704035873, 'fraction_numerical': 0.02092675635276532, 'mean_word_length': 3.840867992766727, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6556262', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1114, 'n_words': 238}