Go to the documentation of this file.00001
00023 #ifndef _COMMON_H_
00024 #define _COMMON_H_
00025
00026 #include <sys/types.h>
00027 #include <sys/socket.h>
00028 #include <linux/types.h>
00029 #include <linux/netlink.h>
00030 #include <linux/rtnetlink.h>
00031 #include <linux/if_ether.h>
00032 #include <mce/mode-names.h>
00033 #include <stdio.h>
00034 #include <net/if.h>
00035 #include <connsettings/conn_settings.h>
00036 #define DBUS_API_SUBJECT_TO_CHANGE
00037 #include <dbus/dbus.h>
00038 #include <wlancond.h>
00039
00040
00041 typedef struct scan_results_t
00042 {
00043 char ssid[WLANCOND_MAX_SSID_SIZE+1];
00044 guint32 ssid_len;
00045 unsigned char bssid[ETH_ALEN];
00046 gint32 rssi;
00047 guint32 channel;
00048 guint32 cap_bits;
00049 guint32 extra_cap_bits;
00050 guint32 wpa_ie_len;
00051 guint8 *wpa_ie;
00052 guint8 *uuid_e;
00053 } scan_results_t;
00054
00055
00056 typedef struct wpa_ie_list_t
00057 {
00058 unsigned char bssid[ETH_ALEN];
00059 guint32 ie_len;
00060 guint8 *wpa_ie;
00061 } wpa_ie_list_t;
00062
00063
00064 typedef struct wpa_ie_save_t
00065 {
00066 guint32 ie_len;
00067 unsigned char *ie;
00068 } wpa_ie_save_t;
00069
00070
00071 typedef struct connect_params_t
00072 {
00073 dbus_int32_t mode;
00074 dbus_int32_t encryption;
00075 dbus_int32_t power_level;
00076 dbus_int32_t default_key;
00077 dbus_uint32_t adhoc_channel;
00078 dbus_uint32_t flags;
00079 guint32 channel;
00080 char ssid[WLANCOND_MAX_SSID_SIZE+1];
00081 unsigned int ssid_len;
00082 unsigned int authentication_type;
00083 int key_len[4];
00084 unsigned char key[4][WLANCOND_MAX_KEY_LEN];
00085 gboolean wep_try_open_mode_first;
00086 unsigned char bssid[ETH_ALEN];
00087 } connect_params;
00088
00089 #define PMK_CACHE_SIZE 32
00090 typedef struct pmksa_cache_t
00091 {
00092 unsigned char mac[ETH_ALEN];
00093 unsigned char pmkid[WLANCOND_PMKID_LEN];
00094 } pmksa_cache;
00095
00096 #define WLANCOND_IF_NAME "wlan0"
00097
00098
00099
00100
00101
00102 typedef struct wlan_status_t
00103 {
00104
00105 gchar ifname[IFNAMSIZ+1];
00106
00107 guint32 ifindex;
00108
00109 gchar own_mac[ETH_ALEN];
00110
00111 gchar scan_ssid[WLANCOND_MAX_SSID_SIZE+1];
00112
00113 gint scan_ssid_len;
00114
00115 guint scan;
00116
00117 guint state;
00118
00119 guint power;
00120
00121 guint pairwise_cipher;
00122 guint group_cipher;
00123
00124 struct wpa_ie_save_t wpa_ie;
00125
00126 struct connect_params_t conn;
00127
00128 ConnSettings *setting;
00129
00130 GSList* pmk_cache;
00131
00132 GSList* roam_cache;
00133
00134 guint retry_count;
00135
00136 guint roam_scan;
00137
00138 guint roam_scan_id;
00139
00140 gint last_scan;
00141
00142 guint scan_id;
00143
00144 guint rescan_id;
00145
00146 guint powersave;
00147
00148 guint call_type;
00149
00150 char* country_code;
00151
00152 gint last_code;
00153
00154 gchar* last_calibrated_code;
00155
00156 FILE* latency_file;
00157
00158 FILE* iptables_file;
00159
00160 gboolean calibration_needed;
00161
00162 gboolean signal;
00163
00164 gboolean ip_ok;
00165
00166 gboolean allow_all_ciphers;
00167
00168 gboolean if_down_self;
00169
00170 gboolean high_traffic;
00171
00172 gboolean full_psm_enabled;
00173
00174 gboolean dbus_filters;
00175
00176 gboolean iptables_loaded;
00177
00178 gboolean interface_up;
00179 } wlan_status_t;
00180
00181
00182 typedef struct roam_cache_key_t
00183 {
00184 unsigned char* bssid;
00185 guint32 channel;
00186 } roam_cache_key_t;
00187
00188
00189 #define WLANCOND_LOW TRUE
00190 #define WLANCOND_HIGH FALSE
00191
00192
00193 enum scan_state {
00194 SCAN_NOT_ACTIVE = 0,
00195 SCAN_ACTIVE
00196 };
00197
00198
00199 #define CALL_VOIP (1<<0)
00200 #define CALL_CELLULAR (1<<1)
00201 #define CALL_GPRS (1<<2)
00202
00203
00204 enum wlan_state {
00205 WLAN_NOT_INITIALIZED = 0,
00206 WLAN_INITIALIZED,
00207 WLAN_INITIALIZED_FOR_SCAN,
00208 WLAN_INITIALIZED_FOR_CONNECTION,
00209 WLAN_NO_ADDRESS,
00210 WLAN_CONNECTED
00211 };
00212
00213
00214 #define WLANCOND_TX_POWERLIMITED 1300 // 13dBm
00215 #define WLANCOND_TX_POWER10DBM 1000 // 10mW = 10dBm = 1000 mBm
00216 #define WLANCOND_TX_POWER100DBM 2000 // 100mW = 20dBm = 2000 mBm
00217
00218
00219 enum wlan_power_state {
00220 WLANCOND_POWER_ON = 1,
00221 WLANCOND_CAM_TIMEOUT,
00222 WLANCOND_FULL_POWERSAVE
00223 };
00224
00225 #define NULL_BSSID (unsigned char*)"\x00\x00\x00\x00\x00\x00"
00226
00227 #define WLANCOND_LATENCY_FILE "/dev/network_latency"
00228 #define WLANCOND_DEFAULT_NETWORK_LATENCY 2000000000 // 100ms
00229 #define WLANCOND_FULL_PSM_LATENCY 1900000001
00230
00231 #define MIC_FAILURE_TIMEOUT 60 // 60 seconds
00232
00233
00234 #define NO_SIGNAL 0
00235 #define DISCONNECTED_SIGNAL 1
00236
00237
00238 #define WLANCOND_MAX_NETWORKS 30
00239 #define WLANCOND_MAX_SCAN_TRIES 3
00240
00241 #define WLANCOND_INITIAL_ROAM_SCAN_DELAY 2 // 2 seconds
00242 #define WLANCOND_ROAM_THRESHOLD 10 // dBm
00243 #define WLANCOND_5GHZ_BENEFIT 5 // dBm
00244 #define WLANCOND_MIN_ROAM_SCAN_INTERVAL 60 // 60 seconds
00245 #define WLANCOND_MAX_ROAM_SCAN_INTERVAL 16*60 // 16 minutes
00246 #define WLANCOND_COUNTRY_CACHE_TIME 3600 // 1 hour
00247 #define WLANCOND_RSSI_PENALTY 25 // 25dBm
00248 #define WLANCOND_MINIMUM_SIGNAL -99
00249 #define WLANCOND_MINIMUM_AUTOCONNECT_RSSI -85
00250
00251
00252 #define WLANCOND_INITIAL_CHANNEL 1
00253
00254
00255 #define SCAN_SYSFS_FILE "/sys/devices/platform/wl1271/"
00256 #define SCAN_SIZE_FILE SCAN_SYSFS_FILE "scan_size"
00257 #define SCAN_DELAY_FILE SCAN_SYSFS_FILE "scan_delay"
00258 #define SCAN_SIZE_SPLIT 1
00259 #define SCAN_SIZE_NORMAL 24
00260 #define SCAN_DELAY_SPLIT 40
00261 #define SCAN_DELAY_NORMAL 0
00262
00263
00264 #define WLANCOND_DEBUG_LEVEL "wlancond_debug_level"
00265 #define WLANCOND_ALLOW_ALL_CIPHERS "allow_wep_ciphers_in_WPA"
00266
00267
00268 #define WLANCOND_PRIO_HIGH 2
00269 #define WLANCOND_PRIO_MEDIUM 1
00270 #define WLANCOND_PRIO_LOW 0
00271
00272
00273 #define WLANCOND_MLME_DEAUTH 0
00274
00275
00276 #define WLANCOND_MLME_DISASSOC 1
00277
00278
00279 #define WLANCOND_NL80211_MLME_DISCONNECT 0xD15C
00280
00281
00282 #define WLANCOND_REASON_LEAVING 3
00283 #define WLANCOND_REASON_MIC_FAILURE 14
00284
00285
00286 #define CSNET_INTERFACE "com.nokia.csd.CSNet"
00287 #define CSNET_OBJECT "/com/nokia/csd/csnet"
00288 #define CSNET_ACTION "Get"
00289 #define CSNET_OPER_IFACE "com.nokia.csd.CSNet.NetworkOperator"
00290 #define CSNET_OPER_MCC "OperatorMCC"
00291 #define CSNET_OPERATOR_CHANGED_SIG "OperatorChanged"
00292
00293
00294 #define GPRS_DBUS_INTERFACE "com.nokia.csd.GPRS"
00295 #define GPRS_DBUS_DATACOUNTERS_SIG "DataCounters"
00296
00297
00298 #define POLICY_SERVICE_NAME "com.nokia.policy"
00299 #define POLICY_ACTIONS_SIG "audio_actions"
00300
00301
00302 #define FULL_PSM_SETTING "full_psm_enabled"
00303
00304
00305
00306 #define WLANCOND_WEP40 (1<<0)
00307 #define WLANCOND_WEP104 (1<<1)
00308 #define WLANCOND_WEP40_GROUP (1<<2)
00309 #define WLANCOND_WEP104_GROUP (1<<3)
00310
00311 #define WLANCOND_UAPSD_SUPPORTED (1<<31)
00312
00313
00314 #define WLANCOND_IF_DORMANT 1
00315 #define WLANCOND_IF_READY 6
00316
00317
00318 void init_logging(void);
00319 void wlancond_print(guint priority, const char *debug, ...);
00320 gboolean monitor_wi(void);
00321 void send_dbus_scan_results(GSList* scan_results_save, const char* sender,
00322 dbus_int32_t number_of_results);
00323 void clean_scan_results(GSList **scan_results_save);
00324 void disconnected_signal(void);
00325 void mode_change(dbus_uint32_t radio_mode);
00326 #ifdef ACTIVITY_CHECK
00327 void activity_check(dbus_bool_t activity);
00328 #endif
00329
00330 void clean_scan_results_item(gpointer data, gpointer user_data);
00331 void print_mac(guint priority, const char *message, guchar* mac);
00332 gboolean roam_scanning(void);
00333 int netlink_send_linkmode(int lmode);
00334 int set_iptables(void);
00335 void remove_iptables(void);
00336 gboolean monitor_iap_keys(void);
00337 gboolean is_connected_state(void);
00338
00339 #endif