Ticket #241: hostapd-rsn+wpa.patch
| File hostapd-rsn+wpa.patch, 1.9 kB (added by parthan@gmail.com, 6 years ago) |
|---|
-
hostapd-0.4.7/driver_madwifi.c
old new 692 692 struct hostapd_data *hapd = drv->hapd; 693 693 struct ieee80211req_wpaie ie; 694 694 int ielen, res; 695 int rsn = 0; 695 696 696 697 /* 697 698 * Fetch negotiated WPA/RSN parameters from the system. … … 702 703 printf("Failed to get WPA/RSN information element.\n"); 703 704 return -1; /* XXX not right */ 704 705 } 705 ielen = ie.wpa_ie[1]; 706 if (ielen == 0) { 706 if ((ie.wpa_ie[1] == 0) && (ie.rsn_ie[1] == 0)){ 707 707 printf("No WPA/RSN information element for station!?\n"); 708 708 return -1; /* XXX not right */ 709 709 } 710 ielen = ie.rsn_ie[1]; 710 711 ielen += 2; 711 res = wpa_validate_wpa_ie(hapd, sta, ie.wpa_ie, ielen, 712 ie.wpa_ie[0] == WLAN_EID_RSN ? 713 HOSTAPD_WPA_VERSION_WPA2 : HOSTAPD_WPA_VERSION_WPA); 714 if (res != WPA_IE_OK) { 715 printf("WPA/RSN information element rejected? (res %u)\n", res); 716 return -1; 717 } 712 res = wpa_validate_wpa_ie(hapd, sta, ie.rsn_ie, ielen, 713 HOSTAPD_WPA_VERSION_WPA2); 714 if (res != WPA_IE_OK){ 715 // now look for WPA IE 716 ielen = ie.wpa_ie[1]; 717 ielen += 2; 718 res = wpa_validate_wpa_ie(hapd, sta, ie.wpa_ie, ielen, 719 HOSTAPD_WPA_VERSION_WPA); 720 if (res != WPA_IE_OK) { 721 printf("WPA/RSN information element rejected? (res %u)\n", res); 722 return -1; 723 } 724 } else { 725 rsn = 1; 726 } 718 727 free(sta->wpa_ie); 719 728 sta->wpa_ie = malloc(ielen); 720 729 if (sta->wpa_ie == NULL) { 721 730 printf("No memory to save WPA/RSN information element!\n"); 722 731 return -1; 723 732 } 724 memcpy(sta->wpa_ie, ie.wpa_ie, ielen); 733 if (rsn) 734 memcpy(sta->wpa_ie, ie.rsn_ie, ielen); 735 else 736 memcpy(sta->wpa_ie, ie.wpa_ie, ielen); 725 737 sta->wpa_ie_len = ielen; 726 738 return 0; 727 739 }
