1#!/usr/bin/python
2
3import dbus
4import sys
5import time
6import gobject
7from dbus.mainloop.glib import DBusGMainLoop
8
9WPAS_DBUS_SERVICE = "fi.w1.wpa_supplicant1"
10WPAS_DBUS_INTERFACE = "fi.w1.wpa_supplicant1"
11WPAS_DBUS_OPATH = "/fi/w1/wpa_supplicant1"
12WPAS_DBUS_INTERFACES_INTERFACE = "fi.w1.wpa_supplicant1.Interface"
13
14def usage():
15	print "Usage: %s <ifname>" % sys.argv[0]
16	print "Press Ctrl-C to stop"
17
18def ProbeRequest(args):
19	if 'addr' in args:
20		print '%.2x:%.2x:%.2x:%.2x:%.2x:%.2x' % tuple(args['addr']),
21	if 'dst' in args:
22		print '-> %.2x:%.2x:%.2x:%.2x:%.2x:%.2x' % tuple(args['dst']),
23	if 'bssid' in args:
24		print '(bssid %.2x:%.2x:%.2x:%.2x:%.2x:%.2x)' % tuple(args['dst']),
25	if 'signal' in args:
26		print 'signal:%d' % args['signal'],
27	if 'ies' in args:
28		print 'have IEs (%d bytes)' % len(args['ies']),
29        print ''
30
31if __name__ == "__main__":
32	global bus
33	global wpas_obj
34	global if_obj
35	global p2p_iface
36
37	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
38
39	bus = dbus.SystemBus()
40	wpas_obj = bus.get_object(WPAS_DBUS_SERVICE, WPAS_DBUS_OPATH)
41
42	# Print list of i/f if no one is specified
43	if (len(sys.argv) < 2)  :
44		usage()
45		sys.exit(0)
46
47	wpas = dbus.Interface(wpas_obj, WPAS_DBUS_INTERFACE)
48
49	ifname = sys.argv[1]
50
51	path = wpas.GetInterface(ifname)
52
53	if_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
54	iface = dbus.Interface(if_obj, WPAS_DBUS_INTERFACES_INTERFACE)
55
56	bus.add_signal_receiver(ProbeRequest,
57				dbus_interface=WPAS_DBUS_INTERFACES_INTERFACE,
58				signal_name="ProbeRequest")
59
60	iface.SubscribeProbeReq()
61
62	gobject.MainLoop().run()
63