def get_if_raw_addr(ifname):
 try:
  fd = os.popen(('%s %s' % (conf.prog.ifconfig, ifname)))
 except OSError as msg:
  warning(('Failed to execute ifconfig: (%s)' % msg))
  return '\x00\x00\x00\x00'
 addresses = [l for l in fd if (l.find('netmask') >= 0)]
 if (not addresses):
  warning(('No IPv4 address found on %s !' % ifname))
  return '\x00\x00\x00\x00'
 address = addresses[0].split(' ')[1]
 return socket.inet_pton(socket.AF_INET, address)

def get_if_raw_addr ( ifname ) : try : fd = os . popen ( ( '%s %s' % ( conf . prog . ifconfig , ifname ) ) ) except OSError as msg : warning ( ( 'Failed to execute ifconfig: (%s)' % msg ) ) return '\x00\x00\x00\x00' addresses = [ l for l in fd if ( l . find ( 'netmask' ) >= 0 ) ] if ( not addresses ) : warning ( ( 'No IPv4 address found on %s !' % ifname ) ) return '\x00\x00\x00\x00' address = addresses [ 0 ] . split ( ' ' ) [ 1 ] return socket . inet_pton ( socket . AF_INET , address )
returns the ipv4 address configured on ifname .