in cmd/ptpcheck/cmd/map.go [84:109]
func getIface(ptpDevice int) error {
ifaces, err := phc.IfacesInfo()
if err != nil {
return err
}
if len(ifaces) == 0 {
return fmt.Errorf("no network devices found")
}
found := []phc.IfaceData{}
if ptpDevice < 0 {
found = ifaces
} else {
for _, d := range ifaces {
if int(d.TSInfo.PHCIndex) == ptpDevice {
found = append(found, d)
}
}
}
if len(found) == 0 {
return fmt.Errorf("no nic found for /dev/ptp%d", ptpDevice)
}
for _, d := range found {
printIfaceData(d, true)
}
return nil
}