int wfaStaSetIBSSResp(BYTE *cmdBuf) { int done=0; dutCmdResponse_t *setIBSSResp = (dutCmdResponse_t *) (cmdBuf + 4); DPRINT_INFO(WFA_OUT, "Entering wfaStaSetIBSSResp ...\n"); switch(setIBSSResp->status) { case STATUS_RUNNING: DPRINT_INFO(WFA_OUT, "wfaStaIBSS running ...\n"); done = 1; break; case STATUS_COMPLETE: sprintf(wfaCAAgetData.gRespStr, "status,COMPLETE\r\n"); break; default: sprintf(wfaCAAgetData.gRespStr, "status,INVALID\r\n"); } DPRINT_INFO(WFA_OUT, "%s", wfaCAAgetData.gRespStr); wfaCtrlSend(wfaCAAgetData.gCaSockfd, (BYTE *)wfaCAAgetData.gRespStr, strlen(wfaCAAgetData.gRespStr)); return done; }
int wfaStaGetStatsResp(BYTE *cmdBuf) { int done=0; dutCmdResponse_t *getStatsResp = (dutCmdResponse_t *) (cmdBuf + 4); caStaGetStatsResp_t *stats = &getStatsResp->cmdru.ifStats; DPRINT_INFO(WFA_OUT, "Entering wfaStaGetStatsResp ...\n"); switch(getStatsResp->status) { case STATUS_RUNNING: DPRINT_INFO(WFA_OUT, "wfaStaGetStats running ...\n"); done = 1; break; case STATUS_COMPLETE: sprintf(wfaCAAgetData.gRespStr, "status,COMPLETE,txFrames,%i,rxFrames,%i,txMulticast,%i,rxMulticast,%i,fcsErrors,%i,txRetries,%i\r\n", stats->txFrames, stats->rxFrames, stats->txMulticast, stats->rxMulticast, stats->fcsErrors, stats->txRetries); break; case STATUS_ERROR: sprintf(wfaCAAgetData.gRespStr, "status,ERROR\r\n"); break; default: sprintf(wfaCAAgetData.gRespStr, "status,INVALID\r\n"); } DPRINT_INFO(WFA_OUT, "%s", wfaCAAgetData.gRespStr); wfaCtrlSend(wfaCAAgetData.gCaSockfd, (BYTE *)wfaCAAgetData.gRespStr, strlen(wfaCAAgetData.gRespStr)); return done; }
int wfaStaGetMacAddressResp(BYTE *cmdBuf) { int done=0; dutCmdResponse_t *getmacResp = (dutCmdResponse_t *) (cmdBuf + 4); DPRINT_INFO(WFA_OUT, "Entering wfaStaGetMacAddressResp ...\n"); switch(getmacResp->status) { case STATUS_RUNNING: DPRINT_INFO(WFA_OUT, "wfaStaGetMacAddress running ...\n"); done = 1; break; case STATUS_COMPLETE: sprintf(wfaCAAgetData.gRespStr, "status,COMPLETE,mac,%s\r\n", getmacResp->cmdru.mac); break; case STATUS_ERROR: sprintf(wfaCAAgetData.gRespStr, "status,COMPLETE,mac,00:00:00:00:00:00\r\n"); break; default: sprintf(wfaCAAgetData.gRespStr, "status,COMPLETE,mac,00:00:00:00:00:00\r\n"); } DPRINT_INFO(WFA_OUT, "%s", wfaCAAgetData.gRespStr); wfaCtrlSend(wfaCAAgetData.gCaSockfd, (BYTE *)wfaCAAgetData.gRespStr, strlen(wfaCAAgetData.gRespStr)); return done; }
int wfaStaSetEncryptionResp(BYTE *cmdBuf) { int done=0; dutCmdResponse_t *getBssidResp = (dutCmdResponse_t *) (cmdBuf + 4); DPRINT_INFO(WFA_OUT, "Entering wfaStaGetBSSIDResp ...\n"); switch(getBssidResp->status) { case STATUS_RUNNING: DPRINT_INFO(WFA_OUT, "wfaStaSetEncryption running ...\n"); done = 1; break; case STATUS_COMPLETE: sprintf(wfaCAAgetData.gRespStr, "status,COMPLETE,bssid,%s\r\n", getBssidResp->cmdru.bssid); break; case STATUS_ERROR: sprintf(wfaCAAgetData.gRespStr, "status,ERROR\r\n"); break; default: sprintf(wfaCAAgetData.gRespStr, "status,INVALID\r\n"); } DPRINT_INFO(WFA_OUT, " %s\n", wfaCAAgetData.gRespStr); wfaCtrlSend(wfaCAAgetData.gCaSockfd, (BYTE *)wfaCAAgetData.gRespStr, strlen(wfaCAAgetData.gRespStr)); return done; }
int wfaStaGetInfoResp(BYTE *cmdBuf) { dutCmdResponse_t *infoResp = (dutCmdResponse_t *)(cmdBuf + 4); int done = 0; switch(infoResp->status) { case STATUS_RUNNING: DPRINT_INFO(WFA_OUT, "wfaStaGetInfo running ...\n"); done = 1; break; case STATUS_COMPLETE: sprintf(wfaCAAgetData.gRespStr, "status,COMPLETE,%s\r\n", infoResp->cmdru.info); break; default: sprintf(wfaCAAgetData.gRespStr, "status,INVALID\r\n"); } DPRINT_INFO(WFA_OUT, "%s", wfaCAAgetData.gRespStr); wfaCtrlSend(wfaCAAgetData.gCaSockfd, (BYTE *)wfaCAAgetData.gRespStr, strlen(wfaCAAgetData.gRespStr)); return done; }
int wfaTrafficAgentPingStopResp(BYTE *cmdBuf) { int done=0; dutCmdResponse_t *stpResp = (dutCmdResponse_t *) (cmdBuf + 4); switch(stpResp->status) { case STATUS_RUNNING: DPRINT_INFO(WFA_OUT, "wfaTrafficAgentPingStop running ...\n"); done = 1; break; case STATUS_COMPLETE: { sprintf(wfaCAAgetData.gRespStr, "status,COMPLETE,sent,%d,replies,%d\r\n", stpResp->cmdru.pingStp.sendCnt, stpResp->cmdru.pingStp.repliedCnt); break; } default: sprintf(wfaCAAgetData.gRespStr, "status,INVALID\r\n"); } DPRINT_INFO(WFA_OUT, "%s", wfaCAAgetData.gRespStr); wfaCtrlSend(wfaCAAgetData.gCaSockfd, (BYTE *)wfaCAAgetData.gRespStr, strlen(wfaCAAgetData.gRespStr)); return done; }
int wfaStaGetPskResp(BYTE *cmdBuf) { int done=0; dutCmdResponse_t *p2pResp = (dutCmdResponse_t *) (cmdBuf + 4); caP2pStaGetPskResp_t *pskInfo= &p2pResp->cmdru.pskInfo; DPRINT_INFO(WFA_OUT, "Entering wfaStaGetPskResp ...\n"); switch(p2pResp->status) { case STATUS_RUNNING: DPRINT_INFO(WFA_OUT, "wfaStaGetPskResp running ...\n"); done = 1; break; case STATUS_COMPLETE: sprintf(wfaCAAgetData.gRespStr, "status,COMPLETE,passphrase,%s,ssid,%s\r\n", pskInfo->passPhrase,pskInfo->ssid); break; default: sprintf(wfaCAAgetData.gRespStr, "status,INVALID\r\n"); } DPRINT_INFO(WFA_OUT, "%s", wfaCAAgetData.gRespStr); wfaCtrlSend(wfaCAAgetData.gCaSockfd, (BYTE *)wfaCAAgetData.gRespStr, strlen(wfaCAAgetData.gRespStr)); return done; }
int wfaStaVerifyIpConnectResp(BYTE *cmdBuf) { int done=0; dutCmdResponse_t *verifyResp = (dutCmdResponse_t *)(cmdBuf + 4); DPRINT_INFO(WFA_OUT, "Entering wfaStaVerifyIpConnectResp\n"); switch(verifyResp->status) { case STATUS_RUNNING: DPRINT_INFO(WFA_OUT, "wfaStaVerifyConnect running ...\n"); done = 1; break; case STATUS_COMPLETE: sprintf(wfaCAAgetData.gRespStr, "status,COMPLETE,connected,%i\r\n", verifyResp->cmdru.connected); break; case STATUS_ERROR: sprintf(wfaCAAgetData.gRespStr, "status,ERROR\r\n"); default: sprintf(wfaCAAgetData.gRespStr, "status,INVALID\r\n"); } DPRINT_INFO(WFA_OUT, "%s", wfaCAAgetData.gRespStr); wfaCtrlSend(wfaCAAgetData.gCaSockfd, (BYTE *)wfaCAAgetData.gRespStr, strlen(wfaCAAgetData.gRespStr)); return done; }
int wfaStaP2pStartGrpFormResp(BYTE *cmdBuf) { int done=0; dutCmdResponse_t *p2pResp = (dutCmdResponse_t *) (cmdBuf + 4); DPRINT_INFO(WFA_OUT, "Entering wfaStaP2pStartGrpFormResp ...\n"); switch(p2pResp->status) { case STATUS_RUNNING: DPRINT_INFO(WFA_OUT, "wfaStaP2pStartGrpFormResp running ...\n"); done = 1; break; case STATUS_COMPLETE: sprintf(wfaCAAgetData.gRespStr, "status,COMPLETE,result,%s,groupid,%s\r\n", p2pResp->cmdru.p2presult,p2pResp->cmdru.grpid); break; default: sprintf(wfaCAAgetData.gRespStr, "status,INVALID\r\n"); } DPRINT_INFO(WFA_OUT, "%s", wfaCAAgetData.gRespStr); wfaCtrlSend(wfaCAAgetData.gCaSockfd, (BYTE *)wfaCAAgetData.gRespStr, strlen(wfaCAAgetData.gRespStr)); return done; }
int wfaDeviceGetInfoResp(BYTE *cmdBuf) { int done=1; dutCmdResponse_t *devInfoResp = (dutCmdResponse_t *) (cmdBuf + 4); caDeviceGetInfoResp_t *dinfo = &devInfoResp->cmdru.devInfo; switch(devInfoResp->status) { case STATUS_RUNNING: DPRINT_INFO(WFA_OUT, "wfaDeviceGetInfo running ...\n"); done = 1; break; case STATUS_COMPLETE: sprintf(wfaCAAgetData.gRespStr, "status,COMPLETE,vendor,%s,model,%s,version,%s\r\n", dinfo->vendor, dinfo->model, dinfo->version); break; default: sprintf(wfaCAAgetData.gRespStr, "status,INVALID\r\n"); } DPRINT_INFO(WFA_OUT, "%s", wfaCAAgetData.gRespStr); wfaCtrlSend(wfaCAAgetData.gCaSockfd, (BYTE *)wfaCAAgetData.gRespStr, strlen(wfaCAAgetData.gRespStr)); return done; }
/* * wfaStaSetEapTTLS(): * This is to set * 1. ssid * 2. username * 3. passwd * 4. encrypType - tkip or aes-ccmp * 5. keyManagementType - wpa or wpa2 * 6. trustedRootCA */ int wfaStaSetEapTTLS(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf) { int ret = 0; char cmdStr[WFA_CMD_STR_SZ]; caStaSetEapTTLS_t *setTTLS = (caStaSetEapTTLS_t *)caCmdBuf; char *ifname = setTTLS->intf; sprintf(cmdStr, "wpa_cli -i %s disable_network 0", ifname); system(cmdStr); sprintf(cmdStr, "wpa_cli -i %s set_network 0 ssid '\"%s\"'", ifname, setTTLS->ssid); system(cmdStr); DPRINT_INFO(WFA_OUT, "%s\n", cmdStr); sprintf(cmdStr, "wpa_cli -i %s set_network 0 identity '\"%s\"'", ifname, setTTLS->username); system(cmdStr); DPRINT_INFO(WFA_OUT, "%s\n", cmdStr); sprintf(cmdStr, "wpa_cli -i %s set_network 0 password '\"%s\"'", ifname, setTTLS->passwd); system(cmdStr); DPRINT_INFO(WFA_OUT, "%s\n", cmdStr); sprintf(cmdStr, "wpa_cli -i %s set_network 0 key_mgmt WPA-EAP", ifname); system(cmdStr); DPRINT_INFO(WFA_OUT, "%s\n", cmdStr); /* This may not need to set. if it is not set, default to take all */ // sprintf(cmdStr, "wpa_cli -i %s set_network 0 pairwise '\"%s\"", ifname, setTTLS->encrptype); // system(cmdStr); sprintf(cmdStr, "wpa_cli -i %s set_network 0 eap TTLS", ifname); system(cmdStr); DPRINT_INFO(WFA_OUT, "%s\n", cmdStr); sprintf(cmdStr, "wpa_cli -i %s set_network 0 ca_cert '\"%s/%s\"'", ifname, CERTIFICATES_PATH, setTTLS->trustedRootCA); system(cmdStr); DPRINT_INFO(WFA_OUT, "%s\n", cmdStr); sprintf(cmdStr, "wpa_cli -i %s set_network 0 proto WPA", ifname); system(cmdStr); DPRINT_INFO(WFA_OUT, "%s\n", cmdStr); sprintf(cmdStr, "wpa_cli -i %s set_network 0 anonymous_identity '\"anonymous\"'", ifname); system(cmdStr); DPRINT_INFO(WFA_OUT, "%s\n", cmdStr); sprintf(cmdStr, "wpa_cli -i %s set_network 0 phase2 '\"auth=MSCHAPV2\"'", ifname); system(cmdStr); DPRINT_INFO(WFA_OUT, "%s\n", cmdStr); sprintf(cmdStr, "wpa_cli -i %s enable_network 0", ifname); system(cmdStr); DPRINT_INFO(WFA_OUT, "%s\n", cmdStr); ret = STATUS_COMPLETE; wfaEncodeTLV(WFA_STA_SET_EAPTTLS_RESP_TLV, 4, (BYTE *)&ret, respBuf); *respLen = WFA_TLV_HDR_LEN + 4; return TRUE; }
/* * wfaTGConfig: store the traffic profile setting that will be used to * instruct traffic generation. * input: cmd -- not used * response: send success back to controller * return: success or fail * Note: the profile storage is a global space. */ int wfaTGConfig(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf) { int ret = FALSE; tgStream_t *myStream = NULL; dutCmdResponse_t *confResp = &gGenericResp; /* if the stream table over maximum, reset it */ if(slotCnt == WFA_MAX_TRAFFIC_STREAMS) slotCnt = 0; if(slotCnt == 0) { printf("resetting stream table\n"); wMEMSET(gStreams, 0, WFA_MAX_TRAFFIC_STREAMS*sizeof(tgStream_t)); } DPRINT_INFO(WFA_OUT, "entering tcConfig ...\n"); myStream = &gStreams[slotCnt++]; wMEMSET(myStream, 0, sizeof(tgStream_t)); wMEMCPY(&myStream->profile, caCmdBuf, len); myStream->id = ++streamId; /* the id start from 1 */ myStream->tblidx = slotCnt-1; #if 0 DPRINT_INFO(WFA_OUT, "profile %i direction %i dest ip %s dport %i source %s sport %i rate %i duration %i size %i class %i delay %i\n", myStream->profile.profile, myStream->profile.direction, myStream->profile.dipaddr, myStream->profile.dport, myStream->profile.sipaddr, myStream->profile.sport, myStream->profile.rate, myStream->profile.duration, myStream->profile.pksize, myStream->profile.trafficClass, myStream->profile.startdelay); #endif confResp->status = STATUS_COMPLETE; confResp->streamId = myStream->id; wfaEncodeTLV(WFA_TRAFFIC_AGENT_CONFIG_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)confResp, respBuf); *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t); return ret; }
static void shutdown_onchannelcallback(void *context) { struct vmbus_channel *channel = context; u32 recvlen; u64 requestid; u8 execute_shutdown = false; struct shutdown_msg_data *shutdown_msg; struct icmsg_hdr *icmsghdrp; struct icmsg_negotiate *negop = NULL; vmbus_recvpacket(channel, shut_txf_buf, PAGE_SIZE, &recvlen, &requestid); if (recvlen > 0) { DPRINT_DBG(VMBUS, "shutdown packet: len=%d, requestid=%lld", recvlen, requestid); icmsghdrp = (struct icmsg_hdr *)&shut_txf_buf[ sizeof(struct vmbuspipe_hdr)]; if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { prep_negotiate_resp(icmsghdrp, negop, shut_txf_buf); } else { shutdown_msg = (struct shutdown_msg_data *)&shut_txf_buf[ sizeof(struct vmbuspipe_hdr) + sizeof(struct icmsg_hdr)]; switch (shutdown_msg->flags) { case 0: case 1: icmsghdrp->status = HV_S_OK; execute_shutdown = true; DPRINT_INFO(VMBUS, "Shutdown request received -" " gracefull shutdown initiated"); break; default: icmsghdrp->status = HV_E_FAIL; execute_shutdown = false; DPRINT_INFO(VMBUS, "Shutdown request received -" " Invalid request"); break; }; } icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE; vmbus_sendpacket(channel, shut_txf_buf, recvlen, requestid, VM_PKT_DATA_INBAND, 0); } if (execute_shutdown == true) orderly_poweroff(false); }
int wfaDeviceGetInfo(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf) { caDeviceGetInfoResp_t dinfo; char cmdStr[WFA_CMD_STR_SZ]; FILE *fd; if ((fd = popen("/tmp/ASD/wl ver | awk '{print $7}'", "r")) == NULL){ printf("Couldn't open either /tmp/ASD/wl or awk\n"); dinfo.status = STATUS_ERROR; } else { memset(&dinfo, 0, sizeof(dinfo)); fgets(cmdStr, sizeof(cmdStr), fd); /* Ignore first line */ fgets(cmdStr, sizeof(cmdStr), fd); cmdStr[strlen(cmdStr) - 1] = 0; /* Get rid of NL */ pclose(fd); dinfo.status = STATUS_COMPLETE; sprintf(dinfo.vendor, "%.16s", "Broadcom"); sprintf(dinfo.version, "%.16s", cmdStr); sprintf(dinfo.model, "%.8s", "BRCM"); DPRINT_INFO(WFA_OUT, "Entering wfaDeviceGetInfo ...\n"); DPRINT_INFO(WFA_OUT, "status %i vendor %s model %s version %s\n", dinfo.status, dinfo.vendor, dinfo.model, dinfo.version); wfaEncodeTLV(WFA_DEVICE_GET_INFO_RESP_TLV, sizeof(dinfo), (BYTE *)&dinfo, respBuf); *respLen = WFA_TLV_HDR_LEN + sizeof(dinfo); } return TRUE; }
bcmSsidObj_t *bcmWfaSsidObjTblAdd(char *ssidStr) { bcmSsidObj_t *bso; DPRINT_INFO(WFA_OUT, "bcmWfaSsidObjTblAdd: ssidStr %s\n", ssidStr); if (bcmSsidIsGood(ssidStr) == FALSE) { return (NULL); } if ((bso = bcmWfaSsidTblSsidFind(ssidStr))) { DPRINT_ERR(WFA_OUT, "bcmWfaSsidObjTblAdd(%s): ssid already exists\n", ssidStr); return (bso); } if (!(bso = bcmWfaSsidTblFreeEntry())) { DPRINT_INFO(WFA_OUT, "no free entry\n"); return (NULL); } strcpy(bso->ssidStr, ssidStr); bso->bssType = BCM_BSS_INFRA; /* init it to infrastructure bss */ bso->primary_key = BCM_PRI_KEY_BAD; /* init it to bad one */ bsotbl.addCnt++; bsotbl.entries++; return (bso); }
/* * wfaStaSetUAPSD() * This is to set * 1. maxSPLength - 0,1,2,or 4 * 2. acBE * 3. acBK * 4. acVI * 5. acVO */ int wfaStaSetUAPSD(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf) { int ret = 0; int retVal = TRUE; caStaSetUAPSD_t *uapsd = (caStaSetUAPSD_t *)caCmdBuf; bcmSsidObj_t *bso; char *ssidStr; DPRINT_INFO(WFA_OUT, "maxSPLength %d acBE %d acBK %d acVI %d acVO %d\n", uapsd->maxSPLength, uapsd->acBE, uapsd->acBK, uapsd->acVI, uapsd->acVO); ssidStr = uapsd->ssid; if (!(bso = bcmWfaSsidTblSsidFind(ssidStr))) { if (!(bso = bcmWfaSsidObjTblAdd(ssidStr))) { DPRINT_INFO(WFA_OUT, "bcmWfaSsidObjTblAdd(%s) failed.\n", ssidStr); retVal = FALSE; goto exit; } } bso->maxSPLength = uapsd->maxSPLength; bso->acBE = uapsd->acBE; bso->acBK = uapsd->acBK; bso->acVI = uapsd->acVI; bso->acVO = uapsd->acVO; exit: ret = STATUS_COMPLETE; wfaEncodeTLV(WFA_STA_SET_UAPSD_RESP_TLV, 4, (BYTE *)&ret, respBuf); *respLen = WFA_TLV_HDR_LEN + 4; return retVal; }
static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice) { struct nvsp_message *revokePacket; int ret = 0; DPRINT_ENTER(NETVSC); if (NetDevice->ReceiveSectionCount) { DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeRevokeReceiveBuffer..."); revokePacket = &NetDevice->RevokePacket; memset(revokePacket, 0, sizeof(struct nvsp_message)); revokePacket->Header.MessageType = NvspMessage1TypeRevokeReceiveBuffer; revokePacket->Messages.Version1Messages.RevokeReceiveBuffer.Id = NETVSC_RECEIVE_BUFFER_ID; ret = NetDevice->Device->Driver->VmbusChannelInterface.SendPacket( NetDevice->Device, revokePacket, sizeof(struct nvsp_message), (unsigned long)revokePacket, VmbusPacketTypeDataInBand, 0); if (ret != 0) { DPRINT_ERR(NETVSC, "unable to send revoke receive " "buffer to netvsp"); DPRINT_EXIT(NETVSC); return -1; } } if (NetDevice->ReceiveBufferGpadlHandle) { DPRINT_INFO(NETVSC, "Tearing down receive buffer's GPADL..."); ret = NetDevice->Device->Driver->VmbusChannelInterface.TeardownGpadl( NetDevice->Device, NetDevice->ReceiveBufferGpadlHandle); if (ret != 0) { DPRINT_ERR(NETVSC, "unable to teardown receive buffer's gpadl"); DPRINT_EXIT(NETVSC); return -1; } NetDevice->ReceiveBufferGpadlHandle = 0; } if (NetDevice->ReceiveBuffer) { DPRINT_INFO(NETVSC, "Freeing up receive buffer..."); osd_PageFree(NetDevice->ReceiveBuffer, NetDevice->ReceiveBufferSize >> PAGE_SHIFT); NetDevice->ReceiveBuffer = NULL; }
int wfaStaUploadResp(BYTE *cmdBuf) { int done=0; dutCmdResponse_t *uploadResp = (dutCmdResponse_t *) (cmdBuf + 4); caStaUploadResp_t *upld = &uploadResp->cmdru.uld; switch(uploadResp->status) { case STATUS_RUNNING: DPRINT_INFO(WFA_OUT, "wfaStaUpload running ...\n"); done = 1; break; case STATUS_COMPLETE: sprintf(wfaCAAgetData.gRespStr, "status,COMPLETE,code,%i,%s\r\n", upld->seqnum, upld->bytes); break; case STATUS_ERROR: sprintf(wfaCAAgetData.gRespStr, "status,ERROR\r\n"); break; } DPRINT_INFO(WFA_OUT, "%s", wfaCAAgetData.gRespStr); wfaCtrlSend(wfaCAAgetData.gCaSockfd, (BYTE *)wfaCAAgetData.gRespStr, strlen(wfaCAAgetData.gRespStr)); return done; }
/* * The function is to set * 1. ssid * 2. passPhrase * 3. keyMangementType - wpa/wpa2 * 4. encrypType - tkip or aes-ccmp */ int wfaStaSetPSK(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf) { int ret = 0; int retVal = TRUE; caStaSetPSK_t *setPSK = (caStaSetPSK_t *)caCmdBuf; bcmSsidObj_t *bso; char *ssidStr; DPRINT_INFO(WFA_OUT, "wfaStaSetPSK()"); ssidStr = setPSK->ssid; if (!(bso = bcmWfaSsidTblSsidFind(ssidStr))) { if (!(bso = bcmWfaSsidObjTblAdd(ssidStr))) { DPRINT_ERR(WFA_OUT, "bcmWfaSsidObjTblAdd(%s) failed.\n", ssidStr); retVal = FALSE; goto exit; } } if (!strcmp(setPSK->keyMgmtType, "wpa")) { bso->wpa_auth = BCM_WPA_AUTH_PSK; /* WPA-PSK/WPA-Personal */ } else if (!strcmp(setPSK->keyMgmtType, "wpa2")) { bso->wpa_auth = BCM_WPA2_AUTH_PSK; /* WPA2-PSK/WPA2-Personal */ } else { DPRINT_ERR(WFA_OUT, "invalid key_mgmt %s", setPSK->keyMgmtType); retVal = FALSE; goto exit; } DPRINT_INFO(WFA_OUT, "wpa_auth %d\n", bso->wpa_auth); if (setPSK->encpType == ENCRYPT_TKIP) { bso->wsec = 3; } else if (setPSK->encpType == ENCRYPT_AESCCMP) { bso->wsec = 7; } else { DPRINT_ERR(WFA_OUT, "invalid encpType %d", setPSK->encpType); goto exit; } DPRINT_INFO(WFA_OUT, "encpType %d wsec %d\n", setPSK->encpType, bso->wsec); strcpy((char *)bso->passphrase, (char *)setPSK->passphrase); bso->auth = 0; if (wfa_defined_debug & (WFA_DEBUG_ERR | WFA_DEBUG_INFO)) { bcmWfaSsidObjPrint(bso); } retVal = TRUE; exit: ret = STATUS_COMPLETE; wfaEncodeTLV(WFA_STA_SET_PSK_RESP_TLV, 4, (BYTE *)&ret, respBuf); *respLen = WFA_TLV_HDR_LEN + 4; return retVal; }
/* Not sure what the intention is, but I am using this routine * as storing info only, no action. Action is taken when we actually associate */ int wfaStaSetIBSS(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf) { int ret; int retVal = TRUE; caStaSetIBSS_t *setIBSS = (caStaSetIBSS_t *)caCmdBuf; bcmSsidObj_t *bso; int idx; char *ssidStr; DPRINT_INFO(WFA_OUT, "wfaStaSetIBSS()\n"); /* Save the settings for when we need them */ ssidStr = setIBSS->ssid; if (!(bso = bcmWfaSsidTblSsidFind(ssidStr))) { if (!(bso = bcmWfaSsidObjTblAdd(ssidStr))) { DPRINT_INFO(WFA_OUT, "bcmWfaSsidObjTblAdd(%s) failed.\n", ssidStr); retVal = FALSE; goto exit; } } bso->bssType = BCM_BSS_INDEPENDENT; if (setIBSS->channel) { bso->channel = setIBSS->channel; } bso->wsec = (!setIBSS->encpType) ? 0 : 1; for(idx = 0; idx < 4; idx++) { if(setIBSS->keys[idx][0] != '\0') { strcpy(bso->keys[idx], setIBSS->keys[idx]); } else { bzero(bso->keys[idx], BCM_WEP_KEY_SIZE_MAX); } } if ((setIBSS->activeKeyIdx > 0) && (setIBSS->activeKeyIdx < 5)) { /* move the index range from (1 to 4) to (0 to 3) */ bso->primary_key = setIBSS->activeKeyIdx - 1; } if (wfa_defined_debug & (WFA_DEBUG_ERR | WFA_DEBUG_INFO)) { bcmWfaSsidObjPrint(bso); } exit: ret = STATUS_COMPLETE; wfaEncodeTLV(WFA_STA_SET_IBSS_RESP_TLV, 4, (BYTE *)&ret, respBuf); *respLen = WFA_TLV_HDR_LEN + 4; return retVal; }
/* * wfaSetEncryption(): * The function is to set the wireless interface with WEP or none. * Input parameters: * 1. I/F * 2. ssid * 3. encpType - wep or none * Optional: * 4. key1 * 5. key2 * 6. key3 * 7. key4 * 8. activeKey Index : 1, 2, 3, or 4 */ int wfaSetEncryption(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf) { int ret = 0; int retVal = TRUE; caStaSetEncryption_t *setEncryp = (caStaSetEncryption_t *)caCmdBuf; int idx; bcmSsidObj_t *bso; char * ssidStr; DPRINT_INFO(WFA_OUT, "wfaSetEncryption()\n"); /* Save the settings for when we need them */ ssidStr = setEncryp->ssid; if (!(bso = bcmWfaSsidTblSsidFind(ssidStr))) { if (!(bso = bcmWfaSsidObjTblAdd(ssidStr))) { DPRINT_INFO(WFA_OUT, "bcmWfaSsidObjTblAdd(%s) failed.\n", ssidStr); retVal = FALSE; goto exit; } } /* set Key management to NONE (NO WPA) for plaintext or WEP */ bso->wpa_auth = BCM_WPA_AUTH_DISABLED; for(idx = 0; idx < 4; idx++) { if(setEncryp->keys[idx][0] != '\0') { strcpy(bso->keys[idx], setEncryp->keys[idx]); } else { bzero(bso->keys[idx], BCM_WEP_KEY_SIZE_MAX); } } if ((setEncryp->activeKeyIdx > 0) && (setEncryp->activeKeyIdx < 5)) { /* move the index range from (1 to 4) to (0 to 3) */ bso->primary_key = setEncryp->activeKeyIdx - 1; } bso->wsec = (!setEncryp->encpType) ? 0 : 1; if (wfa_defined_debug & (WFA_DEBUG_ERR | WFA_DEBUG_INFO)) { bcmWfaSsidObjPrint(bso); } exit: ret = STATUS_COMPLETE; wfaEncodeTLV(WFA_STA_SET_ENCRYPTION_RESP_TLV, 4, (BYTE *)&ret, respBuf); *respLen = WFA_TLV_HDR_LEN + 4; return retVal; }
/* * wfaStaGetMacAddress() * This function is to retrieve the MAC address of a wireless I/F. */ int wfaStaGetMacAddress(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf) { dutCmdResponse_t getmacResp; FILE *tmpfd; DPRINT_INFO(WFA_OUT, "Entering wfaStaGetMacAddress ...\n"); if ((tmpfd = popen("/tmp/ASD/wl dump | grep perm | awk '{print $4}'", "r")) == NULL){ int status = STATUS_ERROR; wfaEncodeTLV(WFA_STA_GET_MAC_ADDRESS_RESP_TLV, 4, (BYTE *)&status, respBuf); *respLen = WFA_TLV_HDR_LEN + 4; DPRINT_ERR(WFA_ERR, "Pipe open for wl dump failed\n"); return FALSE; } fgets(getmacResp.cmdru.mac, sizeof(getmacResp.cmdru.mac), tmpfd); getmacResp.cmdru.mac[strlen(getmacResp.cmdru.mac) - 1] = 0; /* Get rid of NL */ printf("get_mac_addr: returning mac :%s:\n", getmacResp.cmdru.mac); pclose (tmpfd); getmacResp.status = STATUS_COMPLETE; wfaEncodeTLV(WFA_STA_GET_MAC_ADDRESS_RESP_TLV, sizeof(getmacResp), (BYTE *)&getmacResp, respBuf); *respLen = WFA_TLV_HDR_LEN + sizeof(getmacResp); return TRUE; }
/* * wfaStaIsConnected(): * The function is to check whether the station's wireless I/F has * already connected to an AP. */ int wfaStaIsConnected(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf) { char cmdStr[WFA_CMD_STR_SZ]; FILE *tmpfd; dutCmdResponse_t staConnectResp; DPRINT_INFO(WFA_OUT, "Entering isConnected ...\n"); /* Associated gets long response */ if ((tmpfd = popen("/tmp/ASD/wl assoc | wc -l", "r")) == NULL){ printf("wc -l failed\n"); } fgets(cmdStr, sizeof(cmdStr), tmpfd); pclose(tmpfd); /* Short response means not associated */ if (atoi(cmdStr) <= 2) staConnectResp.cmdru.connected = 0; else staConnectResp.cmdru.connected = 1; /* * Report back the status: Complete or Failed. */ staConnectResp.status = STATUS_COMPLETE; wfaEncodeTLV(WFA_STA_IS_CONNECTED_RESP_TLV, sizeof(staConnectResp), (BYTE *)&staConnectResp, respBuf); *respLen = WFA_TLV_HDR_LEN + sizeof(staConnectResp); return TRUE; }
int storvsc_dev_remove(struct hv_device *device) { struct storvsc_device *stor_device; DPRINT_INFO(STORVSC, "disabling storage device (%p)...", device->ext); stor_device = release_stor_device(device); /* * At this point, all outbound traffic should be disable. We * only allow inbound traffic (responses) to proceed so that * outstanding requests can be completed. */ storvsc_wait_to_drain(stor_device); stor_device = final_release_stor_device(device); /* Close the channel */ vmbus_close(device->channel); free_stor_device(stor_device); return 0; }
/* * wfaStaGetStats(): * The function is to retrieve the statistics of the I/F's layer 2 txFrames, * rxFrames, txMulticast, rxMulticast, fcsErrors/crc, and txRetries. * Currently there is not definition how to use these info. */ int wfaStaGetStats(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf) { int ret = 0; caStaGetStatsResp_t statsResp; FILE *fd; char cmdStr[256]; DPRINT_INFO(WFA_OUT, "Entering wfaStaGetStats ...\n"); if ((fd = popen("/tmp/ASD/wl dump stats | grep txframe | awk '{print $2,\"\\n\",$10}'", "r")) == NULL){ DPRINT_ERR(WFA_ERR, "Couldn't get txframe stats\n"); goto wfaStaGetStats_error; } else { fgets(cmdStr, sizeof(cmdStr), fd); /* line 1: tx frame */ statsResp.txFrames = atoi(cmdStr); fgets(cmdStr, sizeof(cmdStr), fd); /* line 2: rx frame */ statsResp.rxFrames = atoi(cmdStr); pclose(fd); } if ((fd = popen("/tmp/ASD/wl dump stats | grep txmulti | awk '{print $4, \"\\n\", $6 + $8}'", "r")) == NULL){ DPRINT_ERR(WFA_ERR, "Couldn't get d11_txmulti stats\n"); goto wfaStaGetStats_error; } else { fgets(cmdStr, sizeof(cmdStr), fd); /* line 1: txmulti */ statsResp.txMulticast = atoi(cmdStr); fgets(cmdStr, sizeof(cmdStr), fd); /* line 2: d11_txretry + d11_txretrie */ statsResp.txRetries = atoi(cmdStr); pclose(fd); } if ((fd = popen("/tmp/ASD/wl dump stats | grep rxdfrmmcast | awk '{print $6 + $8}'", "r")) == NULL){ DPRINT_ERR(WFA_ERR, "Couldn't get rxdfrmmcast stats\n"); goto wfaStaGetStats_error; } else { fgets(cmdStr, sizeof(cmdStr), fd); /* data + mngment mcast frames */ statsResp.rxMulticast = atoi(cmdStr); pclose(fd); } if ((fd = popen("/tmp/ASD/wl dump stats | grep rxbadfcs | awk '{print $8}'", "r")) == NULL){ DPRINT_ERR(WFA_ERR, "Couldn't get rxbadfcs stats\n"); goto wfaStaGetStats_error; } else { fgets(cmdStr, sizeof(cmdStr), fd); statsResp.fcsErrors = atoi(cmdStr); pclose(fd); } statsResp.status = STATUS_COMPLETE; wfaEncodeTLV(WFA_STA_GET_STATS_RESP_TLV, sizeof(statsResp), (BYTE *)&statsResp, respBuf); *respLen = WFA_TLV_HDR_LEN + sizeof(statsResp); return TRUE; wfaStaGetStats_error: ret = STATUS_ERROR; wfaEncodeTLV(WFA_STA_GET_STATS_RESP_TLV, 4, (BYTE *)&ret, respBuf); *respLen = WFA_TLV_HDR_LEN + 4; return FALSE; }
static void netvsc_xmit_completion(void *context) { struct hv_netvsc_packet *packet = (struct hv_netvsc_packet *)context; struct sk_buff *skb = (struct sk_buff *) (unsigned long)packet->Completion.Send.SendCompletionTid; struct net_device *net; DPRINT_ENTER(NETVSC_DRV); kfree(packet); if (skb) { net = skb->dev; dev_kfree_skb_any(skb); if (netif_queue_stopped(net)) { DPRINT_INFO(NETVSC_DRV, "net device (%p) waking up...", net); netif_wake_queue(net); } } DPRINT_EXIT(NETVSC_DRV); }
static void netvsc_drv_exit(void) { struct netvsc_driver *netvsc_drv_obj = &g_netvsc_drv.drv_obj; struct driver_context *drv_ctx = &g_netvsc_drv.drv_ctx; struct device *current_dev; int ret; while (1) { current_dev = NULL; /* Get the device */ ret = driver_for_each_device(&drv_ctx->driver, NULL, ¤t_dev, netvsc_drv_exit_cb); if (ret) DPRINT_WARN(NETVSC_DRV, "driver_for_each_device returned %d", ret); if (current_dev == NULL) break; /* Initiate removal from the top-down */ DPRINT_INFO(NETVSC_DRV, "unregistering device (%p)...", current_dev); device_unregister(current_dev); } if (netvsc_drv_obj->base.OnCleanup) netvsc_drv_obj->base.OnCleanup(&netvsc_drv_obj->base); vmbus_child_driver_unregister(drv_ctx); return; }
/* * wfaStaSetIpConfig(): * The function is to set the ip configuration to a wireless I/F. * 1. IP address * 2. Mac address * 3. default gateway * 4. dns nameserver (pri and sec). */ int wfaStaSetIpConfig(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf) { dutCommand_t *setIpConf = (dutCommand_t *)caCmdBuf; char cmds[128]; int ret = 0; caStaSetIpConfig_t *ipconfig = &setIpConf->cmdsu.ipconfig; DPRINT_INFO(WFA_OUT, "entering wfaStaSetIpConfig ...\n"); /* * Use command 'ifconfig' to configure the interface ip address, mask. * (Linux specific). */ if (!strlen(ipconfig->intf) || !strlen(ipconfig->ipaddr)){ ret = STATUS_ERROR; wfaEncodeTLV(WFA_STA_SET_IP_CONFIG_RESP_TLV, 4, (BYTE *)&ret, respBuf); *respLen = WFA_TLV_HDR_LEN + 4; return TRUE; } sprintf(cmds, "%s %s %s ", IFCONFIG_PATH, ipconfig->intf, ipconfig->ipaddr); if (strlen(ipconfig->mask)) sprintf(&cmds[strlen(cmds)], "netmask %s ", ipconfig->mask); system(cmds); DPRINT_INFO(WFA_OUT, "%s\n", "doing ifconfig"); /* use command 'route add' to set set gatewway (linux specific) */ if(ipconfig->defGateway[0]) { sprintf(cmds, "%s add default gw %s > /dev/null 2>&1", ROUTE_PATH, ipconfig->defGateway); system(cmds); DPRINT_INFO(WFA_OUT, "%s\n", "doing route add"); } /* set dns (linux specific) */ if (ipconfig->pri_dns[0]){ sprintf(cmds, "cp /etc/resolv.conf /tmp/resolv.conf.bk"); system(cmds); sprintf(cmds, "echo nameserv %s > /etc/resolv.conf", ipconfig->pri_dns); system(cmds); sprintf(cmds, "echo nameserv %s >> /etc/resolv.conf", ipconfig->sec_dns); system(cmds); } ret = STATUS_COMPLETE; wfaEncodeTLV(WFA_STA_SET_IP_CONFIG_RESP_TLV, 4, (BYTE *)&ret, respBuf); *respLen = WFA_TLV_HDR_LEN + 4; return TRUE; }
void bcmWfaSsidObjTblDel(char *ssidStr) { bcmSsidObj_t *bso; DPRINT_INFO(WFA_OUT, "bcmWfaSsidObjTblDel: ssidStr %s\n", ssidStr); bso = bcmWfaSsidTblSsidFind(ssidStr); if (bso == NULL) { return; } DPRINT_INFO(WFA_OUT, "bcmWfaSsidObjTblDel: deleting bso %p\n", bso); bzero(bso, sizeof(bcmSsidObj_t)); bsotbl.delCnt++; bsotbl.entries--; }
/* * wfaStaVerifyIpConnection(): * The function is to verify if the station has IP connection with an AP by * send ICMP/pings to the AP. */ int wfaStaVerifyIpConnection(int len, BYTE *caCmdBuf, int *respLen, BYTE *respBuf) { dutCommand_t *verip = (dutCommand_t *)caCmdBuf; char cmdStr[WFA_CMD_STR_SZ]; FILE *tmpfile; dutCmdResponse_t verifyIpResp; dutCommand_t vvv; DPRINT_INFO(WFA_OUT, "Entering wfaStaVerifyIpConnection ...\n"); memcpy(&vvv, caCmdBuf, sizeof(dutCommand_t)); /* set timeout value in case not set */ if(verip->cmdsu.verifyIp.timeout <= 0) verip->cmdsu.verifyIp.timeout = 10; /* execute the ping command and pipe the result to a tmp file */ sprintf(cmdStr, "ping %s -c 3 -W %d | grep '100%%'", verip->cmdsu.verifyIp.dipaddr, verip->cmdsu.verifyIp.timeout); DPRINT_INFO(WFA_OUT, "%s\n", cmdStr); if (strlen(verip->cmdsu.verifyIp.dipaddr) == 0 || ((tmpfile = popen(cmdStr, "r")) == NULL)){ int status = STATUS_ERROR; wfaEncodeTLV(WFA_STA_VERIFY_IP_CONNECTION_RESP_TLV, 4, (BYTE *)&status, respBuf); *respLen = WFA_TLV_HDR_LEN + 4; DPRINT_ERR(WFA_ERR, "Could not execute %s\n", cmdStr); return FALSE; } verifyIpResp.status = STATUS_COMPLETE; if (fgets(cmdStr, sizeof(cmdStr), tmpfile) == NULL){ verifyIpResp.cmdru.connected = 1; } else{ verifyIpResp.cmdru.connected = 0; } pclose(tmpfile); wfaEncodeTLV(WFA_STA_VERIFY_IP_CONNECTION_RESP_TLV, sizeof(dutCmdResponse_t), (BYTE *)&verifyIpResp, respBuf); *respLen = WFA_TLV_HDR_LEN + sizeof(dutCmdResponse_t); return TRUE; }