Merge lp://staging/~drf54321/wicd/drf-experimental into lp://staging/wicd/1.6

Proposed by Dario Freddi
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~drf54321/wicd/drf-experimental
Merge into: lp://staging/wicd/1.6
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~drf54321/wicd/drf-experimental
Reviewer Review Type Date Requested Status
Dan O'Reilly Approve
Review via email: mp+4045@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Dario Freddi (drf54321) wrote :

Added bitrate support for channels and interface to external backend and core interface.

314. By Dario Freddi

Adding the possibility of a custom iwconfig

315. By Dario Freddi

Adding GetOperationalMode() to determine op mode of an interface

316. By Dario Freddi

Adding available auth methods

Revision history for this message
Dan O'Reilly (oreilldf) wrote :

FYI -- here's a way to get the raw bitrate using ioctls. You probably have to convert it to mb/s for it to be useful.

>>> import struct, fcntl, socket
>>> s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>>> ifreq = "eth1" + '\0'*32
>>> fmt = "ihbb"
>>> size = struct.calcsize(fmt)
>>> data = fcntl.ioctl(s, 0x8B21, ifreq)[16:] # 0x8B21 is SIOCGIWRATE in /usr/include/linux/wireless.h
>>> f, e, x, x = struct.unpack(fmt, data[:size])
>>> print f
54000000

Revision history for this message
Dan O'Reilly (oreilldf) wrote :

Other than the missing ioctl implementation for GetBitRate, it looks good.

317. By Dario Freddi

Fixing implementation in ioctl

Revision history for this message
Dario Freddi (drf54321) wrote :

I fixed that in ioctl, and added placeholders for the other functions in ioctl, check latest revision

Revision history for this message
Dan O'Reilly (oreilldf) wrote :

It's actually better if you don't implement placeholders at all. That way the ioctl backend will juse use the inherited methods in wnettools.py.

Also, a couple of things regarding the ioctl GetBitRate method:
1) You should use self.sock instead of creating another socket object.
2) You should create a global constant called SIOCGIWRATE and use that instead of 0x8B21 directly.
3) You're using a variable called 'ifreq' in the ioctl call, but it doesn't exist. I think you meant 'data'.

318. By Dario Freddi

Removing placeholders, and fixing issues pointed out by Dan

Revision history for this message
Dario Freddi (drf54321) wrote :

"It's actually better if you don't implement placeholders at all. That way the ioctl backend will juse use the inherited methods in wnettools.py."

I didn't know, I just commented them now, so we still know they're waiting for an implementation

"Also, a couple of things regarding the ioctl GetBitRate method:"

Thanks, fixed them all and some more. I think I completely overlooked that part.

319. By Dario Freddi

Merging last changes

Revision history for this message
Dan O'Reilly (oreilldf) wrote :

Looks good now, except it doesn't look like you defined defined SIOCGIWRATE.

320. By Dario Freddi

Forgot to add a definition

Revision history for this message
Dario Freddi (drf54321) wrote :

Ops, fixed & pushed

321. By Dario Freddi

Merges

Revision history for this message
Dan O'Reilly (oreilldf) wrote :

Approved, I made a few more small changes to fix some issues I saw, but all the functionality is merged to the mainline experimental branch.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'wicd/backends/be-ioctl.py'
2--- wicd/backends/be-ioctl.py 2009-02-27 05:08:31 +0000
3+++ wicd/backends/be-ioctl.py 2009-03-01 15:01:21 +0000
4@@ -1,4 +1,5 @@
5 #!/usr/bin/env python
6+# -*- coding: utf-8 -*-
7
8 """ ioctl Network interface control tools for wicd.
9
10@@ -479,6 +480,19 @@
11 raw_addr = struct.unpack("xxBBBBBB", result[:8])
12 return "%02X:%02X:%02X:%02X:%02X:%02X" % raw_addr
13
14+ def GetCurrentBitrate(self, iwconfig=None):
15+ """ Get the current bitrate for the interface. """
16+ if not self.iface: return ""
17+ data = (self.iface + '\0' * 32)[:32]
18+ try:
19+ result = fcntl.ioctl(self.sock.fileno(), SIOCGIWAP, data)[16:]
20+ except IOError, e:
21+ if self.verbose:
22+ print "SIOCGIWAP failed: " + str(e)
23+ return ""
24+ raw_addr = struct.unpack("xxBBBBBB", result[:8])
25+ return "%02X:%02X:%02X:%02X:%02X:%02X" % raw_addr
26+
27 def GetSignalStrength(self, iwconfig=None):
28 """ Get the signal strength of the current network.
29
30
31=== modified file 'wicd/networking.py'
32--- wicd/networking.py 2009-02-27 05:35:53 +0000
33+++ wicd/networking.py 2009-03-01 15:01:21 +0000
34@@ -1,4 +1,5 @@
35 #!/usr/bin/env python
36+# -*- coding: utf-8 -*-
37
38 """ networking - Provides wrappers for common network operations
39
40@@ -624,6 +625,16 @@
41 """
42 return self.wiface.GetBSSID()
43
44+ def GetCurrentBitrate(self):
45+ """ Get the current bitrate of the interface.
46+
47+ Returns:
48+ The bitrate of the active access point as a string, or
49+ None the bitrate can't be found.
50+
51+ """
52+ return self.wiface.GetCurrentBitrate()
53+
54 def GetIwconfig(self):
55 """ Get the out of iwconfig. """
56 return self.wiface.GetIwconfig()
57
58=== modified file 'wicd/wicd-daemon.py'
59--- wicd/wicd-daemon.py 2009-02-27 05:08:31 +0000
60+++ wicd/wicd-daemon.py 2009-03-01 15:01:21 +0000
61@@ -1,4 +1,5 @@
62 #!/usr/bin/env python
63+# -*- coding: utf-8 -*-
64
65 """ wicd - wireless connection daemon implementation.
66
67@@ -996,6 +997,10 @@
68 return self.wifi.GetBSSID()
69
70 @dbus.service.method('org.wicd.daemon.wireless')
71+ def GetCurrentBitrate(self):
72+ return self.wifi.GetCurrentBitrate()
73+
74+ @dbus.service.method('org.wicd.daemon.wireless')
75 def CreateAdHocNetwork(self, essid, channel, ip, enctype, key, encused,
76 ics):
77 """ Creates an ad-hoc network using user inputted settings. """
78
79=== modified file 'wicd/wnettools.py'
80--- wicd/wnettools.py 2009-02-27 05:08:31 +0000
81+++ wicd/wnettools.py 2009-03-01 15:46:58 +0000
82@@ -1,4 +1,5 @@
83 #!/usr/bin/env python
84+# -*- coding: utf-8 -*-
85
86 """ Network interface control tools for wicd.
87
88@@ -49,6 +50,7 @@
89 strength_pattern = re.compile('.*Quality:?=? ?(\d+)\s*/?\s*(\d*)', __re_mode)
90 altstrength_pattern = re.compile('.*Signal level:?=? ?(\d+)\s*/?\s*(\d*)', __re_mode)
91 signaldbm_pattern = re.compile('.*Signal level:?=? ?(-\d\d*)', __re_mode)
92+bitrates_pattern = re.compile('.*Bit Rates:(.*?)E', __re_mode)
93 mode_pattern = re.compile('.*Mode:(.*?)\n', __re_mode)
94 freq_pattern = re.compile('.*Frequency:(.*?)\n', __re_mode)
95 wep_pattern = re.compile('.*Encryption key:(.*?)\n', __re_mode)
96@@ -59,6 +61,7 @@
97 #iwconfig-only regular expressions.
98 ip_pattern = re.compile(r'inet [Aa]d?dr[^.]*:([^.]*\.[^.]*\.[^.]*\.[0-9]*)',re.S)
99 bssid_pattern = re.compile('.*Access Point: (([0-9A-Z]{2}:){5}[0-9A-Z]{2})', __re_mode)
100+bitrate_pattern = re.compile('.*Bit Rate=(.*?)s', __re_mode)
101
102 # Regular expressions for wpa_cli output
103 auth_pattern = re.compile('.*wpa_state=(.*?)\n', __re_mode)
104@@ -1056,6 +1059,9 @@
105 freq = misc.RunRegex(freq_pattern, cell)
106 ap['channel'] = self._FreqToChannel(freq)
107
108+ # Bit Rate
109+ ap['bitrates'] = misc.RunRegex(bitrates_pattern, cell).replace('\n', '; ').replace(' ', '')[:-2]
110+
111 # BSSID
112 ap['bssid'] = misc.RunRegex(ap_mac_pattern, cell)
113
114@@ -1180,6 +1186,18 @@
115 bssid = misc.RunRegex(bssid_pattern, output)
116 return bssid
117
118+ def GetCurrentBitrate(self, iwconfig=None):
119+ """ Get the MAC address for the interface. """
120+ if not iwconfig:
121+ cmd = 'iwconfig ' + self.iface
122+ if self.verbose: print cmd
123+ output = misc.Run(cmd)
124+ else:
125+ output = iwconfig
126+
127+ bitrate = misc.RunRegex(bitrate_pattern, output)
128+ return bitrate + 's'
129+
130 def _get_link_quality(self, output):
131 """ Parse out the link quality from iwlist scan or iwconfig output. """
132 try:

Subscribers

People subscribed via source and target branches

to status/vote changes: