aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/examples
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-04-01 18:13:38 (GMT)
committerJouni Malinen <j@w1.fi>2012-04-01 18:14:48 (GMT)
commit2d43d37ff2c3115da812bec8ea4c72048e1194d8 (patch)
tree42a666b285ec68a6ad9525a3238886eb541ea51b /wpa_supplicant/examples
parentbaf513d6952c67b94925c5e82291be19f858ad1e (diff)
downloadhostap-2d43d37ff2c3115da812bec8ea4c72048e1194d8.zip
hostap-2d43d37ff2c3115da812bec8ea4c72048e1194d8.tar.gz
hostap-2d43d37ff2c3115da812bec8ea4c72048e1194d8.tar.bz2
DBus: Add ability to report probe requests
Some applications require knowing about probe requests to identify devices. This can be the case in AP mode to see the devices before they connect, or even in P2P mode when operating as a P2P device to identify non-P2P peers (P2P peers are identified via PeerFound signals). As there are typically a lot of probe requests, require that an interested application subscribes to this signal so the bus isn't always flooded with these notifications. The notifications in DBus are then unicast only to that application. A small test script is also included. Signed-hostap: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'wpa_supplicant/examples')
-rwxr-xr-xwpa_supplicant/examples/dbus-listen-preq.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/wpa_supplicant/examples/dbus-listen-preq.py b/wpa_supplicant/examples/dbus-listen-preq.py
new file mode 100755
index 0000000..5ac9859
--- /dev/null
+++ b/wpa_supplicant/examples/dbus-listen-preq.py
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+import time
+import gobject
+from dbus.mainloop.glib import DBusGMainLoop
+
+WPAS_DBUS_SERVICE = "fi.w1.wpa_supplicant1"
+WPAS_DBUS_INTERFACE = "fi.w1.wpa_supplicant1"
+WPAS_DBUS_OPATH = "/fi/w1/wpa_supplicant1"
+WPAS_DBUS_INTERFACES_INTERFACE = "fi.w1.wpa_supplicant1.Interface"
+
+def usage():
+ print "Usage: %s <ifname>" % sys.argv[0]
+ print "Press Ctrl-C to stop"
+
+def ProbeRequest(args):
+ if 'addr' in args:
+ print '%.2x:%.2x:%.2x:%.2x:%.2x:%.2x' % tuple(args['addr']),
+ if 'dst' in args:
+ print '-> %.2x:%.2x:%.2x:%.2x:%.2x:%.2x' % tuple(args['dst']),
+ if 'bssid' in args:
+ print '(bssid %.2x:%.2x:%.2x:%.2x:%.2x:%.2x)' % tuple(args['dst']),
+ if 'signal' in args:
+ print 'signal:%d' % args['signal'],
+ if 'ies' in args:
+ print 'have IEs (%d bytes)' % len(args['ies']),
+ print ''
+
+if __name__ == "__main__":
+ global bus
+ global wpas_obj
+ global if_obj
+ global p2p_iface
+
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+ bus = dbus.SystemBus()
+ wpas_obj = bus.get_object(WPAS_DBUS_SERVICE, WPAS_DBUS_OPATH)
+
+ # Print list of i/f if no one is specified
+ if (len(sys.argv) < 2) :
+ usage()
+ sys.exit(0)
+
+ wpas = dbus.Interface(wpas_obj, WPAS_DBUS_INTERFACE)
+
+ ifname = sys.argv[1]
+
+ path = wpas.GetInterface(ifname)
+
+ if_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
+ iface = dbus.Interface(if_obj, WPAS_DBUS_INTERFACES_INTERFACE)
+
+ bus.add_signal_receiver(ProbeRequest,
+ dbus_interface=WPAS_DBUS_INTERFACES_INTERFACE,
+ signal_name="ProbeRequest")
+
+ iface.SubscribeProbeReq()
+
+ gobject.MainLoop().run()