$search
00001 # -*- coding: latin1 -*- 00002 # Python WiFi -- a library to access wireless card properties via Python 00003 # Copyright (C) 2004 - 2008 Róman Joost 00004 # Copyright (C) 2008 - 2009 Sean Robinson 00005 # 00006 # This library is free software; you can redistribute it and/or 00007 # modify it under the terms of the GNU Lesser General Public License 00008 # as published by the Free Software Foundation; either version 2.1 of 00009 # the License, or (at your option) any later version. 00010 # 00011 # This library is distributed in the hope that it will be useful, but 00012 # WITHOUT ANY WARRANTY; without even the implied warranty of 00013 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 # Lesser General Public License for more details. 00015 # 00016 # You should have received a copy of the GNU Lesser General Public 00017 # License along with this library; if not, write to the Free Software 00018 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00019 # USA 00020 00021 modes = ['Auto', 00022 'Ad-Hoc', 00023 'Managed', 00024 'Master', 00025 'Repeat', 00026 'Second', 00027 'Monitor', 00028 'Unknown/bug'] 00029 00030 IFNAMSIZE = 16 00031 IW_ESSID_MAX_SIZE = 32 00032 IW_MAX_FREQUENCIES = 32 00033 IW_MAX_BITRATES = 32 00034 IW_MAX_TXPOWER = 8 00035 00036 SIOCGIFCONF = 0x8912 # ifconf struct 00037 00038 # ioctl calls for the Linux/i386 kernel 00039 SIOCSIWCOMMIT = 0x8B00 # Commit pending changes to driver 00040 SIOCGIWNAME = 0x8B01 # get name == wireless protocol 00041 SIOCSIWNWID = 0x8B02 # set network id (pre-802.11) 00042 SIOCGIWNWID = 0x8B03 # get network id (the cell) 00043 SIOCSIWFREQ = 0x8B04 # set channel/frequency 00044 SIOCGIWFREQ = 0x8B05 # get channel/frequency 00045 SIOCSIWMODE = 0x8B06 # set the operation mode 00046 SIOCGIWMODE = 0x8B07 # get operation mode 00047 SIOCSIWSENS = 0x8B08 # set sensitivity (dBm) 00048 SIOCGIWSENS = 0x8B09 # get sensitivity 00049 SIOCSIWRANGE = 0x8B0A # Unused 00050 SIOCGIWRANGE = 0x8B0B # Get range of parameters 00051 SIOCSIWPRIV = 0x8B0C # Unused 00052 SIOCGIWPRIV = 0x8B0D # get private ioctl interface info 00053 SIOCSIWSTATS = 0x8B0E # Unused 00054 SIOCGIWSTATS = 0x8B0F # Get /proc/net/wireless stats 00055 SIOCSIWSPY = 0x8B10 # set spy addresses 00056 SIOCGIWSPY = 0x8B11 # get spy info (quality of link) 00057 SIOCSIWTHRSPY = 0x8B12 # set spy threshold (spy event) 00058 SIOCGIWTHRSPY = 0x8B13 # get spy threshold 00059 SIOCSIWAP = 0x8B14 # set AP MAC address 00060 SIOCGIWAP = 0x8B15 # get AP MAC addresss 00061 SIOCGIWAPLIST = 0x8B17 # Deprecated in favor of scanning 00062 SIOCSIWSCAN = 0x8B18 # set scanning off 00063 SIOCGIWSCAN = 0x8B19 # get scanning results 00064 SIOCSIWESSID = 0x8B1A # set essid 00065 SIOCGIWESSID = 0x8B1B # get essid 00066 SIOCSIWNICKN = 0x8B1C # set node name/nickname 00067 SIOCGIWNICKN = 0x8B1D # get node name/nickname 00068 SIOCSIWRATE = 0x8B20 # set default bit rate (bps) 00069 SIOCGIWRATE = 0x8B21 # get default bit rate (bps) 00070 SIOCSIWRTS = 0x8B22 # set RTS/CTS threshold (bytes) 00071 SIOCGIWRTS = 0x8B23 # get RTS/CTS threshold (bytes) 00072 SIOCSIWFRAG = 0x8B24 # set fragmentation thr (bytes) 00073 SIOCGIWFRAG = 0x8B25 # get fragmentation thr (bytes) 00074 SIOCSIWTXPOW = 0x8B26 # set transmit power (dBm) 00075 SIOCGIWTXPOW = 0x8B27 # get transmit power (dBm) 00076 SIOCSIWRETRY = 0x8B28 # set retry limits and lifetime 00077 SIOCGIWRETRY = 0x8B29 # get retry limits and lifetime 00078 SIOCSIWENCODE = 0x8B2A # set encryption information 00079 SIOCGIWENCODE = 0x8B2B # get encryption information 00080 SIOCSIWPOWER = 0x8B2C # set Power Management settings 00081 SIOCGIWPOWER = 0x8B2D # get power managment settings 00082 SIOCSIWMODUL = 0x8B2E # set Modulations settings 00083 SIOCGIWMODUL = 0x8B2F # get Modulations settings 00084 SIOCSIWGENIE = 0x8B30 # set generic IE 00085 SIOCGIWGENIE = 0x8B31 # get generic IE 00086 # WPA 00087 SIOCSIWMLME = 0x8B16 # request MLME operation; uses struct iw_mlme 00088 SIOCSIWAUTH = 0x8B32 # set authentication mode params 00089 SIOCGIWAUTH = 0x8B33 # get authentication mode params 00090 SIOCSIWENCODEEXT = 0x8B34 # set encoding token & mode 00091 SIOCGIWENCODEEXT = 0x8B35 # get encoding token & mode 00092 SIOCSIWPMKSA = 0x8B36 # PMKSA cache operation 00093 00094 SIOCIWFIRST = 0x8B00 # FIRST ioctl identifier 00095 SIOCIWLAST = 0x8BFF # LAST ioctl identifier 00096 00097 # Wireless events 00098 IWEVFIRST = 0x8C00 # FIRST event identifier 00099 IWEVTXDROP = 0x8C00 # Packet dropped to excessive retry 00100 IWEVQUAL = 0x8C01 # Quality statistics from scan 00101 IWEVCUSTOM = 0x8C02 # Custom Ascii string from Driver 00102 IWEVREGISTERED = 0x8C03 # Discovered a new node (AP mode) 00103 IWEVEXPIRED = 0x8C04 # Expired a node (AP mode) 00104 IWEVGENIE = 0x8C05 # Generic IE (WPA, RSN, WMM, ..) 00105 IWEVMICHAELMICFAILURE = 0x8C06 # Michael MIC failure 00106 IWEVASSOCREQIE = 0x8C07 # IEs used in (Re)Association Request. 00107 IWEVASSOCRESPIE = 0x8C08 # IEs used in (Re)Association Response. 00108 IWEVPMKIDCAND = 0x8C09 # PMKID candidate for RSN pre-authentication 00109 IWEVLAST = 0x8C0A # LAST event identifier 00110 00111 # Power management flags 00112 IW_POWER_ON = 0x0000 # No details ... 00113 IW_POWER_TYPE = 0xF000 # Type of parameter 00114 IW_POWER_PERIOD = 0x1000 # Value is a period/duration of 00115 IW_POWER_TIMEOUT = 0x2000 # Value is a timeout 00116 IW_POWER_SAVING = 0x4000 # Value is relative (how aggressive) 00117 IW_POWER_MODE = 0x0F00 # Power management mode 00118 IW_POWER_UNICAST_R = 0x0100 # Receive only unicast messages 00119 IW_POWER_MULTICAST_R = 0x0200 # Receive only multicast messages 00120 IW_POWER_ALL_R = 0x0300 # Receive all messages though PM 00121 IW_POWER_FORCE_S = 0x0400 # Force PM procedure for sending unicast 00122 IW_POWER_REPEATER = 0x0800 # Repeat broadcast messages in PM period 00123 IW_POWER_MODIFIER = 0x000F # Modify a parameter 00124 IW_POWER_MIN = 0x0001 # Value is a minimum 00125 IW_POWER_MAX = 0x0002 # Value is a maximum 00126 IW_POWER_RELATIVE = 0x0004 # Value is not in seconds/ms/us 00127 00128 # Retry limits and lifetime flags available 00129 IW_RETRY_ON = 0x0000 # No details... 00130 IW_RETRY_TYPE = 0xF000 # Type of parameter 00131 IW_RETRY_LIMIT = 0x1000 # Maximum number of retries 00132 IW_RETRY_LIFETIME = 0x2000 # Maximum duration of retries in us 00133 IW_RETRY_MODIFIER = 0x00FF # Modify a parameter 00134 IW_RETRY_MIN = 0x0001 # Value is a minimum 00135 IW_RETRY_MAX = 0x0002 # Value is a maximum 00136 IW_RETRY_RELATIVE = 0x0004 # Value is not in seconds/ms/us 00137 IW_RETRY_SHORT = 0x0010 # Value is for short packets 00138 IW_RETRY_LONG = 0x0020 # Value is for long packets 00139 00140 # Modes of operation 00141 IW_MODE_AUTO = 0 # Let the driver decides 00142 IW_MODE_ADHOC = 1 # Single cell network 00143 IW_MODE_INFRA = 2 # Multi cell network, roaming, ... 00144 IW_MODE_MASTER = 3 # Synchronisation master or Access Point 00145 IW_MODE_REPEAT = 4 # Wireless Repeater (forwarder) 00146 IW_MODE_SECOND = 5 # Secondary master/repeater (backup) 00147 IW_MODE_MONITOR = 6 # Passive monitor (listen only) 00148 00149 # Statistics flags (bitmask in updated) 00150 IW_QUAL_QUAL_UPDATED = 0x01 # Value was updated since last read 00151 IW_QUAL_LEVEL_UPDATED = 0x02 00152 IW_QUAL_NOISE_UPDATED = 0x04 00153 IW_QUAL_ALL_UPDATED = 0x07 00154 IW_QUAL_DBM = 0x08 # Level + Noise are dBm 00155 IW_QUAL_QUAL_INVALID = 0x10 # Driver doesn't provide value 00156 IW_QUAL_LEVEL_INVALID = 0x20 00157 IW_QUAL_NOISE_INVALID = 0x40 00158 IW_QUAL_RCPI = 0x80 # Level + Noise are 802.11k RCPI 00159 IW_QUAL_ALL_INVALID = 0x70 00160 00161 # Frequency flags 00162 IW_FREQ_AUTO = 0x00 # Let the driver decide 00163 IW_FREQ_FIXED = 0x01 # Force a specific value 00164 00165 # Maximum number of size of encoding token available 00166 IW_MAX_ENCODING_SIZES = 8 00167 00168 # Maximum size of the encoding token in bytes 00169 IW_ENCODING_TOKEN_MAX = 64 # 512 bits (for now) 00170 00171 # Flags for encoding (along with the token) 00172 IW_ENCODE_INDEX = 0x00FF # Token index (if needed) 00173 IW_ENCODE_FLAGS = 0xFF00 # Flags defined below 00174 IW_ENCODE_MODE = 0xF000 # Modes defined below 00175 IW_ENCODE_DISABLED = 0x8000 # Encoding disabled 00176 IW_ENCODE_ENABLED = 0x0000 # Encoding enabled 00177 IW_ENCODE_RESTRICTED = 0x4000 # Refuse non-encoded packets 00178 IW_ENCODE_OPEN = 0x2000 # Accept non-encoded packets 00179 IW_ENCODE_NOKEY = 0x0800 # Key is write only, so not present 00180 IW_ENCODE_TEMP = 0x0400 # Temporary key 00181 00182 # MAC address length 00183 ETH_ALEN = 6 00184 00185 # constants responsible for scanning 00186 IW_SCAN_MAX_DATA = 4096 00187 00188 # event sizes 00189 IW_EV_LCP_LEN = 4 00190 IW_EV_CHAR_LEN = IW_EV_LCP_LEN + IFNAMSIZE 00191 IW_EV_UINT_LEN = IW_EV_LCP_LEN + 4 00192 IW_EV_FREQ_LEN = IW_EV_LCP_LEN + 8 00193 IW_EV_ADDR_LEN = IW_EV_LCP_LEN + 16 00194 IW_EV_POINT_LEN = IW_EV_LCP_LEN + 4 00195 IW_EV_PARAM_LEN = IW_EV_LCP_LEN + 8 00196 IW_EV_QUAL_LEN = IW_EV_LCP_LEN + 4 00197 00198 IW_EV_LCP_PK_LEN = 4 00199 00200 IWHT_NULL = 0 00201 IWHT_CHAR = 2 00202 IWHT_UINT = 4 00203 IWHT_FREQ = 5 00204 IWHT_ADDR = 6 00205 IWHT_POINT = 8 00206 IWHT_PARAM = 9 00207 IWHT_QUAL = 10 00208