static SANE_Status usb_send_command (struct scanner *s, struct cmd *c, struct response *r, void *buf) { SANE_Status st; struct bulk_header *h = (struct bulk_header *) buf; u8 resp[sizeof (*h) + STATUS_SIZE]; size_t sz = sizeof (*h) + MAX_CMD_SIZE; memset (h, 0, sz); h->length = cpu2be32 (sz); h->type = cpu2be16 (COMMAND_BLOCK); h->code = cpu2be16 (COMMAND_CODE); memcpy (h + 1, c->cmd, c->cmd_size); st = sanei_usb_write_bulk (s->file, (const SANE_Byte *) h, &sz); if (st) return st; if (sz != sizeof (*h) + MAX_CMD_SIZE) return SANE_STATUS_IO_ERROR; if (c->dir == CMD_IN) { sz = sizeof (*h) + c->data_size; st = sanei_usb_read_bulk (s->file, (SANE_Byte *) h, &sz); c->data = h + 1; c->data_size = sz - sizeof (*h); if (st || sz < sizeof (*h)) { st = sanei_usb_release_interface (s->file, 0); if (st) return st; st = sanei_usb_claim_interface (s->file, 0); if (st) return st; r->status = CHECK_CONDITION; return SANE_STATUS_GOOD; } } else if (c->dir == CMD_OUT) { sz = sizeof (*h) + c->data_size; memset (h, 0, sizeof (*h)); h->length = cpu2be32 (sizeof (*h) + c->data_size); h->type = cpu2be16 (DATA_BLOCK); h->code = cpu2be16 (DATA_CODE); memcpy (h + 1, c->data, c->data_size); st = sanei_usb_write_bulk (s->file, (const SANE_Byte *) h, &sz); if (st) return st; } sz = sizeof (resp); st = sanei_usb_read_bulk (s->file, resp, &sz); if (st || sz != sizeof (resp)) return SANE_STATUS_IO_ERROR; r->status = be2cpu32 (*((u32 *) (resp + sizeof (*h)))); return st; }
/* ======================================================================== Routine Description: Send EAPoL-Start packet to AP. Arguments: pAd - NIC Adapter pointer Return Value: None IRQL = DISPATCH_LEVEL Note: Actions after link up 1. Change the correct parameters 2. Send EAPOL - START ======================================================================== */ VOID WpaSendEapolStart( IN PRTMP_ADAPTER pAd, IN PUCHAR pBssid) { IEEE8021X_FRAME Packet; UCHAR Header802_3[14]; DBGPRINT(RT_DEBUG_TRACE, ("-----> WpaSendEapolStart\n")); NdisZeroMemory(Header802_3,sizeof(UCHAR)*14); MAKE_802_3_HEADER(Header802_3, pBssid, &pAd->CurrentAddress[0], EAPOL); /* Zero message 2 body */ NdisZeroMemory(&Packet, sizeof(Packet)); Packet.Version = EAPOL_VER; Packet.Type = EAPOLStart; Packet.Length = cpu2be16(0); /* Copy frame to Tx ring */ RTMPToWirelessSta((PRTMP_ADAPTER)pAd, &pAd->MacTab.Content[BSSID_WCID], Header802_3, LENGTH_802_3, (PUCHAR)&Packet, 4, TRUE); DBGPRINT(RT_DEBUG_TRACE, ("<----- WpaSendEapolStart\n")); }
static void cmdline_options(l argc,void *argv[]) { #define OPTION(string) strncmp(string,argv[j],sizeof(string)-1)==0 #define CHECK_ARG if(argc<=j+1){usage();exit(0);} for(i j=1;j<argc;j+=2){ if(OPTION("-inet")){ CHECK_ARG u64 len=0; if(!strnlen(&len,argv[j+1],sizeof("xxx.xxx.xxx.xxx")-1)){ PERR("FATAL:invalid listening IPv4 address(size):%s\n",argv[j+1]); exit(-1); } if(!str_2ipv4_blk((u32*)&srv_addr.sin_addr,argv[j+1],argv[j+1]+len-1)){ PERR("FATAL:invalid listening IPv4 address(format):%s\n",argv[j+1]); exit(-1); } }else if(OPTION("-port")){ CHECK_ARG if(!dec2u16(&srv_addr.sin_port,argv[j+1])){ PERR("FATAL:failed network port conversion:%s\n",argv[j+1]); exit(-1); } srv_addr.sin_port=cpu2be16(srv_addr.sin_port); }else if(OPTION("-psmax")){
VOID ApcliWpaSendEapolStart( IN PRTMP_ADAPTER pAd, IN PUCHAR pBssid, IN PMAC_TABLE_ENTRY pMacEntry, IN PAPCLI_STRUCT pApCliEntry) { IEEE8021X_FRAME Packet; UCHAR Header802_3[14]; DBGPRINT(RT_DEBUG_TRACE, ("-----> ApCliWpaSendEapolStart\n")); NdisZeroMemory(Header802_3,sizeof(UCHAR)*14); MAKE_802_3_HEADER(Header802_3, pBssid, &pApCliEntry->CurrentAddress[0], EAPOL); // Zero message 2 body NdisZeroMemory(&Packet, sizeof(Packet)); Packet.Version = EAPOL_VER; Packet.Type = EAPOLStart; Packet.Length = cpu2be16(0); // Copy frame to Tx ring RTMPToWirelessSta((PRTMP_ADAPTER)pAd, pMacEntry, Header802_3, LENGTH_802_3, (PUCHAR)&Packet, 4, TRUE); DBGPRINT(RT_DEBUG_TRACE, ("<----- WpaSendEapolStart\n")); }
SANE_Status kvs40xx_set_timeout (struct scanner * s, int timeout) { u16 t = cpu2be16 ((u16) timeout); struct cmd c = { {0}, 10, NULL, 0, CMD_OUT }; c.data = &t; c.data_size = sizeof (t); c.cmd[0] = SET_TIMEOUT; c.cmd[2] = 0x8d; copy16 (c.cmd + 7, cpu2be16 (sizeof (t))); if (s->bus == USB) sanei_usb_set_timeout (timeout * 1000); return send_command (s, &c); }
SANE_Status kvs40xx_set_window (struct scanner * s, int wnd_id) { struct window wnd; struct cmd c = { {0}, 10, NULL, 0, CMD_OUT }; c.data = &wnd; c.data_size = sizeof (wnd); c.cmd[0] = SET_WINDOW; copy16 (c.cmd + 7, cpu2be16 (sizeof (wnd))); kvs40xx_init_window (s, &wnd, wnd_id); return send_command (s, &c); }
INT NfcBuildOOBDevPasswdTLV( IN PRTMP_ADAPTER pAd, IN PWSC_CTRL pWscCtrl, IN UCHAR HandoverType, OUT UCHAR *pbuf, OUT USHORT *pBufLen) { INT Status = NDIS_STATUS_SUCCESS; UCHAR *TB = NULL;; PUCHAR pData = NULL, pSrcData = NULL; USHORT PasswdID = 0, len; PWSC_REG_DATA pReg = (PWSC_REG_DATA) &pWscCtrl->RegData; INT Len = 0, templen = 0; INT DH_Len = 0, idx; UCHAR HashData[SHA256_DIGEST_SIZE]; INT nfc_dev_passwd_len=0; #ifdef WSC_V2_SUPPORT PWSC_TLV pWscTLV = &pWscCtrl->WscV2Info.ExtraTlv; #endif /* WSC_V2_SUPPORT */ os_alloc_mem(pAd, (UCHAR **)&pData, (NFC_WSC_TLV_SIZE*sizeof(UCHAR))); if (pData == NULL) { return NDIS_STATUS_RESOURCES; } os_alloc_mem(pAd, (UCHAR **)&TB, (128*sizeof(UCHAR))); if (pData == NULL) { os_free_mem(NULL, pData); return NDIS_STATUS_RESOURCES; } DH_Len = sizeof(pWscCtrl->RegData.Pke); /* Enrollee 192 random bytes for DH key generation */ for (idx = 0; idx < 192; idx++) pWscCtrl->RegData.EnrolleeRandom[idx] = RandomByte(pAd); RT_DH_PublicKey_Generate ( WPS_DH_G_VALUE, sizeof(WPS_DH_G_VALUE), WPS_DH_P_VALUE, sizeof(WPS_DH_P_VALUE), pWscCtrl->RegData.EnrolleeRandom, sizeof(pWscCtrl->RegData.EnrolleeRandom), pWscCtrl->RegData.Pke, (UINT *) &DH_Len); /* For Handover case, We may as Registrar So keep the same public key for Registrar */ RTMPMoveMemory(pWscCtrl->RegData.Pkr, pWscCtrl->RegData.Pke, DH_Len); hex_dump("Pkr", pWscCtrl->RegData.Pkr, DH_Len); hex_dump("Pke", pWscCtrl->RegData.Pkr, DH_Len); RT_SHA256(&pWscCtrl->RegData.Pke[0], 192, &HashData[0]); RTMPMoveMemory(&pWscCtrl->NfcPasswdHash[0], &HashData[0], NFC_DEV_PASSWD_HASH_LEN); hex_dump("NfcBuildOOBDevPasswdTLV - Public Key HashData", &HashData[0], 20); if (HandoverType == TYPE_PASSWDHO_S || HandoverType == TYPE_PASSWDHO_R) { PasswdID = DEV_PASS_ID_NFC_HANDOVER; pWscCtrl->NfcPasswdID = cpu2be16(PasswdID); NdisZeroMemory(&pWscCtrl->NfcPasswd[0], 32); pWscCtrl->NfcPasswdLen = NFC_DEV_PASSWD_LEN; } else { PasswdID = (RandomByte(pAd) << 8) + RandomByte(pAd); if (PasswdID < 0x10) PasswdID = 0x10; pWscCtrl->NfcPasswdID = cpu2be16(PasswdID); NfcGenRandomPasswd(pAd, pWscCtrl); hex_dump("NfcBuildOOBDevPasswdTLV - NfcPasswd", &pWscCtrl->NfcPasswd[0], NFC_DEV_PASSWD_LEN); } pSrcData = pData; NdisZeroMemory(pData, NFC_WSC_TLV_SIZE); NdisZeroMemory(&TB[0], 128); if (HandoverType == TYPE_PASSWDHO_R || HandoverType == TYPE_PASSWDHO_S) { /* Reserv for "Length of WSC attribute" */ pData += 2; } hex_dump("NfcBuildOOBDevPasswdTLV - 1 pSrcData", pSrcData, Len); NdisMoveMemory(&TB[0], &HashData[0], NFC_DEV_PASSWD_HASH_LEN); NdisMoveMemory(&TB[20], &pWscCtrl->NfcPasswdID, sizeof(pWscCtrl->NfcPasswdID)); if (HandoverType == TYPE_PASSWORD) { /* New SPEC Handover remove this part. */ NdisMoveMemory(&TB[22], &pWscCtrl->NfcPasswd[0], NFC_DEV_PASSWD_LEN); nfc_dev_passwd_len = NFC_DEV_PASSWD_LEN; } templen = AppendWSCTLV(WSC_ID_OOB_DEV_PWD, pData, &TB[0], NFC_DEV_PASSWD_HASH_LEN+sizeof(PasswdID)+nfc_dev_passwd_len); pData += templen; Len += templen; hex_dump("NfcBuildOOBDevPasswdTLV - 2 pSrcData", pSrcData, Len); if (HandoverType == TYPE_PASSWDHO_S) /* Build for Handover Select Message */ { templen = AppendWSCTLV(WSC_ID_SSID, pData, pAd->ApCfg.MBSSID[0].Ssid, pAd->ApCfg.MBSSID[0].SsidLen); pData += templen; Len += templen; /* Optional items. RF_Band, AP_Channel and MAC_Address */ UCHAR RF_Band; if (pAd->CommonCfg.Channel > 14) RF_Band = 0x02; /* 5.0GHz */ else RF_Band = 0x01; /* 2.4GHz */ templen = AppendWSCTLV(WSC_ID_RF_BAND, pData, &RF_Band, 0); pData += templen; Len += templen; USHORT Channel = 0; Channel = pAd->CommonCfg.Channel; #ifdef RT_BIG_ENDIAN Channel = SWAP16(Channel); #endif /* RT_BIG_ENDIAN */ templen = AppendWSCTLV(WSC_ID_AP_CHANNEL, pData, (UINT8 *)&Channel, 0); pData += templen; Len += templen; templen = AppendWSCTLV(WSC_ID_MAC_ADDR, pData, pAd->CommonCfg.Bssid, 0); pData += templen; Len += templen; } else if (HandoverType == TYPE_PASSWDHO_R) /* Build for Handover Request Message */ { templen = AppendWSCTLV(WSC_ID_UUID_E, pData, &pWscCtrl->Wsc_Uuid_E[0], 0); pData += templen; Len += templen; } #ifdef WSC_V2_SUPPORT if (pWscCtrl->WscV2Info.bEnableWpsV2) { /* Version2 */ WscGenV2Msg(pWscCtrl, FALSE, NULL, 0, &pData, &Len); /* Extra attribute that is not defined in WSC Sepc. */ if (pWscTLV->pTlvData && pWscTLV->TlvLen) { templen = AppendWSCTLV(pWscTLV->TlvTag, pData, (UINT8 *)pWscTLV->pTlvData, pWscTLV->TlvLen); pData += templen; Len += templen; } } #endif // WSC_V2_SUPPORT // if (HandoverType == TYPE_PASSWDHO_R || HandoverType == TYPE_PASSWDHO_S) { /*Assign for "Length of WSC attribute" */ len = cpu2be16(Len); memcpy(pSrcData, &len, 2); hex_dump("NfcBuildOOBDevPasswdTLV - pSrcData", pSrcData, Len+2); } else hex_dump("NfcBuildOOBDevPasswdTLV - pSrcData", pSrcData, Len); if (pbuf && (Len < NFC_WSC_TLV_SIZE)) { if (HandoverType == TYPE_PASSWDHO_R || HandoverType == TYPE_PASSWDHO_S) { NdisMoveMemory(pbuf, pSrcData, Len+2); *pBufLen = (USHORT)Len+2; } else { NdisMoveMemory(pbuf, pSrcData, Len); *pBufLen = (USHORT)Len; } hex_dump("NfcBuildOOBDevPasswdTLV", pbuf, *pBufLen); } else { DBGPRINT(RT_DEBUG_TRACE, ("%s: (Len=%d)\n", __FUNCTION__, Len)); Status = NDIS_STATUS_RESOURCES; } os_free_mem(NULL, pSrcData); os_free_mem(NULL, TB); return Status; }
INT NfcBuildWscProfileTLV( IN PRTMP_ADAPTER pAd, IN PWSC_CTRL pWscCtrl, OUT UCHAR *pbuf, OUT USHORT *pBufLen) { INT Status = NDIS_STATUS_SUCCESS; PWSC_CREDENTIAL pCredential = NULL; UCHAR apidx = pWscCtrl->EntryIfIdx; UCHAR *TB = NULL; UCHAR *pData = NULL, *pSrcData = NULL; INT CerLen = 0; USHORT AuthType = 0; USHORT EncrType = 0; PWSC_REG_DATA pReg = (PWSC_REG_DATA) &pWscCtrl->RegData; INT Len = 0, templen = 0; struct wifi_dev *wdev; MULTISSID_STRUCT *pMbss; #ifdef WSC_V2_SUPPORT PWSC_TLV pWscTLV = &pWscCtrl->WscV2Info.ExtraTlv; #endif /* WSC_V2_SUPPORT */ os_alloc_mem(pAd, (UCHAR **)&pData, (NFC_WSC_TLV_SIZE*sizeof(UCHAR))); if (pData == NULL) { return NDIS_STATUS_RESOURCES; } os_alloc_mem(pAd, (UCHAR **)&TB, (256*sizeof(UCHAR))); if (TB == NULL) { os_free_mem(NULL, pData); return NDIS_STATUS_RESOURCES; } pMbss = &pAd->ApCfg.MBSSID[apidx]; wdev = &pMbss->wdev; pSrcData = pData; NdisZeroMemory(pData, NFC_WSC_TLV_SIZE); NdisZeroMemory(&TB[0], 256); WscCreateProfileFromCfg(pAd, REGISTRAR_ACTION | AP_MODE, pWscCtrl, &pWscCtrl->WscProfile); pCredential = &pAd->ApCfg.MBSSID[apidx].WscControl.WscProfile.Profile[0]; // Credential CerLen += AppendWSCTLV(WSC_ID_NW_INDEX, &TB[0], (PUCHAR)"1", 0); AuthType = cpu2be16(pCredential->AuthType); EncrType = cpu2be16(pCredential->EncrType); CerLen += AppendWSCTLV(WSC_ID_SSID, &TB[CerLen], pCredential->SSID.Ssid, pCredential->SSID.SsidLength); CerLen += AppendWSCTLV(WSC_ID_AUTH_TYPE, &TB[CerLen], (UINT8 *)&AuthType, 0); CerLen += AppendWSCTLV(WSC_ID_ENCR_TYPE, &TB[CerLen], (UINT8 *)&EncrType, 0); CerLen += AppendWSCTLV(WSC_ID_NW_KEY_INDEX, &TB[CerLen], &pCredential->KeyIndex, 0); CerLen += AppendWSCTLV(WSC_ID_NW_KEY, &TB[CerLen], pCredential->Key, pCredential->KeyLength); CerLen += AppendWSCTLV(WSC_ID_MAC_ADDR, &TB[CerLen], wdev->bssid, 0); // Prepare plain text // Reguired attribute item in M8 if Enrollee is STA. templen = AppendWSCTLV(WSC_ID_CREDENTIAL, pData, TB, CerLen); pData += templen; Len += templen; /* Optional items. RF_Band, AP_Channel, MAC_Address */ UCHAR RF_Band; if (pAd->CommonCfg.Channel > 14) RF_Band = 0x02; /* 5.0GHz */ else RF_Band = 0x01; /* 2.4GHz */ templen = AppendWSCTLV(WSC_ID_RF_BAND, pData, &RF_Band, 0); pData += templen; Len += templen; USHORT Channel = 0; Channel = pAd->CommonCfg.Channel; #ifdef RT_BIG_ENDIAN Channel = SWAP16(Channel); #endif /* RT_BIG_ENDIAN */ templen = AppendWSCTLV(WSC_ID_AP_CHANNEL, pData, (UINT8 *)&Channel, 0); pData += templen; Len += templen; templen = AppendWSCTLV(WSC_ID_MAC_ADDR, pData, wdev->bssid, 0); pData += templen; Len += templen; #ifdef WSC_V2_SUPPORT if (pWscCtrl->WscV2Info.bEnableWpsV2) { /* Version2 */ WscGenV2Msg(pWscCtrl, FALSE, NULL, 0, &pData, &Len); /* Extra attribute that is not defined in WSC Sepc. */ if (pWscTLV->pTlvData && pWscTLV->TlvLen) { templen = AppendWSCTLV(pWscTLV->TlvTag, pData, (UINT8 *)pWscTLV->pTlvData, pWscTLV->TlvLen); pData += templen; Len += templen; } } #endif // WSC_V2_SUPPORT // hex_dump("NfcBuildWscProfileTLV - pData", pSrcData, Len); if (pbuf && (Len < NFC_WSC_TLV_SIZE)) { NdisMoveMemory(pbuf, pSrcData, Len); *pBufLen = (USHORT)Len; hex_dump("NfcBuildWscProfileTLV", pbuf, *pBufLen); } else { DBGPRINT(RT_DEBUG_TRACE, ("%s: (Len=%d)\n", __FUNCTION__, Len)); Status = NDIS_STATUS_RESOURCES; } os_free_mem(NULL, pSrcData); os_free_mem(NULL, TB); return Status; }
ULONG InsertWfdSubelmtTlv( IN PRTMP_ADAPTER pAd, IN UCHAR SubId, IN PUCHAR pInBuffer, IN PUCHAR pOutBuffer, IN UINT Action) { PRT_WFD_CONFIG pWFDCtrl = &pAd->StaCfg.WfdCfg; PUCHAR pDest; ULONG Length, tmpValue = 0; USHORT EidLen = 0; pDest = pOutBuffer; RTMPZeroMemory(pDest, 255); *pDest = SubId; pDest += 1; Length = 0; switch (SubId) { case SUBID_WFD_DEVICE_INFO: { WFD_DEVICE_INFO DevInfo; PUSHORT pDevInfo = &DevInfo; RTMPZeroMemory(&DevInfo, sizeof(WFD_DEVICE_INFO)); EidLen = SUBID_WFD_DEVICE_INFO_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); DevInfo.DeviceType = pWFDCtrl->DeviceType; DevInfo.SourceCoupled = pWFDCtrl->SourceCoupled; DevInfo.SinkCoupled = pWFDCtrl->SinkCoupled; DevInfo.SessionAvail = pWFDCtrl->SessionAvail; DevInfo.WSD = pWFDCtrl->WSD; if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && (INFRA_ON(pAd))) DevInfo.PC = pWFDCtrl->PC; else DevInfo.PC = WFD_PC_P2P; DevInfo.CP = pWFDCtrl->CP; DevInfo.TimeSync = pWFDCtrl->TimeSync; /* RTMPMoveMemory(pDest + 1, &DevInfo, sizeof(WFD_DEVICE_INFO)); */ tmpValue = cpu2be16(*pDevInfo); RTMPMoveMemory((pDest + 2), &tmpValue, 2); tmpValue = cpu2be16(pWFDCtrl->RtspPort); RTMPMoveMemory((pDest + 4), &tmpValue, 2); tmpValue = cpu2be16(pWFDCtrl->MaxThroughput); RTMPMoveMemory((pDest + 6), &tmpValue, 2); Length = 9; break; } case SUBID_WFD_ASSOCIATED_BSSID: { UCHAR AllZero[MAC_ADDR_LEN] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_ASSOCIATED_BSSID_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; if (!NdisEqualMemory(AllZero, pAd->CommonCfg.Bssid, MAC_ADDR_LEN) && (Action == ACTION_GAS_INITIAL_RSP)) { RTMPMoveMemory(pDest + 2, pAd->CommonCfg.Bssid, MAC_ADDR_LEN); } } else { if (!NdisEqualMemory(AllZero, pAd->CommonCfg.Bssid, MAC_ADDR_LEN)) { EidLen = SUBID_WFD_ASSOCIATED_BSSID_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); RTMPMoveMemory(pDest + 2, pAd->CommonCfg.Bssid, MAC_ADDR_LEN); Length = EidLen + 3; } } break; } case SUBID_WFD_AUDIO_FORMATS: { if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_AUDIO_FORMATS_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; } break; } case SUBID_WFD_VIDEO_FORMATS: { if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_VIDEO_FORMATS_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; } break; } case SUBID_WFD_3D_VIDEO_FORMATS: { if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_3D_VIDEO_FORMATS_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; } break; } case SUBID_WFD_CONTENT_PROTECTION: { if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_CONTENT_PROTECTION_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; } break; } case SUBID_WFD_COUPLED_SINK_INFO: { // if ((pWFDCtrl->DeviceType != WFD_SOURCE ) && (pWFDCtrl->SinkCoupled == WFD_COUPLED_SUPPORT)) { WFD_COUPLED_SINK_INFO SinkInfo; RTMPZeroMemory(&SinkInfo, sizeof(WFD_COUPLED_SINK_INFO)); EidLen = SUBID_WFD_COUPLED_SINK_INFO_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); SinkInfo.CoupledStat = pWFDCtrl->CoupledSinkStatus.CoupledStat; RTMPMoveMemory(pDest + 2, &SinkInfo, sizeof(WFD_COUPLED_SINK_INFO)); Length = EidLen + 3; } break; } case SUBID_WFD_EXTENDED_CAP: { if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_EXTENDED_CAP_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; } break; } case SUBID_WFD_LOCAL_IP_ADDR: { if ((Action == ACTION_GAS_INITIAL_REQ) || (Action == ACTION_GAS_INITIAL_RSP)) { EidLen = SUBID_WFD_LOCAL_IP_ADDR_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); Length = EidLen + 3; } else { EidLen = SUBID_WFD_LOCAL_IP_ADDR_LEN; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); RTMPMoveMemory(pDest + 2, &pWFDCtrl->wfd_serv_disc_query_info.wfd_local_ip_ie, SUBID_WFD_LOCAL_IP_ADDR_LEN); Length = EidLen + 3; } break; } case SUBID_WFD_SESSION_INFO: { INT i = 0, NumOfDev = 0; UCHAR P2pIdx = P2P_NOT_FOUND; PRT_P2P_TABLE Tab = &pAd->P2pTable; if (P2P_GO_ON(pAd) #ifdef RT_CFG80211_SUPPORT || (pWFDCtrl->bSuppGoOn) #endif /* RT_CFG80211_SUPPORT */ ) { for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++) { MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[i]; P2pIdx = P2pGroupTabSearch(pAd, pEntry->Addr); if ((P2pIdx < MAX_P2P_GROUP_SIZE) && (Tab->Client[P2pIdx].WfdEntryInfo.bWfdClient == TRUE)) NumOfDev++; } EidLen = 24*NumOfDev; tmpValue = cpu2be16(EidLen); RTMPMoveMemory(pDest, &tmpValue, 2); DBGPRINT(RT_DEBUG_INFO, ("%s:: NumOfDev = %d, Len = %d\n", __FUNCTION__, NumOfDev, *pDest)); pDest+=2; for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++) { MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[i]; P2pIdx = P2pGroupTabSearch(pAd, pEntry->Addr); if ((P2pIdx < MAX_P2P_GROUP_SIZE) && (Tab->Client[P2pIdx].WfdEntryInfo.bWfdClient == TRUE)) { INT j = 0; WFD_SESSION_INFO SessionInfo; RTMPZeroMemory(&SessionInfo, sizeof(WFD_SESSION_INFO)); SessionInfo.Length = 23; RTMPMoveMemory(&SessionInfo.DeviceAddr[0], &pAd->P2pTable.Client[P2pIdx].addr[0], MAC_ADDR_LEN); RTMPMoveMemory(&SessionInfo.Bssid[0], &pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.assoc_addr[0], MAC_ADDR_LEN); /* Below is the WFD Device Information */ SessionInfo.WfdDevInfo.DeviceType = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.wfd_devive_type; SessionInfo.WfdDevInfo.SourceCoupled = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.source_coupled; SessionInfo.WfdDevInfo.SinkCoupled = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.sink_coupled; SessionInfo.WfdDevInfo.SessionAvail = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.session_avail; SessionInfo.WfdDevInfo.WSD = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.wfd_service_discovery; SessionInfo.WfdDevInfo.PC = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.wfd_PC; SessionInfo.WfdDevInfo.TimeSync = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.wfd_time_sync; SessionInfo.MaxThroughput = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.max_throughput; SessionInfo.CoupledSinkInfo = pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.coupled_sink_status; /* So far we cannot know the address of coupled devices, the coupled address will be filled "0" until WiFi Display spec. is ready for this part. */ RTMPMoveMemory(&SessionInfo.CoupledPeerAddr[0], &pAd->P2pTable.Client[P2pIdx].WfdEntryInfo.coupled_peer_addr[0], MAC_ADDR_LEN); RTMPMoveMemory(pDest, &SessionInfo, sizeof(WFD_SESSION_INFO)); for (j = 0; j < 24; j++) DBGPRINT(RT_DEBUG_INFO, ("%02x ", *(pDest+j))); DBGPRINT(RT_DEBUG_INFO, ("\n")); pDest += 24; } } Length = 24*NumOfDev + 3; } break; } case SUBID_WFD_ALTERNATE_MAC_ADDR: { UCHAR AllZero[MAC_ADDR_LEN] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; if (!NdisEqualMemory(AllZero, pAd->CurrentAddress, MAC_ADDR_LEN)) { EidLen = SUBID_WFD_ALTERNATE_MAC_ADDR_LEN; *((PUSHORT) (pDest)) = cpu2be16(EidLen); RTMPMoveMemory(pDest + 2, pAd->CurrentAddress, MAC_ADDR_LEN); Length = EidLen + 3; } break; } default: *pDest = 0; Length = 0; break; } return Length; }
void kvs40xx_init_window (struct scanner *s, struct window *wnd, int wnd_id) { int paper = str_index (paper_list, s->val[PAPER_SIZE].s), i; memset (wnd, 0, sizeof (struct window)); copy16 (wnd->window_descriptor_block_length, cpu2be16 (66)); wnd->window_identifier = wnd_id; copy16 (wnd->x_resolution, cpu2be16 (s->val[RESOLUTION].w)); copy16 (wnd->y_resolution, cpu2be16 (s->val[RESOLUTION].w)); if (!paper) { copy32 (wnd->upper_left_x, cpu2be32 (mm2scanner_units (s->val[TL_X].w))); copy32 (wnd->upper_left_y, cpu2be32 (mm2scanner_units (s->val[TL_Y].w))); copy32 (wnd->document_width, cpu2be32 (mm2scanner_units (s->val[BR_X].w))); copy32 (wnd->width, cpu2be32 (mm2scanner_units (s->val[BR_X].w - s->val[TL_X].w))); copy32 (wnd->document_length, cpu2be32 (mm2scanner_units (s->val[BR_Y].w))); copy32 (wnd->length, cpu2be32 (mm2scanner_units (s->val[BR_Y].w - s->val[TL_Y].w))); } else { u32 w = cpu2be32 (mm2scanner_units (paper_sizes[paper].width)); u32 h = cpu2be32 (mm2scanner_units (paper_sizes[paper].height)); copy32 (wnd->upper_left_x, cpu2be32 (mm2scanner_units (0))); copy32 (wnd->upper_left_y, cpu2be32 (mm2scanner_units (0))); if (!s->val[LANDSCAPE].b) { copy32 (wnd->width, w); copy32 (wnd->length, h); copy32 (wnd->document_width, w); copy32 (wnd->document_length, h); } else { copy32 (wnd->width, h); copy32 (wnd->length, w); copy32 (wnd->document_width, h); copy32 (wnd->document_length, w); } } wnd->brightness = s->val[BRIGHTNESS].w; wnd->threshold = s->val[THRESHOLD].w; wnd->contrast = s->val[CONTRAST].w; wnd->image_composition = mode_val[str_index (mode_list, s->val[MODE].s)]; wnd->bit_per_pixel = bps_val[str_index (mode_list, s->val[MODE].s)]; copy16 (wnd->halftone_pattern, cpu2be16 (str_index (halftone_pattern, s->val[HALFTONE_PATTERN].s))); wnd->rif_padding = s->val[INVERSE].b << 7; copy16 (wnd->bit_ordering, cpu2be16 (BIT_ORDERING)); wnd->compression_type = s->val[COMPRESSION].b ? 0x81 : 0; wnd->compression_argument = s->val[COMPRESSION_PAR].w; wnd->vendor_unique_identifier = 0; wnd->nobuf_fstspeed_dfstop = str_index (source_list, s->val[SOURCE].s) << 7 | str_index (stapeled_list, s->val[STAPELED_DOC].s) << 5 | s->val[STOP_SKEW].b << 4 | s->val[CROP].b << 3 | s->val[DFSTOP].b << 0; wnd->mirror_image = s->val[MIRROR].b << 7 | s->val[DFEED_L].b << 2 | s->val[DFEED_C].b << 1 | s->val[DFEED_R].b << 0; wnd->image_emphasis = str_index (image_emphasis_list, s->val[IMAGE_EMPHASIS].s); wnd->gamma_correction = gamma_val[str_index (gamma_list, s->val[GAMMA_CORRECTION].s)]; wnd->mcd_lamp_dfeed_sens = str_index (lamp_list, s->val[LAMP].s) << 4 | str_index (dfeed_sence_list, s->val[DFEED_SENCE].s); wnd->document_size = (paper != 0) << 7 | s->val[LENGTHCTL].b << 6 | s->val[LONG_PAPER].b << 5 | s->val[LANDSCAPE].b << 4 | paper_val[paper]; wnd->ahead_deskew_dfeed_scan_area_fspeed_rshad = (s->val[DESKEW].b || s->val[CROP].b ? 2 : 0) << 5 | /*XXX*/ s->val[DBLFEED].b << 4 | s->val[FIT_TO_PAGE].b << 2; wnd->continuous_scanning_pages = str_index (feeder_mode_list, s->val[FEEDER_MODE].s) ? 0xff : 0; wnd->automatic_threshold_mode = automatic_threshold_val [str_index (automatic_threshold_list, s->val[AUTOMATIC_THRESHOLD].s)]; wnd->automatic_separation_mode = 0; /*Does not supported */ wnd->standard_white_level_mode = white_level_val[str_index (white_level_list, s->val[WHITE_LEVEL].s)]; wnd->b_wnr_noise_reduction = str_index (noise_reduction_list, s->val[NOISE_REDUCTION].s); i = str_index (manual_feed_list, s->val[MANUALFEED].s); wnd->mfeed_toppos_btmpos_dsepa_hsepa_dcont_rstkr = i << 6 | s->val[TOPPOS].b << 5 | s->val[BTMPOS].b << 4; wnd->stop_mode = 1; wnd->red_chroma = s->val[RED_CHROMA].w; wnd->blue_chroma = s->val[BLUE_CHROMA].w; }