/* * Configures local channel for finding server. * Server call this fucntion for getting its current channel, * client uses this fucntion for setting its channel to new channel. */ static int rwl_wifi_config_channel(void *wl, int cmd, int *channel) { int error; channel_info_t ci; /* Get functionality is used only by server */ if (cmd == WLC_GET_CHANNEL) { memset((char*)&ci, 0, sizeof(ci)); if ((error = wl_get(wl, cmd, &ci, sizeof(channel_info_t)))) return error; ci.hw_channel = dtoh32(ci.hw_channel); ci.scan_channel = dtoh32(ci.scan_channel); ci.target_channel = dtoh32(ci.target_channel); if (ci.scan_channel) printf("Scan in progress.\n"); *channel = ci.hw_channel; } if (cmd == WLC_SET_CHANNEL) { /* Set functionality is used by the client */ ci.target_channel = *channel; /* When user wants to execute local CMD being in remote wifi mode, * rwl_wifi_swap_remote_type fucntion is used to change the remote types. */ rwl_wifi_swap_remote_type(remote_type); error = wl_set(wl, cmd, &ci.target_channel, sizeof(int)); /* rever it back to same old remote type */ rwl_wifi_swap_remote_type(remote_type); } return error; }
/* This function will send the buffer to the dongle driver */ int rwl_var_send_vs_actionframe(void* wl, const char* iovar, void* param, int param_len) { int len; memset(rwl_buf, 0, WLC_IOCTL_MAXLEN); strcpy((char*) rwl_buf, iovar); /* include the null */ len = strlen(iovar) + 1; if (param_len) memcpy((void*)&rwl_buf[len+ OFFSETOF(wl_action_frame_t, data)], param, param_len); /* Set the PacketID (not used by remote WL */ memset((void*)&rwl_buf[len + OFFSETOF(wl_action_frame_t, packetId)], 0, 4); /* Set the dest addr */ memcpy((void*)&rwl_buf[len + OFFSETOF(wl_action_frame_t, da)], (void*)&rwlea, ETHER_ADDR_LEN); /* set the length */ memcpy((void*)&rwl_buf[len + OFFSETOF(wl_action_frame_t, len)], (void*) ¶m_len, 2); len += param_len + ETHER_ADDR_LEN + 2 + 4; DPRINT_DBG(OUTPUT, "setbuf:%s, len:%d\n", rwl_buf, len); return wl_set(wl, WLC_SET_VAR, &rwl_buf[0], len); }
int dhd_set(void *dhd, int cmd, void *buf, int len) { static int dnode = -1; switch (cmd) { case DHD_DLDN_ST: if (dnode == -1) dnode = open(NODE, O_RDWR); else fprintf(stderr, "devnode already opened!\n"); return dnode; break; case DHD_DLDN_WRITE: if (dnode > 0) return write(dnode, buf, len); break; case DHD_DLDN_END: if (dnode > 0) return close(dnode); break; default: return wl_set(dhd, cmd, buf, len); } return -1; }
/* now IOCTL SET commands shall call wlu_set() instead of wl_set() so that the commands * can be batched when needed */ int wlu_set(void *wl, int cmd, void *cmdbuf, int len) { if (cmd_batching_mode) { return add_one_batched_cmd(cmd, cmdbuf, len); } else { return wl_set(wl, cmd, cmdbuf, len); } }
/* This function will send the buffer to the dongle driver */ int rwl_var_setbuf(void* wl, const char* iovar, void* param, int param_len) { int len; memset(rwl_buf, 0, WLC_IOCTL_MAXLEN); strcpy((char*)rwl_buf, iovar); /* include the null */ len = strlen(iovar) + 1; if (param_len) memcpy(&rwl_buf[len], param, param_len); len += param_len; DPRINT_DBG(OUTPUT, "setbuf:%s, len:%d\n", rwl_buf, len); return wl_set(wl, WLC_SET_VAR, &rwl_buf[0], len); }
/* This function will send the buffer to the dongle driver */ int rwl_var_send_vs_actionframe(void* wl, const char* iovar, void* param, int param_len) { int len, error; memset(g_rwl_aligned_buf, 0, WLC_IOCTL_MAXLEN); strcpy(g_rwl_aligned_buf, iovar); /* include the null */ len = strlen(iovar) + 1; if (param_len) memcpy((void*)&g_rwl_aligned_buf[len+ OFFSETOF(wl_action_frame_t, data)], param, param_len); /* Set the PacketID (not used by remote WL */ memset((void*)&g_rwl_aligned_buf[len + OFFSETOF(wl_action_frame_t, packetId)], 0, 4); /* Set the dest addr */ memcpy((void*)&g_rwl_aligned_buf[len + OFFSETOF(wl_action_frame_t, da)], (void*)g_rwl_buf_mac, ETHER_ADDR_LEN); /* set the length */ memcpy((void*)&g_rwl_aligned_buf[len + OFFSETOF(wl_action_frame_t, len)], (void*) ¶m_len, 2); len += param_len + ETHER_ADDR_LEN + 2 + 4; /* When user wants to execute local CMD being in remote wifi mode, * rwl_wifi_swap_remote_type fucntion is used to change the remote types. */ rwl_wifi_swap_remote_type(remote_type); error = wl_set(wl, WLC_SET_VAR, &g_rwl_aligned_buf[0], len); /* revert back to the old type */ rwl_wifi_swap_remote_type(remote_type); return error; }
int rwl_var_setbuf(void *wl, const char *iovar, void *param, int param_len) { int len, error; memset(g_rwl_aligned_buf, 0, WLC_IOCTL_MAXLEN); strcpy(g_rwl_aligned_buf, iovar); /* include the null */ len = strlen(iovar) + 1; if (param_len) memcpy(&g_rwl_aligned_buf[len], param, param_len); len += param_len; /* When user wants to execute local CMD being in remote wifi mode, * rwl_wifi_swap_remote_type fucntion is used to change the remote types. */ rwl_wifi_swap_remote_type(remote_type); error = wl_set(wl, WLC_SET_VAR, &g_rwl_aligned_buf[0], len); /* revert back to the old type */ rwl_wifi_swap_remote_type(remote_type); return error; }
int wlmDeviceImageWrite(const char* byteStream, int length, WLM_IMAGE_TYPE imageType) { srom_rw_t *srt; char buffer[WLC_IOCTL_MAXLEN] = {0}; char *bufp; char *cisp, *cisdata; cis_rw_t cish; if (byteStream == NULL) { printf("wlmDeviceImageWrite: Buffer is invalid!\n"); return FALSE; } if (length > SROM_MAX+1) { printf("wlmDeviceImageWrite: Data length should be less than %d bytes\n", SROM_MAX); return FALSE; } switch (imageType) { case WLM_TYPE_SROM: srt = (srom_rw_t *)buffer; memcpy(srt->buf, byteStream, length); if (length == SROM4_WORDS * 2) { if ((srt->buf[SROM4_SIGN] != SROM4_SIGNATURE) && (srt->buf[SROM8_SIGN] != SROM4_SIGNATURE)) { printf("wlmDeviceImageWrite: Data lacks a REV4 signature!\n"); return FALSE; } } else if ((length != SROM_WORDS * 2) && (length != SROM_MAX)) { printf("wlmDeviceImageWrite: Data length is invalid!\n"); return FALSE; } srt->nbytes = length; if (wlu_set(irh, WLC_SET_SROM, buffer, length + 8)) { printf("wlmDeviceImageWrite: %s\n", wlmLastError()); return FALSE; } break; case WLM_TYPE_OTP: bufp = buffer; strcpy(bufp, "ciswrite"); bufp += strlen("ciswrite") + 1; cisp = bufp; cisdata = cisp + sizeof(cish); cish.source = htod32(0); memcpy(cisdata, byteStream, length); cish.byteoff = htod32(0); cish.nbytes = htod32(length); memcpy(cisp, (char*)&cish, sizeof(cish)); if (wl_set(irh, WLC_SET_VAR, buffer, (cisp - buffer) + sizeof(cish) + length) < 0) { printf("wlmDeviceImageWrite: %s\n", wlmLastError()); return FALSE; } break; case WLM_TYPE_AUTO: if (!wlmDeviceImageWrite(byteStream, length, WLM_TYPE_SROM) && !wlmDeviceImageWrite(byteStream, length, WLM_TYPE_OTP)) { printf("wlmDeviceImageWrite: %s\n", wlmLastError()); return FALSE; } break; default: printf("wlmDeviceImageWrite: Invalid image type!\n"); return FALSE; } return TRUE; }