You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: sockopt.go
    path of file: ./repos/dae/component/outbound/dialer
    
    the code of the file until where you have to start completion: /*
 * SPDX-License-Identifier: AGPL-3.0-only
 * Copyright (c) 2022-2024, daeuniverse Organization <dae@v2raya.org>
 */

package dialer

import (
	"fmt"
	"net/netip"
	"runtime"
	"syscall"

	"golang.org/x/sys/unix"
)

var fwmarkIoctl int

func init() {
	switch runtime.GOOS {
	case "linux", "android":
		fwmarkIoctl = 36 /* unix.SO_MARK */
	case "freebsd":
		fwmarkIoctl = 0x1015 /* unix.SO_USER_COOKIE */
	case "o
    
func bindAddr(fd uintptr, addrPort netip.AddrPort) error {
	if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1); err != nil {
		return fmt.Errorf("error setting SO_REUSEADDR socket option: %w", err)
	}

	if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil {
		return fmt.Errorf("error setting SO_REUSEPORT socket option: %w", err)
	}

	var sockAddr syscall.Sockaddr

	addr := addrPort.Addr()
	switch {
	case addr.Is4() || addr.Is4In6():
		a4 := &syscall.SockaddrInet4{
			Port: int(addrPort.Port()),
		}
		a4.Addr = addr.As4()
		sockAddr = a4
	case addr.Is6():
		a6 := &syscall.SockaddrInet6{
			Port: int(addrPort.Port()),
		}
		zone := addrPort.Addr().Zone()
		if zone != "" {
			//if link, e := netlink.LinkByName(zone); e == nil {
			//	a6.ZoneId = uint32(link.Attrs().Index)
			//}
			return fmt.Errorf("unsupported ipv6 zone")
		}
		a6.Addr = addr.As16()
		sockAddr = a6
	default:
		return fmt.Errorf("unexpected length of ip")
	}

	return syscall.Bind(int(fd), sockAddr)
}