func getCurrentMacInfo(name string) (result string, err error) {
	currentMacInfo, err := getMacInfo(name, "CurrentMAC")
	if err != nil {
		return
	}
	permanentMac, err := lmf.GetPermanentMac(name)
	if err != nil {
		LogWriter.Err(err.Error())
	}
	permanentMacVendor, err := lmf.FindVendorByMac(permanentMac.String())
	if err != nil {
		if strings.HasPrefix(err.Error(),
			"No vendor found in OuiDb for vendor prefix") {
			permanentMacVendor.Vendor = "Unknown"
		} else {
			return
		}
	}
	if privatevar {
		result = fmt.Sprintf(
			"%s - CurrentMAC: xx:xx:xx:xx:xx:xx (Unknown) Permanent MAC: xx:xx:xx:xx:xx:xx (Unknown)",
			name)
	} else {
		result = fmt.Sprintf("%sPermanent MAC: %s (%s)",
			currentMacInfo, permanentMac, permanentMacVendor.Vendor)
	}
	err = nil
	return
}
func getMacInfo(name string, macType string) (result string, err error) {
	newMac, err := lmf.GetCurrentMac(name)
	if err != nil {
		return
	}
	newMacVendor, err := lmf.FindVendorByMac(newMac.String())
	if err != nil {
		if err == err.(lmf.NoVendorError) {
			newMacVendor.Vendor = "Unknown"
			err = nil
		} else {
			return
		}
	}
	result = fmt.Sprintf("%s - %s: %s (%s) ",
		name, macType, newMac, newMacVendor.Vendor)
	return
}
Exemple #3
0
func getCurrentMacInfo(name string) (result string, err error) {
	currentMacInfo, err := getMacInfo(name, "CurrentMAC")
	if err != nil {
		return
	}
	permanentMac, err := lmf.GetPermanentMac(name)
	if err != nil {
		fmt.Println(err)
	}
	permanentMacVendor, err := lmf.FindVendorByMac(permanentMac.String())
	if err != nil {
		if strings.HasPrefix(err.Error(),
			"No vendor found in OuiDb for vendor prefix") {
			permanentMacVendor.Vendor = "Unknown"
		} else {
			return
		}
	}
	result = fmt.Sprintf("%sPermanent MAC:\t%s (%s)",
		currentMacInfo,
		permanentMac, permanentMacVendor.Vendor)
	return
}