To obtain the local all interface, the lo interface can only get back?

def all_interfaces():
"Get all the local interface"
max_possible = 128
bytes = max_possible *32
outbytes = struct.unpack('iL',fcntl.ioctl(s.fileno(),0x8912,struct.pack('iL',bytes,names.buffer_info()[0])))[0]
return [namestr[i:i+32].split('\0',1)[0]for i in range(0,outbytes,32)]

Use this function, can only get Lo interface, unable to obtain the eth0 interface? This is why?

Started by Sonia at February 11, 2016 - 6:52 AM

The last line is replaced by the following can:
return [namestr[i:i+16].split('\0',1)[0]for i in range(0,outbytes,40)]

Posted by Sonia at February 24, 2016 - 7:51 AM