int createSetupRequest(WifiRequest& request) { int result = request.create(GOOGLE_OUI, GSCAN_SUBCMD_SET_SIGNIFICANT_CHANGE_CONFIG); if (result < 0) { return result; } nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); result = request.put_u8(GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH, 1); if (result < 0) { return result; } result = request.put_u16(GSCAN_ATTRIBUTE_RSSI_SAMPLE_SIZE, mParams.rssi_sample_size); if (result < 0) { return result; } result = request.put_u16(GSCAN_ATTRIBUTE_LOST_AP_SAMPLE_SIZE, mParams.lost_ap_sample_size); if (result < 0) { return result; } result = request.put_u16(GSCAN_ATTRIBUTE_MIN_BREACHING, mParams.min_breaching); if (result < 0) { return result; } result = request.put_u16(GSCAN_ATTRIBUTE_NUM_AP, mParams.num_ap); if (result < 0) { return result; } struct nlattr * attr = request.attr_start(GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_BSSIDS); for (int i = 0; i < mParams.num_ap; i++) { nlattr *attr2 = request.attr_start(i); if (attr2 == NULL) { return WIFI_ERROR_OUT_OF_MEMORY; } result = request.put_addr(GSCAN_ATTRIBUTE_BSSID, mParams.ap[i].bssid); if (result < 0) { return result; } result = request.put_u32(GSCAN_ATTRIBUTE_RSSI_HIGH, mParams.ap[i].high); if (result < 0) { return result; } result = request.put_u32(GSCAN_ATTRIBUTE_RSSI_LOW, mParams.ap[i].low); if (result < 0) { return result; } request.attr_end(attr2); } request.attr_end(attr); request.attr_end(data); return result; }
int createTeardownRequest(WifiRequest& request) { int result = request.create(GOOGLE_OUI, GSCAN_SUBCMD_SET_SIGNIFICANT_CHANGE_CONFIG); if (result < 0) { return result; } nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); result = request.put_u16(GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH, 1); if (result < 0) { return result; } request.attr_end(data); return result; }
int createRequest(WifiRequest &request) { int result; switch (mType) { case START_MKEEP_ALIVE: { result = request.create(GOOGLE_OUI, WIFI_OFFLOAD_START_MKEEP_ALIVE); if (result != WIFI_SUCCESS) { ALOGE("Failed to create start keep alive request; result = %d", result); return result; } nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); result = request.put_u8(MKEEP_ALIVE_ATTRIBUTE_ID, mIndex); if (result < 0) { ALOGE("Failed to put id request; result = %d", result); return result; } result = request.put_u16(MKEEP_ALIVE_ATTRIBUTE_IP_PKT_LEN, mIpPktLen); if (result < 0) { ALOGE("Failed to put ip pkt len request; result = %d", result); return result; } result = request.put(MKEEP_ALIVE_ATTRIBUTE_IP_PKT, (u8*)mIpPkt, mIpPktLen); if (result < 0) { ALOGE("Failed to put ip pkt request; result = %d", result); return result; } result = request.put_addr(MKEEP_ALIVE_ATTRIBUTE_SRC_MAC_ADDR, mSrcMacAddr); if (result < 0) { ALOGE("Failed to put src mac address request; result = %d", result); return result; } result = request.put_addr(MKEEP_ALIVE_ATTRIBUTE_DST_MAC_ADDR, mDstMacAddr); if (result < 0) { ALOGE("Failed to put dst mac address request; result = %d", result); return result; } result = request.put_u32(MKEEP_ALIVE_ATTRIBUTE_PERIOD_MSEC, mPeriodMsec); if (result < 0) { ALOGE("Failed to put period request; result = %d", result); return result; } request.attr_end(data); break; } case STOP_MKEEP_ALIVE: { result = request.create(GOOGLE_OUI, WIFI_OFFLOAD_STOP_MKEEP_ALIVE); if (result != WIFI_SUCCESS) { ALOGE("Failed to create stop keep alive request; result = %d", result); return result; } nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); result = request.put_u8(MKEEP_ALIVE_ATTRIBUTE_ID, mIndex); if (result < 0) { ALOGE("Failed to put id request; result = %d", result); return result; } request.attr_end(data); break; } default: ALOGE("Unknown wifi keep alive command"); result = WIFI_ERROR_UNKNOWN; } return result; }