github.com/jlowellwofford/u-root@v1.0.0/pkg/wifi/native.go (about)

     1  // Copyright 2018 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package wifi
     6  
     7  import (
     8  	"fmt"
     9  	"syscall"
    10  	"unsafe"
    11  )
    12  
    13  type NativeWorker struct {
    14  	Interface string
    15  	FD        int
    16  	Range     IWRange
    17  }
    18  
    19  func NewNativeWorker(i string) (WiFi, error) {
    20  	s, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_DGRAM, syscall.IPPROTO_IP)
    21  	if err != nil {
    22  		return nil, err
    23  	}
    24  	return &NativeWorker{FD: s, Interface: i}, nil
    25  }
    26  
    27  func (w *NativeWorker) Scan() ([]Option, error) {
    28  	return nil, fmt.Errorf("Not Yet")
    29  }
    30  
    31  func (w *NativeWorker) GetID() (string, error) {
    32  	return "", fmt.Errorf("Not Yet")
    33  }
    34  
    35  func (w *NativeWorker) Connect(a ...string) error {
    36  	_, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(w.FD), SIOCGIWRANGE, uintptr(unsafe.Pointer(&w.Range)))
    37  	return err
    38  }