Ejemplo n.º 1
0
int wlmTxPacketStart(unsigned int interPacketDelay,
	unsigned int numPackets, unsigned int packetLength,
	const char* destMac, int withAck, int syncMode)
{
	wl_pkteng_t pkteng;

	if (!wl_ether_atoe(destMac, (struct ether_addr *)&pkteng.dest)) {
		printf("wlmTxPacketStart: destMac invalid\n");
		return FALSE;
	}

	pkteng.flags = withAck ? WL_PKTENG_PER_TX_WITH_ACK_START : WL_PKTENG_PER_TX_START;

	if (syncMode)
		pkteng.flags |= WL_PKTENG_SYNCHRONOUS;
	else
		pkteng.flags &= ~WL_PKTENG_SYNCHRONOUS;

	pkteng.delay = interPacketDelay;
	pkteng.length = packetLength;
	pkteng.nframes = numPackets;

	pkteng.seqno = 0;			/* not used */
	pkteng.src = ether_null;	/* implies current ether addr */

	if (wlu_var_setbuf(irh, "pkteng", &pkteng, sizeof(pkteng))) {
		printf("wlmTxPacketStart: %s\n", wlmLastError());
		return FALSE;
	}

	return TRUE;
}
Ejemplo n.º 2
0
int wlmRxPacketStart(const char* srcMac, int withAck,
	int syncMode, unsigned int numPackets, unsigned int timeout)
{
	wl_pkteng_t pkteng;

	if (!wl_ether_atoe(srcMac, (struct ether_addr *)&pkteng.dest)) {
		printf("wlmRxPacketStart: srcMac invalid\n");
		return FALSE;
	}

	pkteng.flags = withAck ? WL_PKTENG_PER_RX_WITH_ACK_START : WL_PKTENG_PER_RX_START;

	if (syncMode) {
		pkteng.flags |= WL_PKTENG_SYNCHRONOUS;
		pkteng.nframes = numPackets;
		pkteng.delay = timeout;
	}
	else
		pkteng.flags &= ~WL_PKTENG_SYNCHRONOUS;

	if (wlu_var_setbuf(irh, "pkteng", &pkteng, sizeof(pkteng))) {
		printf("wlmRxPacketStart: %s\n", wlmLastError());
		return FALSE;
	}

	return TRUE;
}
Ejemplo n.º 3
0
int wl_wifiaction(void *wl, uint32 packet_id,
	struct ether_addr *da, uint16 len, uint8 *data)
{
	wl_action_frame_t * action_frame;
	int err = 0;

	if (len > ACTION_FRAME_SIZE)
		return -1;

	if ((action_frame = (wl_action_frame_t *) malloc(WL_WIFI_ACTION_FRAME_SIZE)) == NULL) {
		return -1;
	}

	/* Add the packet Id */
	action_frame->packetId = packet_id;

	memcpy(&action_frame->da, (char*)da, ETHER_ADDR_LEN);

	action_frame->len = htod16(len);
	memcpy(action_frame->data, data, len);

	err = wlu_var_setbuf(wl, "wifiaction", action_frame, WL_WIFI_ACTION_FRAME_SIZE);

	free(action_frame);

	return (err);
}
Ejemplo n.º 4
0
int wl_tdls_endpoint(void *wl, char *cmd, struct ether_addr *ea)
{
	const char *cmdname_tdls = "tdls_endpoint";
	tdls_iovar_t info;

	memset(&info, 0, sizeof(tdls_iovar_t));

	if (!strcmp("create", cmd))
		info.mode = TDLS_MANUAL_EP_CREATE;
	else if (!strcmp("modify", cmd))
		info.mode = TDLS_MANUAL_EP_MODIFY;
	else if (!strcmp("delete", cmd))
		info.mode = TDLS_MANUAL_EP_DELETE;
	else if (!strcmp("PM", cmd))
		info.mode = TDLS_MANUAL_EP_PM;
	else if (!strcmp("wake", cmd))
		info.mode = TDLS_MANUAL_EP_WAKE;
	else if (!strcmp("disc", cmd))
		info.mode = TDLS_MANUAL_EP_DISCOVERY;
	else if (!strcmp("cw", cmd)) {
		info.mode = TDLS_MANUAL_EP_CHSW;
	}
	else {
		printf("error: invalid mode string\n");
		return USAGE_ERROR;
	}

	memcpy(&info.ea, ea, sizeof(info.ea));

	return wlu_var_setbuf(wl, cmdname_tdls, &info, sizeof(info));
}
Ejemplo n.º 5
0
int wlmIovarBufferSet(const char *iovar, void *param, int param_len)
{
	if (wlu_var_setbuf(irh, iovar, param, param_len)) {
		printf("wlmIovarBufferSet: %s\n", wlmLastError());
		return FALSE;
	}
	return TRUE;
}
Ejemplo n.º 6
0
int wlmFullCal(void)
{
	if (wlu_var_setbuf(irh, "sslpnphy_fullcal", NULL, 0)) {
		printf("wlmFULLCAL: %s\n", wlmLastError());
		return FALSE;
	}
	return TRUE;
}
Ejemplo n.º 7
0
int wl_p2p_state(void *wl, uint8 state, chanspec_t chspec, uint16 dwell)
{
	wl_p2p_disc_st_t st;

	st.state = state;
	st.chspec = chspec;
	st.dwell = dwell;

	return wlu_var_setbuf(wl, "p2p_state", &st, sizeof(st));
}
Ejemplo n.º 8
0
int wlmRxPacketStop(void)
{
	wl_pkteng_t pkteng;

	pkteng.flags = WL_PKTENG_PER_RX_STOP;

	if (wlu_var_setbuf(irh, "pkteng", &pkteng, sizeof(pkteng))) {
		printf("wlmRxPacketStop: %s\n", wlmLastError());
		return FALSE;
	}

	return TRUE;
}
Ejemplo n.º 9
0
int wlmCga5gOffsetsSet(char* values, int len)
{
	if (len != CGA_5G_OFFSETS_LEN) {
		printf("wlmCga5gOffsetsSet() requires a %d-value array as a parameter\n",
		      CGA_5G_OFFSETS_LEN);
		return FALSE;
	}

	if ((wlu_var_setbuf(irh, "sslpnphy_cga_5g", values,
	                    CGA_5G_OFFSETS_LEN * sizeof(int8))) < 0) {
		printf("wlmCga5gOffsetsSet(): Error setting offset values (%s)\n",  wlmLastError());
		return FALSE;
	}

	return TRUE;
}
Ejemplo n.º 10
0
int wl_actframe(void *wl, int bsscfg_idx, uint32 packet_id,
	uint32 channel, int32 dwell_time,
	struct ether_addr *BSSID, struct ether_addr *da,
	uint16 len, uint8 *data)
{
	wl_action_frame_t * action_frame;
	wl_af_params_t * af_params;
	struct ether_addr *bssid;
	int err = 0;

	if (len > ACTION_FRAME_SIZE)
		return -1;

	if ((af_params = (wl_af_params_t *) malloc(WL_WIFI_AF_PARAMS_SIZE)) == NULL) {
		return -1;
	}
	action_frame = &af_params->action_frame;

	/* Add the packet Id */
	action_frame->packetId = packet_id;

	memcpy(&action_frame->da, (char*)da, ETHER_ADDR_LEN);

	/* set default BSSID */
	bssid = da;
	if (BSSID != 0)
		bssid = BSSID;
	memcpy(&af_params->BSSID, (char*)bssid, ETHER_ADDR_LEN);

	action_frame->len = htod16(len);
	af_params->channel = htod32(channel);
	af_params->dwell_time = htod32(dwell_time);
	memcpy(action_frame->data, data, len);

	if (bsscfg_idx == DEFAULT_BSSCFG_INDEX)
	err = wlu_var_setbuf(wl, "actframe", af_params, WL_WIFI_AF_PARAMS_SIZE);
	else
		err = wlu_bssiovar_setbuf(wl, "actframe", bsscfg_idx,
			af_params, WL_WIFI_AF_PARAMS_SIZE, buf, WLC_IOCTL_MAXLEN);

	free(af_params);
	return (err);
}
Ejemplo n.º 11
0
int wl_ie(void *wl, uchar id, uchar len, uchar *data)
{
	int err;
	uchar *buf;
	uint32 pktflag;
	int iecount;
	ie_setbuf_t *ie_setbuf;
	uchar count;

	/* use VNDR_IE_CUSTOM_FLAG flags for none vendor IE */
	pktflag = htod32(VNDR_IE_CUSTOM_FLAG);

	count = sizeof(ie_setbuf_t) + len - 1;
	buf = malloc(count);
	if (buf == NULL) {
		fprintf(stderr, "memory alloc failure\n");
		return -1;
	}

	ie_setbuf = (ie_setbuf_t *) buf;
	/* Copy the ie SET command ("add") to the buffer */
	strncpy(ie_setbuf->cmd, "add", VNDR_IE_CMD_LEN - 1);
	ie_setbuf->cmd[VNDR_IE_CMD_LEN - 1] = '\0';

	/* Buffer contains only 1 IE */
	iecount = htod32(1);
	memcpy((void *)&ie_setbuf->ie_buffer.iecount, &iecount, sizeof(int));

	memcpy((void *)&ie_setbuf->ie_buffer.ie_list[0].pktflag, &pktflag, sizeof(uint32));

	/* Now, add the IE to the buffer */
	ie_setbuf->ie_buffer.ie_list[0].ie_data.id = id;
	ie_setbuf->ie_buffer.ie_list[0].ie_data.len = len;

	memcpy((uchar *)&ie_setbuf->ie_buffer.ie_list[0].ie_data.data[0], data, len);

	err = wlu_var_setbuf(wl, "ie", buf, count);

	free(buf);
	return (err);
}
Ejemplo n.º 12
0
int wlmPaParametersSet(WLM_BANDRANGE bandrange,
	unsigned int a1, unsigned int b0, unsigned int b1)
{
	const pavars_t *pav = pavars;
	uint16 inpa[WL_PHY_PAVARS_LEN];
	int i = 0;

	pav += bandrange;
	inpa[i++] = pav->phy_type;
	inpa[i++] = pav->bandrange;
	inpa[i++] = pav->chain;
	inpa[i++] = b0;
	inpa[i++] = b1;
	inpa[i++] = a1;

	if (wlu_var_setbuf(irh, "pavars", inpa, WL_PHY_PAVARS_LEN * sizeof(uint16))) {
		printf("wlmPaParametersSet: %s\n", wlmLastError());
		return FALSE;
	}

	return TRUE;
}
static int
lua_set_led(lua_State *L, void *wl, lua_cmd_t *cmd, char *argv)
{
	int err;
	wl_led_info_t led;
	void	*ptr = NULL;

	memset(&led, 0, sizeof(wl_led_info_t));

	/* Read the original back so we don't toggle the activehi */
	if ((err = wlu_var_getbuf(wl, cmd->name, (void*)&led,
		sizeof(wl_led_info_t), &ptr)) < 0) {
		return err;
	}
	led.behavior = (uint32)strtoul(argv, NULL, 10);
	led.activehi = ((wl_led_info_t*)ptr)->activehi;

	if ((err = wlu_var_setbuf(wl, cmd->name, (void*)&led,
		sizeof(wl_led_info_t))) < 0) {
		return err;
	}
	return err;
}
Ejemplo n.º 14
0
int wl_wnm_url(void *wl, uchar datalen, uchar *url_data)
{
	wnm_url_t *url;
	int err;
	uchar *data;
	uchar count;
	count = sizeof(wnm_url_t) + datalen - 1;
	data = malloc(count);
	if (data == NULL) {
		fprintf(stderr, "memory alloc failure\n");
		return -1;
	}

	url = (wnm_url_t *) data;
	url->len = datalen;
	if (datalen > 0) {
		memcpy(url->data, url_data, datalen);
	}

	err = wlu_var_setbuf(wl, "wnm_url", data, count);
	free(data);

	return (err);
}
Ejemplo n.º 15
0
static int
wl_vndr_ie(void *wl, int bsscfg_idx, const char *command, uint32 pktflag, int len, uchar *data)
{
	vndr_ie_setbuf_t *ie_setbuf;
	int buflen, iecount;
	int err = 0;

	/* OUI is included in first 3 bytes of len and data */

	if ((pktflag &
	    ~(VNDR_IE_BEACON_FLAG |
	      VNDR_IE_PRBRSP_FLAG |
	      VNDR_IE_ASSOCRSP_FLAG |
	      VNDR_IE_AUTHRSP_FLAG |
	      VNDR_IE_PRBREQ_FLAG |
	      VNDR_IE_ASSOCREQ_FLAG))) {
		fprintf(stderr, "Invalid packet flag 0x%x (%d)\n", pktflag, pktflag);
		return -1;
	}

	if (len < VNDR_IE_MIN_LEN || len >= VNDR_IE_MAX_LEN) {
		fprintf(stderr, "Invalid length %d\n", len);
		return -1;
	}

	/* struct includes OUI + 1 byte */
	buflen = sizeof(vndr_ie_setbuf_t) - VNDR_IE_MIN_LEN - 1 + len;

	ie_setbuf = (vndr_ie_setbuf_t *) malloc(buflen);

	if (ie_setbuf == NULL) {
		fprintf(stderr, "memory alloc failure\n");
		return -1;
	}

	/* Copy the vndr_ie SET command ("add"/"del") to the buffer */
	strncpy(ie_setbuf->cmd, command, VNDR_IE_CMD_LEN - 1);
	ie_setbuf->cmd[VNDR_IE_CMD_LEN - 1] = '\0';


	/* Buffer contains only 1 IE */
	iecount = htod32(1);
	memcpy((void *)&ie_setbuf->vndr_ie_buffer.iecount, &iecount, sizeof(int));

	/*
	 * The packet flag bit field indicates the packets that will
	 * contain this IE
	 */
	pktflag = htod32(pktflag);
	memcpy((void *)&ie_setbuf->vndr_ie_buffer.vndr_ie_list[0].pktflag,
	       &pktflag, sizeof(uint32));

	/* Now, add the IE to the buffer */
	ie_setbuf->vndr_ie_buffer.vndr_ie_list[0].vndr_ie_data.len = (uchar)len;

	/* copy OUI */
	memcpy(&ie_setbuf->vndr_ie_buffer.vndr_ie_list[0].vndr_ie_data.oui[0],
		data, VNDR_IE_MIN_LEN);

	/* copy IE data */
	if (len - VNDR_IE_MIN_LEN > 0) {
		memcpy(&ie_setbuf->vndr_ie_buffer.vndr_ie_list[0].vndr_ie_data.data[0],
			&data[VNDR_IE_MIN_LEN], len - VNDR_IE_MIN_LEN);
	}

	if (bsscfg_idx == DEFAULT_BSSCFG_INDEX)
	err = wlu_var_setbuf(wl, "vndr_ie", ie_setbuf, buflen);
	else
		err = wlu_bssiovar_setbuf(wl, "vndr_ie", bsscfg_idx,
			ie_setbuf, buflen, buf, WLC_IOCTL_MAXLEN);

	free(ie_setbuf);

	return (err);
}
Ejemplo n.º 16
0
int wl_scan_abort(void *wl)
{
	return wlu_var_setbuf(wl, "scanabort", NULL, 0);
}