Advertisement
Guest User

iphitus

a guest
Aug 14th, 2008
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.31 KB | None | 0 0
  1. import dbus
  2.  
  3. WPAS_DBUS_SERVICE = "fi.epitest.hostap.WPASupplicant"
  4. WPAS_DBUS_INTERFACE = "fi.epitest.hostap.WPASupplicant"
  5. WPAS_DBUS_OPATH = "/fi/epitest/hostap/WPASupplicant"
  6.  
  7. WPAS_DBUS_INTERFACES_INTERFACE = "fi.epitest.hostap.WPASupplicant.Interface"
  8. WPAS_DBUS_INTERFACES_OPATH = "/fi/epitest/hostap/WPASupplicant/Interfaces"
  9. WPAS_DBUS_BSSID_INTERFACE = "fi.epitest.hostap.WPASupplicant.BSSID"
  10. WPAS_DBUS_NETWORKS_INTERFACE = "fi.epitest.hostap.WPASupplicant.Network"
  11.  
  12. def str_to_byte_array(s):
  13.     array=[]
  14.     for c in s:
  15.         array.append(dbus.Byte(c))
  16.     return array
  17.  
  18. bus = dbus.SystemBus()
  19. wpas_obj = bus.get_object(WPAS_DBUS_SERVICE, WPAS_DBUS_OPATH)
  20. wpas = dbus.Interface(wpas_obj, WPAS_DBUS_INTERFACE)
  21.  
  22. path = wpas.addInterface("ipw0")
  23.  
  24. # Get an interface
  25. if_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
  26. iface = dbus.Interface(if_obj, WPAS_DBUS_INTERFACES_INTERFACE);
  27.  
  28.  
  29. # Add new network!
  30. path=iface.addNetwork()
  31. net_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
  32. rnet = dbus.Interface(net_obj, WPAS_DBUS_NETWORKS_INTERFACE)
  33.  
  34. # None of these work
  35. rnet.set(dbus.Dictionary({'ssid':str_to_byte_array('rayner')}))      
  36. #rnet.set(dbus.Dictionary({'ssid':'rayner'}))
  37. #rnet.set({'ssid':'rayner'})              
  38.        
  39. # Remove interface from wpa_supplicant
  40. wpas.removeInterface(iface)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement