am dd9faa94: (-s ours) am d8cec50a: am bca3fd8d: (-s ours) tnetw1271: Add "HANGED" processing (b/2310372) (DO NOT MERGE)

Merge commit 'dd9faa94a93b0a9831ae654c172f467b31328c4e'

* commit 'dd9faa94a93b0a9831ae654c172f467b31328c4e':
  tnetw1271: Add "HANGED" processing (b/2310372) (DO NOT MERGE)
diff --git a/lib/scanmerge.c b/lib/scanmerge.c
index 2b376ff..36f17a2 100644
--- a/lib/scanmerge.c
+++ b/lib/scanmerge.c
@@ -19,6 +19,25 @@
 #include "shlist.h"
 
 #define IS_HIDDEN_AP(a)	(((a)->ssid_len == 0) || ((a)->ssid[0] == '\0'))
+
+scan_ssid_t *scan_get_ssid( scan_result_t *res_ptr )
+{
+    static scan_ssid_t ssid_temp;
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+    const u8 *res_ie;
+
+    res_ie = wpa_scan_get_ie(res_ptr, WLAN_EID_SSID);
+    if (!res_ie)
+        return NULL;
+    ssid_temp.ssid_len = (size_t)res_ie[1];
+    os_memcpy(ssid_temp.ssid, (res_ie + 2), ssid_temp.ssid_len);
+#else
+    ssid_temp.ssid_len = res_ptr->ssid_len;
+    os_memcpy(ssid_temp.ssid, res_ptr->ssid, ssid_temp.ssid_len);
+#endif
+    return &ssid_temp;
+}
+
 /*-----------------------------------------------------------------------------
 Routine Name: scan_init
 Routine Description: Inits scan merge list
@@ -29,7 +48,7 @@
 void scan_init( struct wpa_driver_ti_data *mydrv )
 {
     mydrv->last_scan = -1;
-    shListInitList( &(mydrv->scan_merge_list) );
+    shListInitList(&(mydrv->scan_merge_list));
 }
 
 /*-----------------------------------------------------------------------------
@@ -41,7 +60,7 @@
 -----------------------------------------------------------------------------*/
 static void scan_free( void *ptr )
 {
-    os_free( ptr );
+    os_free(ptr);
 }
 
 /*-----------------------------------------------------------------------------
@@ -53,7 +72,19 @@
 -----------------------------------------------------------------------------*/
 void scan_exit( struct wpa_driver_ti_data *mydrv )
 {
-    shListDelAllItems( &(mydrv->scan_merge_list), scan_free );
+    shListDelAllItems(&(mydrv->scan_merge_list), scan_free);
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: scan_count
+Routine Description: Gives number of list elements
+Arguments:
+   mydrv   - pointer to private driver data structure
+Return Value: Number of elements in the list
+-----------------------------------------------------------------------------*/
+unsigned long scan_count( struct wpa_driver_ti_data *mydrv )
+{
+    return shListGetCount(&(mydrv->scan_merge_list));
 }
 
 /*-----------------------------------------------------------------------------
@@ -66,17 +97,27 @@
 -----------------------------------------------------------------------------*/
 static int scan_equal( void *val,  void *idata )
 {
-    struct wpa_scan_result *new_res = (struct wpa_scan_result *)val;
-    struct wpa_scan_result *lst_res =
-               (struct wpa_scan_result *)(&(((scan_merge_t *)idata)->scanres));
+    scan_ssid_t n_ssid, l_ssid, *p_ssid;
+    scan_result_t *new_res = (scan_result_t *)val;
+    scan_result_t *lst_res =
+               (scan_result_t *)(&(((scan_merge_t *)idata)->scanres));
     int ret;
     size_t len;
 
-    len = (IS_HIDDEN_AP(new_res) || IS_HIDDEN_AP(lst_res)) ?
-          0 : new_res->ssid_len;
-    ret = ((lst_res->ssid_len != new_res->ssid_len) && (len != 0)) ||
+    p_ssid = scan_get_ssid(new_res);
+    if (!p_ssid)
+        return 0;
+    os_memcpy(&n_ssid, p_ssid, sizeof(scan_ssid_t));
+    p_ssid = scan_get_ssid(lst_res);
+    if (!p_ssid)
+        return 0;
+    os_memcpy(&l_ssid, p_ssid, sizeof(scan_ssid_t));
+
+    len = (IS_HIDDEN_AP(&n_ssid) || IS_HIDDEN_AP(&l_ssid)) ?
+          0 : n_ssid.ssid_len;
+    ret = ((l_ssid.ssid_len != n_ssid.ssid_len) && (len != 0)) ||
           (os_memcmp(new_res->bssid, lst_res->bssid, ETH_ALEN) ||
-           os_memcmp(new_res->ssid, lst_res->ssid, len));
+           os_memcmp(n_ssid.ssid, l_ssid.ssid, len));
     return !ret;
 }
 
@@ -88,13 +129,15 @@
    src - source pointer to scan result structure
 Return Value: NONE
 -----------------------------------------------------------------------------*/
-void copy_scan_res( struct wpa_scan_result *dst, struct wpa_scan_result *src )
+void copy_scan_res( scan_result_t *dst, scan_result_t *src )
 {
+#ifdef WPA_SUPPLICANT_VER_0_5_X
     if( IS_HIDDEN_AP(src) ) {
-        os_memcpy( src->ssid, dst->ssid, dst->ssid_len );
+        os_memcpy(src->ssid, dst->ssid, dst->ssid_len);
         src->ssid_len = dst->ssid_len;
     }
-    os_memcpy( dst, src, sizeof(struct wpa_scan_result) );
+#endif
+    os_memcpy(dst, src, sizeof(scan_result_t));
 }
 
 /*-----------------------------------------------------------------------------
@@ -105,16 +148,20 @@
    res_ptr - pointer to scan result structure
 Return Value: Pointer to scan merge item
 -----------------------------------------------------------------------------*/
-static scan_merge_t *scan_add( SHLIST *head, struct wpa_scan_result *res_ptr )
+static scan_merge_t *scan_add( SHLIST *head, scan_result_t *res_ptr )
 {
     scan_merge_t *scan_ptr;
+    unsigned size = 0;
 
-    scan_ptr = (scan_merge_t *)os_malloc( sizeof(scan_merge_t) );
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+    size += res_ptr->ie_len;
+#endif
+    scan_ptr = (scan_merge_t *)os_malloc(sizeof(scan_merge_t) + size);
     if( !scan_ptr )
         return( NULL );
-    os_memcpy( &(scan_ptr->scanres), res_ptr, sizeof(struct wpa_scan_result) );
+    os_memcpy(&(scan_ptr->scanres), res_ptr, sizeof(scan_result_t) + size);
     scan_ptr->count = SCAN_MERGE_COUNT;
-    shListInsLastItem( head, (void *)scan_ptr );
+    shListInsLastItem(head, (void *)scan_ptr);
     return scan_ptr;
 }
 
@@ -127,18 +174,45 @@
    number_items - current number of items
 Return Value: 1 - if item was found, 0 - otherwise
 -----------------------------------------------------------------------------*/
-static int scan_find( scan_merge_t *scan_ptr, struct wpa_scan_result *results,
+static int scan_find( scan_merge_t *scan_ptr, scan_result_t *results,
                       unsigned int number_items )
 {
     unsigned int i;
 
     for(i=0;( i < number_items );i++) {
-        if( scan_equal( &(results[i]), scan_ptr ) )
+        if( scan_equal(&(results[i]), scan_ptr) )
             return 1;
     }
     return 0;
 }
 
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+/*-----------------------------------------------------------------------------
+Routine Name: scan_dup
+Routine Description: Create copy of scan results entry
+Arguments:
+   res_ptr - pointer to scan result item
+Return Value: pointer to new scan result item, or NULL
+-----------------------------------------------------------------------------*/
+static scan_result_t *scan_dup( scan_result_t *res_ptr )
+{
+    unsigned size;
+    scan_result_t *new_ptr;
+
+    if (!res_ptr)
+        return NULL;
+
+    size = sizeof(scan_result_t) + res_ptr->ie_len;
+    new_ptr = os_malloc(size);
+    if (!new_ptr)
+        return NULL;
+    if (res_ptr) {
+        os_memcpy(new_ptr, res_ptr, size);
+    }
+    return new_ptr;
+}
+#endif
+
 /*-----------------------------------------------------------------------------
 Routine Name: scan_merge
 Routine Description: Merges current scan results with previous
@@ -149,33 +223,59 @@
    max_size - maximum namber of items
 Return Value: Merged number of items
 -----------------------------------------------------------------------------*/
+#ifdef WPA_SUPPLICANT_VER_0_6_X
 unsigned int scan_merge( struct wpa_driver_ti_data *mydrv,
-                         struct wpa_scan_result *results, int force_flag,
+                         scan_result_t **results, int force_flag,
                          unsigned int number_items, unsigned int max_size )
+#else
+unsigned int scan_merge( struct wpa_driver_ti_data *mydrv,
+                         scan_result_t *results, int force_flag,
+                         unsigned int number_items, unsigned int max_size )
+#endif
 {
     SHLIST *head = &(mydrv->scan_merge_list);
     SHLIST *item, *del_item;
+    scan_result_t *res_ptr;
     scan_merge_t *scan_ptr;
     unsigned int i;
 
     /* Prepare items for removal */
-    item = shListGetFirstItem( head );
+    item = shListGetFirstItem(head);
     while( item != NULL ) {
         scan_ptr = (scan_merge_t *)(item->data);
         if( scan_ptr->count != 0 )
             scan_ptr->count--;
-        item = shListGetNextItem( head, item );
+        item = shListGetNextItem(head, item);
     }
 
     for(i=0;( i < number_items );i++) { /* Find/Add new items */
-        item = shListFindItem( head, &(results[i]), scan_equal );
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+        res_ptr = results[i];
+#else
+        res_ptr = &(results[i]);
+#endif
+        item = shListFindItem( head, res_ptr, scan_equal );
         if( item ) {
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+            scan_ssid_t *p_ssid;
+            scan_result_t *new_ptr;
+#endif
             scan_ptr = (scan_merge_t *)(item->data);
-            copy_scan_res(&(scan_ptr->scanres), &(results[i]));
+            copy_scan_res(&(scan_ptr->scanres), res_ptr);
             scan_ptr->count = SCAN_MERGE_COUNT;
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+	    p_ssid = scan_get_ssid(res_ptr);
+            if (p_ssid && IS_HIDDEN_AP(p_ssid)) {
+                new_ptr = scan_dup(res_ptr);
+                if (new_ptr) {
+                    results[i] = new_ptr;
+                    os_free(res_ptr);
+                }
+            }
+#endif
         }
         else {
-            scan_add( head, &(results[i]) );
+            scan_add(head, res_ptr);
         }
     }
 
@@ -185,18 +285,27 @@
         scan_ptr = (scan_merge_t *)(item->data);
         if( scan_ptr->count != SCAN_MERGE_COUNT ) {
             if( !force_flag && ((scan_ptr->count == 0) ||
-                (mydrv->last_scan == SCAN_TYPE_NORMAL_ACTIVE)) )
+                (mydrv->last_scan == SCAN_TYPE_NORMAL_ACTIVE)) ) {
                 del_item = item;
+            }
             else {
                 if( number_items < max_size ) {
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+                    res_ptr = scan_dup(&(scan_ptr->scanres));
+                    if (res_ptr) {
+                        results[number_items] = res_ptr;
+                        number_items++;
+                    }
+#else
                     os_memcpy(&(results[number_items]),
-                          &(scan_ptr->scanres),sizeof(struct wpa_scan_result));
+                          &(scan_ptr->scanres), sizeof(scan_result_t));
                     number_items++;
+#endif
                 }
             }
         }
-        item = shListGetNextItem( head, item );
-        shListDelItem( head, del_item, scan_free );
+        item = shListGetNextItem(head, item);
+        shListDelItem(head, del_item, scan_free);
     }
 
     return( number_items );
@@ -210,24 +319,24 @@
    bssid   - pointer to bssid value
 Return Value: pointer to scan_result item
 -----------------------------------------------------------------------------*/
-struct wpa_scan_result *scan_get_by_bssid( struct wpa_driver_ti_data *mydrv,
-                         u8 *bssid )
+scan_result_t *scan_get_by_bssid( struct wpa_driver_ti_data *mydrv, u8 *bssid )
 {
     SHLIST *head = &(mydrv->scan_merge_list);
     SHLIST *item;
-    struct wpa_scan_result *cur_res;
+    scan_result_t *cur_res;
+    scan_ssid_t *p_ssid;
 
-    item = shListGetFirstItem( head );  /* Add/Remove missing items */
+    item = shListGetFirstItem(head);
     if( item == NULL )
         return( NULL );
     do {
-        cur_res =
-          (struct wpa_scan_result *)&(((scan_merge_t *)(item->data))->scanres);
+        cur_res = (scan_result_t *)&(((scan_merge_t *)(item->data))->scanres);
+        p_ssid = scan_get_ssid(cur_res);
         if( (!os_memcmp(cur_res->bssid, bssid, ETH_ALEN)) &&
-            (!IS_HIDDEN_AP(cur_res)) ) {
+            (!IS_HIDDEN_AP(p_ssid)) ) {
             return( cur_res );
         }
-        item = shListGetNextItem( head, item );
+        item = shListGetNextItem(head, item);
     } while( item != NULL );
 
     return( NULL );
diff --git a/lib/scanmerge.h b/lib/scanmerge.h
index 4d50cd4..35843bc 100644
--- a/lib/scanmerge.h
+++ b/lib/scanmerge.h
@@ -23,16 +23,36 @@
 
 #define SCAN_MERGE_COUNT        4
 
+typedef
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+    struct wpa_scan_res
+#else
+    struct wpa_scan_result
+#endif
+scan_result_t;
+
+typedef struct {
+    u8 ssid[MAX_SSID_LEN];
+    size_t ssid_len;
+} scan_ssid_t;
+
 typedef struct SCANMERGE_STRUCT {
-    struct wpa_scan_result scanres;
     unsigned long count;
+    scan_result_t scanres;
 } scan_merge_t;
 
 void scan_init( struct wpa_driver_ti_data *mydrv );
 void scan_exit( struct wpa_driver_ti_data *mydrv );
+unsigned long scan_count( struct wpa_driver_ti_data *mydrv );
+scan_ssid_t *scan_get_ssid( scan_result_t *res_ptr );
+#ifdef WPA_SUPPLICANT_VER_0_6_X
 unsigned int scan_merge( struct wpa_driver_ti_data *mydrv,
-                         struct wpa_scan_result *results, int force_flag,
+                         scan_result_t **results, int force_flag,
                          unsigned int number_items, unsigned int max_size );
-struct wpa_scan_result *scan_get_by_bssid( struct wpa_driver_ti_data *mydrv,
-                         u8 *bssid );
+#else
+unsigned int scan_merge( struct wpa_driver_ti_data *mydrv,
+                         scan_result_t *results, int force_flag,
+                         unsigned int number_items, unsigned int max_size );
+#endif
+scan_result_t *scan_get_by_bssid( struct wpa_driver_ti_data *mydrv, u8 *bssid );
 #endif
diff --git a/sta_dk_4_0_4_32/CUDK/tiwlan_loader/Android.mk b/sta_dk_4_0_4_32/CUDK/tiwlan_loader/Android.mk
index 1d828db..1851248 100644
--- a/sta_dk_4_0_4_32/CUDK/tiwlan_loader/Android.mk
+++ b/sta_dk_4_0_4_32/CUDK/tiwlan_loader/Android.mk
@@ -79,7 +79,7 @@
 else
 LOCAL_SHARED_LIBRARIES := libWifiApi
 endif
-LOCAL_SHARED_LIBRARIES += libc libhardware_legacy
+LOCAL_SHARED_LIBRARIES += libcutils liblog libc libhardware_legacy
 
 INCLUDES = $(DK_INCS) $(CLI_STA_DK_ROOT)/pform/linux/inc \
 	$(CLI_CUDK_ROOT)/Inc                             \
diff --git a/sta_dk_4_0_4_32/wpa_supplicant_lib/Android.mk b/sta_dk_4_0_4_32/wpa_supplicant_lib/Android.mk
index 7f5a5cb..c8b760a 100644
--- a/sta_dk_4_0_4_32/wpa_supplicant_lib/Android.mk
+++ b/sta_dk_4_0_4_32/wpa_supplicant_lib/Android.mk
@@ -24,6 +24,13 @@
   $(error This makefile must not be included when building the simulator)
 endif
 
+ifndef WPA_SUPPLICANT_VERSION
+WPA_SUPPLICANT_VERSION := VER_0_5_X
+endif
+ifneq ($(WPA_SUPPLICANT_VERSION),VER_0_5_X)
+  $(error This wlan can be used only with 0.5.X version of the wpa_supplicant)
+endif
+
 DK_ROOT = $(BOARD_WLAN_TI_STA_DK_ROOT)
 OS_ROOT = $(BOARD_WLAN_TI_STA_DK_ROOT)/pform
 COMMON  = $(DK_ROOT)/common
@@ -129,6 +136,7 @@
 	$(DK_ROOT)/../lib
   
 L_CFLAGS += -DCONFIG_DRIVER_CUSTOM -DHOST_COMPILE
+L_CFLAGS += -DWPA_SUPPLICANT_VER=$(WPA_SUPPLICANT_VERSION)
 ifeq ($(notdir $(BOARD_WLAN_TI_STA_DK_ROOT)),sta_dk_5_0_0_94)
 L_CFLAGS += -DSTA_DK_VER_5_0_0_94 
 endif
diff --git a/wilink_6_1/platforms/os/linux/zoom2_env.bash b/wilink_6_1/platforms/os/linux/zoom2_env.bash
index 5d5d4a5..f1a216b 100644
--- a/wilink_6_1/platforms/os/linux/zoom2_env.bash
+++ b/wilink_6_1/platforms/os/linux/zoom2_env.bash
@@ -1,4 +1,4 @@
 export CROSS_COMPILE=arm-eabi-
 export ARCH=arm
 export HOST_PLATFORM=zoom2
-export KERNEL_DIR=/usr/local/google/android/eclair-mr2/kernel
+export KERNEL_DIR=/usr/local/google/android/master/kernel
\ No newline at end of file
diff --git a/wilink_6_1/wpa_supplicant_lib/Android.mk b/wilink_6_1/wpa_supplicant_lib/Android.mk
index 6d737ef..cd1d4c2 100644
--- a/wilink_6_1/wpa_supplicant_lib/Android.mk
+++ b/wilink_6_1/wpa_supplicant_lib/Android.mk
@@ -24,6 +24,25 @@
   $(error This makefile must not be included when building the simulator)
 endif
 
+ifndef WPA_SUPPLICANT_VERSION
+WPA_SUPPLICANT_VERSION := VER_0_5_X
+endif
+
+ifeq ($(WPA_SUPPLICANT_VERSION),VER_0_5_X)
+WPA_SUPPL_DIR = external/wpa_supplicant
+else
+WPA_SUPPL_DIR = external/wpa_supplicant_6/wpa_supplicant
+endif
+WPA_SUPPL_DIR_INCLUDE = $(WPA_SUPPL_DIR)
+ifeq ($(WPA_SUPPLICANT_VERSION),VER_0_6_X)
+WPA_SUPPL_DIR_INCLUDE += $(WPA_SUPPL_DIR)/src \
+	$(WPA_SUPPL_DIR)/src/common \
+	$(WPA_SUPPL_DIR)/src/drivers \
+	$(WPA_SUPPL_DIR)/src/l2_packet \
+	$(WPA_SUPPL_DIR)/src/utils \
+	$(WPA_SUPPL_DIR)/src/wps
+endif
+
 DK_ROOT = $(BOARD_WLAN_TI_STA_DK_ROOT)
 OS_ROOT = $(DK_ROOT)/platforms
 STAD	= $(DK_ROOT)/stad
@@ -34,12 +53,7 @@
 CUDK	= $(DK_ROOT)/CUDK
 LIB	= ../../lib
 
-include external/wpa_supplicant/.config
-
-# To force sizeof(enum) = 4
-ifneq ($(TARGET_SIMULATOR),true)
-L_CFLAGS += -mabi=aapcs-linux
-endif
+include $(WPA_SUPPL_DIR)/.config
 
 INCLUDES = $(STAD)/Export_Inc \
 	$(STAD)/src/Application \
@@ -54,12 +68,18 @@
 	$(CUDK)/configurationutility/inc \
 	$(CUDK)/os/common/inc \
 	external/openssl/include \
-	external/wpa_supplicant \
+	$(WPA_SUPPL_DIR_INCLUDE) \
 	$(DK_ROOT)/../lib
   
-L_CFLAGS += -DCONFIG_DRIVER_CUSTOM -DHOST_COMPILE -D__BYTE_ORDER_LITTLE_ENDIAN
+L_CFLAGS = -DCONFIG_DRIVER_CUSTOM -DHOST_COMPILE -D__BYTE_ORDER_LITTLE_ENDIAN
+L_CFLAGS += -DWPA_SUPPLICANT_$(WPA_SUPPLICANT_VERSION)
 OBJS = driver_ti.c $(LIB)/scanmerge.c $(LIB)/shlist.c
 
+# To force sizeof(enum) = 4
+ifneq ($(TARGET_SIMULATOR),true)
+L_CFLAGS += -mabi=aapcs-linux
+endif
+
 ifdef CONFIG_NO_STDOUT_DEBUG
 L_CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
 endif
@@ -68,10 +88,18 @@
 L_CFLAGS += -DCONFIG_DEBUG_FILE
 endif
 
+ifdef CONFIG_ANDROID_LOG
+L_CFLAGS += -DCONFIG_ANDROID_LOG
+endif
+
 ifdef CONFIG_IEEE8021X_EAPOL
 L_CFLAGS += -DIEEE8021X_EAPOL
 endif
 
+ifdef CONFIG_WPS
+L_CFLAGS += -DCONFIG_WPS
+endif
+
 ########################
  
 include $(CLEAR_VARS)
diff --git a/wilink_6_1/wpa_supplicant_lib/driver_ti.c b/wilink_6_1/wpa_supplicant_lib/driver_ti.c
index 1e7b2a7..0fcd0d4 100644
--- a/wilink_6_1/wpa_supplicant_lib/driver_ti.c
+++ b/wilink_6_1/wpa_supplicant_lib/driver_ti.c
@@ -30,6 +30,9 @@
 #endif
 #include "driver_ti.h"
 #include "scanmerge.h"
+#ifdef CONFIG_WPS
+#include "wps_defs.h"
+#endif
 
 /*-------------------------------------------------------------------*/
 #define TI2WPA_STATUS(s)	(((s) != 0) ? -1 : 0)
@@ -86,6 +89,9 @@
 	switch (keymgmt) {
 	case KEY_MGMT_802_1X:
 	case KEY_MGMT_802_1X_NO_WPA:
+#ifdef CONFIG_WPS
+	case KEY_MGMT_WPS:
+#endif
 		return IW_AUTH_KEY_MGMT_802_1X;
 	case KEY_MGMT_PSK:
 		return IW_AUTH_KEY_MGMT_PSK;
@@ -660,20 +666,22 @@
 		wpa_printf(MSG_DEBUG, "buf %s", buf);
 	}
 	else if( os_strcasecmp(cmd, "rssi-approx") == 0 ) {
-		struct wpa_scan_result *cur_res;
+		scan_result_t *cur_res;
 		struct wpa_supplicant *wpa_s = (struct wpa_supplicant *)(drv->ctx);
+		scan_ssid_t *p_ssid;
 		int rssi, len;
 
 		wpa_printf(MSG_DEBUG,"rssi-approx command");
 
 		if( !wpa_s )
 			return( ret );
-		cur_res = scan_get_by_bssid( drv, wpa_s->bssid );
+		cur_res = scan_get_by_bssid(drv, wpa_s->bssid);
 		if( cur_res ) {
-			len = (int)(cur_res->ssid_len);
+			p_ssid = scan_get_ssid(cur_res);
+			len = (int)(p_ssid->ssid_len);
 			rssi = cur_res->level;
 			if( (len > 0) && (len <= MAX_SSID_LEN) && (len < (int)buf_len)) {
-				os_memcpy( (void *)buf, (void *)(cur_res->ssid), len );
+				os_memcpy((void *)buf, (void *)(p_ssid->ssid), len);
 				ret = len;
 				ret += snprintf(&buf[ret], buf_len-len, " rssi %d\n", rssi);
 			}
@@ -681,7 +689,7 @@
 	}
 	else if( os_strcasecmp(cmd, "rssi") == 0 ) {
 		u8 ssid[MAX_SSID_LEN];
-		struct wpa_scan_result *cur_res;
+		scan_result_t *cur_res;
 		struct wpa_supplicant *wpa_s = (struct wpa_supplicant *)(drv->ctx);
 		int rssi_data, rssi_beacon, len;
 
@@ -689,17 +697,17 @@
 
 		ret = wpa_driver_tista_get_rssi(priv, &rssi_data, &rssi_beacon);
 		if( ret == 0 ) {
-			len = wpa_driver_tista_get_ssid( priv, (u8 *)ssid );
+			len = wpa_driver_tista_get_ssid(priv, (u8 *)ssid);
 			wpa_printf(MSG_DEBUG,"rssi_data %d rssi_beacon %d", rssi_data, rssi_beacon);
 			if( (len > 0) && (len <= MAX_SSID_LEN) ) {
-				os_memcpy( (void *)buf, (void *)ssid, len );
+				os_memcpy((void *)buf, (void *)ssid, len);
 				ret = len;
 				ret += sprintf(&buf[ret], " rssi %d\n", rssi_beacon);
 				wpa_printf(MSG_DEBUG, "buf %s", buf);
 				/* Update cached value */
 				if( !wpa_s )
 					return( ret );
-				cur_res = scan_get_by_bssid( drv, wpa_s->bssid );
+				cur_res = scan_get_by_bssid(drv, wpa_s->bssid);
 				if( cur_res )
 					cur_res->level = rssi_beacon;
 			}
@@ -818,6 +826,86 @@
 	return ret;
 }
 
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_set_probe_req_ie
+Routine Description: set probe request ie for WSC mode change
+Arguments:
+   priv - pointer to private data structure
+   ies - probe_req_ie data
+   ies_len - ie data length
+Return Value: actual buffer length - success, -1 - failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_set_probe_req_ie(void *priv, const u8* ies, size_t ies_len)
+{
+	struct wpa_driver_ti_data *drv = (struct wpa_driver_ti_data *)priv;
+#ifdef CONFIG_WPS
+	TWscMode WscModeStruct;
+
+        TI_CHECK_DRIVER( drv->driver_is_loaded, -1 );
+
+	if ((!ies || (0 == ies_len)) && (NULL == drv->probe_req_ie)) {
+		return 0;
+	}
+
+	if (ies && drv->probe_req_ie) {
+		size_t len = wpabuf_len(drv->probe_req_ie);
+		u8* data = (u8*)wpabuf_head(drv->probe_req_ie);
+		if ((ies_len == len) && (0 == os_memcmp(ies, data, ies_len))) {
+			return 0;
+		}
+	}
+
+	os_memset(&WscModeStruct, 0, sizeof(TWscMode));
+
+	if (!ies || (0 == ies_len)) {
+		WscModeStruct.WSCMode = TIWLN_SIMPLE_CONFIG_OFF;
+	} else {
+		const size_t head_len = 6; /* probeReqIe head: dd xx 00 50 f2 04 */
+		u8 *pos, *end;
+		u16 password_id = 0;
+		size_t min_len = 0;
+
+		pos = (u8*)ies + head_len; /* Find the WSC mode in probe_req_ie by password_id */
+		end = (u8*)ies + ies_len;
+		while (pos < end) {
+			if (ATTR_DEV_PASSWORD_ID == WPA_GET_BE16(pos)) {
+				password_id = WPA_GET_BE16(pos+4);
+				break;
+			}
+			pos += (4 + WPA_GET_BE16(pos+2));
+		}
+		WscModeStruct.WSCMode = (DEV_PW_PUSHBUTTON == password_id)?TIWLN_SIMPLE_CONFIG_PBC_METHOD:TIWLN_SIMPLE_CONFIG_PIN_METHOD;
+
+		pos = (u8*)ies + head_len;
+		min_len = ies_len - head_len;
+		if (min_len > sizeof(WscModeStruct.probeReqWSCIE)) {
+			min_len = sizeof(WscModeStruct.probeReqWSCIE);
+		}
+		os_memcpy(WscModeStruct.probeReqWSCIE, pos, min_len);
+	}
+
+	wpa_hexdump(MSG_DEBUG, "SetProbeReqIe:WscModeStruct", (u8*)&WscModeStruct, sizeof(TWscMode));
+	if(0 == wpa_driver_tista_private_send(priv, SITE_MGR_SIMPLE_CONFIG_MODE, (void*)&WscModeStruct, sizeof(TWscMode), NULL, 0)) {
+		/* Update the cached probe req ie */
+		wpabuf_free(drv->probe_req_ie);
+		drv->probe_req_ie = NULL;
+
+		if (ies && ies_len) {
+			drv->probe_req_ie = wpabuf_alloc(sizeof(WscModeStruct.probeReqWSCIE));
+			if (drv->probe_req_ie) {
+				wpabuf_put_data(drv->probe_req_ie, ies, ies_len);
+			}
+		}
+	} else {
+		wpa_printf(MSG_ERROR, "ERROR - Failed to set wsc mode!");
+		return -1;
+	}
+#endif
+	return 0;
+}
+#endif
+
 /**
  * wpa_driver_tista_init - Initialize WE driver interface
  * @ctx: context to be used when calling wpa_supplicant functions,
@@ -865,6 +953,11 @@
 	/* BtCoex mode is read from tiwlan.ini file */
 	drv->btcoex_mode = 0; /* SG_DISABLE */
 
+#ifdef CONFIG_WPS
+	/* The latest probe_req_ie for WSC */
+	drv->probe_req_ie = NULL;
+#endif
+
 	/* Number of sequential errors */
 	drv->errors = 0;
 	return drv;
@@ -884,6 +977,10 @@
 	wpa_driver_wext_deinit(drv->wext);
 	close(drv->ioctl_sock);
 	scan_exit(drv);
+#ifdef CONFIG_WPS
+	wpabuf_free(drv->probe_req_ie);
+	drv->probe_req_ie = NULL;
+#endif
 	os_free(drv);
 }
 
@@ -1098,15 +1195,60 @@
 	return ret;
 }
 
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+static struct wpa_scan_results *wpa_driver_tista_get_scan_results(void *priv)
+{
+	struct wpa_driver_ti_data *drv = priv;
+	struct wpa_scan_results *res;
+	struct wpa_scan_res **tmp;
+	unsigned ap_num;
+
+	TI_CHECK_DRIVER( drv->driver_is_loaded, NULL );
+	res = wpa_driver_wext_get_scan_results(drv->wext);
+	if (res == NULL) {
+		return NULL;
+	}
+
+	wpa_printf(MSG_DEBUG, "Actual APs number %d", res->num);
+	ap_num = (unsigned)scan_count(drv) + res->num;
+	tmp = os_realloc(res->res, ap_num * sizeof(struct wpa_scan_res *));
+	if (tmp == NULL)
+		return res;
+	res->num = scan_merge(drv, tmp, drv->force_merge_flag, res->num, ap_num);
+	wpa_printf(MSG_DEBUG, "After merge, APs number %d", res->num);
+	tmp = os_realloc(tmp, res->num * sizeof(struct wpa_scan_res *));
+	res->res = tmp;
+	return res;
+}
+
+static int wpa_driver_tista_set_gen_ie(void *priv, const u8 *ie, size_t ie_len)
+{
+	struct wpa_driver_ti_data *drv = priv;
+	struct iwreq iwr;
+	int ret = 0;
+
+	os_memset(&iwr, 0, sizeof(iwr));
+	os_strncpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
+	iwr.u.data.pointer = (caddr_t)ie;
+	iwr.u.data.length = ie_len;
+
+	if (ioctl(drv->ioctl_sock, SIOCSIWGENIE, &iwr) < 0) {
+		perror("ioctl[SIOCSIWGENIE]");
+		ret = -1;
+	}
+
+	return ret;
+}
+#else
 /*-----------------------------------------------------------------------------
 Compare function for sorting scan results. Return >0 if @b is considered better.
 -----------------------------------------------------------------------------*/
 static int wpa_driver_tista_scan_result_compare(const void *a, const void *b)
 {
-    const struct wpa_scan_result *wa = a;
-    const struct wpa_scan_result *wb = b;
+	const struct wpa_scan_result *wa = a;
+	const struct wpa_scan_result *wb = b;
 
-    return( wb->level - wa->level );
+	return( wb->level - wa->level );
 }
 
 static int wpa_driver_tista_get_scan_results(void *priv,
@@ -1116,7 +1258,7 @@
 	struct wpa_driver_ti_data *drv = priv;
 	int ap_num = 0;
 
-        TI_CHECK_DRIVER( drv->driver_is_loaded, -1 );	
+        TI_CHECK_DRIVER( drv->driver_is_loaded, -1 );
 	ap_num = wpa_driver_wext_get_scan_results(drv->wext, results, max_size);
 	wpa_printf(MSG_DEBUG, "Actual APs number %d", ap_num);
 
@@ -1124,12 +1266,13 @@
 		return -1;
 
 	/* Merge new results with previous */
-        ap_num = scan_merge( drv, results, drv->force_merge_flag, ap_num, max_size );
+        ap_num = scan_merge(drv, results, drv->force_merge_flag, ap_num, max_size);
 	wpa_printf(MSG_DEBUG, "After merge, APs number %d", ap_num);
-	qsort( results, ap_num, sizeof(struct wpa_scan_result),
-		wpa_driver_tista_scan_result_compare );
+	qsort(results, ap_num, sizeof(struct wpa_scan_result),
+		wpa_driver_tista_scan_result_compare);
 	return ap_num;
 }
+#endif
 
 static int wpa_driver_tista_associate(void *priv,
 			  struct wpa_driver_associate_params *params)
@@ -1147,10 +1290,21 @@
 	/* Set driver network mode (Adhoc/Infrastructure) according to supplied parameters */
 	wpa_driver_wext_set_mode(drv->wext, params->mode);
 
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+	wpa_driver_tista_set_gen_ie(drv, params->wpa_ie, params->wpa_ie_len);
+#endif
 	if (params->wpa_ie == NULL || params->wpa_ie_len == 0)
 		value = IW_AUTH_WPA_VERSION_DISABLED;
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+	else if (params->wpa_ie[0] == WLAN_EID_RSN)
+#else
 	else if (params->wpa_ie[0] == RSN_INFO_ELEM)
+#endif
 		value = IW_AUTH_WPA_VERSION_WPA2;
+#ifdef CONFIG_WPS
+	else if (params->key_mgmt_suite == KEY_MGMT_WPS)
+		value = IW_AUTH_WPA_VERSION_DISABLED;
+#endif
 	else
 		value = IW_AUTH_WPA_VERSION_WPA;
 	wpa_driver_tista_set_auth_param(drv, IW_AUTH_WPA_VERSION, value);
@@ -1163,7 +1317,11 @@
 	value = params->key_mgmt_suite != KEY_MGMT_NONE ||
 		params->pairwise_suite != CIPHER_NONE ||
 		params->group_suite != CIPHER_NONE ||
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+		(params->wpa_ie_len && (params->key_mgmt_suite != KEY_MGMT_WPS));
+#else
 		params->wpa_ie_len;
+#endif
 	wpa_driver_tista_set_auth_param(drv, IW_AUTH_PRIVACY_INVOKED, value);
 
 	/* Allow unencrypted EAPOL messages even if pairwise keys are set when
@@ -1212,7 +1370,11 @@
 	.set_countermeasures = wpa_driver_tista_set_countermeasures,
 	.set_drop_unencrypted = wpa_driver_tista_set_drop_unencrypted,
 	.scan = wpa_driver_tista_scan,
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+	.get_scan_results2 = wpa_driver_tista_get_scan_results,
+#else
 	.get_scan_results = wpa_driver_tista_get_scan_results,
+#endif
 	.deauthenticate = wpa_driver_tista_deauthenticate,
 	.disassociate = wpa_driver_tista_disassociate,
 	.associate = wpa_driver_tista_associate,
@@ -1224,5 +1386,8 @@
 	.remove_pmkid = wpa_driver_tista_remove_pmkid,
 	.flush_pmkid = wpa_driver_tista_flush_pmkid,
 	.set_operstate = wpa_driver_tista_set_operstate,
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+	.set_probe_req_ie = wpa_driver_tista_set_probe_req_ie,
+#endif
 	.driver_cmd = wpa_driver_tista_driver_cmd
 };
diff --git a/wilink_6_1/wpa_supplicant_lib/driver_ti.h b/wilink_6_1/wpa_supplicant_lib/driver_ti.h
index 6f36119..c60d43e 100644
--- a/wilink_6_1/wpa_supplicant_lib/driver_ti.h
+++ b/wilink_6_1/wpa_supplicant_lib/driver_ti.h
@@ -29,14 +29,16 @@
 #include "driver.h"
 #include "l2_packet.h"
 #include "eloop.h"
-#include "wpa_supplicant.h"
 #include "priv_netlink.h"
 #include "driver_wext.h"
-#include "wpa.h"
 #include "wpa_ctrl.h"
 #include "wpa_supplicant_i.h"
 #include "config.h"
-
+#ifdef WPA_SUPPLICANT_VER_0_6_X
+#include "ieee802_11_defs.h"
+#else
+#include "wpa.h"
+#endif
 #include "cu_ostypes.h"
 #include "STADExternalIf.h"
 #include "convert.h"
@@ -75,6 +77,9 @@
 	u32 btcoex_mode;		/* BtCoex Mode */
 	int last_scan;			/* Last scan type */
 	SHLIST scan_merge_list;		/* Previous scan list */
+#ifdef CONFIG_WPS
+	struct wpabuf *probe_req_ie;    /* Store the latest probe_req_ie for WSC */
+#endif
 	int errors;			/* Number of sequential errors */
 };
 #endif