Example #1
0
/**
 * \fn     scanResultTable_UpdateWSCParams
 * \brief  Update a scan result table entry with WSC information
 *
 * Update a scan result table entry with WSC information
 *
 * \param  pSite - a pointer to the site entry to update
 * \param  pFrame - a pointer to the received frame
 * \return None
 * \sa     scanResultTable_UpdateSiteData
 */
void scanResultTable_UpdateWSCParams (TSiteEntry *pSite, TScanFrameInfo *pFrame)
{
    /* if the IE is not null => the WSC is on - check which method is supported */
    if (pFrame->parsedIEs->content.iePacket.WSCParams != NULL)
    {
        TI_UINT8    *tlvPtr,*endPtr;
        TI_UINT16   tlvPtrType,tlvPtrLen,selectedMethod=0;

        tlvPtr = (TI_UINT8*)pFrame->parsedIEs->content.iePacket.WSCParams->WSCBeaconOrProbIE;
        endPtr = tlvPtr + pFrame->parsedIEs->content.iePacket.WSCParams->hdr[1] - (DOT11_OUI_LEN + 1);

        do
        {
            tlvPtrType = WLANTOHS (WLAN_WORD(tlvPtr));

            if (tlvPtrType == DOT11_WSC_DEVICE_PASSWORD_ID)
            {
                tlvPtr+=2;
                tlvPtr+=2;
                selectedMethod = WLANTOHS (WLAN_WORD(tlvPtr));
                break;
            }
            else
            {
                tlvPtr+=2;
                tlvPtrLen = WLANTOHS (WLAN_WORD(tlvPtr));
                tlvPtr+=tlvPtrLen+2;
            }
        } while ((tlvPtr < endPtr) && (selectedMethod == 0));

        if (tlvPtr > endPtr)
        {
            pSite->WSCSiteMode = TIWLN_SIMPLE_CONFIG_OFF;
            return;
        }

        if (selectedMethod == DOT11_WSC_DEVICE_PASSWORD_ID_PIN)
            pSite->WSCSiteMode = TIWLN_SIMPLE_CONFIG_PIN_METHOD;
        else if (selectedMethod == DOT11_WSC_DEVICE_PASSWORD_ID_PBC)
            pSite->WSCSiteMode = TIWLN_SIMPLE_CONFIG_PBC_METHOD;
        else
            pSite->WSCSiteMode = TIWLN_SIMPLE_CONFIG_OFF;
    }
    else
    {
        pSite->WSCSiteMode = TIWLN_SIMPLE_CONFIG_OFF;
    }
}
Example #2
0
/************************************************************************
 *                        buildArpRspTemplate							*
 ************************************************************************
DESCRIPTION: This function builds an ARP Response template to set to 
			 the HAL when joining an infrastructure network.

             The function's steps:
             - It builds the template & set the template len. 
             - If QoS is inactive, it discards the QoS Control Field.
             ** The template type is set in the site mgr.
                                           
INPUT:       pSiteMgr  - Handle to site manager.
			 pTemplate - Pointer to the template structure.

OUTPUT:		

RETURN:     TI_OK

************************************************************************/
TI_STATUS buildArpRspTemplate(siteMgr_t * pSiteMgr, TSetTemplate * pTemplate,
			      TIpAddr staIp)
{
	siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
	ArpRspTemplate_t *pBuffer = (ArpRspTemplate_t *) pTemplate->ptr;
	TI_UINT8 *ptr = (TI_UINT8 *) pBuffer;

	paramInfo_t param;	/* To get Site and QoS params */
	TI_UINT16 fc;		/* Frame Control field in MAC header */
	TI_UINT16 macAddrItr;
	TI_BOOL privacyInvoked;
	TI_UINT8 encryptionFieldSize, copyPayloadOffset, lenToCopy;

	/* Reset the buffer */
	os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(ArpRspTemplate_t));

	/* Turn on the To_DS bit in the Frame Control field */
	fc = (1 << DOT11_FC_TO_DS_SHIFT);
	
	    /* Set MAC header address fields:
	       -----------------------------
	       Since To_DS is on and From_DS is off the address meaning is as follows:
	       Address1 - BSSID
	       Address2 - Source Address
	       Address3 - Destination Address
	       Address4 - Not present */
	    /* - Set BSSID */
	    if (pPrimarySite) {
		MAC_COPY(pBuffer->hdr.address1, pPrimarySite->bssid);
	} else {
		TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION,
		       "No Primary site so cannot fill QosNullData template.\n");
	}
	/* - Set Source Address */
	param.paramType = CTRL_DATA_MAC_ADDRESS;
	ctrlData_getParam(pSiteMgr->hCtrlData, &param);
	MAC_COPY(pBuffer->hdr.address2, param.content.ctrlDataDeviceMacAddress);
	/* - Set Destination Address: ARP response should be sent with broadcast DA - Set accordingly */
	for (macAddrItr = 0; macAddrItr < MAC_ADDR_LEN; macAddrItr++) {
		pBuffer->hdr.address3[macAddrItr] = 0xFF;
	}

	pBuffer->LLC.DSAP = 0xaa;
	pBuffer->LLC.SSAP = 0xaa;
	pBuffer->LLC.Control = 0x03;

	/* pBuffer->LLC.Control.OUI these 3 bytes are zeroed already */
	pBuffer->LLC.Type = WLANTOHS((TI_UINT16) 0x806);
	pBuffer->hardType = WLANTOHS((TI_UINT16) 1);
	pBuffer->protType = WLANTOHS((TI_UINT16) 0x800);
	pBuffer->hardSize = 6;
	pBuffer->protSize = 4;
	pBuffer->op = WLANTOHS((TI_UINT16) 2);	/*filled as for ARP-RSP, not for RARP_RSP */

	MAC_COPY(pBuffer->StaMac, pBuffer->hdr.address2);
	IP_COPY(pBuffer->StaIp, staIp);

	pTemplate->len = sizeof(ArpRspTemplate_t);

	/* Get encryption status */
	txCtrlParams_getCurrentEncryptionInfo(pSiteMgr->hTxCtrl,
					      &privacyInvoked,
					      &encryptionFieldSize);

	/* If no encryption is used, encryptionFieldSize has garbage value */
	encryptionFieldSize = privacyInvoked ? encryptionFieldSize : 0;

	/* Set the subtype field of fc with WEP_BIT */
	fc |= (privacyInvoked << DOT11_FC_WEP_SHIFT);

	/* Get QoS type to check if QoS is active */
	param.paramType = QOS_MNGR_ACTIVE_PROTOCOL;
	qosMngr_getParams(pSiteMgr->hQosMngr, &param);

	if (param.content.qosSiteProtocol == QOS_NONE) {	/* QoS is not active */
		copyPayloadOffset =
		    sizeof(pBuffer->hdr.qosControl) +
		    AES_AFTER_HEADER_FIELD_SIZE - encryptionFieldSize;
		/* Set the subtype field of fc with DATA value (non Qos) */
		fc |= DOT11_FC_DATA;
	} else {		/* QoS is active */

		copyPayloadOffset =
		    AES_AFTER_HEADER_FIELD_SIZE - encryptionFieldSize;
		/* Set the subtype field of fc with DATA_QOS */
		fc |= DOT11_FC_DATA_QOS;
	}

	/* Need to copy backward to overwrite security or QoS offset */
	if (copyPayloadOffset > 0) {
		ptr = (TI_UINT8 *) & pBuffer->LLC.DSAP;
		/* Copy back the actual payload without header & security */
		lenToCopy =
		    sizeof(ArpRspTemplate_t) - sizeof(dot11_header_t) -
		    AES_AFTER_HEADER_FIELD_SIZE;

		os_memoryCopy(pSiteMgr->hOs, ptr - copyPayloadOffset, ptr,
			      lenToCopy);
		pTemplate->len -= copyPayloadOffset;
	}

	COPY_WLAN_WORD(&pBuffer->hdr.fc, &fc);	/* copy with endianess handling. */

	return TI_OK;
}