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 } wlan_status_t;
00132
00133 typedef struct wireless_iface
00134 {
00135
00136 struct wireless_iface * next;
00137
00138
00139 int ifindex;
00140
00141
00142 char ifname[IFNAMSIZ + 1];
00143 struct iw_range range;
00144 int has_range;
00145 } wireless_iface;
00146
00147
00148 typedef enum {
00149 FORCE_NO,
00150 FORCE_YES,
00151 } force_t;
00152
00153
00154 #define WLANCOND_LOW TRUE
00155 #define WLANCOND_HIGH FALSE
00156
00157
00158 enum scan_state {
00159 SCAN_NOT_ACTIVE = 0,
00160 SCAN_ACTIVE
00161 };
00162
00163
00164 enum wlan_state {
00165 WLAN_NOT_INITIALIZED = 0,
00166 WLAN_INITIALIZED,
00167 WLAN_INITIALIZED_FOR_SCAN,
00168 WLAN_INITIALIZED_FOR_CONNECTION,
00169 WLAN_NO_ADDRESS,
00170 WLAN_CONNECTED
00171 };
00172
00173
00174 #define WLANCOND_TX_POWER10DBM 10 // 10mW = 10dBm
00175 #define WLANCOND_TX_POWER100DBM 20 // 100mW = 20dBm
00176
00177
00178 enum wlan_power_state {
00179 WLANCOND_POWER_ON = 1,
00180 WLANCOND_LONG_CAM,
00181 WLANCOND_SHORT_CAM,
00182 WLANCOND_VERY_SHORT_CAM,
00183 WLANCOND_FULL_POWERSAVE
00184 };
00185
00186 #define NULL_BSSID (unsigned char*)"\x00\x00\x00\x00\x00\x00"
00187
00188 #define WLANCOND_DEFAULT_SLEEP_TIMEOUT 200 // 200ms
00189 #define WLANCOND_VERY_SHORT_CAM_TIMEOUT 100 // 100ms
00190 #define WLANCOND_LONG_CAM_TIMEOUT 4000 // 4000ms
00191
00192 #define MIC_FAILURE_TIMEOUT 60000 // 60 seconds
00193
00194
00195 #define NO_SIGNAL 0
00196 #define DISCONNECTED_SIGNAL 1
00197
00198
00199 #define WLANCOND_MAX_NETWORKS 30
00200 #define WLANCOND_MAX_SCAN_TRIES 3
00201
00202 #define WLANCOND_ROAM_THRESHOLD 10
00203 #define WLANCOND_MIN_ROAM_SCAN_INTERVAL 60000 // 60 seconds
00204 #define WLANCOND_MAX_ROAM_SCAN_INTERVAL 16*60000 // 16 minutes
00205 #define WLANCOND_RSSI_PENALTY 25 // 25dBm
00206 #define WLANCOND_MINIMUM_SIGNAL -99
00207
00208
00209 #define GCONF_PATH_PREFIX "/system/osso/connectivity/IAP/"
00210 #define SLEEP_GCONF_PATH GCONF_PATH_PREFIX "wlan_sleep_timeout"
00211 #define INACTIVE_SLEEP_GCONF_PATH GCONF_PATH_PREFIX "inactive_wlan_sleep_timeout"
00212
00213
00214 #define WLANCOND_REASON_LEAVING 3
00215 #define WLANCOND_REASON_MIC_FAILURE 14
00216
00217
00218 gboolean monitor_wi(void);
00219 void del_all_interface_data(void);
00220 struct wireless_iface *get_interface_data(int ifindex);
00221 int print_event_token(struct iw_event * event, struct scan_results_t *scan_results, int ifindex, gboolean scan_event);
00222 void send_dbus_scan_results(GSList* scan_results_save, const char* sender,
00223 dbus_int32_t number_of_results);
00224 GSList *save_scan_results(struct scan_results_t *scan_results,
00225 GSList *scan_results_save);
00226 void clean_scan_results(GSList **scan_results_save);
00227 void disconnected_signal(void);
00228 void mode_change(const char *mode);
00229 #ifdef ACTIVITY_CHECK
00230 void activity_check(dbus_bool_t activity);
00231 #endif
00232
00233 void clean_scan_results_item(gpointer data, gpointer user_data);
00234 void print_mac(const char *message, guchar* mac);
00235
00236 #endif