int result = nla_parse(mAttributes, NL80211_ATTR_MAX_INTERNAL, genlmsg_attrdata(mHeader, 0),
genlmsg_attrlen(mHeader, 0), NULL);
- ALOGD("event len = %d", nlmsg_hdr(mMsg)->nlmsg_len);
return result;
}
int WifiCommand::requestEvent(int cmd) {
- ALOGD("requesting event %d", cmd);
-
int res = wifi_register_handler(wifiHandle(), cmd, event_handler, this);
if (res < 0) {
return res;
if (res < 0)
goto out;
- ALOGD("waiting for response %d", cmd);
-
res = nl_send_auto_complete(mInfo->cmd_sock, mMsg.getMessage()); /* send message */
if (res < 0)
goto out;
- ALOGD("waiting for event %d", cmd);
res = mCondition.wait();
if (res < 0)
goto out;
int *ret = (int *)arg;
*ret = err->error;
- ALOGD("error_handler received : %d", err->error);
+ /*ALOGD("error_handler received : %d", err->error);*/
return NL_SKIP;
}
}
virtual int create() {
- ALOGD("Creating message to get scan capablities; iface = %d", mIfaceInfo->id);
-
int ret = mMsg.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_GET_CAPABILITIES);
if (ret < 0) {
ALOGE("NL message creation failed");
void *data = reply.get_vendor_data();
int len = reply.get_vendor_data_len();
- ALOGD("GetCapabilities::handleResponse - Id = %0x, subcmd = %d, len = %d, expected len = %d", id, subcmd, len,
- sizeof(*mCapabilities));
-
memcpy(mCapabilities, data, min(len, (int) sizeof(*mCapabilities)));
return NL_OK;
memset(channels, 0, sizeof(wifi_channel) * max_channels);
}
virtual int create() {
- ALOGD("Creating message to get channel list; iface = %d", mIfaceInfo->id);
-
int ret = mMsg.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_GET_VALID_CHANNELS);
if (ret < 0) {
return ret;
nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA);
int len = reply.get_vendor_data_len();
- ALOGD("GetChannelList::handleResponse - Id = %0x, subcmd = %d, len = %d", id, subcmd, len);
if (vendor_data == NULL || len == 0) {
ALOGE("no vendor data in GetChannelList response; ignoring it");
return NL_SKIP;
for (nl_iterator it(vendor_data); it.has_next(); it.next()) {
if (it.get_type() == GSCAN_ATTRIBUTE_NUM_CHANNELS) {
num_channels_to_copy = it.get_u32();
- ALOGD("Got channel list with %d channels", num_channels_to_copy);
+ /*ALOGD("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;
for (nl_iterator it(attr); it.has_next() && i < num; it.next(), i++) {
int index = it.get_type();
- ALOGD("retrieved scan result %d", index);
nlattr *sc_data = (nlattr *) it.get_data();
wifi_scan_result *result = results + i;
}
int start() {
- ALOGD(" sending scan req to driver");
+ ALOGD("starting Gscan");
WifiRequest request(familyId(), ifaceId());
int result = createSetupRequest(request);
if (result != WIFI_SUCCESS) {
ALOGE("failed to create setup request; result = %d", result);
return result;
}
- ALOGD("Starting scan");
registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SCAN_RESULTS_AVAILABLE);
registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_COMPLETE_SCAN);
}
virtual int cancel() {
- ALOGD("Stopping scan");
+ ALOGD("Stopping Gscan");
WifiRequest request(familyId(), ifaceId());
int result = createStopRequest(request);
}
virtual int handleEvent(WifiEvent& event) {
- ALOGD("Got a scan results event");
-
event.log();
nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
unsigned int len = event.get_vendor_data_len();
int event_id = event.get_vendor_subcmd();
- ALOGD("handleEvent, event_id = %d", event_id);
if(event_id == GSCAN_EVENT_COMPLETE_SCAN) {
if (vendor_data == NULL || len != 4) {
wifi_scan_event evt_type;
evt_type = (wifi_scan_event) event.get_u32(NL80211_ATTR_VENDOR_DATA);
- ALOGD("Scan complete: Received event type %d", evt_type);
if(*mHandler.on_scan_event)
(*mHandler.on_scan_event)(evt_type, evt_type);
} else if(event_id == GSCAN_EVENT_FULL_SCAN_RESULTS) {
{
wifi_handle handle = getWifiHandle(iface);
- ALOGD("Starting GScan, halHandle = %p", handle);
-
ScanCommand *cmd = new ScanCommand(iface, id, ¶ms, handler);
wifi_register_cmd(handle, id, cmd);
return (wifi_error)cmd->start();
wifi_error wifi_stop_gscan(wifi_request_id id, wifi_interface_handle iface)
{
- ALOGD("Stopping GScan");
wifi_handle handle = getWifiHandle(iface);
if(id == -1) {
int execute() {
WifiRequest request(familyId(), ifaceId());
- ALOGD("retrieving %d scan results", mMax);
for (int i = 0; i < 10 && mRetrieved < mMax; i++) {
int result = createRequest(request, (mMax - mRetrieved), mFlush);
int id = reply.get_vendor_id();
int subcmd = reply.get_vendor_subcmd();
- ALOGD("GetScanResultsCommand::handleResponse - Id = %0x, subcmd = %d", id, subcmd);
-
nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA);
int len = reply.get_vendor_data_len();
wifi_error wifi_get_cached_gscan_results(wifi_interface_handle iface, byte flush,
int max, wifi_cached_scan_results *results, int *num) {
- ALOGD("Getting cached scan results, iface handle = %p, num = %d", iface, *num);
-
GetScanResultsCommand *cmd = new GetScanResultsCommand(iface, flush, results, max, num);
return (wifi_error)cmd->execute();
}
}
int start() {
- ALOGD("Executing hotlist setup request, num = %d", mParams.num_bssid);
WifiRequest request(familyId(), ifaceId());
int result = createSetupRequest(request);
if (result < 0) {
return result;
}
- ALOGD("Successfully set %d APs in the hotlist", mParams.num_bssid);
-
registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_FOUND);
registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_LOST);
return result;
}
- ALOGD("Successfully reset APs in current hotlist");
return result;
}
}
virtual int handleEvent(WifiEvent& event) {
- ALOGD("Hotlist AP event");
int event_id = event.get_vendor_subcmd();
event.log();
}
int start() {
- ALOGD("Set significant wifi change");
WifiRequest request(familyId(), ifaceId());
int result = createSetupRequest(request);
return result;
}
- ALOGD("successfully reset significant wifi change");
return result;
}
}
virtual int handleEvent(WifiEvent& event) {
- ALOGD("Got a significant wifi change event");
-
nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
int len = event.get_vendor_data_len();
mResults[i] = reinterpret_cast<wifi_significant_change_result *>(&(mResultsBuffer[i]));
}
- ALOGD("Retrieved %d scan results", num);
-
if (num != 0) {
(*mHandler.on_significant_change)(id(), num, mResults);
} else {
}
ALOGI("ePNO [min5GHz_rssi:%d min24GHz_rssi:%d initial_score_max:%d current_connection_bonus:%d same_network_bonus:%d secure_bonus:%d band5GHz_bonus:%d num_networks:%d]",
- epno_params->min5GHz_rssi,
- epno_params->min24GHz_rssi,
- epno_params->initial_score_max,
- epno_params->current_connection_bonus,
- epno_params->same_network_bonus,
- epno_params->secure_bonus,
- epno_params->band5GHz_bonus,
- epno_params->num_networks);
+ epno_params->min5GHz_rssi,
+ epno_params->min24GHz_rssi,
+ epno_params->initial_score_max,
+ epno_params->current_connection_bonus,
+ epno_params->same_network_bonus,
+ epno_params->secure_bonus,
+ epno_params->band5GHz_bonus,
+ epno_params->num_networks);
struct nlattr * attr = request.attr_start(EPNO_ATTRIBUTE_SSID_LIST);
for (int i = 0; i < epno_params->num_networks; i++) {
return result;
}
result = request.put(EPNO_ATTRIBUTE_SSID, epno_params->networks[i].ssid, strlen(epno_params->networks[i].ssid));
- ALOGI("ePNO [SSID:%s flags:%d auth:%d]", epno_params->networks[i].ssid,
- epno_params->networks[i].flags,
- epno_params->networks[i].auth_bit_field);
if (result < 0) {
return result;
}
}
if (epno_params) {
- ALOGI("Successfully set %d SSIDs for ePNO", epno_params->num_networks);
registerVendorHandler(GOOGLE_OUI, WIFI_EPNO_EVENT);
- } else {
- ALOGI("Successfully reset ePNO");
}
return result;
}
}
virtual int handleEvent(WifiEvent& event) {
- ALOGI("ePNO event");
int event_id = event.get_vendor_subcmd();
// event.log();
}
virtual int handleResponse(WifiEvent& reply) {
- ALOGD("Request complete!");
/* Nothing to do on response! */
return NL_SKIP;
}
virtual int handleEvent(WifiEvent& event) {
-
- ALOGI("hotspot matched event");
nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
unsigned int len = event.get_vendor_data_len();
if (vendor_data == NULL || len < sizeof(wifi_scan_result)) {
int anqp_len = *(u16 *)anqp;
anqp += sizeof(u16);
- ALOGI("%-32s\t", result->ssid);
-
- ALOGI("%02x:%02x:%02x:%02x:%02x:%02x ", result->bssid[0], result->bssid[1],
- result->bssid[2], result->bssid[3], result->bssid[4], result->bssid[5]);
-
- ALOGI("%d\t", result->rssi);
- ALOGI("%d\t", result->channel);
- ALOGI("%lld\t", result->ts);
- ALOGI("%lld\t", result->rtt);
- ALOGI("%lld\n", result->rtt_sd);
-
if(*mHandler.on_passpoint_network_found)
(*mHandler.on_passpoint_network_found)(id(), networkId, result, anqp_len, anqp);
}
int start() {
- ALOGD("Executing bssid blacklist request, num = %d", mParams->num_bssid);
WifiRequest request(familyId(), ifaceId());
int result = createRequest(request);
if (result < 0) {
return result;
}
- ALOGI("Successfully added %d blacklist bssids", mParams->num_bssid);
return result;
}
return result;
}
- ALOGD("Successfully set Link Layer Statistics measurement");
return result;
}
return result;
}
- ALOGD("Successfully clear Link Layer Statistics measurement");
return result;
}
}
virtual int create() {
- ALOGI("Creating message to get link statistics");
-
int ret = mMsg.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_LLS_GET_INFO);
if (ret < 0) {
ALOGE("Failed to create %x - %d", SLSI_NL80211_VENDOR_SUBCMD_LLS_GET_INFO, ret);
protected:
virtual int handleResponse(WifiEvent& reply) {
-
- ALOGI("In GetLinkStatsCommand::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();
- ALOGI("Id = %0x, subcmd = %d", id, subcmd);
-
u8 *data = (u8 *)reply.get_vendor_data();
int len = reply.get_vendor_data_len();
#include <errno.h>
#include <stdint.h>
+#include <string.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <netlink/genl/genl.h>
static nl_sock * wifi_create_nl_socket(int port)
{
- ALOGI("Creating socket");
struct nl_sock *sock = nl_socket_alloc();
if (sock == NULL) {
ALOGE("Could not create handle");
wifi_socket_set_local_port(sock, port);
- ALOGI("Connecting socket");
if (nl_connect(sock, NETLINK_GENERIC)) {
ALOGE("Could not connect handle");
nl_socket_free(sock);
memset(info, 0, sizeof(*info));
- ALOGI("Creating socket");
if (socketpair(AF_UNIX, SOCK_STREAM, 0, info->cleanup_socks) == -1) {
ALOGE("Could not create cleanup sockets");
free(info);
pthread_mutex_init(&info->cb_lock, NULL);
*handle = (wifi_handle) info;
- ALOGD("wifi_initialize, handle = %p\n", handle);
- ALOGD("wifi_initialize, *handle = %p\n", *handle);
- ALOGD("wifi_initialize, info = %p\n", info);
- ALOGD("wifi_initialize, *info = %pn", *info);
+
wifi_add_membership(*handle, "scan");
wifi_add_membership(*handle, "mlme");
wifi_add_membership(*handle, "regulatory");
wifi_add_membership(*handle, "vendor");
wifi_init_interfaces(*handle);
- ALOGD("Found %d interfaces", info->num_interfaces);
+ char intf_name_buff[10 * 10 + 4]; /* Randomly choosen max interface 10. each interface name max 9 + 1(for space) */
+ char *pos = intf_name_buff;
+ for (int i = 0; i < (info->num_interfaces < 10 ? info->num_interfaces : 10); i++) {
+ strncpy(pos, info->interfaces[i]->name, sizeof(intf_name_buff) - (pos - intf_name_buff));
+ pos += strlen(pos);
+ }
+ if (info->num_interfaces > 10) {
+ strncpy(pos, "...", 3);
+ }
+ ALOGD("Found %d interfaces[%s]. Initialized Wifi HAL Successfully", info->num_interfaces, intf_name_buff);
- ALOGI("Initialized Wifi HAL Successfully; vendor cmd = %d", NL80211_CMD_VENDOR);
return WIFI_SUCCESS;
}
if (ret < 0) {
ALOGE("Could not add membership to group %s", group);
}
-
- ALOGI("Successfully added membership for group %s", group);
return ret;
}
(*cleaned_up_handler)(handle);
pthread_mutex_destroy(&info->cb_lock);
free(info);
-
- ALOGI("Internal cleanup completed");
}
void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler)
memset(buf, 0, sizeof(buf));
int result = read(info->cleanup_socks[0], buf, sizeof(buf));
ALOGE("%s: Read after POLL returned %d, error no = %d", __FUNCTION__, result, errno);
- if (strncmp(buf, "Done", 4) == 0) {
- ALOGE("Event processing terminated");
- } else {
+ if (strncmp(buf, "Done", 4) != 0) {
ALOGD("Rx'ed %s", buf);
}
}
static int internal_pollin_handler(wifi_handle handle)
{
hal_info *info = getHalInfo(handle);
- ALOGI("even_loop info = %p", info);
struct nl_cb *cb = nl_socket_get_cb(info->event_sock);
int res = nl_recvmsgs(info->event_sock, cb);
- ALOGD("nl_recvmsgs returned %d", res);
nl_cb_put(cb);
return res;
}
void wifi_event_loop(wifi_handle handle)
{
hal_info *info = getHalInfo(handle);
- ALOGI("even_loop info = %p", info);
- ALOGI("even_loop info = %p", handle);
if (info->in_event_loop) {
return;
} else {
int result = poll(pfd, 2, timeout);
if (result < 0) {
} else if (pfd[0].revents & POLLERR) {
- ALOGE("POLL Error; error no = %d", errno);
+ int prev_err = (int)errno;
int result2 = read(pfd[0].fd, buf, sizeof(buf));
- ALOGE("Read after POLL returned %d, error no = %d", result2, errno);
+ ALOGE("Poll err:%d | Read after POLL returned %d, error no = %d", prev_err, result2, errno);
} else if (pfd[0].revents & POLLHUP) {
ALOGE("Remote side hung up");
break;
ALOGE("Unknown event - %0x, %0x", pfd[0].revents, pfd[1].revents);
}
} while (!info->clean_up);
- ALOGI("Exit %s", __FUNCTION__);
}
///////////////////////////////////////////////////////////////////////////////////////
{
wifi_handle handle = (wifi_handle)arg;
hal_info *info = getHalInfo(handle);
- ALOGI("even_loop info = %p", handle);
- ALOGD("internal_valid_message_handler, info = %p", info);
WifiEvent event(msg);
int res = event.parse();
subcmd = event.get_u32(NL80211_ATTR_VENDOR_SUBCMD);
ALOGI("event received %s, vendor_id = 0x%0x, subcmd = 0x%0x",
event.get_cmdString(), vendor_id, subcmd);
- } else {
- ALOGI("event received %s", event.get_cmdString());
}
//ALOGI("event received %s, vendor_id = 0x%0x", event.get_cmdString(), vendor_id);
pthread_mutex_lock(&info->cb_lock);
- ALOGI("Number of events %d", info->num_event_cb);
-
for (int i = 0; i < info->num_event_cb; i++) {
if (cmd == info->event_cb[i].nl_cmd) {
if (cmd == NL80211_CMD_VENDOR
virtual int create() {
int nlctrlFamily = genl_ctrl_resolve(mInfo->cmd_sock, "nlctrl");
- ALOGI("ctrl family = %d", nlctrlFamily);
int ret = mMsg.create(nlctrlFamily, CTRL_CMD_GETFAMILY, 0, 0);
if (ret < 0) {
return ret;
}
virtual int handleResponse(WifiEvent& reply) {
-
- ALOGE("handling reponse in %s", __func__);
-
struct nlattr **tb = reply.attributes();
struct nlattr *mcgrp = NULL;
int i;
if (!tb[CTRL_ATTR_MCAST_GROUPS]) {
ALOGE("No multicast groups found");
return NL_SKIP;
- } else {
- ALOGE("Multicast groups attr size = %d", nla_len(tb[CTRL_ATTR_MCAST_GROUPS]));
}
for_each_attr(mcgrp, tb[CTRL_ATTR_MCAST_GROUPS], i) {
- ALOGE("Processing group");
struct nlattr *tb2[CTRL_ATTR_MCAST_GRP_MAX + 1];
nla_parse(tb2, CTRL_ATTR_MCAST_GRP_MAX, (nlattr *)nla_data(mcgrp),
nla_len(mcgrp), NULL);
char *grpName = (char *)nla_data(tb2[CTRL_ATTR_MCAST_GRP_NAME]);
int grpNameLen = nla_len(tb2[CTRL_ATTR_MCAST_GRP_NAME]);
- ALOGE("Found group name %s", grpName);
-
if (strncmp(grpName, mGroup, grpNameLen) != 0)
continue;
}
int start() {
- ALOGD("Sending mac address OUI");
WifiRequest request(familyId(), ifaceId());
int result = createRequest(request, SLSI_NL80211_VENDOR_SUBCMD_SET_GSCAN_OUI, mOui);
if (result != WIFI_SUCCESS) {
}
protected:
virtual int handleResponse(WifiEvent& reply) {
- ALOGD("Request complete!");
/* Nothing to do on response! */
return NL_SKIP;
}
if (result < 0) {
return result;
}
- ALOGD("create request");
+
result = request.put_u8(RSSI_MONITOR_ATTRIBUTE_MIN_RSSI, (enable? mMin_rssi: 0));
if (result < 0) {
return result;
ALOGI("Successfully set RSSI monitoring");
registerVendorHandler(GOOGLE_OUI, WIFI_RSSI_REPORT_EVENT);
- ALOGI("Done!");
return result;
}
}
virtual int handleEvent(WifiEvent& event) {
- ALOGI("Got a RSSI monitor event");
nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
int len = event.get_vendor_data_len();
{
strcpy(info->name, name);
info->id = if_nametoindex(name);
- ALOGI("found an interface : %s, id = %d", name, info->id);
return WIFI_SUCCESS;
}
wifi_error wifi_init_interfaces(wifi_handle handle)
{
hal_info *info = (hal_info *)handle;
- ALOGD("wifi_init_interfaces, info = %p", info);
-
struct dirent *de;
DIR *d = opendir("/sys/class/net");
}
virtual int handleResponse(WifiEvent& reply) {
- ALOGD("In MKeepAliveCommand::handleResponse");
if (reply.get_cmd() != NL80211_CMD_VENDOR) {
ALOGD("Ignoring reply with cmd = %d", reply.get_cmd());