func getIfaceAddr(idx uint32, family uint8) (*syscall.NetlinkMessage, error) {
	dat, err := syscall.NetlinkRIB(syscall.RTM_GETADDR, int(family))
	if err != nil {
		return nil, err
	}

	msgs, msgErr := syscall.ParseNetlinkMessage(dat)
	if msgErr != nil {
		return nil, msgErr
	}

	ifaddrmsg := syscall.IfAddrmsg{}
	for _, m := range msgs {
		if m.Header.Type != syscall.RTM_NEWADDR {
			continue
		}
		buf := bytes.NewBuffer(m.Data[:syscall.SizeofIfAddrmsg])
		if rerr := binary.Read(buf, cpuutil.ByteOrder(), &ifaddrmsg); rerr != nil {
			continue
		}
		if ifaddrmsg.Index == idx {
			return &m, nil
		}
	}

	return nil, fmt.Errorf("could not find address for interface index %v", idx)

}
func getIfaceAddr(idx uint32, family uint8) (*syscall.NetlinkMessage, error) {
	dat, err := syscall.NetlinkRIB(syscall.RTM_GETADDR, int(family))
	if err != nil {
		return nil, err
	}

	msgs, msgErr := syscall.ParseNetlinkMessage(dat)
	if msgErr != nil {
		return nil, msgErr
	}

	ifaddrmsg := syscall.IfAddrmsg{}
	for _, m := range msgs {
		if m.Header.Type != syscall.RTM_NEWADDR {
			continue
		}
		buf := bytes.NewBuffer(m.Data[:syscall.SizeofIfAddrmsg])
		if rerr := binary.Read(buf, cpuutil.ByteOrder(), &ifaddrmsg); rerr != nil {
			continue
		}
		if ifaddrmsg.Index == idx {
			return &m, nil
		}
	}

	return nil, fmt.Errorf("could not find address for interface index %v", idx)

}
func getIfaceAddr ( idx uint32 , family uint8 ) ( * syscall . NetlinkMessage , error ) { dat , err := syscall . NetlinkRIB ( syscall . RTM_GETADDR , int ( family ) ) if err != nil { return nil , err } msgs , msgErr := syscall . ParseNetlinkMessage ( dat ) if msgErr != nil { return nil , msgErr } ifaddrmsg := syscall . IfAddrmsg { } for _ , m := range msgs { if m . Header . Type != syscall . RTM_NEWADDR { continue } buf := bytes . NewBuffer ( m . Data [ : syscall . SizeofIfAddrmsg ] ) if rerr := binary . Read ( buf , cpuutil . ByteOrder ( ) , & ifaddrmsg ) ; rerr != nil { continue } if ifaddrmsg . Index == idx { return & m , nil } } return nil , fmt . Errorf ( " " , idx ) }
// Used to get an address of interface.
Used to get an address of interface .