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 <iwlib.h>
00033 #include <wireless.h>
00034 #define DBUS_API_SUBJECT_TO_CHANGE
00035 #include <dbus/dbus.h>
00036 #include <wlancond.h>
00037
00038
00039 typedef struct scan_results_t
00040 {
00041 char ssid[WLANCOND_MAX_SSID_SIZE+1];
00042 gint32 ssid_len;
00043 unsigned char bssid[ETH_ALEN];
00044 gint32 rssi;
00045 guint32 channel;
00046 guint32 cap_bits;
00047 guint32 wpa_ie_len;
00048 guint8 *wpa_ie;
00049 } scan_results_t;
00050
00051
00052 typedef struct wpa_ie_list_t
00053 {
00054 unsigned char bssid[ETH_ALEN];
00055 guint32 ie_len;
00056 guint8 *wpa_ie;
00057 } wpa_ie_list_t;
00058
00059
00060 typedef struct wpa_ie_save_t
00061 {
00062 guint32 ie_len;
00063 unsigned char *ie;
00064 } wpa_ie_save_t;
00065
00066
00067 typedef struct connect_params_t
00068 {
00069 dbus_int32_t mode;
00070 dbus_int32_t encryption;
00071 dbus_int32_t power_level;
00072 dbus_int32_t default_key;
00073 dbus_uint32_t adhoc_channel;
00074 dbus_uint32_t flags;
00075 char ssid[WLANCOND_MAX_SSID_SIZE+1];
00076 unsigned int ssid_len;
00077 unsigned int authentication_type;
00078 unsigned char key[4][32];
00079 int key_len[4];
00080 unsigned char bssid[ETH_ALEN];
00081 } connect_params;
00082
00083 #define PMK_CACHE_SIZE 32
00084 typedef struct pmksa_cache_t
00085 {
00086 unsigned char mac[ETH_ALEN];
00087 unsigned char pmkid[IW_PMKID_LEN];
00088 } pmksa_cache;
00089
00090
00091
00092
00093
00094 typedef struct wlan_status_t
00095 {
00096
00097 gchar ifname[IFNAMSIZ+1];
00098
00099 gchar own_mac[ETH_ALEN];
00100
00101 gchar scan_ssid[WLANCOND_MAX_SSID_SIZE+1];
00102
00103 gint scan_ssid_len;
00104
00105 guint scan;
00106
00107 guint state;
00108
00109 guint power;
00110
00111 guint pairwise_cipher;
00112 guint group_cipher;
00113
00114 struct wpa_ie_save_t wpa_ie;
00115
00116 struct connect_params_t conn;
00117
00118 GSList* pmk_cache;
00119
00120 GSList* roam_cache;
00121
00122 guint retry_count;
00123
00124 guint roam_scan;
00125
00126 guint roam_scan_id;
00127
00128 guint scan_id;
00129
00130 gboolean signal;
00131
00132 gboolean ip_ok;
00133 } wlan_status_t;
00134
00135 typedef struct wireless_iface
00136 {
00137
00138 struct wireless_iface * next;
00139
00140
00141 int ifindex;
00142
00143
00144 char ifname[IFNAMSIZ + 1];
00145 struct iw_range range;
00146 int has_range;
00147 } wireless_iface;
00148
00149
00150 typedef enum {
00151 FORCE_NO,
00152 FORCE_YES,
00153 } force_t;
00154
00155
00156 #define WLANCOND_LOW TRUE
00157 #define WLANCOND_HIGH FALSE
00158
00159
00160 enum scan_state {
00161 SCAN_NOT_ACTIVE = 0,
00162 SCAN_ACTIVE
00163 };
00164
00165
00166 enum wlan_state {
00167 WLAN_NOT_INITIALIZED = 0,
00168 WLAN_INITIALIZED,
00169 WLAN_INITIALIZED_FOR_SCAN,
00170 WLAN_INITIALIZED_FOR_CONNECTION,
00171 WLAN_NO_ADDRESS,
00172 WLAN_CONNECTED
00173 };
00174
00175
00176 #define WLANCOND_TX_POWER10DBM 10 // 10mW = 10dBm
00177 #define WLANCOND_TX_POWER100DBM 20 // 100mW = 20dBm
00178
00179
00180 enum wlan_power_state {
00181 WLANCOND_POWER_ON = 1,
00182 WLANCOND_LONG_CAM,
00183 WLANCOND_SHORT_CAM,
00184 WLANCOND_VERY_SHORT_CAM,
00185 WLANCOND_FULL_POWERSAVE
00186 };
00187
00188 #define NULL_BSSID (unsigned char*)"\x00\x00\x00\x00\x00\x00"
00189
00190 #define WLANCOND_DEFAULT_SLEEP_TIMEOUT 200000 // 200ms
00191 #define WLANCOND_VERY_SHORT_CAM_TIMEOUT 100000 // 100ms
00192 #define WLANCOND_LONG_CAM_TIMEOUT 4000000 // 4s
00193
00194 #define MIC_FAILURE_TIMEOUT 60 // 60 seconds
00195
00196
00197 #define NO_SIGNAL 0
00198 #define DISCONNECTED_SIGNAL 1
00199
00200
00201 #define WLANCOND_MAX_NETWORKS 30
00202 #define WLANCOND_MAX_SCAN_TRIES 3
00203
00204 #define WLANCOND_INITIAL_ROAM_SCAN_DELAY 2 // 2 seconds
00205 #define WLANCOND_ROAM_THRESHOLD 10
00206 #define WLANCOND_MIN_ROAM_SCAN_INTERVAL 60 // 60 seconds
00207 #define WLANCOND_MAX_ROAM_SCAN_INTERVAL 16*60 // 16 minutes
00208 #define WLANCOND_RSSI_PENALTY 25 // 25dBm
00209 #define WLANCOND_MINIMUM_SIGNAL -99
00210
00211
00212 #define GCONF_PATH_PREFIX "/system/osso/connectivity/IAP/"
00213 #define SLEEP_GCONF_PATH GCONF_PATH_PREFIX "wlan_sleep_timeout"
00214 #define INACTIVE_SLEEP_GCONF_PATH GCONF_PATH_PREFIX "inactive_wlan_sleep_timeout"
00215
00216
00217 #define WLANCOND_REASON_LEAVING 3
00218 #define WLANCOND_REASON_MIC_FAILURE 14
00219
00220
00221 gboolean monitor_wi(void);
00222 void del_all_interface_data(void);
00223 struct wireless_iface *get_interface_data(int ifindex);
00224 int print_event_token(struct iw_event * event, struct scan_results_t *scan_results, int ifindex, gboolean scan_event);
00225 void send_dbus_scan_results(GSList* scan_results_save, const char* sender,
00226 dbus_int32_t number_of_results);
00227 GSList *save_scan_results(struct scan_results_t *scan_results,
00228 GSList *scan_results_save);
00229 void clean_scan_results(GSList **scan_results_save);
00230 void disconnected_signal(void);
00231 void mode_change(const char *mode);
00232 #ifdef ACTIVITY_CHECK
00233 void activity_check(dbus_bool_t activity);
00234 #endif
00235
00236 void clean_scan_results_item(gpointer data, gpointer user_data);
00237 void print_mac(const char *message, guchar* mac);
00238
00239 #endif