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