2017-09-11 07:42:19 +00:00
|
|
|
package converter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
"regexp"
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
macStripRegexp = regexp.MustCompile(`[^a-fA-F0-9]`)
|
|
|
|
)
|
|
|
|
|
2017-09-11 07:50:25 +00:00
|
|
|
func MacToUint64(hwAddr net.HardwareAddr) (uint64, error) {
|
2017-09-11 07:42:19 +00:00
|
|
|
mac := hwAddr.String()
|
|
|
|
hex := macStripRegexp.ReplaceAllLiteralString(mac, "")
|
|
|
|
|
|
|
|
return strconv.ParseUint(hex, 16, 64)
|
|
|
|
}
|