virtual int handleResponse(WifiEvent& reply) { ALOGD("In SetAlertHandler::handleResponse"); if (reply.get_cmd() != NL80211_CMD_VENDOR) { ALOGD("Ignoring reply with cmd = %d", reply.get_cmd()); return NL_SKIP; } nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA); int len = reply.get_vendor_data_len(); ALOGD("len = %d", len); if (vendor_data == NULL || len == 0) { ALOGE("no vendor data in memory dump response; ignoring it"); return NL_SKIP; } for (nl_iterator it(vendor_data); it.has_next(); it.next()) { if (it.get_type() == LOGGER_ATTRIBUTE_FW_DUMP_DATA) { ALOGI("Initiating alert callback"); if (mHandler.on_alert) { (*mHandler.on_alert)(id(), mBuff, mBuffSize, mErrCode); } if (mBuff) { free(mBuff); mBuff = NULL; } } } return NL_OK; }
int handleResponse(WifiEvent& reply) { ALOGD("In GetPktFateCommand::handleResponse\n"); if (reply.get_cmd() != NL80211_CMD_VENDOR) { ALOGI("Ignoring reply with cmd = %d", reply.get_cmd()); return NL_SKIP; } int id = reply.get_vendor_id(); int subcmd = reply.get_vendor_subcmd(); nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA); int len = reply.get_vendor_data_len(); ALOGI("Id = %0x, subcmd = %d, len = %d", id, subcmd, len); if (mReqType == TX_PACKET_FATE) { ALOGI("Response recieved for get TX pkt fate command\n"); } else if (mReqType == RX_PACKET_FATE) { ALOGI("Response recieved for get RX pkt fate command\n"); } else if (mReqType == PACKET_MONITOR_START) { ALOGI("Response recieved for monitor pkt fate command\n"); return NL_OK; } else { ALOGE("Response recieved for unknown pkt fate command\n"); return NL_SKIP; } if (vendor_data == NULL || len == 0) { ALOGE("no vendor data in GetPktFateCommand response; ignoring it\n"); return NL_SKIP; } for (nl_iterator it(vendor_data); it.has_next(); it.next()) { if (it.get_type() == LOGGER_ATTRIBUTE_PKT_FATE_NUM) { *mNoProvidedFates = it.get_u32(); ALOGI("No: of pkt fates provided is %d\n", *mNoProvidedFates); } else { ALOGE("Ignoring invalid attribute type = %d, size = %d\n", it.get_type(), it.get_len()); } } return NL_OK; }
virtual int handleEvent(WifiEvent& event) { char *buffer = NULL; int buffer_size = 0; // ALOGD("In SetLogHandler::handleEvent"); nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA); int len = event.get_vendor_data_len(); int event_id = event.get_vendor_subcmd(); // ALOGI("Got Logger event: %d", event_id); if (vendor_data == NULL || len == 0) { ALOGE("No Debug data found"); return NL_SKIP; } if(event_id == GOOGLE_DEBUG_RING_EVENT) { wifi_ring_buffer_status status; memset(&status, 0, sizeof(status)); for (nl_iterator it(vendor_data); it.has_next(); it.next()) { if (it.get_type() == LOGGER_ATTRIBUTE_RING_STATUS) { memcpy(&status, it.get_data(), sizeof(status)); } else if (it.get_type() == LOGGER_ATTRIBUTE_RING_DATA) { buffer_size = it.get_len(); buffer = (char *)it.get_data(); } else { ALOGW("Ignoring invalid attribute type = %d, size = %d", it.get_type(), it.get_len()); } } // ALOGI("Retrieved Debug data"); if (mHandler.on_ring_buffer_data) { (*mHandler.on_ring_buffer_data)((char *)status.name, buffer, buffer_size, &status); } } else { ALOGE("Unknown Event"); return NL_SKIP; } return NL_OK; }
virtual int handleResponse(WifiEvent& reply) { ALOGD("[WIFI HAL]In GetChannelList::handleResponse"); if (reply.get_cmd() != NL80211_CMD_VENDOR) { ALOGD("Ignoring reply with cmd = %d", reply.get_cmd()); return NL_SKIP; } int id = reply.get_vendor_id(); int subcmd = reply.get_vendor_subcmd(); int num_channels_to_copy = 0; nlattr *vendor = reply.get_attribute(NL80211_ATTR_VENDOR_DATA); int len = reply.get_vendor_data_len(); ALOGD("Id = %0x, subcmd = %d, len = %d", id, subcmd, len); if (vendor == NULL || len == 0) { ALOGE("no vendor data in GetChannelList response; ignoring it"); return NL_SKIP; } for (nl_iterator it(vendor); it.has_next(); it.next()) { if (it.get_type() == GSCAN_ATTRIBUTE_NUM_CHANNELS) { num_channels_to_copy = it.get_u32(); ALOGI("Got channel list with %d channels", num_channels_to_copy); if(num_channels_to_copy > max_channels) num_channels_to_copy = max_channels; *num_channels = num_channels_to_copy; } else if (it.get_type() == GSCAN_ATTRIBUTE_CHANNEL_LIST && num_channels_to_copy) { memcpy(channels, it.get_data(), sizeof(int) * num_channels_to_copy); if(channels) ALOGD("channel[0]=%d, ", channels[0]); } else { ALOGW("Ignoring invalid attribute type = %d, size = %d", it.get_type(), it.get_len()); } } return NL_OK; }
virtual int handleResponse(WifiEvent& reply) { ALOGD("In GetScanResultsCommand::handleResponse"); if (reply.get_cmd() != NL80211_CMD_VENDOR) { ALOGE("Ignoring reply with cmd = %d", reply.get_cmd()); return NL_SKIP; } int id = reply.get_vendor_id(); int subcmd = reply.get_vendor_subcmd(); /* if (subcmd != GSCAN_SUBCMD_SCAN_RESULTS) { ALOGE("Invalid response to GetScanResultsCommand; ignoring it"); return NL_SKIP; } */ nlattr *vendor = reply.get_attribute(NL80211_ATTR_VENDOR_DATA); int len = reply.get_vendor_data_len(); ALOGD("Id = %0x, subcmd = %d, vendor=%p, get_vendor_data()=%p vendor->nla_type=%d len=%d", id, subcmd, vendor, reply.get_vendor_data(), vendor->nla_type, len); if (vendor == NULL || len == 0) { ALOGE("no vendor data in GetScanResults response; ignoring it"); return NL_SKIP; } for (nl_iterator it(vendor); it.has_next(); it.next()) { if (it.get_type() == GSCAN_ATTRIBUTE_SCAN_RESULTS_COMPLETE) { mCompleted = it.get_u8(); ALOGI("retrieved mCompleted flag : %d", mCompleted); } else if (it.get_type() == GSCAN_ATTRIBUTE_SCAN_RESULTS || it.get_type() == 0) { for (nl_iterator it2(it.get()); it2.has_next(); it2.next()) { int scan_id = 0, flags = 0, num = 0; if (it2.get_type() == GSCAN_ATTRIBUTE_SCAN_ID) { scan_id = it.get_u32(); } else if (it2.get_type() == GSCAN_ATTRIBUTE_SCAN_FLAGS) { flags = it.get_u8(); } else if (it2.get_type() == GSCAN_ATTRIBUTE_NUM_OF_RESULTS) { num = it2.get_u32(); } else if (it2.get_type() == GSCAN_ATTRIBUTE_SCAN_RESULTS) { num = it2.get_len() / sizeof(wifi_scan_result); num = min(*mNum - mRetrieved, num); memcpy(mResults + mRetrieved, it2.get_data(), sizeof(wifi_scan_result) * num); ALOGD("Retrieved %d scan results", num); wifi_scan_result *results = (wifi_scan_result *)it2.get_data(); for (int i = 0; i < num; i++) { wifi_scan_result *result = results + i; ALOGD("%02d %-32s %02x:%02x:%02x:%02x:%02x:%02x %04d channel=%d", i, result->ssid, result->bssid[0], result->bssid[1], result->bssid[2], result->bssid[3], result->bssid[4], result->bssid[5], result->rssi, result->channel); } mRetrieved += num; } else { ALOGW("Ignoring invalid attribute type = %d, size = %d", it.get_type(), it.get_len()); } } } else { ALOGW("Ignoring invalid attribute type = %d, size = %d", it.get_type(), it.get_len()); } } return NL_OK; }
virtual int handleResponse(WifiEvent& reply) { ALOGD("In MemoryDumpCommand::handleResponse"); if (reply.get_cmd() != NL80211_CMD_VENDOR) { ALOGD("Ignoring reply with cmd = %d", reply.get_cmd()); return NL_SKIP; } nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA); int len = reply.get_vendor_data_len(); ALOGD("len = %d", len); if (vendor_data == NULL || len == 0) { ALOGE("no vendor data in memory dump response; ignoring it"); return NL_SKIP; } for (nl_iterator it(vendor_data); it.has_next(); it.next()) { if (it.get_type() == LOGGER_ATTRIBUTE_FW_DUMP_LEN) { mBuffSize = it.get_u32(); if (mBuff) free(mBuff); mBuff = (char *)malloc(mBuffSize); if (!mBuff) { ALOGE("Buffer allocation failed"); return NL_SKIP; } WifiRequest request(familyId(), ifaceId()); int result = request.create(GOOGLE_OUI, LOGGER_GET_MEM_DUMP); if (result != WIFI_SUCCESS) { ALOGE("Failed to create get memory dump request; result = %d", result); free(mBuff); return NL_SKIP; } nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); result = request.put_u32(LOGGER_ATTRIBUTE_FW_DUMP_LEN, mBuffSize); if (result != WIFI_SUCCESS) { ALOGE("Failed to put get memory dump request; result = %d", result); return result; } result = request.put_u64(LOGGER_ATTRIBUTE_FW_DUMP_DATA, (uint64_t)mBuff); if (result != WIFI_SUCCESS) { ALOGE("Failed to put get memory dump request; result = %d", result); return result; } request.attr_end(data); result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("Failed to register get momory dump response; result = %d", result); } } else if (it.get_type() == LOGGER_ATTRIBUTE_FW_DUMP_DATA) { ALOGI("Initiating memory dump callback"); if (mHandler.on_firmware_memory_dump) { (*mHandler.on_firmware_memory_dump)(mBuff, mBuffSize); } if (mBuff) { free(mBuff); mBuff = NULL; } } else { ALOGW("Ignoring invalid attribute type = %d, size = %d", it.get_type(), it.get_len()); } } return NL_OK; }
virtual int handleEvent(WifiEvent& event) { wifi_ring_buffer_id ring_id; char *buffer = NULL; int buffer_size = 0; nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA); int len = event.get_vendor_data_len(); int event_id = event.get_vendor_subcmd(); ALOGI("Got event: %d", event_id); if (vendor_data == NULL || len == 0) { ALOGE("No Debug data found"); return NL_SKIP; } if (event_id == GOOGLE_DEBUG_MEM_DUMP_EVENT) { for (nl_iterator it(vendor_data); it.has_next(); it.next()) { if (it.get_type() == LOGGER_ATTRIBUTE_FW_DUMP_LEN) { mBuffSize = it.get_u32(); } else if (it.get_type() == LOGGER_ATTRIBUTE_RING_DATA) { buffer_size = it.get_len(); buffer = (char *)it.get_data(); /* } else if (it.get_type() == LOGGER_ATTRIBUTE_FW_ERR_CODE) { mErrCode = it.get_u32(); */ } else { ALOGW("Ignoring invalid attribute type = %d, size = %d", it.get_type(), it.get_len()); } } if (mBuffSize) { ALOGD("dump size: %d meta data size: %d", mBuffSize, buffer_size); if (mBuff) free(mBuff); mBuff = (char *)malloc(mBuffSize + buffer_size); if (!mBuff) { ALOGE("Buffer allocation failed"); return NL_SKIP; } memcpy(mBuff, buffer, buffer_size); WifiRequest request(familyId(), ifaceId()); int result = request.create(GOOGLE_OUI, LOGGER_GET_MEM_DUMP); if (result != WIFI_SUCCESS) { ALOGE("Failed to create get memory dump request; result = %d", result); free(mBuff); return NL_SKIP; } nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); result = request.put_u32(LOGGER_ATTRIBUTE_FW_DUMP_LEN, mBuffSize); if (result != WIFI_SUCCESS) { ALOGE("Failed to put get memory dump request; result = %d", result); return result; } result = request.put_u64(LOGGER_ATTRIBUTE_FW_DUMP_DATA, (uint64_t)(mBuff+buffer_size)); if (result != WIFI_SUCCESS) { ALOGE("Failed to put get memory dump request; result = %d", result); return result; } request.attr_end(data); mBuffSize += buffer_size; result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("Failed to register get momory dump response; result = %d", result); } } else { ALOGE("dump event missing dump length attribute"); return NL_SKIP; } } return NL_OK; }
virtual int handleResponse(WifiEvent& reply) { ALOGD("In DebugCommand::handleResponse"); if (reply.get_cmd() != NL80211_CMD_VENDOR) { ALOGD("Ignoring reply with cmd = %d", reply.get_cmd()); return NL_SKIP; } switch (mType) { case GET_DRV_VER: case GET_FW_VER: { void *data = reply.get_vendor_data(); int len = reply.get_vendor_data_len(); ALOGD("len = %d, expected len = %d", len, *mBuffSize); memcpy(mBuff, data, min(len, *mBuffSize)); if (*mBuffSize < len) return NL_SKIP; *mBuffSize = len; break; } case START_RING_LOG: case GET_RING_DATA: break; case GET_RING_STATUS: { nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA); int len = reply.get_vendor_data_len(); wifi_ring_buffer_status *status(mStatus); if (vendor_data == NULL || len == 0) { ALOGE("No Debug data found"); return NL_SKIP; } nl_iterator it(vendor_data); if (it.get_type() == LOGGER_ATTRIBUTE_RING_NUM) { unsigned int num_rings = it.get_u32(); if (*mNumRings < num_rings) { ALOGE("Not enough status buffers provided, available: %d required: %d", *mNumRings, num_rings); } else { *mNumRings = num_rings; } } else { ALOGE("Unknown attribute: %d expecting %d", it.get_type(), LOGGER_ATTRIBUTE_RING_NUM); return NL_SKIP; } it.next(); for (unsigned int i = 0; it.has_next() && i < *mNumRings; it.next()) { if (it.get_type() == LOGGER_ATTRIBUTE_RING_STATUS) { memcpy(status, it.get_data(), sizeof(wifi_ring_buffer_status)); i++; status++; } else { ALOGW("Ignoring invalid attribute type = %d, size = %d", it.get_type(), it.get_len()); } } break; } case GET_FEATURE: { void *data = reply.get_vendor_data(); int len = reply.get_vendor_data_len(); ALOGD("len = %d, expected len = %d", len, sizeof(unsigned int)); memcpy(mSupport, data, sizeof(unsigned int)); break; } default: ALOGW("Unknown Debug command"); } return NL_OK; }