Separated more client classes.
[cnetworkmanager.git] / device06.py
bloba74b6689c31c7c93f6276cf34c07a84d78a1424b
1 from device import cDevice, cDeviceEth
3 class cDevice_06(cDevice):
4 def DeviceType0(self):
5 if self.dt is None:
6 self.dt = self.devi.getProperties()[2]
7 if self.dt == 1:
8 self.__class__ = cDeviceEth_06
9 elif self.dt == 2:
10 self.__class__ = cDeviceWifi_06
11 return self.dt
13 NM_ACT_STAGE = [
14 "UNKNOWN", "DEVICE_PREPARE", "DEVICE_CONFIG", "NEED_USER_KEY",
15 "IP_CONFIG_START", "IP_CONFIG_GET", "IP_CONFIG_COMMIT",
16 "ACTIVATED", "FAILED", "CANCELLED", ]
18 def Dump(self):
19 cDevice.Dump(self)
20 print " Driver:", self.devi.getDriver()
21 props = self.devi.getProperties() # osusb ussss sssii biuus as
22 print " Self:", props[0] # o
23 print " Interface:", props[1] # s
24 print " Type:", self.DEVICE_TYPE[props[2]] # u
25 print " UDI:", props[3] # s
26 print " Active:", bool(props[4]) # b
27 print " Activation Stage:", self.NM_ACT_STAGE[props[5]] # u
28 print " IP:", props[6] # s
29 print " Mask:", props[7] # s
30 print " Bcast:", props[8] # s
31 print " HwAddress:", props[9] # s
32 print " GW:", props[10] # s
33 print " NS1:", props[11] # s
34 print " NS2:", props[12] # s
35 self.DumpMore()
37 def DumpMore(self):
38 print " (unknown device type, not dumping more)"
40 class cDeviceEth_06(cDevice_06, cDeviceEth):
41 def DumpMore(self):
42 props = self.devi.getProperties() # osusb ussss sssii biuus as
43 print " Link Active:", bool(props[15]) # b
44 print " Speed:", props[16] # i
45 print " Generic Capabilities:", bitmask_str(self.NM_DEVICE_CAP, props[17]) # u
47 class cDeviceWifi_06(cDevice_06):
48 NM_802_11_CAP = {
49 0x00000001: "PROTO_NONE",
50 0x00000002: "PROTO_WEP",
51 0x00000004: "PROTO_WPA",
52 0x00000008: "PROTO_WPA2",
53 0x00000010: "RESERVED1",
54 0x00000020: "RESERVED2",
55 0x00000040: "KEY_MGMT_PSK",
56 0x00000080: "KEY_MGMT_802_1X",
57 0x00000100: "RESERVED3",
58 0x00000200: "RESERVED4",
59 0x00000400: "RESERVED5",
60 0x00000800: "RESERVED6",
61 0x00001000: "CIPHER_WEP40",
62 0x00002000: "CIPHER_WEP104",
63 0x00004000: "CIPHER_TKIP",
64 0x00008000: "CIPHER_CCMP",
67 def APs(self):
68 self.wdevi = dbus.Interface(self.devo, NMI + ".Device.Wireless")
69 aps = self.devi.getProperties()[20]
70 return map(cAP_06, aps)
72 def DumpMore(self):
73 props = self.devi.getProperties() # osusb ussss sssii biuus as
74 print " Mode:", self.IW_MODE[props[13]] # i
75 print " Strength:", props[14] # i
76 print " Link Active:", bool(props[15]) # b
77 print " Speed:", props[16] # i
78 print " Generic Capabilities:", bitmask_str(self.NM_DEVICE_CAP, props[17]) # u
79 print " Capabilities:", bitmask_str(self.NM_802_11_CAP, props[18]) # u
80 print " Current net:", props[19] # s
81 nets = props[20] # as
82 print " Seen nets:", " ".join(nets)
83 if options.ap:
84 print " Access Points"
85 for ap in self.APs():
86 ap.Dump()