github.com/sagernet/wireguard-go@v0.0.0-20231215174105-89dec3b2f3e8/conn/boundif_android.go (about)

     1  /* SPDX-License-Identifier: MIT
     2   *
     3   * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved.
     4   */
     5  
     6  package conn
     7  
     8  func (s *StdNetBind) PeekLookAtSocketFd4() (fd int, err error) {
     9  	sysconn, err := s.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 (s *StdNetBind) PeekLookAtSocketFd6() (fd int, err error) {
    23  	sysconn, err := s.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  }