| 1 |
package network |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
import "C" |
| 12 |
|
| 13 |
import ( |
| 14 |
"encoding/json" |
| 15 |
"errors" |
| 16 |
"net" |
| 17 |
"unsafe" |
| 18 |
) |
| 19 |
|
| 20 |
func getInterfaceName(iface net.Interface) string { |
| 21 |
return iface.Name |
| 22 |
} |
| 23 |
|
| 24 |
func ForceMonitorMode(iface string) error { |
| 25 |
return nil |
| 26 |
} |
| 27 |
|
| 28 |
func SetInterfaceChannel(iface string, channel int) error { |
| 29 |
cIface := C.CString(iface) |
| 30 |
defer C.free(unsafe.Pointer(cIface)) |
| 31 |
|
| 32 |
success := C.SetInterfaceChannel(cIface, C.int(channel)) |
| 33 |
if !success { |
| 34 |
return errors.New("failed to set interface channel") |
| 35 |
} |
| 36 |
|
| 37 |
SetInterfaceCurrentChannel(iface, channel) |
| 38 |
return nil |
| 39 |
} |
| 40 |
|
| 41 |
func GetSupportedFrequencies(iface string) ([]int, error) { |
| 42 |
cIface := C.CString(iface) |
| 43 |
defer C.free(unsafe.Pointer(cIface)) |
| 44 |
|
| 45 |
cFrequencies := C.GetSupportedFrequencies(cIface) |
| 46 |
if cFrequencies == nil { |
| 47 |
return nil, errors.New("failed to get supported frequencies") |
| 48 |
} |
| 49 |
defer C.free(unsafe.Pointer(cFrequencies)) |
| 50 |
|
| 51 |
frequenciesStr := C.GoString(cFrequencies) |
| 52 |
var frequencies []int |
| 53 |
err := json.Unmarshal([]byte(frequenciesStr), &frequencies) |
| 54 |
if err != nil { |
| 55 |
return nil, err |
| 56 |
} |
| 57 |
|
| 58 |
return frequencies, nil |
| 59 |
} |