misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
evilsocket 2018-03-12 15:58:45 +01:00
commit 0a8b8548b6
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
6 changed files with 39 additions and 38 deletions

View file

@ -26,6 +26,24 @@ var (
IPv4Validator = regexp.MustCompile("^[0-9\\.]+/?\\d*$")
)
func IsZeroMac(mac net.HardwareAddr) bool {
for _, b := range mac {
if b != 0x00 {
return false
}
}
return true
}
func IsBroadcastMac(mac net.HardwareAddr) bool {
for _, b := range mac {
if b != 0xff {
return false
}
}
return true
}
func NormalizeMac(mac string) string {
var parts []string
if strings.ContainsRune(mac, '-') {

View file

@ -7,6 +7,17 @@ import (
"time"
)
func Dot11Freq2Chan(freq int) int {
if freq <= 2472 {
return ((freq - 2412) / 5) + 1
} else if freq == 2484 {
return 14
} else if freq >= 5035 && freq <= 5865 {
return ((freq - 5035) / 5) + 7
}
return 0
}
type APNewCallback func(ap *AccessPoint)
type APLostCallback func(ap *AccessPoint)