diff --git a/AirportItlwm/AirportItlwm.cpp b/AirportItlwm/AirportItlwm.cpp index d8d98b3f0..3b426cd8c 100644 --- a/AirportItlwm/AirportItlwm.cpp +++ b/AirportItlwm/AirportItlwm.cpp @@ -29,6 +29,7 @@ bool AirportItlwm::init(OSDictionary *properties) bool ret = super::init(properties); awdlSyncEnable = true; power_state = 0; + memset(geo_location_cc, 0, sizeof(geo_location_cc)); return ret; } diff --git a/AirportItlwm/AirportItlwm.hpp b/AirportItlwm/AirportItlwm.hpp index 5b48626af..470a5903b 100644 --- a/AirportItlwm/AirportItlwm.hpp +++ b/AirportItlwm/AirportItlwm.hpp @@ -169,7 +169,7 @@ IOReturn set##REQ(OSObject *object, struct DATA_TYPE *data); FUNC_IOCTL_GET(AP_IE_LIST, apple80211_ap_ie_data) FUNC_IOCTL_GET(LINK_CHANGED_EVENT_DATA, apple80211_link_changed_event_data) FUNC_IOCTL_GET(ASSOCIATION_STATUS, apple80211_assoc_status_data) - FUNC_IOCTL_GET(COUNTRY_CODE, apple80211_country_code_data) + FUNC_IOCTL(COUNTRY_CODE, apple80211_country_code_data) FUNC_IOCTL_GET(RADIO_INFO, apple80211_radio_info_data) FUNC_IOCTL_GET(MCS, apple80211_mcs_data) FUNC_IOCTL_SET(VIRTUAL_IF_CREATE, apple80211_virt_if_create_data) @@ -260,6 +260,7 @@ IOReturn set##REQ(OSObject *object, struct DATA_TYPE *data); UInt64 currentSpeed; UInt32 currentStatus; bool disassocIsVoluntary; + char geo_location_cc[3]; IO80211P2PInterface *fP2PDISCInterface; IO80211P2PInterface *fP2PGOInterface; diff --git a/AirportItlwm/AirportSTAIOCTL.cpp b/AirportItlwm/AirportSTAIOCTL.cpp index b6f6cbd62..e51ad4dfc 100644 --- a/AirportItlwm/AirportSTAIOCTL.cpp +++ b/AirportItlwm/AirportSTAIOCTL.cpp @@ -132,7 +132,7 @@ SInt32 AirportItlwm::apple80211Request(unsigned int request_type, IOCTL_GET(request_type, ASSOCIATION_STATUS, apple80211_assoc_status_data); break; case APPLE80211_IOC_COUNTRY_CODE: // 51 - IOCTL_GET(request_type, COUNTRY_CODE, apple80211_country_code_data); + IOCTL(request_type, COUNTRY_CODE, apple80211_country_code_data); break; case APPLE80211_IOC_RADIO_INFO: IOCTL_GET(request_type, RADIO_INFO, apple80211_radio_info_data); @@ -1139,11 +1139,25 @@ IOReturn AirportItlwm:: getCOUNTRY_CODE(OSObject *object, struct apple80211_country_code_data *cd) { - char cc[3]; + char user_override_cc[3]; + const char *cc_fw = fHalService->getDriverInfo()->getFirmwareCountryCode(); + cd->version = APPLE80211_VERSION; - memset(cc, 0, sizeof(cc)); - PE_parse_boot_argn("itlwm_cc", cc, 3); - strncpy((char*)cd->cc, cc[0] == 0 ? fHalService->getDriverInfo()->getFirmwareCountryCode() : cc, sizeof(cd->cc)); + memset(user_override_cc, 0, sizeof(user_override_cc)); + PE_parse_boot_argn("itlwm_cc", user_override_cc, 3); + /* user_override_cc > firmware_cc > geo_location_cc */ + strncpy((char*)cd->cc, user_override_cc[0] ? user_override_cc : ((cc_fw[0] == 'Z' && cc_fw[1] == 'Z' && geo_location_cc[0]) ? geo_location_cc : cc_fw), sizeof(cd->cc)); + return kIOReturnSuccess; +} + +IOReturn AirportItlwm:: +setCOUNTRY_CODE(OSObject *object, struct apple80211_country_code_data *data) +{ + XYLog("%s cc=%s\n", __FUNCTION__, data->cc); + if (data->cc[0] != 120 && data->cc[0] != 88) { + memcpy(geo_location_cc, data->cc, sizeof(geo_location_cc)); + fNetIf->postMessage(APPLE80211_M_COUNTRY_CODE_CHANGED); + } return kIOReturnSuccess; }