github.com/tailscale/wireguard-go@v0.0.20201119-0.20210522003738-46b531feb08a/conn/boundif_android.go (about)

     1  /* SPDX-License-Identifier: MIT
     2   *
     3   * Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
     4   */
     5  
     6  package conn
     7  
     8  func (bind *StdNetBind) PeekLookAtSocketFd4() (fd int, err error) {
     9  	sysconn, err := bind.ipv4.SyscallConn()
    10  	if err != nil {
    11  		return -1, err
    12  	}
    13  	err = sysconn.Control(func(f uintptr) {
    14  		fd = int(f)
    15  	})
    16  	if err != nil {
    17  		return -1, err
    18  	}
    19  	return
    20  }
    21  
    22  func (bind *StdNetBind) PeekLookAtSocketFd6() (fd int, err error) {
    23  	sysconn, err := bind.ipv6.SyscallConn()
    24  	if err != nil {
    25  		return -1, err
    26  	}
    27  	err = sysconn.Control(func(f uintptr) {
    28  		fd = int(f)
    29  	})
    30  	if err != nil {
    31  		return -1, err
    32  	}
    33  	return
    34  }