summaryrefslogtreecommitdiffstats
path: root/src-wireless/wireless-dbus
diff options
context:
space:
mode:
authorJames Rayner <james@archlinux.org>2009-04-28 14:15:43 +0200
committerJames Rayner <james@archlinux.org>2009-04-28 14:15:43 +0200
commit7b31dcd7b6da4f26db8f09924adc059f5a6ee589 (patch)
treeb58eacd9ad091bb42d242af6946e259d0623888d /src-wireless/wireless-dbus
parent9f8ec61efe91504d6cad6c4b99a748ce316187f6 (diff)
downloadnetctl-7b31dcd7b6da4f26db8f09924adc059f5a6ee589.tar.gz
netctl-7b31dcd7b6da4f26db8f09924adc059f5a6ee589.tar.xz
Add WEP support to wireless-dbus, remove broken interface type check in wireless
Diffstat (limited to 'src-wireless/wireless-dbus')
-rwxr-xr-xsrc-wireless/wireless-dbus58
1 files changed, 46 insertions, 12 deletions
diff --git a/src-wireless/wireless-dbus b/src-wireless/wireless-dbus
index 2a60fc4..0e241a9 100755
--- a/src-wireless/wireless-dbus
+++ b/src-wireless/wireless-dbus
@@ -26,6 +26,25 @@ def read_config(config):
options[var] = value
return options
+
+def wep_hex2dec(key):
+ if len(key) not in [10, 26]:
+ print "Bad key"
+ raise SyntaxError
+
+ x=0
+ new_key=[]
+ while x<len(key):
+ new_key.append(str(int(key[x:x+2],16)).zfill(3))
+ # Convert hex pair to decimal
+ #part = int(key[x:x+2],16)
+ # Convert to string with 00's filled and append
+ #new_key+=str(part).zfill(3)
+ # Increment to get next pair
+ x+=2
+
+ return new_key
+
def start(profile):
# TODO: Add check if it's even a wireless interface
# Interface up - probably redundant, should be 'ip' instead.
@@ -52,7 +71,7 @@ def start(profile):
args.append("-c" + profile["WPA_CONF"])
except KeyError:
args.append("-c/etc/wpa_supplicant.conf")
- elif not profile['SECURITY'] in ['wpa', 'wep']:
+ elif not profile['SECURITY'] in ['wpa', 'wep', 'none']:
print " - Invalid security chosen"
return False
@@ -84,27 +103,42 @@ def start(profile):
if_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
iface = dbus.Interface(if_obj, WPAS_DBUS_INTERFACES_INTERFACE);
- # Connect
-
- if profile['SECURITY'] in ['wpa','wep']:
- # Add+select the network
+ # Add and select the network. Networks already specified for wpa-config
+ if profile['SECURITY'] in ['wpa','wep','none']:
+
path = iface.addNetwork()
net_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
rnet = dbus.Interface(net_obj, WPAS_DBUS_NETWORKS_INTERFACE)
iface.selectNetwork(rnet)
- if profile['SECURITY'] == "wpa":
- # Set the options
- opts = dbus.Dictionary({"ssid": dbus.ByteArray(profile['ESSID']), "psk": dbus.String(profile['KEY'])}, signature="sv")
- elif profile['SECURITY'] == "wep":
- opts = dbus.Dictionary({"ssid": dbus.ByteArray(profile['ESSID']), "wpa_key0": dbus.String(profile['KEY'])}, signature="sv")
+ if profile['SECURITY'] == "wpa":
+ opts = dbus.Dictionary({"ssid": dbus.ByteArray(profile['ESSID']),
+ "psk": dbus.String(profile['KEY'])},
+ signature="sv")
+ rnet.set(opts)
+ elif profile['SECURITY'] == "wep":
+ key=profile['KEY']
+ if key[:2] == "s:": # String key prefixed by "s:"
+ key=key[2:]
+ else: # Hex key
+ key=wep_hex2dec(key)
+
+ print key
+ opts = dbus.Dictionary({"ssid": dbus.ByteArray(profile['ESSID']),
+ "key_mgmt": dbus.String("NONE"),
+ "wep_tx_keyidx": dbus.Int32(1),
+ "wep_key0": dbus.ByteArray(key)},
+ signature="sv")
+ rnet.set(opts)
+ elif profile['SECURITY'] == "none":
+ opts = dbus.Dictionary({"ssid": dbus.ByteArray(profile['ESSID'])},
+ signature="sv")
rnet.set(opts)
-
# Determine timeout
try:
- timeout = profile["TIMEOUT"]
+ timeout = int(profile["TIMEOUT"])
except KeyError:
timeout = 15