(ifname, fd)
return int(struct.unpack('16si', res)[1])
Get the index corresponding to interface ifname used by socket fd
Get the index corresponding to interface ifname used by socket fd
Get the index corresponding to interface ifname used by socket fd
def _get_if_index(ifname, fd):
    """Get the index corresponding to interface ifname used by socket fd"""
    ifreq = struct.pack('16si', ifname.encode(), 0)
    res = fcntl.ioctl(fd, SIOCGIFINDEX, ifreq)
    return int(struct.unpack('16si', res)[1])
def _get_if_index ( ifname , fd ) : ifreq = struct . pack ( '16si' , ifname . encode ( ) , 0 ) res = fcntl . ioctl ( fd , SIOCGIFINDEX , ifreq ) return int ( struct . unpack ( '16si' , res ) [ 1 ] )