示例#1
0
int CResPermissionsCache::lookup( IArrayOf<ISecResource>& resources, bool* pFound )
{
    time_t tstamp;
    time(&tstamp);

    int timeout = m_pParentCache->getCacheTimeout();
    if(timeout == 0 && m_pParentCache->isTransactionalEnabled())
        timeout = 10; //Transactional timeout is set to 10 seconds for long transactions that might take over 10 seconds.
    tstamp -= timeout;
    if (m_tLastCleanup < tstamp)
        removeStaleEntries(tstamp);

    int nresources = resources.ordinality();
    int nFound = 0;

    for (int i = 0; i < nresources; i++)
    {
        ISecResource& secResource = resources.item(i);
        const char* resource = secResource.getName();
        if(resource == NULL)
        {
            *pFound++ = false;
            continue;
        }
#ifdef _DEBUG
        DBGLOG("CACHE: CResPermissionsCache Looking up resource(%d of %d) %s:%s", i, nresources, m_user.c_str(), resource);
#endif
        MapResAccess::iterator it = m_resAccessMap.find(SecCacheKeyEntry(resource, secResource.getResourceType()));
        if (it != m_resAccessMap.end())//exists in cache
        {
            ResPermCacheEntry& resParamCacheEntry = (*it).second;
            const time_t timestamp = resParamCacheEntry.first;

            if (timestamp < tstamp)//entry was not stale during last cleanup but is stale now
                *pFound++ = false;
            else if(!m_pParentCache->isCacheEnabled() && m_pParentCache->isTransactionalEnabled())//m_pParentCache->getOriginalTimeout() == 0)
            {
                time_t tctime = getThreadCreateTime();
                if(tctime <= 0 || timestamp < tctime)
                {
                    *pFound++ = false;
                }
                else
                {
                    secResource.copy(resParamCacheEntry.second);
#ifdef _DEBUG
                    DBGLOG("CACHE: CResPermissionsCache FoundA %s:%s=>%d", m_user.c_str(), resource, ((ISecResource*)resParamCacheEntry.second)->getAccessFlags());
#endif
                    *pFound++ = true;
                    nFound++;
                }
            }
            else
            {
                secResource.copy(resParamCacheEntry.second);
#ifdef _DEBUG
                DBGLOG("CACHE: CResPermissionsCache FoundB %s:%s=>%d", m_user.c_str(), resource, ((ISecResource*)resParamCacheEntry.second)->getAccessFlags());
#endif
                *pFound++ = true;
                nFound++;
            }
        }
        else
            *pFound++ = false;
    }
    return nFound;
}
/*----------------------------------------------------------------------------*/
int
mtk_cfg80211_join_ibss (
    struct wiphy *wiphy,
    struct net_device *ndev,
    struct cfg80211_ibss_params *params
    )
{
    PARAM_SSID_T rNewSsid;
    P_GLUE_INFO_T prGlueInfo = NULL;
    UINT_32 u4ChnlFreq; /* Store channel or frequency information */
    UINT_32 u4BufLen = 0;
    WLAN_STATUS rStatus;

    prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy);
    ASSERT(prGlueInfo);

    /* set channel */
#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 7, 0)
    if(params->channel) {
        u4ChnlFreq = nicChannelNum2Freq(params->channel->hw_value);
#else
    if(params->chandef.chan) {
        u4ChnlFreq = nicChannelNum2Freq(params->chandef.chan->hw_value);
#endif

        rStatus = kalIoctl(prGlueInfo,
                           wlanoidSetFrequency,
                           &u4ChnlFreq,
                           sizeof(u4ChnlFreq),
                           FALSE,
                           FALSE,
                           FALSE,
                           FALSE,
                           &u4BufLen);
        if (rStatus != WLAN_STATUS_SUCCESS) {
            return -EFAULT;
        }
    }

    /* set SSID */
    kalMemCopy(rNewSsid.aucSsid, params->ssid, params->ssid_len);
    rStatus = kalIoctl(prGlueInfo,
            wlanoidSetSsid,
            (PVOID) &rNewSsid,
            sizeof(PARAM_SSID_T),
            FALSE,
            FALSE,
            TRUE,
            FALSE,
            &u4BufLen);

    if (rStatus != WLAN_STATUS_SUCCESS) {
        DBGLOG(REQ, WARN, ("set SSID:%lx\n", rStatus));
        return -EFAULT;
    }

    return 0;


    return -EINVAL;
}


/*----------------------------------------------------------------------------*/
/*!
 * @brief This routine is responsible for requesting to leave from IBSS group
 *
 * @param 
 *
 * @retval 0:       successful
 *         others:  failure
 */
/*----------------------------------------------------------------------------*/
int
mtk_cfg80211_leave_ibss (
    struct wiphy *wiphy,
    struct net_device *ndev
    )
{
    P_GLUE_INFO_T prGlueInfo = NULL;
    WLAN_STATUS rStatus;
    UINT_32 u4BufLen;

    prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy);
    ASSERT(prGlueInfo);

    rStatus = kalIoctl(prGlueInfo,
        wlanoidSetDisassociate,
        NULL,
        0,
        FALSE,
        FALSE,
        TRUE,
        FALSE,
        &u4BufLen);

    if (rStatus != WLAN_STATUS_SUCCESS) {
        DBGLOG(REQ, WARN, ("disassociate error:%lx\n", rStatus));
        return -EFAULT;
    }

    return 0;
}
示例#3
0
/*----------------------------------------------------------------------------*/
VOID
kalP2PInvitationIndication (
    IN P_GLUE_INFO_T prGlueInfo,
    IN P_P2P_DEVICE_DESC_T prP2pDevDesc,
    IN PUINT_8 pucSsid,
    IN UINT_8 ucSsidLen,
    IN UINT_8 ucOperatingChnl,
    IN UINT_8 ucInvitationType,
    IN PUINT_8 pucGroupBssid
    )
{
#if 1
    union iwreq_data evt;
    UINT_8 aucBuffer[IW_CUSTOM_MAX];

    ASSERT(prGlueInfo);

    /* buffer peer information for later IOC_P2P_GET_STRUCT access */
    prGlueInfo->prP2PInfo->u4ConnReqNameLength = (UINT_32)((prP2pDevDesc->u2NameLength > 32)? 32 : prP2pDevDesc->u2NameLength);
    kalMemCopy(prGlueInfo->prP2PInfo->aucConnReqDevName,
                    prP2pDevDesc->aucName,
                    prGlueInfo->prP2PInfo->u4ConnReqNameLength);
    COPY_MAC_ADDR(prGlueInfo->prP2PInfo->rConnReqPeerAddr, prP2pDevDesc->aucDeviceAddr);
    COPY_MAC_ADDR(prGlueInfo->prP2PInfo->rConnReqGroupAddr, pucGroupBssid);
    prGlueInfo->prP2PInfo->i4ConnReqConfigMethod = (INT_32)(prP2pDevDesc->u2ConfigMethod);
    prGlueInfo->prP2PInfo->ucOperatingChnl = ucOperatingChnl;
    prGlueInfo->prP2PInfo->ucInvitationType = ucInvitationType;

    // prepare event structure
    memset(&evt, 0, sizeof(evt));

    snprintf(aucBuffer, IW_CUSTOM_MAX-1, "P2P_INV_INDICATE");
    evt.data.length = strlen(aucBuffer);

    /* indicate in IWEVCUSTOM event */
    wireless_send_event(prGlueInfo->prP2PInfo->prDevHandler,
            IWEVCUSTOM,
            &evt,
            aucBuffer);
    return;

#else
    P_MSG_P2P_CONNECTION_REQUEST_T prP2pConnReq = (P_MSG_P2P_CONNECTION_REQUEST_T)NULL;
    P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T)NULL;
    P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = (P_P2P_CONNECTION_SETTINGS_T)NULL;

    do {
        ASSERT_BREAK((prGlueInfo != NULL) && (prP2pDevDesc != NULL));


        // Not a real solution

        prP2pSpecificBssInfo = prGlueInfo->prAdapter->rWifiVar.prP2pSpecificBssInfo;
        prP2pConnSettings = prGlueInfo->prAdapter->rWifiVar.prP2PConnSettings;

        prP2pConnReq = (P_MSG_P2P_CONNECTION_REQUEST_T)cnmMemAlloc(prGlueInfo->prAdapter,
                                                                                RAM_TYPE_MSG,
                                                                                sizeof(MSG_P2P_CONNECTION_REQUEST_T));

        if (prP2pConnReq == NULL) {
            break;
        }


        kalMemZero(prP2pConnReq, sizeof(MSG_P2P_CONNECTION_REQUEST_T));

        prP2pConnReq->rMsgHdr.eMsgId = MID_MNY_P2P_CONNECTION_REQ;

        prP2pConnReq->eFormationPolicy = ENUM_P2P_FORMATION_POLICY_AUTO;

        COPY_MAC_ADDR(prP2pConnReq->aucDeviceID, prP2pDevDesc->aucDeviceAddr);

        prP2pConnReq->u2ConfigMethod = prP2pDevDesc->u2ConfigMethod;

        if (ucInvitationType == P2P_INVITATION_TYPE_INVITATION) {
            prP2pConnReq->fgIsPersistentGroup = FALSE;
            prP2pConnReq->fgIsTobeGO = FALSE;

        }

        else if (ucInvitationType == P2P_INVITATION_TYPE_REINVOKE) {
            DBGLOG(P2P, TRACE, ("Re-invoke Persistent Group\n"));
            prP2pConnReq->fgIsPersistentGroup = TRUE;
            prP2pConnReq->fgIsTobeGO = (prGlueInfo->prP2PInfo->ucRole == 2)?TRUE:FALSE;

        }


        p2pFsmRunEventDeviceDiscoveryAbort(prGlueInfo->prAdapter, NULL);

        if (ucOperatingChnl != 0) {
            prP2pSpecificBssInfo->ucPreferredChannel = ucOperatingChnl;
        }

        if ((ucSsidLen < 32) && (pucSsid != NULL)) {
            COPY_SSID(prP2pConnSettings->aucSSID,
                            prP2pConnSettings->ucSSIDLen,
                            pucSsid,
                            ucSsidLen);
        }

        mboxSendMsg(prGlueInfo->prAdapter,
                        MBOX_ID_0,
                        (P_MSG_HDR_T)prP2pConnReq,
                        MSG_SEND_METHOD_BUF);



    } while (FALSE);

    // frog add.
    // TODO: Invitation Indication

    return;
#endif

} /* kalP2PInvitationIndication */
示例#4
0
bool CWsDfuXRefEx::onDFUXRefArrayAction(IEspContext &context, IEspDFUXRefArrayActionRequest &req, IEspDFUXRefArrayActionResponse &resp)
{
    try
    {
        StringBuffer username;
        context.getUserID(username);
        DBGLOG("CWsDfuXRefEx::onDFUXRefArrayAction User=%s",username.str());
        Owned<IUserDescriptor> userdesc;
        if(username.length() > 0)
        {
            const char* passwd = context.queryPassword();
            userdesc.setown(createUserDescriptor());
            userdesc->set(username.str(), passwd);
        }

        if(*req.getAction() == 0 || *req.getType() == 0 || *req.getCluster() == 0)
        {
            ERRLOG("Invalid Parameters into CWsDfuXRefEx::onDFUXRefArrayAction");
            throw MakeStringExceptionDirect(ECLWATCH_INVALID_INPUT, "Action, cluster, or type not defined.");
        }
        
        Owned<IXRefNode> xRefNode = XRefNodeManager->getXRefNode(req.getCluster());
        if (xRefNode.get() == 0)
        {
            ERRLOG("Unable to resolve XRef cluster name %s",req.getCluster());
            throw MakeStringException(ECLWATCH_CANNOT_RESOLVE_CLUSTER_NAME, "Unable to resolve cluster name %s",req.getCluster());
        }

        
        Owned<IXRefFilesNode> _fileNode = getFileNodeInterface(*xRefNode.get(),req.getType());
        if (_fileNode.get() == 0)
        {
            ERRLOG("Unable to find a suitable IXRefFilesNode interface for %s",req.getType());
            throw MakeStringException(ECLWATCH_CANNOT_FIND_IXREFFILESNODE, "Unable to find a suitable IXRefFilesNode interface for %s",req.getType());
        }

        if (!context.validateFeatureAccess(FEATURE_URL, SecAccess_Full, false))
            throw MakeStringException(ECLWATCH_DFU_XREF_ACCESS_DENIED, "Failed to run Xref command. Permission denied.");
       
        StringBuffer returnStr,UserName;
        const char* ActionType = req.getAction();

        DBGLOG("Running Xref Command %s for user %s",ActionType,context.getUserID(UserName).str());

        for(unsigned i = 0; i < req.getXRefFiles().length();i++)
        {
            DBGLOG("CWsDfuXRefEx::onDFUXRefArrayAction %s file %s for User=%s", ActionType, req.getXRefFiles().item(i), username.str());

            StringBuffer errstr;
            if (strcmp("Delete" ,ActionType) == 0)
            {
                if (_fileNode->RemovePhysical(req.getXRefFiles().item(i),userdesc,req.getCluster(),errstr))
                    appendReplyMessage(returnStr,NULL,"Removed Physical part %s",req.getXRefFiles().item(i));
                else
                    appendReplyMessage(returnStr,NULL,"Error(s) removing physical part %s\n%s",req.getXRefFiles().item(i),errstr.str());
            }
            else if (strcmp("Attach" ,ActionType) == 0)
            {
                if(_fileNode->AttachPhysical(req.getXRefFiles().item(i),userdesc,req.getCluster(),errstr) )
                    appendReplyMessage(returnStr,NULL,"Reattached Physical part %s",req.getXRefFiles().item(i));
                else
                    appendReplyMessage(returnStr,NULL,"Error(s) attaching physical part %s\n%s",req.getXRefFiles().item(i),errstr.str());
            }
            if (strcmp("DeleteLogical" ,ActionType) == 0)
            {
                // Note we don't want to physically delete 'lost' files - this will end up with orphans on next time round but that is safer
                if (_fileNode->RemoveLogical(req.getXRefFiles().item(i),userdesc,req.getCluster(),errstr)) {
                    appendReplyMessage(returnStr,NULL,"Removed Logical File %s",req.getXRefFiles().item(i));
                }
                else
                    appendReplyMessage(returnStr,NULL,"Error(s) removing File %s\n%s",req.getXRefFiles().item(i),errstr.str());
            }
        }

        xRefNode->commit();
        resp.setDFUXRefArrayActionResult(returnStr.str());
    }
    catch(IException* e)
    {   
        FORWARDEXCEPTION(context, e,  ECLWATCH_INTERNAL_ERROR);
    }
    return true;
}
/*----------------------------------------------------------------------------*/
int 
mtk_cfg80211_scan (
    struct wiphy *wiphy,
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)
    struct net_device *ndev,
#endif
    struct cfg80211_scan_request *request
    )
{
    P_GLUE_INFO_T prGlueInfo = NULL;
    WLAN_STATUS rStatus;
    UINT_32 u4BufLen;
    PARAM_SCAN_REQUEST_EXT_T rScanRequest;

    prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy);
    ASSERT(prGlueInfo);
    
    kalMemZero(&rScanRequest, sizeof(PARAM_SCAN_REQUEST_EXT_T));
    
    /* check if there is any pending scan not yet finished */
    if(prGlueInfo->prScanRequest != NULL) {
        return -EBUSY;
    }

    if(request->n_ssids == 0) {
        rScanRequest.rSsid.u4SsidLen = 0;
    }
    else if(request->n_ssids == 1) {
        COPY_SSID(rScanRequest.rSsid.aucSsid, rScanRequest.rSsid.u4SsidLen, request->ssids[0].ssid, request->ssids[0].ssid_len);
    }
    else {
        return -EINVAL;
    }

    if(request->ie_len > 0) {
        rScanRequest.u4IELength = request->ie_len;
        rScanRequest.pucIE = (PUINT_8)(request->ie);
    }
    else {
        rScanRequest.u4IELength = 0;
    }

    rStatus = kalIoctl(prGlueInfo,
        wlanoidSetBssidListScanExt,
        &rScanRequest,
        sizeof(PARAM_SCAN_REQUEST_EXT_T),
        FALSE,
        FALSE,
        FALSE,
        FALSE,
        &u4BufLen);

    if (rStatus != WLAN_STATUS_SUCCESS) {
        DBGLOG(REQ, WARN, ("scan error:%lx\n", rStatus));
        return -EINVAL;
    }

    prGlueInfo->prScanRequest = request;

    return 0;
}
VOID rlmDomainPassiveScanSendCmd(    
	P_ADAPTER_T     prAdapter, 
    BOOLEAN         fgIsOid	
)
{
    P_DOMAIN_INFO_ENTRY     prDomainInfo;
	P_CMD_SET_DOMAIN_INFO_T prCmd;
    WLAN_STATUS             rStatus;
    P_DOMAIN_SUBBAND_INFO   prSubBand;
    UINT_8                  i;	


	prCmd = cnmMemAlloc(prAdapter, RAM_TYPE_BUF, sizeof(CMD_SET_DOMAIN_INFO_T));
   	ASSERT(prCmd);


	/* To do: exception handle */
	if (!prCmd) {
	   DBGLOG(RLM, ERROR, ("Domain: no buf to send cmd\n"));
	   return;
	}
	kalMemZero(prCmd, sizeof(CMD_SET_DOMAIN_INFO_T));

	prCmd->u2CountryCode = prAdapter->rWifiVar.rConnSettings.u2CountryCode;
	prCmd->u2IsSetPassiveScan = 1;
	prCmd->uc2G4Bandwidth = prAdapter->rWifiVar.rConnSettings.uc2G4BandwidthMode;
	prCmd->uc5GBandwidth = prAdapter->rWifiVar.rConnSettings.uc5GBandwidthMode;
	prCmd->aucReserved[0] = 0;
	prCmd->aucReserved[1] = 0;


	DBGLOG(RLM, INFO, ("rlmDomainPassiveScanSendCmd(), CountryCode = %x\n", prAdapter->rWifiVar.rConnSettings.u2CountryCode));

	if (prAdapter->rWifiVar.rConnSettings.u2CountryCode == COUNTRY_CODE_UDF){
		prDomainInfo = &arSupportedRegDomains_Passive[REG_DOMAIN_PASSIVE_UDF_IDX];
	}
	else{
		prDomainInfo = &arSupportedRegDomains_Passive[REG_DOMAIN_PASSIVE_DEF_IDX];
	}

	for (i = 0; i < 6; i++) {
	   prSubBand = &prDomainInfo->rSubBand[i];

	   prCmd->rSubBand[i].ucRegClass = prSubBand->ucRegClass;
	   prCmd->rSubBand[i].ucBand = prSubBand->ucBand;

	   if (prSubBand->ucBand != BAND_NULL && prSubBand->ucBand < BAND_NUM) {
		   prCmd->rSubBand[i].ucChannelSpan = prSubBand->ucChannelSpan;
		   prCmd->rSubBand[i].ucFirstChannelNum = prSubBand->ucFirstChannelNum;
		   prCmd->rSubBand[i].ucNumChannels = prSubBand->ucNumChannels;
	   }
	}

	rStatus = wlanSendSetQueryCmd (
				prAdapter,					/* prAdapter */
				CMD_ID_SET_DOMAIN_INFO, 	/* ucCID */
				TRUE,						/* fgSetQuery */
				FALSE,						/* fgNeedResp */
				fgIsOid,					/* fgIsOid */
				NULL,						/* pfCmdDoneHandler*/
				NULL,						/* pfCmdTimeoutHandler */
				sizeof(CMD_SET_DOMAIN_INFO_T),	  /* u4SetQueryInfoLen */
				(PUINT_8) prCmd,			/* pucInfoBuffer */
				NULL,						/* pvSetQueryBuffer */
				0							/* u4SetQueryBufferLen */
				);

	ASSERT(rStatus == WLAN_STATUS_PENDING);

	cnmMemFree(prAdapter, prCmd);			
}
示例#7
0
void OrderedInput::updateSequentialDistance(const void * seek, const void * next, unsigned numFields, bool seekToSameLocation, bool nowMatched)
{
    //Note: With large numbers of matches in all documents, the ordered inputs will remain stable,
    //because the first input will have a better distance than the exact matches.
    assertex(distanceCalculator);
    SkipDistance thisDistance;
    thisDistance.field = distanceCalculator->getDistance(thisDistance.distance, seek, next, numFields);

#ifdef IGNORE_SEEK_TO_SELF
    //If the previous seek was a nextGE() that returned a row which didn't match the criteia, that then matched
    //a different index, and we then get a subsequent call which does match property on the same record
    //then we shouldn't include this is the skipping distance.
    if (thisDistance.field == DISTANCE_EXACT_MATCH)
    {
        assertex(nowMatched);
        if (nowMatched && seekToSameLocation)
            return;
    }
#endif

    distances[nextDistanceIndex].set(thisDistance);
    if (nextDistanceIndex == MaxDistanceSamples-1)
        nextDistanceIndex = 0;
    else
        nextDistanceIndex++;

    if (numSamples < MaxDistanceSamples)
        numSamples++;

    if (numSamples < MaxDistanceSamples)
    {
        //choose the last to start with - fairly arbitrary.
        medianDistance.set(thisDistance);
    }
    else
    {
        int c01 = distances[0].compare(distances[1]);
        unsigned median;
        if (c01 == 0)
        {
            //Same => the median must be the same as either of them.
            median = 0;
        }
        else
        {
            int c02 = distances[0].compare(distances[2]);
            if (c01 < 0)
            {
                if (c02 >= 0)
                {
                    //c <= a < b
                    median = 0;
                }
                else
                {
                    //a < b, a < c  => smallest of b,c
                    int c12 = distances[1].compare(distances[2]);
                    median = c12 <= 0 ? 1 : 2;
                }
            }
            else
            {
                if (c02 <= 0)
                {
                    // c >= a > b
                    median = 0;
                }
                else
                {
                    // a > b, a > c  => median is largest if b,c
                    int c12 = distances[1].compare(distances[2]);
                    median = c12 >= 0 ? 1 : 2;
                }
            }
        }
#ifdef TRACE_JOIN_OPTIMIZATION
        if (medianDistance.compare(distances[median]) != 0)
            DBGLOG("Median for input %d changed from %d:%" I64F "d to %d:%" I64F "d", 
                    originalIndex, medianDistance.field, medianDistance.distance, 
                                   distances[median].field, distances[median].distance);
#endif
        medianDistance.set(distances[median]);
    }
}
/*
 * @brief Initialization of exception handling
 * @param
 *     None
 * @return
 *     This function returns KAL_SUCCESS always.
 */
KAL_INT32 eemcs_expt_mod_init(void)
{
    KAL_UINT32 i = 0;
    //KAL_UINT32 except_txq = 0, except_rxq = 0;
    //KAL_UINT32 nonstop_rxq = 0; /* for Log path to output as much as possible */
    KAL_INT32  ret;
    ccci_port_cfg *log_queue_config;
    DEBUG_LOG_FUNCTION_ENTRY;

    //Init md exception type
    g_except_inst.md_ex_type = 0;

    /* init expt_cb and expt_cb_lock*/
    spin_lock_init(&g_except_inst.expt_cb_lock);
    for(i = 0; i < CCCI_PORT_NUM_MAX; i++) {
        g_except_inst.expt_cb[i] = NULL;

        if(TR_Q_INVALID != ccci_expt_port_info[i].expt_txq_id)
        {
            set_bit(SDIO_TXQ(ccci_expt_port_info[i].expt_txq_id), (unsigned long *)&except_txq);
        }
        if(TR_Q_INVALID != ccci_expt_port_info[i].expt_rxq_id)
        {
            set_bit(SDIO_RXQ(ccci_expt_port_info[i].expt_rxq_id), (unsigned long *)&except_rxq);
        }
    }

    eemcs_expt_ut_init();

    log_queue_config = ccci_get_port_info(CCCI_PORT_MD_LOG);
    set_bit(SDIO_RXQ(log_queue_config->rxq_id), (unsigned long *)&nonstop_rxq);
    hif_except_init(nonstop_rxq, (except_txq << 16) | except_rxq);

    ret = hif_reg_expt_cb(ccci_df_to_ccci_exception_callback);
    KAL_ASSERT(ret == KAL_SUCCESS);
    
    DBGLOG(EXPT, TRA, "nonstop_txq=%d, nonstop_rxq=%d, exp_txq=%d, exp_rxq=%d", \
		0, nonstop_rxq, except_txq, except_rxq);


    /* Init Tx Q list */
    for (i = 0; i < SDIO_TX_Q_NUM; i++) {
        g_except_inst.txq[i].id = -1;
        atomic_set(&g_except_inst.txq[i].pkt_cnt, 0);
        skb_queue_head_init(&g_except_inst.txq[i].skb_list);
    }
    /* Init Rx Q list */
    for (i = 0; i < SDIO_RX_Q_NUM; i++) {
        g_except_inst.rxq[i].id = -1;
        atomic_set(&g_except_inst.rxq[i].pkt_cnt, 0);
        skb_queue_head_init(&g_except_inst.rxq[i].skb_list);
    }
    /* Init port list */
    for (i = 0; i < CCCI_PORT_NUM; i++) {
        atomic_set(&g_except_inst.port[i].pkt_cnt, 0);
        skb_queue_head_init(&g_except_inst.port[i].skb_list);
    }
    /* initialize drop count */
    eemcs_expt_reset_statistics();

    /* initialize exception*/
    eemcs_exception_state = EEMCS_EX_NONE;

    /* initialize exception timer*/
    init_timer(&g_except_inst.md_ex_monitor);
    g_except_inst.md_ex_monitor.function = ex_monitor_func;
    g_except_inst.md_ex_monitor.data = (unsigned long)&g_except_inst;

    /* allocate memory for modem assert info*/
    g_except_inst.expt_info_mem = (KAL_UINT8 *)kmalloc(MD_EX_MEM_SIZE, GFP_KERNEL);
    if (g_except_inst.expt_info_mem) {
        DBGLOG(EXPT, ERR, "alloc exception info memory ok: %p", g_except_inst.expt_info_mem);
        memset(g_except_inst.expt_info_mem, 0, MD_EX_MEM_SIZE);
    } else {
        DBGLOG(EXPT, ERR, "alloc exception info memory fail");
    }
    
#ifdef ENABLE_MD_WDT_PROCESS
    eemcs_ccci_register_WDT_callback(eemcs_wdt_reset_callback);
#endif

    DEBUG_LOG_FUNCTION_LEAVE;

    return KAL_SUCCESS;
}
/*
 * @brief dump ee info to string and send to eemcs_aed
 * @param
 *     debug_info    [in] debug info get from MD_EX_REC_OK msg, 
 *                        parse by eemcs_md_exception_data_parse.
 *   
 * @return
 *     none.
 */
void eemcs_ee_info_dump(DEBUG_INFO_T *debug_info, char* except_info_addr)
{
	char ex_info[EE_BUF_LEN]="";
	char i_bit_ex_info[EE_BUF_LEN]="\nMay I-Bit dis too long\n";
	
	struct rtc_time		tm;
	struct timeval		tv = {0};
	struct timeval		tv_android = {0};
	struct rtc_time		tm_android;

	do_gettimeofday(&tv);
	tv_android = tv;
	rtc_time_to_tm(tv.tv_sec, &tm);
	tv_android.tv_sec -= sys_tz.tz_minuteswest*60;
	rtc_time_to_tm(tv_android.tv_sec, &tm_android);
	DBGLOG(EXPT, DBG, "");
	DBGLOG(EXPT, DBG, "Sync:%d%02d%02d %02d:%02d:%02d.%u(%02d:%02d:%02d.%03d(TZone))", 
		   tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
		   tm.tm_hour, tm.tm_min, tm.tm_sec,
		   (unsigned int) tv.tv_usec,
		   tm_android.tm_hour, tm_android.tm_min, tm_android.tm_sec,
		   (unsigned int) tv_android.tv_usec);
	DBGLOG(EXPT, DBG, "exception type(%d):%s",debug_info->type,debug_info->name?:"Unknown");

	switch(debug_info->type)
	{
		case MD_EX_TYPE_ASSERT_DUMP:
		case MD_EX_TYPE_ASSERT:
			DBGLOG(EXPT, DBG, "filename = %s", debug_info->assert.file_name);
			DBGLOG(EXPT, DBG, "line = %d", debug_info->assert.line_num);
			DBGLOG(EXPT, DBG, "para0 = %d, para1 = %d, para2 = %d", 
					debug_info->assert.parameters[0],
					debug_info->assert.parameters[1],
					debug_info->assert.parameters[2]);
			snprintf(ex_info,EE_BUF_LEN,"\n[%s] file:%s line:%d\np1:0x%08x\np2:0x%08x\np3:0x%08x\n",
					debug_info->name, 
					debug_info->assert.file_name,
					debug_info->assert.line_num, 
					debug_info->assert.parameters[0],
					debug_info->assert.parameters[1],
					debug_info->assert.parameters[2]);
			break;
		case MD_EX_TYPE_UNDEF:
		case MD_EX_TYPE_SWI:
		case MD_EX_TYPE_PREF_ABT:
		case MD_EX_TYPE_DATA_ABT:
		case MD_EX_TYPE_FATALERR_BUF:
		case MD_EX_TYPE_FATALERR_TASK:
			DBGLOG(EXPT, DBG, "fatal error code 1 = %d", debug_info->fatal_error.err_code1);
			DBGLOG(EXPT, DBG, "fatal error code 2 = %d", debug_info->fatal_error.err_code2);
			snprintf(ex_info,EE_BUF_LEN,"\n[%s] err_code1:%d err_code2:%d\n", debug_info->name, 
					debug_info->fatal_error.err_code1, debug_info->fatal_error.err_code2);
			break;
		case MD_EX_TYPE_EMI_CHECK:
			DBGLOG(EXPT, ERR, "md_emi_check: %08X, %08X, %02d, %08X", 
					debug_info->data.data0, debug_info->data.data1,
					debug_info->data.channel, debug_info->data.reserved);
			snprintf(ex_info,EE_BUF_LEN,"\n[emi_chk] %08X, %08X, %02d, %08X\n", 
					debug_info->data.data0, debug_info->data.data1,
					debug_info->data.channel, debug_info->data.reserved);
			break;
		case DSP_EX_TYPE_ASSERT:
			DBGLOG(EXPT, DBG, "filename = %s", debug_info->dsp_assert.file_name);
			DBGLOG(EXPT, DBG, "line = %d", debug_info->dsp_assert.line_num);
			DBGLOG(EXPT, DBG, "exec unit = %s", debug_info->dsp_assert.execution_unit);
			DBGLOG(EXPT, DBG, "para0 = %d, para1 = %d, para2 = %d", 
					debug_info->dsp_assert.parameters[0],
					debug_info->dsp_assert.parameters[1],
					debug_info->dsp_assert.parameters[2]);
			snprintf(ex_info,EE_BUF_LEN,"\n[%s] file:%s line:%d\nexec:%s\np1:%d\np2:%d\np3:%d\n",
					debug_info->name, debug_info->assert.file_name, debug_info->assert.line_num,
					debug_info->dsp_assert.execution_unit, 
					debug_info->dsp_assert.parameters[0],
					debug_info->dsp_assert.parameters[1],
					debug_info->dsp_assert.parameters[2]);
			break;
		case DSP_EX_TYPE_EXCEPTION:
			DBGLOG(EXPT, DBG, "exec unit = %s, code1:0x%08x", debug_info->dsp_exception.execution_unit,
					debug_info->dsp_exception.code1);
			snprintf(ex_info,EE_BUF_LEN,"\n[%s] exec:%s code1:0x%08x\n",
					debug_info->name, debug_info->dsp_exception.execution_unit,
					debug_info->dsp_exception.code1);
			break;
		case DSP_EX_FATAL_ERROR:
			DBGLOG(EXPT, DBG, "exec unit = %s", debug_info->dsp_fatal_err.execution_unit);
			DBGLOG(EXPT, DBG, "err_code0 = 0x%08x, err_code1 = 0x%08x", 
					debug_info->dsp_fatal_err.err_code[0],
					debug_info->dsp_fatal_err.err_code[1]);

			snprintf(ex_info,EE_BUF_LEN,"\n[%s] exec:%s err_code1:0x%08x err_code2:0x%08x\n",
					debug_info->name, debug_info->dsp_fatal_err.execution_unit, 
					debug_info->dsp_fatal_err.err_code[0],
					debug_info->dsp_fatal_err.err_code[1]);
			break;
		default: // Only display exception name
			snprintf(ex_info,EE_BUF_LEN,"\n[%s]\n", debug_info->name);
			break;
	}

	// Add additional info
	switch(debug_info->more_info)
	{
		case MD_EE_CASE_ONLY_EX:
			strcat(ex_info, "\nTime out case\n");
			break;
			
		case MD_EE_CASE_ONLY_EX_OK:
			strcat(ex_info, "\nOnly EX_OK case\n");
			break;
		case MD_EE_CASE_AP_MASK_I_BIT_TOO_LONG:
			strcat(i_bit_ex_info, ex_info);
			strcpy(ex_info, i_bit_ex_info);
			break;
		case MD_EE_CASE_TX_TRG:
		case MD_EE_CASE_ISR_TRG:
			//strcat(ex_info, "\nMay I-Bit dis too long\n");
			break;

		case MD_EE_CASE_NO_RESPONSE:
			strcat(ex_info, "\nMD long time no response\n");
			break;
			
		default:
			break;
	}

	// Dump Exception share memory
	
	memcpy(g_except_inst.expt_info_mem, except_info_addr, MD_EX_LOG_SIZE);
	eemcs_aed(CCCI_AED_DUMP_EX_MEM, ex_info);
}
示例#10
0
extern "C" void caughtSIGTERM(int sig)
{
    DBGLOG("Caught sigterm %d", sig);
}
/*
 * @brief Flush all packets in exception instance to files for debugging
 * @param
 *     None
 * @return
 *     This function returns KAL_SUCCESS always.
 */
KAL_INT32 eemcs_expt_flush()
{
    KAL_UINT32 pkts = 0;
    KAL_UINT32 i = 0;
//    struct sk_buff *skb = NULL;

	/* Flush all port skb from expt skb list  */
	for (i = 0; i < CCCI_PORT_NUM; i++) {
		pkts = atomic_read(&g_except_inst.port[i].pkt_cnt);

		/* No data in port */
		if (pkts == 0)
			continue;

		DBGLOG(EXPT, DBG, "free %d skb in port%d expt list", pkts, i);
		skb_queue_purge(&g_except_inst.port[i].skb_list);
		atomic_set(&g_except_inst.port[i].pkt_cnt, 0);
	}

	/* Flush all rx skb from expt skb list  */
	for (i = 0; i < SDIO_RX_Q_NUM; i++) {
		pkts = atomic_read(&g_except_inst.rxq[i].pkt_cnt);

		/* No data in port */
		if (pkts == 0)
			continue;

		DBGLOG(EXPT, DBG, "free %d skb in rxq%d expt list", pkts, i);
		skb_queue_purge(&g_except_inst.rxq[i].skb_list);
		atomic_set(&g_except_inst.rxq[i].pkt_cnt, 0);
	}

	/* Flush all tx skb from expt skb list  */
	for (i = 0; i < SDIO_TX_Q_NUM; i++) {
		pkts = atomic_read(&g_except_inst.txq[i].pkt_cnt);

		/* No data in port */
		if (pkts == 0)
			continue;

		DBGLOG(EXPT, DBG, "free %d skb in txq%d expt list", pkts, i);
		skb_queue_purge(&g_except_inst.txq[i].skb_list);
		atomic_set(&g_except_inst.txq[i].pkt_cnt, 0);
	}

#if 0    
    char log_file[NAME_MAX] = {0};
    struct file *fp = NULL;
    KAL_UINT32 pkts = 0;
    KAL_UINT32 i = 0, j = 0;
    struct sk_buff *skb = NULL;

    DEBUG_LOG_FUNCTION_ENTRY;
    /* Flush all DL packets to a file */
    for (i = 0; i < SDIO_RX_Q_NUM; i++) {
        pkts = atomic_read(&g_except_inst.rxq[i].pkt_cnt);
        DBGLOG(EXPT, DBG, "[EXPT] %d packets in DL SWQ %d", pkts, i);
        /* No data in Rx Q */
        if (pkts == 0)
            continue;

        sprintf(log_file, "%s/eemcs_expt_rx-%02d_%d.bak", EEMCS_EXCEPTION_LOG_PATH, g_except_inst.rxq[i].id, pkts);
        fp = file_open(log_file, O_RDWR | O_CREAT | O_TRUNC, 0777);
        if (fp == NULL) {
            DBGLOG(EXPT, ERR, "[EXPT] Failed to open file %s", log_file);
            continue;
        }
        // Write packets number
        file_write(fp, (char*)&pkts, sizeof(KAL_UINT32));
        /* Write each skb in list */
        for (j = 0; j < pkts; j++) {
            skb = skb_dequeue(&g_except_inst.rxq[i].skb_list);
            if (skb == NULL) {
                DBGLOG(EXPT, WAR, "[EXPT] Failed to read skb from RX list %d", i);
            } else {
                hif_dl_pkt_handle_complete(i);
                // Write skb data length
                file_write(fp, (char*)&skb->len, sizeof(unsigned int));
                // Write skb data
                file_write(fp, skb->data, skb->len);
                atomic_dec(&g_except_inst.rxq[i].pkt_cnt);
            }
        }
        file_close(fp);
        DBGLOG(EXPT, TRA, "[EXPT] All unhandled DL packets in Q are saved to %s", log_file);
    }
    /* Flush all UL packets to a file */
    for (i = 0; i < SDIO_TX_Q_NUM; i++) {
        pkts = atomic_read(&g_except_inst.txq[i].pkt_cnt);
        DBGLOG(EXPT, DBG, "[EXPT] %d packets in UL SWQ %d", pkts, i);
        /* No data in Tx Q */
        if (pkts == 0)
            continue;

        sprintf(log_file, "%s/eemcs_expt_tx-%02d_%d.bak", EEMCS_EXCEPTION_LOG_PATH, g_except_inst.txq[i].id, pkts);
        fp = file_open(log_file, O_RDWR | O_CREAT | O_TRUNC, 0777);
        if (fp == NULL) {
            DBGLOG(EXPT, ERR, "[EXPT] Failed to open file %s", log_file);
            continue;
        }
        // Write packets number
        file_write(fp, (char*)&pkts, sizeof(KAL_UINT32));
        /* Write each skb in list */
        for (j = 0; j < pkts; j++) {
            skb = skb_dequeue(&g_except_inst.txq[i].skb_list);
            if (skb == NULL) {
                DBGLOG(EXPT, WAR, "[EXPT] Failed to read skb from TX list %d", i);
            } else {
                // Write skb data length
                file_write(fp, (char*)&skb->len, sizeof(unsigned int));
                // Write skb data
                file_write(fp, skb->data, skb->len);
                atomic_dec(&g_except_inst.txq[i].pkt_cnt);
            }
        }
        file_close(fp);
        DBGLOG(EXPT, TRA, "[EXPT] All unhandled UL packets in Q are saved to %s", log_file);
    }
    /* Flush all port packets to a file */
    for (i = 0; i < CCCI_CDEV_NUM; i++) {
        pkts = atomic_read(&g_except_inst.port[i].pkt_cnt);
        DBGLOG(EXPT, DBG, "[EXPT] %d packets in port %d", pkts, i);
        /* No data in port */
        if (pkts == 0)
            continue;

        sprintf(log_file, "%s/eemcs_expt_port-%02d_%d.bak", EEMCS_EXCEPTION_LOG_PATH, i, pkts);
        fp = file_open(log_file, O_RDWR | O_CREAT, 0777);
        if (fp == NULL) {
            DBGLOG(EXPT, ERR, "[EXPT] Failed to open file %s", log_file);
            continue;
        }
        // Write packets number
        file_write(fp, (char*)&pkts, sizeof(KAL_UINT32));
        /* Write each skb in list */
        for (j = 0; j < pkts; j++) {
            skb = skb_dequeue(&g_except_inst.port[i].skb_list);
            if (skb == NULL) {
                DBGLOG(EXPT, WAR, "[EXPT] Failed to read skb from port list %d", i);
            } else {
                // Write skb data length
                file_write(fp, (char*)&skb->len, sizeof(unsigned int));
                // Write skb data
                file_write(fp, skb->data, skb->len);
                atomic_dec(&g_except_inst.port[i].pkt_cnt);
            }
        }
        file_close(fp);
        DBGLOG(EXPT, TRA, "[EXPT] All unhandled UL packets in port are saved to %s", log_file);
    }
    DBGLOG(EXPT, TRA, "[EXPT] eemcs_expt_flush() Finished !!");

    DEBUG_LOG_FUNCTION_LEAVE;
#else
    DEBUG_LOG_FUNCTION_ENTRY;
    DEBUG_LOG_FUNCTION_LEAVE;
#endif
    return KAL_SUCCESS;
}
示例#12
0
extern "C" void caughtSIGALRM(int sig)
{
    DBGLOG("Caught sigalrm %d", sig);
}
示例#13
0
extern "C" void caughtSIGHUP(int sig)
{
    DBGLOG("Caught sighup %d", sig);
}
示例#14
0
//=========================================================================================
//////////////////////////////////////////////////////////////////////////////////////////////
extern "C" void caughtSIGPIPE(int sig)
{
    DBGLOG("Caught sigpipe %d", sig);
}
示例#15
0
/*----------------------------------------------------------------------------*/
P_DOMAIN_INFO_ENTRY
rlmDomainGetDomainInfo (
    P_ADAPTER_T     prAdapter
    )
{
#define REG_DOMAIN_GROUP_NUM \
        (sizeof(arSupportedRegDomains) / sizeof(DOMAIN_INFO_ENTRY))

    UINT_16                 i, j;
    P_DOMAIN_INFO_ENTRY     prDomainInfo;
    P_REG_INFO_T            prRegInfo;
    UINT_16                 u2TargetCountryCode;

    ASSERT(prAdapter);

    prRegInfo = &prAdapter->prGlueInfo->rRegInfo;

    DBGLOG(RLM, INFO, ("Domain: map=%d, idx=%d, code=0x%04x\n",
        prRegInfo->eRegChannelListMap, prRegInfo->ucRegChannelListIndex,
        prAdapter->rWifiVar.rConnSettings.u2CountryCode));

	/* only 1 is set among idx/customized/countryCode in NVRAM */
	
	/* searched by idx */
    if (prRegInfo->eRegChannelListMap == REG_CH_MAP_TBL_IDX &&
        prRegInfo->ucRegChannelListIndex < REG_DOMAIN_GROUP_NUM) {
        prDomainInfo = &arSupportedRegDomains[prRegInfo->ucRegChannelListIndex];
        goto L_set_domain_info;
    }	/* searched by customized */
    else if (prRegInfo->eRegChannelListMap == REG_CH_MAP_CUSTOMIZED) {
        prDomainInfo = &prRegInfo->rDomainInfo;
        goto L_set_domain_info;
    }


	/* searched by countryCode */
    u2TargetCountryCode = prAdapter->rWifiVar.rConnSettings.u2CountryCode;
	
    for (i = 0; i < REG_DOMAIN_GROUP_NUM; i++) {
        prDomainInfo = &arSupportedRegDomains[i];

        ASSERT((prDomainInfo->u4CountryNum && prDomainInfo->pu2CountryGroup) ||
               prDomainInfo->u4CountryNum == 0);

        for (j = 0; j < prDomainInfo->u4CountryNum; j++) {
            if (prDomainInfo->pu2CountryGroup[j] == u2TargetCountryCode) {
                break;
            }
        }
        if (j < prDomainInfo->u4CountryNum) {
            break; /* Found */
        }
    }

    DATA_STRUC_INSPECTING_ASSERT(REG_DOMAIN_DEF_IDX < REG_DOMAIN_GROUP_NUM);


	/* If no matched countryCode */
	if (i >= REG_DOMAIN_GROUP_NUM){
		if (prAdapter->prDomainInfo) /* use previous NVRAM setting */
			return prAdapter->prDomainInfo;
		else	/* if never set before, use EU */
			prDomainInfo = &arSupportedRegDomains[REG_DOMAIN_DEF_IDX];	
	}
	

L_set_domain_info:

    prAdapter->prDomainInfo = prDomainInfo;
    return prDomainInfo;
}
/*
 * @brief EEMCS exception handshake .
 * @param
 *     skb   [in] SKB from MD exception, call by eemcs_boot_rx_callback
 *                when receive with MAGIC "MD_EX_MAGIC".
 *
 * @return
 *     KAL_SUCCESS  success.
 *     KAL_FAIL     fail.
 */
KAL_INT32 eemcs_expt_handshake(struct sk_buff *skb){
    CCCI_BUFF_T *msg = (CCCI_BUFF_T *)skb->data;
    DEBUG_INFO_T debug_info = {0};
    KAL_INT32 ret = KAL_SUCCESS;

    switch(msg->id){
       case MD_EX :
            if(msg->reserved != MD_EX_CHK_ID){
                DBGLOG(EXPT, ERR, "Invalid MD_EX: %08X, %08X, %08X, %08X",
                	msg->magic, msg->id, msg->channel, msg->reserved);
                ret = KAL_FAIL;
                break;
            }
            DBGLOG(EXPT, DBG, "receive MD_EX");
           
            //change_device_state(EEMCS_EXCEPTION);
            /*move to ccci_df_to_ccci_exception_callback*/
            //eemcs_cdev_msg(CCCI_PORT_CTRL, CCCI_MD_MSG_EXCEPTION, 0);

            msg->channel = CH_CTRL_TX;
            eemcs_ccci_UL_write_skb_to_swq(CH_CTRL_TX, skb);
			
            //2. set up timer for waiting MD_EX_REC_OK msg
            if (eemcs_exception_state != EEMCS_EX_REC_MSG_OK) {
                set_exception_mode(EEMCS_EX_MSG_OK);
                mod_timer(&g_except_inst.md_ex_monitor, jiffies+EE_HS2_TIMER);
            }
			
            return ret;
            
        case MD_EX_REC_OK :
            if(msg->reserved != MD_EX_REC_OK_CHK_ID){
                DBGLOG(EXPT, ERR, "Invalid MD_EX_REC_OK: %08X, %08X, %08X, %08X",
                	msg->magic, msg->id, msg->channel, msg->reserved);
                ret = KAL_FAIL;
                break;
            }
            DBGLOG(EXPT, DBG, "receive MD_EX_REC_OK");

            set_exception_mode(EEMCS_EX_REC_MSG_OK);
            del_timer(&g_except_inst.md_ex_monitor);

            DBGLOG(EXPT, DBG, "eemcs_md_exception_data_parse");
            eemcs_md_exception_data_parse((char*)(msg+1), &debug_info);
            eemcs_ee_info_dump(&debug_info, (char*)(msg+1));
            break;
            
        case MD_EX_RESUME_CHK_ID :
            DBGLOG(EXPT, DBG, "receive MD_EX_RESUME_CHK_ID");
            md_emi_check(msg, &debug_info);
            eemcs_ee_info_dump(&debug_info, (char*)(msg+1));
            break;
            
        case CCCI_DRV_VER_ERROR :
            DBGLOG(EXPT, ERR, "AP EEMCS driver version mis-match to MD!!");
            eemcs_aed(0, "AP/MD driver version mis-match\n");
            break;
            
        default:
            DBGLOG(EXPT, ERR, "[EXPT] Invalid MD_EX_MAGIC: %08X, %08X, %02d, %08X",
            	msg->magic, msg->id, msg->channel, msg->reserved);
            break;
    }
	
    dev_kfree_skb(skb);
    return ret;
}
示例#17
0
/*----------------------------------------------------------------------------*/
VOID
rlmDomainSendCmd (
    P_ADAPTER_T     prAdapter,
    BOOLEAN         fgIsOid
    )
{
    P_DOMAIN_INFO_ENTRY     prDomainInfo;
    P_CMD_SET_DOMAIN_INFO_T prCmd;
    WLAN_STATUS             rStatus;
    P_DOMAIN_SUBBAND_INFO   prSubBand;
    UINT_8                  i;	


    prDomainInfo = rlmDomainGetDomainInfo(prAdapter);
    ASSERT(prDomainInfo);

    prCmd = cnmMemAlloc(prAdapter, RAM_TYPE_BUF, sizeof(CMD_SET_DOMAIN_INFO_T));
    ASSERT(prCmd);

    /* To do: exception handle */
    if (!prCmd) {
        DBGLOG(RLM, ERROR, ("Domain: no buf to send cmd\n"));
        return;
    }
    kalMemZero(prCmd, sizeof(CMD_SET_DOMAIN_INFO_T));

    /* previous country code == FF : ignore country code,  current country code == FE : resume */    
    if(prAdapter->rWifiVar.rConnSettings.u2CountryCodeBakup == COUNTRY_CODE_FF){
        if (prAdapter->rWifiVar.rConnSettings.u2CountryCode != COUNTRY_CODE_FE){
            DBGLOG(RLM, INFO, ("Domain: skip country code cmd (0x%x)\n",prAdapter->rWifiVar.rConnSettings.u2CountryCode));            
            return;
        }else{
            DBGLOG(RLM, INFO, ("Domain: disable skip country code cmd (0x%x)\n",prAdapter->rWifiVar.rConnSettings.u2CountryCode));            
        }
    }
        
    prAdapter->rWifiVar.rConnSettings.u2CountryCodeBakup = prAdapter->rWifiVar.rConnSettings.u2CountryCode;
    DBGLOG(RLM, INFO, ("Domain: country code backup %x \n",prAdapter->rWifiVar.rConnSettings.u2CountryCodeBakup));

    prCmd->u2CountryCode = prAdapter->rWifiVar.rConnSettings.u2CountryCode;
    prCmd->u2IsSetPassiveScan = 0;
    prCmd->uc2G4Bandwidth = prAdapter->rWifiVar.rConnSettings.uc2G4BandwidthMode;
    prCmd->uc5GBandwidth = prAdapter->rWifiVar.rConnSettings.uc5GBandwidthMode;
	prCmd->aucReserved[0] = 0;
	prCmd->aucReserved[1] = 0;	

    for (i = 0; i < 6; i++) {
        prSubBand = &prDomainInfo->rSubBand[i];

        prCmd->rSubBand[i].ucRegClass = prSubBand->ucRegClass;
        prCmd->rSubBand[i].ucBand = prSubBand->ucBand;

        if (prSubBand->ucBand != BAND_NULL && prSubBand->ucBand < BAND_NUM) {
            prCmd->rSubBand[i].ucChannelSpan = prSubBand->ucChannelSpan;
            prCmd->rSubBand[i].ucFirstChannelNum = prSubBand->ucFirstChannelNum;
            prCmd->rSubBand[i].ucNumChannels = prSubBand->ucNumChannels;
        }
    }
	
	DBGLOG(RLM, INFO, ("rlmDomainSendCmd(), SetQueryCmd\n"));

    /* Update domain info to chip */
    rStatus = wlanSendSetQueryCmd (
                prAdapter,                  /* prAdapter */
                CMD_ID_SET_DOMAIN_INFO,     /* ucCID */
                TRUE,                       /* fgSetQuery */
                FALSE,                      /* fgNeedResp */
                fgIsOid,                    /* fgIsOid */
                NULL,                       /* pfCmdDoneHandler*/
                NULL,                       /* pfCmdTimeoutHandler */
                sizeof(CMD_SET_DOMAIN_INFO_T),    /* u4SetQueryInfoLen */
                (PUINT_8) prCmd,            /* pucInfoBuffer */
                NULL,                       /* pvSetQueryBuffer */
                0                           /* u4SetQueryBufferLen */
                );

    ASSERT(rStatus == WLAN_STATUS_PENDING);

    cnmMemFree(prAdapter, prCmd);

	rlmDomainPassiveScanSendCmd(prAdapter, fgIsOid);
}
static void eemcs_wdt_reset_work_func(struct work_struct *work){
    DBGLOG(EXPT, DBG, "eemcs_wdt_reset_work_func modem reset");
    eemcs_md_reset();
}
示例#19
0
int
mtk_cfg80211_get_station (
    struct wiphy *wiphy,
    struct net_device *ndev,
    u8 *mac,
    struct station_info *sinfo
    )
{
    P_GLUE_INFO_T prGlueInfo = NULL;
    WLAN_STATUS rStatus;
    PARAM_MAC_ADDRESS arBssid;
    UINT_32 u4BufLen, u4Rate;
    INT_32 i4Rssi;

    prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy);
    ASSERT(prGlueInfo);

    kalMemZero(arBssid, MAC_ADDR_LEN);
    wlanQueryInformation(prGlueInfo->prAdapter,
            wlanoidQueryBssid,
            &arBssid[0],
            sizeof(arBssid),
            &u4BufLen);

    /* 1. check BSSID */
    if(UNEQUAL_MAC_ADDR(arBssid, mac)) {
        /* wrong MAC address */
        DBGLOG(REQ, WARN, ("incorrect BSSID: ["MACSTR"] currently connected BSSID["MACSTR"]\n", 
                    MAC2STR(mac), MAC2STR(arBssid)));
        return -ENOENT;
    }

    /* 2. fill TX rate */
    rStatus = kalIoctl(prGlueInfo,
        wlanoidQueryLinkSpeed,
        &u4Rate,
        sizeof(u4Rate),
        TRUE,
        FALSE,
        FALSE,
        FALSE,
        &u4BufLen);

    if (rStatus != WLAN_STATUS_SUCCESS) {
        DBGLOG(REQ, WARN, ("unable to retrieve link speed\n"));
    }
    else {
        sinfo->filled |= STATION_INFO_TX_BITRATE;
        sinfo->txrate.legacy = u4Rate / 1000; /* convert from 100bps to 100kbps */
    }

    if(prGlueInfo->eParamMediaStateIndicated != PARAM_MEDIA_STATE_CONNECTED) {
        /* not connected */
        DBGLOG(REQ, WARN, ("not yet connected\n"));
    }
    else {
        /* 3. fill RSSI */
        rStatus = kalIoctl(prGlueInfo,
                wlanoidQueryRssi,
                &i4Rssi,
                sizeof(i4Rssi),
                TRUE,
                FALSE,
                FALSE,
                FALSE,
                &u4BufLen);
        
        if (rStatus != WLAN_STATUS_SUCCESS) {
            DBGLOG(REQ, WARN, ("unable to retrieve link speed\n"));
        }
        else {
            sinfo->filled |= STATION_INFO_SIGNAL;
            sinfo->signal = i4Rssi; /* dBm */
        }
    }

    return 0;
}
KAL_INT32 eemcs_wdt_reset_callback(void){
    static DECLARE_WORK(eemcs_wdt_reset_work, eemcs_wdt_reset_work_func);
    DBGLOG(EXPT, DBG, "eemcs_wdt_reset_callback");
    schedule_work(&eemcs_wdt_reset_work);
    return 0;
}
示例#21
0
bool CWsDfuXRefEx::onDFUXRefDirectories(IEspContext &context, IEspDFUXRefDirectoriesQueryRequest &req, IEspDFUXRefDirectoriesQueryResponse &resp)
{
    try
    {
        if (!context.validateFeatureAccess(FEATURE_URL, SecAccess_Read, false))
            throw MakeStringException(ECLWATCH_DFU_XREF_ACCESS_DENIED, "Failed to get Xref Directories. Permission denied.");

        StringBuffer username;
        context.getUserID(username);
        DBGLOG("CWsDfuXRefEx::onDFUXRefDirectories User=%s",username.str());
        if (!req.getCluster() || !*req.getCluster())
            throw MakeStringExceptionDirect(ECLWATCH_INVALID_INPUT, "Cluster not defined.");

        Owned<IXRefNode> xRefNode = XRefNodeManager->getXRefNode(req.getCluster());
        if (xRefNode.get() == 0)
            return false;

        StringBuffer buf0;
        xRefNode->serializeDirectories(buf0);

        Owned <IPropertyTree> dirs = createPTreeFromXMLString(buf0.str()); // Why are we doing this?
        Owned<IPropertyTreeIterator> iter = dirs->getElements("Directory");
        ForEach(*iter)
        {
            IPropertyTree &node = iter->query();

            StringBuffer positive, negative;
            char* skew = (char*) node.queryProp("Skew");
            if (!skew || !*skew)
                continue;

            char* skewPtr = strchr(skew, '/');
            if (skewPtr)
            {
                if (skew[0] == '+' && (strlen(skew) > 1))
                    positive.append(skewPtr - skew - 1, skew+1);
                else
                    positive.append(skewPtr - skew, skew);
                skewPtr++;
                if (skewPtr)
                {
                    if (skewPtr[0] == '-')
                        negative.append(skewPtr+1);
                    else
                        negative.append(skewPtr);
                }
            }
            else
            {
                if (skew[0] == '+' && (strlen(skew) > 1))
                    positive.append(skew+1);
                else
                    positive.append(skew);
            }

            node.removeProp("Skew");
            node.addProp("PositiveSkew", positive);
            node.addProp("NegativeSkew", negative);
        }
        
        StringBuffer buf;
        toXML(dirs, buf);
        resp.setDFUXRefDirectoriesQueryResult(buf.str());
    }
    catch(IException* e)
    {   
        FORWARDEXCEPTION(context, e,  ECLWATCH_INTERNAL_ERROR);
    }
    return true;
}
/**
 * @brief function that fill the multimap (passed as parameter) with Precedence attribute and Action Tuple checking the Action Option attribute
 */
void ActionPluginFinalCallback::executionModeController(
		std::multimap<int, Tuple>& multimapOfExecution) {

	const AnswerSetPtr& bestModel = (*(ctxData.iteratorBestModel));

	// used to have only the Action Atoms
	InterpretationPtr intr = InterpretationPtr(new Interpretation(registryPtr));
	intr->getStorage() |= ctxData.myAuxiliaryPredicateMask.mask()->getStorage();
	intr->getStorage() &= bestModel->interpretation->getStorage();

	Interpretation::TrueBitIterator bit, bit_end;
	for (boost::tie(bit, bit_end) = intr->trueBits(); bit != bit_end; ++bit) {

		const OrdinaryAtom& oatom = registryPtr->ogatoms.getByAddress(*bit);
		const Tuple & tuple = oatom.tuple;

		int precedence, precedence_position = tuple.size() - 3;
		dlvhex::ID id_actionOption = tuple[tuple.size() - 4];

		Tuple action_tuple;

		for (int i = 1; i < tuple.size() - 4; i++)
			action_tuple.push_back(tuple[i]);

		if (tuple[precedence_position].isIntegerTerm()
				&& id_actionOption.isConstantTerm()) {

			precedence = tuple[precedence_position].address;

			DBGLOG(DBG,
					"actionOption: "
							<< registryPtr->getTermStringByID(id_actionOption));
			DBGLOG(DBG, "Precedence: " << precedence);

			if (id_actionOption == ctxData.getIDBrave())
				;
			else if (id_actionOption == ctxData.getIDCautious())
				if (!isPresentInAllAnswerSets(action_tuple)) {
					std::stringstream ss;
					printTuple(ss, action_tuple, registryPtr);
					DBGLOG(DBG,
							"This action atom isn't present in all AnswerSet: "
									<< ss.str());
					continue;
				} else if (id_actionOption == ctxData.getIDPreferredCautious())
					if (!isPresentInAllTheBestModelsAnswerSets(action_tuple)) {
						std::stringstream ss;
						printTuple(ss, action_tuple, registryPtr);
						DBGLOG(DBG,
								"This action atom isn't present in all BestModels AnswerSet: "
										<< ss.str());
						continue;
					} else
						throw PluginError(
								"Error in the selection of brave, cautious or preferred_cautious");

			multimapOfExecution.insert(
					std::pair<int, Tuple>(precedence, action_tuple));

		} else
			throw PluginError(
					"Precedence isn't Integer term or actionOption haven't a valid value");

	}

}
int
mtk_cfg80211_get_station (
    struct wiphy *wiphy,
    struct net_device *ndev,
    u8 *mac,
    struct station_info *sinfo
    )
{
    P_GLUE_INFO_T prGlueInfo = NULL;
    WLAN_STATUS rStatus;
    PARAM_MAC_ADDRESS arBssid;
    UINT_32 u4BufLen, u4Rate;
    INT_32 i4Rssi;

    prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy);
    ASSERT(prGlueInfo);

    kalMemZero(arBssid, MAC_ADDR_LEN);
    wlanQueryInformation(prGlueInfo->prAdapter,
            wlanoidQueryBssid,
            &arBssid[0],
            sizeof(arBssid),
            &u4BufLen);

    /* 1. check BSSID */
    if(UNEQUAL_MAC_ADDR(arBssid, mac)) {
        /* wrong MAC address */
        DBGLOG(REQ, WARN, ("incorrect BSSID: ["MACSTR"] currently connected BSSID["MACSTR"]\n", 
                    MAC2STR(mac), MAC2STR(arBssid)));
        return -ENOENT;
    }

    /* 2. fill TX rate */
    rStatus = kalIoctl(prGlueInfo,
        wlanoidQueryLinkSpeed,
        &u4Rate,
        sizeof(u4Rate),
        TRUE,
        FALSE,
        FALSE,
        FALSE,
        &u4BufLen);

    if (rStatus != WLAN_STATUS_SUCCESS) {
        DBGLOG(REQ, WARN, ("unable to retrieve link speed\n"));
    }
    else {
        sinfo->filled |= STATION_INFO_TX_BITRATE;
        sinfo->txrate.legacy = u4Rate / 1000; /* convert from 100bps to 100kbps */
    }

    if(prGlueInfo->eParamMediaStateIndicated != PARAM_MEDIA_STATE_CONNECTED) {
        /* not connected */
        DBGLOG(REQ, WARN, ("not yet connected\n"));
    }
    else {
        /* 3. fill RSSI */
        rStatus = kalIoctl(prGlueInfo,
                wlanoidQueryRssi,
                &i4Rssi,
                sizeof(i4Rssi),
                TRUE,
                FALSE,
                FALSE,
                FALSE,
                &u4BufLen);
        
        if (rStatus != WLAN_STATUS_SUCCESS) {
            DBGLOG(REQ, WARN, ("unable to retrieve link speed\n"));
        }
        else {
            sinfo->filled |= STATION_INFO_SIGNAL;
	    //in the cfg80211 layer, the signal is a signed char variable.
            if(i4Rssi < -128)
		sinfo->signal = -128;
	    else
	        sinfo->signal = i4Rssi; /* dBm */
        }
    }

    sinfo->rx_packets = prGlueInfo->rNetDevStats.rx_packets;
    sinfo->filled |= STATION_INFO_TX_PACKETS;
    sinfo->tx_packets = prGlueInfo->rNetDevStats.tx_packets;
    sinfo->filled |= STATION_INFO_TX_FAILED;

#if 1
   {
            WLAN_STATUS rStatus;
            UINT_32 u4XmitError = 0;
//           UINT_32 u4XmitOk = 0;
//          UINT_32 u4RecvError = 0;
//           UINT_32 u4RecvOk = 0;
//           UINT_32 u4BufLen;

           /* @FIX ME: need a more clear way to do this */


            rStatus = kalIoctl(prGlueInfo,
                    wlanoidQueryXmitError,
                    &u4XmitError,
                    sizeof(UINT_32),
                    TRUE,
                    TRUE,
                    TRUE,
                    FALSE,
                    &u4BufLen);

           prGlueInfo->rNetDevStats.tx_errors = u4XmitError;

   }
#else
         prGlueInfo->rNetDevStats.tx_errors = 0;
#endif

    sinfo->tx_failed = prGlueInfo->rNetDevStats.tx_errors;

    return 0;
}
/**
 * @brief Best Model Selector, Execution Schedule Builder, Execute Actions on Environment
 */
void ActionPluginFinalCallback::operator()() {
	DBGLOG(DBG, "\nActionPluginFinalCallback called");

	if (ctxData.nameBestModelSelectorMap.count(
			ctxData.getBestModelSelectorSelected()) == 0)
		throw PluginError("The BestModelSelector chosen doesn't exist");

	ctxData.nameBestModelSelectorMap[ctxData.getBestModelSelectorSelected()]->getBestModel(
			ctxData.iteratorBestModel, ctxData.bestModelsContainer);

	std::stringstream ss;
	(*ctxData.iteratorBestModel)->interpretation->print(ss);
	DBGLOG(DBG, "\nBestModel selected: " << ss.str());

	DBGLOG(DBG, "\nCall the executionModeController");
	std::multimap<int, Tuple> multimapOfExecution;
	executionModeController(multimapOfExecution);

	DBGLOG(DBG, "\nThe MultiMapOfExecution:");
	DBGLOG(DBG, "Precedence\tTuple");
	std::multimap<int, Tuple>::iterator itMMOE;
	for (itMMOE = multimapOfExecution.begin();
			itMMOE != multimapOfExecution.end(); itMMOE++) {
		const Tuple& tempTuple = itMMOE->second;
		std::stringstream ss;
		printTuple(ss, tempTuple, registryPtr);
		DBGLOG(DBG, itMMOE->first << "\t\t" << ss.str());
	}

	if (ctxData.nameExecutionScheduleBuilderMap.count(
			ctxData.getExecutionScheduleBuilderSelected()) == 0)
		throw PluginError("The ExecutionScheduleBuilder chosen doesn't exist");

	DBGLOG(DBG, "\nCall the executionScheduleBuilder");
	std::list < std::set<Tuple> > listOfExecution;
	ctxData.nameExecutionScheduleBuilderMap[ctxData.getExecutionScheduleBuilderSelected()]->rewrite(
			multimapOfExecution, listOfExecution, (*(ctxData.iteratorBestModel))->interpretation);

	DBGLOG(DBG, "\nThe ListOfExecution:");
	std::list<std::set<Tuple> >::iterator itLOE;
	for (itLOE = listOfExecution.begin(); itLOE != listOfExecution.end();
			itLOE++) {
		std::set < Tuple > &tempSet = (*itLOE);
		for (std::set<Tuple>::iterator itLOEs = tempSet.begin();
				itLOEs != tempSet.end(); itLOEs++) {
			const Tuple& tempTuple = (*itLOEs);
			std::stringstream ss;
			printTuple(ss, tempTuple, registryPtr);
			DBGLOG(DBG, ss.str());
		}
	}

	DBGLOG(DBG,
			"\nControl if the order of Set in the List corresponds to their precedence");
	if (checkIfTheListIsCorrect(multimapOfExecution, listOfExecution)) {
		DBGLOG(DBG, "The List is correct");
	} else {
		DBGLOG(DBG, "The List isn't correct");
		throw PluginError(
				"The order of Set in the ListOfExecution doens't correspond to their precedence");
	}

	DBGLOG(DBG, "\nExecute the actions in the right order");

	for (itLOE = listOfExecution.begin(); itLOE != listOfExecution.end();
			itLOE++) {

		std::set < Tuple > &tempSet = (*itLOE);

		for (std::set<Tuple>::iterator itLOEs = tempSet.begin();
				itLOEs != tempSet.end(); itLOEs++) {

			const Tuple& tempTuple = (*itLOEs);

			if (*tempTuple.begin() == ctxData.getIDContinue()) {
				ctxData.continueIteration = true;
				continue;
			} else if (*tempTuple.begin() == ctxData.getIDStop()) {
				ctxData.stopIteration = true;
				continue;
			}

			Tuple tupleForExecute;
			tupleForExecute.insert(tupleForExecute.begin(),
					tempTuple.begin() + 1, tempTuple.end());

			std::stringstream ss;
			printTuple(ss, tempTuple, registryPtr);
			DBGLOG(DBG, "tupleForExecute: " << ss.str());
			ss.str("");
			printTuple(ss, tupleForExecute, registryPtr);
			DBGLOG(DBG, "tempTuple: " << ss.str());

			std::map<std::string, PluginActionBasePtr>::iterator it =
					ctxData.namePluginActionBaseMap.find(
							registryPtr->getTermStringByID(*tempTuple.begin()));

			if (it != ctxData.namePluginActionBaseMap.end())
				it->second->execute(programCtx,
						(*(ctxData.iteratorBestModel))->interpretation,
						tupleForExecute);
			else
				DBGLOG(DBG,
						"For the action '"
								<< registryPtr->getTermStringByID(
										*tempTuple.begin())
								<< "' wasn't found a definition");

		}
	}

	DBGLOG(DBG, "\nCheck Iteration");
	if (ctxData.getIterationType() == DEFAULT && ctxData.continueIteration)
		programCtx.config.setOption("RepeatEvaluation", 1);
	else if (ctxData.getIterationType() != DEFAULT && ctxData.stopIteration)
		programCtx.config.setOption("RepeatEvaluation", 0);
	else if (ctxData.getIterationType() == INFINITE)
		programCtx.config.setOption("RepeatEvaluation", 1);
	else if (ctxData.getIterationType() == FIXED) {
		if (!ctxData.getTimeDuration().is_not_a_date_time()) {
			boost::posix_time::time_duration diff =
					boost::posix_time::second_clock::local_time()
							- ctxData.getStartingTime();
			if (diff > ctxData.getTimeDuration())
				programCtx.config.setOption("RepeatEvaluation", 0);
			else if (ctxData.getNumberIterations() != -1) {
				programCtx.config.setOption("RepeatEvaluation",
						ctxData.getNumberIterations());
				ctxData.decreaseNumberIterations();
			} else
				programCtx.config.setOption("RepeatEvaluation", 1);
		}
	}

	if (programCtx.config.getOption("RepeatEvaluation") > 0) {

		DBGLOG(DBG, "\nIncrease iteration in the UtilitiesPlugin");
		ctxData.increaseIteration(programCtx);

		DBGLOG(DBG, "\nClear data structures");
		ctxData.clearDataStructures();

		ctxData.continueIteration = false;
		ctxData.stopIteration = false;

		DBGLOG(DBG, "\nReset cache");
		programCtx.resetCacheOfPlugins();

	}

}
/*----------------------------------------------------------------------------*/
int
mtk_cfg80211_connect (
    struct wiphy *wiphy,
    struct net_device *ndev,
    struct cfg80211_connect_params *sme
    )
{
    P_GLUE_INFO_T prGlueInfo = NULL;
    WLAN_STATUS rStatus;
    UINT_32 u4BufLen;
    ENUM_PARAM_ENCRYPTION_STATUS_T eEncStatus;
    ENUM_PARAM_AUTH_MODE_T eAuthMode;
    UINT_32 cipher;
    PARAM_SSID_T rNewSsid;
    BOOLEAN fgCarryWPSIE = FALSE;
    ENUM_PARAM_OP_MODE_T eOpMode;

    prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy);
    ASSERT(prGlueInfo);

    if (prGlueInfo->prAdapter->rWifiVar.rConnSettings.eOPMode > NET_TYPE_AUTO_SWITCH)
		eOpMode = NET_TYPE_AUTO_SWITCH;
	else 
	    eOpMode = prGlueInfo->prAdapter->rWifiVar.rConnSettings.eOPMode;
	
	rStatus = kalIoctl(prGlueInfo,
		wlanoidSetInfrastructureMode,
		&eOpMode,
		sizeof(eOpMode),
		FALSE,
		FALSE,
		TRUE,
		FALSE,
		&u4BufLen);

	if (rStatus != WLAN_STATUS_SUCCESS) {
		DBGLOG(INIT, INFO, ("wlanoidSetInfrastructureMode fail 0x%lx\n", rStatus));
		return -EFAULT;
	}

	/* after set operation mode, key table are cleared */

	/* reset wpa info */
	prGlueInfo->rWpaInfo.u4WpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
	prGlueInfo->rWpaInfo.u4KeyMgmt = 0;
	prGlueInfo->rWpaInfo.u4CipherGroup = IW_AUTH_CIPHER_NONE;
	prGlueInfo->rWpaInfo.u4CipherPairwise = IW_AUTH_CIPHER_NONE;
	prGlueInfo->rWpaInfo.u4AuthAlg = IW_AUTH_ALG_OPEN_SYSTEM;
#if CFG_SUPPORT_802_11W
	prGlueInfo->rWpaInfo.u4Mfp = IW_AUTH_MFP_DISABLED;
#endif

    if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
        prGlueInfo->rWpaInfo.u4WpaVersion = IW_AUTH_WPA_VERSION_WPA;
    else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)
        prGlueInfo->rWpaInfo.u4WpaVersion = IW_AUTH_WPA_VERSION_WPA2;
    else
        prGlueInfo->rWpaInfo.u4WpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
 
    switch (sme->auth_type) {
    case NL80211_AUTHTYPE_OPEN_SYSTEM:
        prGlueInfo->rWpaInfo.u4AuthAlg = IW_AUTH_ALG_OPEN_SYSTEM;
        break;
    case NL80211_AUTHTYPE_SHARED_KEY:
        prGlueInfo->rWpaInfo.u4AuthAlg = IW_AUTH_ALG_SHARED_KEY;
        break;
    default:
        prGlueInfo->rWpaInfo.u4AuthAlg = IW_AUTH_ALG_OPEN_SYSTEM | IW_AUTH_ALG_SHARED_KEY;
        break;
    }

    if (sme->crypto.n_ciphers_pairwise) {
        prGlueInfo->prAdapter->rWifiVar.rConnSettings.rRsnInfo.au4PairwiseKeyCipherSuite[0] = sme->crypto.ciphers_pairwise[0];
        switch (sme->crypto.ciphers_pairwise[0]) {
        case WLAN_CIPHER_SUITE_WEP40:
            prGlueInfo->rWpaInfo.u4CipherPairwise = IW_AUTH_CIPHER_WEP40;
            break;
        case WLAN_CIPHER_SUITE_WEP104:
            prGlueInfo->rWpaInfo.u4CipherPairwise = IW_AUTH_CIPHER_WEP104;
            break;
        case WLAN_CIPHER_SUITE_TKIP:
            prGlueInfo->rWpaInfo.u4CipherPairwise = IW_AUTH_CIPHER_TKIP;
            break;
        case WLAN_CIPHER_SUITE_CCMP:
            prGlueInfo->rWpaInfo.u4CipherPairwise = IW_AUTH_CIPHER_CCMP;
            break;
        case WLAN_CIPHER_SUITE_AES_CMAC:
            prGlueInfo->rWpaInfo.u4CipherPairwise = IW_AUTH_CIPHER_CCMP;
            break;
        default:
            DBGLOG(REQ, WARN, ("invalid cipher pairwise (%d)\n",
                   sme->crypto.ciphers_pairwise[0]));
            return -EINVAL;
        }
    }

    if (sme->crypto.cipher_group) {
        prGlueInfo->prAdapter->rWifiVar.rConnSettings.rRsnInfo.u4GroupKeyCipherSuite = sme->crypto.cipher_group;
        switch (sme->crypto.cipher_group) {
        case WLAN_CIPHER_SUITE_WEP40:
            prGlueInfo->rWpaInfo.u4CipherGroup = IW_AUTH_CIPHER_WEP40;
            break;          
        case WLAN_CIPHER_SUITE_WEP104:
            prGlueInfo->rWpaInfo.u4CipherGroup = IW_AUTH_CIPHER_WEP104;
            break;
        case WLAN_CIPHER_SUITE_TKIP:
            prGlueInfo->rWpaInfo.u4CipherGroup = IW_AUTH_CIPHER_TKIP;
            break;
        case WLAN_CIPHER_SUITE_CCMP:
            prGlueInfo->rWpaInfo.u4CipherGroup = IW_AUTH_CIPHER_CCMP;
            break;
        case WLAN_CIPHER_SUITE_AES_CMAC:
            prGlueInfo->rWpaInfo.u4CipherGroup = IW_AUTH_CIPHER_CCMP;
            break;
        default:
            DBGLOG(REQ, WARN, ("invalid cipher group (%d)\n",
                   sme->crypto.cipher_group));
            return -EINVAL;
        }
    }

    if (sme->crypto.n_akm_suites) {
        prGlueInfo->prAdapter->rWifiVar.rConnSettings.rRsnInfo.au4AuthKeyMgtSuite[0] = sme->crypto.akm_suites[0];
        if (prGlueInfo->rWpaInfo.u4WpaVersion == IW_AUTH_WPA_VERSION_WPA) {
            switch (sme->crypto.akm_suites[0]) {
            case WLAN_AKM_SUITE_8021X:
                eAuthMode = AUTH_MODE_WPA;
                break;
            case WLAN_AKM_SUITE_PSK:
                eAuthMode = AUTH_MODE_WPA_PSK;
            break;
            default:
                DBGLOG(REQ, WARN, ("invalid cipher group (%d)\n",
                       sme->crypto.cipher_group));
                return -EINVAL;
            }
        } else if (prGlueInfo->rWpaInfo.u4WpaVersion == IW_AUTH_WPA_VERSION_WPA2) {
            switch (sme->crypto.akm_suites[0]) {
            case WLAN_AKM_SUITE_8021X:
            eAuthMode = AUTH_MODE_WPA2;
            break;
            case WLAN_AKM_SUITE_PSK:
            eAuthMode = AUTH_MODE_WPA2_PSK;
            break;
            default:
                DBGLOG(REQ, WARN, ("invalid cipher group (%d)\n",
                       sme->crypto.cipher_group));
                return -EINVAL;
            }
        }
    }

    if (prGlueInfo->rWpaInfo.u4WpaVersion == IW_AUTH_WPA_VERSION_DISABLED) {
        eAuthMode = (prGlueInfo->rWpaInfo.u4AuthAlg == IW_AUTH_ALG_OPEN_SYSTEM) ?
             AUTH_MODE_OPEN : AUTH_MODE_AUTO_SWITCH;
    }

    prGlueInfo->rWpaInfo.fgPrivacyInvoke = sme->privacy;

    //prGlueInfo->prAdapter->rWifiVar.rConnSettings.fgWapiMode = FALSE;
    //prGlueInfo->prAdapter->prGlueInfo->u2WapiAssocInfoIESz = 0;
    prGlueInfo->fgWpsActive = FALSE;
    //prGlueInfo->prAdapter->prGlueInfo->u2WSCAssocInfoIELen = 0;

    if (sme->ie && sme->ie_len > 0) {
        WLAN_STATUS rStatus;
        UINT_32 u4BufLen;
        PUINT_8 prDesiredIE = NULL;

#if CFG_SUPPORT_WAPI
        rStatus = kalIoctl(prGlueInfo,
                wlanoidSetWapiAssocInfo,
                sme->ie,
                sme->ie_len,
                FALSE,
                FALSE,
                FALSE,
                FALSE,
                &u4BufLen);
        
        if (rStatus != WLAN_STATUS_SUCCESS) {
            DBGLOG(SEC, WARN, ("[wapi] set wapi assoc info error:%lx\n", rStatus));
        }
#endif
#if CFG_SUPPORT_WPS2
        if (wextSrchDesiredWPSIE(sme->ie,
                    sme->ie_len,
                    0xDD,
                    (PUINT_8 *)&prDesiredIE)) {
            prGlueInfo->fgWpsActive = TRUE;
            fgCarryWPSIE = TRUE;

            rStatus = kalIoctl(prGlueInfo,
                    wlanoidSetWSCAssocInfo,
                    prDesiredIE,
                    IE_SIZE(prDesiredIE),
                    FALSE,
                    FALSE,
                    FALSE,
                    FALSE,
                    &u4BufLen);
            if (rStatus != WLAN_STATUS_SUCCESS) {
                DBGLOG(SEC, WARN, ("WSC] set WSC assoc info error:%lx\n", rStatus));
            }
        }
#endif
    }

    /* clear WSC Assoc IE buffer in case WPS IE is not detected */
    if(fgCarryWPSIE == FALSE) {
        kalMemZero(&prGlueInfo->aucWSCAssocInfoIE, 200);
        prGlueInfo->u2WSCAssocInfoIELen = 0;
    }

    rStatus = kalIoctl(prGlueInfo,
            wlanoidSetAuthMode,
            &eAuthMode,
            sizeof(eAuthMode),
            FALSE,
            FALSE,
            FALSE,
            FALSE,
            &u4BufLen);
    if (rStatus != WLAN_STATUS_SUCCESS) {
        DBGLOG(REQ, WARN, ("set auth mode error:%lx\n", rStatus));
    }

    cipher = prGlueInfo->rWpaInfo.u4CipherGroup | prGlueInfo->rWpaInfo.u4CipherPairwise;

    if (prGlueInfo->rWpaInfo.fgPrivacyInvoke) {
        if (cipher & IW_AUTH_CIPHER_CCMP) {
            eEncStatus = ENUM_ENCRYPTION3_ENABLED;
        }
        else if (cipher & IW_AUTH_CIPHER_TKIP) {
            eEncStatus = ENUM_ENCRYPTION2_ENABLED;
        }
        else if (cipher & (IW_AUTH_CIPHER_WEP104 | IW_AUTH_CIPHER_WEP40)) {
            eEncStatus = ENUM_ENCRYPTION1_ENABLED;
        }
        else if (cipher & IW_AUTH_CIPHER_NONE){
            if (prGlueInfo->rWpaInfo.fgPrivacyInvoke)
                eEncStatus = ENUM_ENCRYPTION1_ENABLED;
            else
                eEncStatus = ENUM_ENCRYPTION_DISABLED;
        }
        else {
            eEncStatus = ENUM_ENCRYPTION_DISABLED;
        }
    }
    else {
        eEncStatus = ENUM_ENCRYPTION_DISABLED;
    }
    
    rStatus = kalIoctl(prGlueInfo,
            wlanoidSetEncryptionStatus,
            &eEncStatus,
            sizeof(eEncStatus),
            FALSE,
            FALSE,
            FALSE,
            FALSE,
            &u4BufLen);
    if (rStatus != WLAN_STATUS_SUCCESS) {
        DBGLOG(REQ, WARN, ("set encryption mode error:%lx\n", rStatus));
    }

    if (sme->key_len != 0 && prGlueInfo->rWpaInfo.u4WpaVersion == IW_AUTH_WPA_VERSION_DISABLED) {
        P_PARAM_WEP_T prWepKey = (P_PARAM_WEP_T) wepBuf;
        
        kalMemSet(prWepKey, 0, sizeof(prWepKey));
        prWepKey->u4Length = 12 + sme->key_len;
        prWepKey->u4KeyLength = (UINT_32) sme->key_len;
        prWepKey->u4KeyIndex = (UINT_32) sme->key_idx;
        prWepKey->u4KeyIndex |= BIT(31);
        if (prWepKey->u4KeyLength > 32) {
            DBGLOG(REQ, WARN, ("Too long key length (%u)\n", prWepKey->u4KeyLength));
            return -EINVAL;
        }
        kalMemCopy(prWepKey->aucKeyMaterial, sme->key, prWepKey->u4KeyLength);

        rStatus = kalIoctl(prGlueInfo,
                     wlanoidSetAddWep,
                     prWepKey,
                     prWepKey->u4Length,
                     FALSE,
                     FALSE,
                     TRUE,
                     FALSE,
                     &u4BufLen);
        
        if (rStatus != WLAN_STATUS_SUCCESS) {
            DBGLOG(INIT, INFO, ("wlanoidSetAddWep fail 0x%lx\n", rStatus));
            return -EFAULT;
        }
    }

    if(sme->ssid_len > 0) {
        /* connect by SSID */
        COPY_SSID(rNewSsid.aucSsid, rNewSsid.u4SsidLen, sme->ssid, sme->ssid_len);

        rStatus = kalIoctl(prGlueInfo,
                wlanoidSetSsid,
                (PVOID) &rNewSsid,
                sizeof(PARAM_SSID_T),
                FALSE,
                FALSE,
                TRUE,
                FALSE,
                &u4BufLen);

        if (rStatus != WLAN_STATUS_SUCCESS) {
            DBGLOG(REQ, WARN, ("set SSID:%lx\n", rStatus));
            return -EINVAL;
        }
    }
    else {
        /* connect by BSSID */
        rStatus = kalIoctl(prGlueInfo,
                wlanoidSetBssid,
                (PVOID) sme->bssid,
                sizeof(MAC_ADDR_LEN),
                FALSE,
                FALSE,
                TRUE,
                FALSE,
                &u4BufLen);

        if (rStatus != WLAN_STATUS_SUCCESS) {
            DBGLOG(REQ, WARN, ("set BSSID:%lx\n", rStatus));
            return -EINVAL;
        }
    }

    return 0;
}
VOID
p2pStateInit_GC_JOIN (
    IN P_ADAPTER_T prAdapter,
    IN P_P2P_FSM_INFO_T prP2pFsmInfo,
    IN P_BSS_INFO_T prP2pBssInfo,
    IN P_P2P_JOIN_INFO_T prJoinInfo,
    IN P_BSS_DESC_T prBssDesc
    )
{
    P_MSG_JOIN_REQ_T prJoinReqMsg = (P_MSG_JOIN_REQ_T)NULL;
    P_STA_RECORD_T prStaRec = (P_STA_RECORD_T)NULL;
    P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = (P_P2P_CONNECTION_SETTINGS_T)NULL;

    do {
        ASSERT_BREAK((prAdapter != NULL) &&
                                    (prP2pFsmInfo != NULL) &&
                                    (prP2pBssInfo != NULL) &&
                                    (prJoinInfo != NULL) &&
                                    (prBssDesc != NULL));

        prP2pConnSettings = prAdapter->rWifiVar.prP2PConnSettings;

        if (prBssDesc->ucSSIDLen) {
            COPY_SSID(prP2pConnSettings->aucSSID,
                            prP2pConnSettings->ucSSIDLen,
                            prBssDesc->aucSSID,
                            prBssDesc->ucSSIDLen);
        }


        // Setup a join timer.
        DBGLOG(P2P, TRACE, ("Start a join init timer\n"));
        cnmTimerStartTimer(prAdapter,
                            &(prAdapter->rP2pFsmTimeoutTimer),
                            (prP2pFsmInfo->u4GrantInterval - AIS_JOIN_CH_GRANT_THRESHOLD));

        //2 <1> We are goin to connect to this BSS
        prBssDesc->fgIsConnecting = TRUE;

        //2 <2> Setup corresponding STA_RECORD_T
        prStaRec = bssCreateStaRecFromBssDesc(prAdapter,
                                    (prBssDesc->fgIsP2PPresent?(STA_TYPE_P2P_GO):(STA_TYPE_LEGACY_AP)),
                                    NETWORK_TYPE_P2P_INDEX,
                                    prBssDesc);

        if (prStaRec == NULL) {
            DBGLOG(P2P, TRACE, ("Create station record fail\n"));
            break;
        }


        prJoinInfo->prTargetStaRec = prStaRec;
        prJoinInfo->fgIsJoinComplete = FALSE;
        prJoinInfo->u4BufLength = 0;

        //2 <2.1> Sync. to FW domain
        cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);


        if (prP2pBssInfo->eConnectionState == PARAM_MEDIA_STATE_DISCONNECTED) {
            P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = (P_P2P_CONNECTION_SETTINGS_T)NULL;

            prStaRec->fgIsReAssoc = FALSE;

            prP2pConnSettings = prAdapter->rWifiVar.prP2PConnSettings;

            switch (prP2pConnSettings->eAuthMode) {
            case AUTH_MODE_OPEN:                /* Note: Omit break here. */
            case AUTH_MODE_WPA:
            case AUTH_MODE_WPA_PSK:
            case AUTH_MODE_WPA2:
            case AUTH_MODE_WPA2_PSK:
                prJoinInfo->ucAvailableAuthTypes = (UINT_8)AUTH_TYPE_OPEN_SYSTEM;
                break;
            case AUTH_MODE_SHARED:
                prJoinInfo->ucAvailableAuthTypes = (UINT_8)AUTH_TYPE_SHARED_KEY;
                break;
            case AUTH_MODE_AUTO_SWITCH:
                DBGLOG(P2P, LOUD, ("JOIN INIT: eAuthMode == AUTH_MODE_AUTO_SWITCH\n"));
                prJoinInfo->ucAvailableAuthTypes = (UINT_8)(AUTH_TYPE_OPEN_SYSTEM |
                                                              AUTH_TYPE_SHARED_KEY);
                break;
            default:
                ASSERT(!(prP2pConnSettings->eAuthMode == AUTH_MODE_WPA_NONE));
                DBGLOG(P2P, ERROR, ("JOIN INIT: Auth Algorithm : %d was not supported by JOIN\n",
                                               prP2pConnSettings->eAuthMode));
                /* TODO(Kevin): error handling ? */
                return;
            }
            prStaRec->ucTxAuthAssocRetryLimit = TX_AUTH_ASSOCI_RETRY_LIMIT;
        }
        else {
            ASSERT(FALSE);
            // TODO: Shall we considering ROAMIN case for P2P Device?.
        }


        //2 <4> Use an appropriate Authentication Algorithm Number among the ucAvailableAuthTypes.
        if (prJoinInfo->ucAvailableAuthTypes &
            (UINT_8)AUTH_TYPE_OPEN_SYSTEM) {

            DBGLOG(P2P, TRACE, ("JOIN INIT: Try to do Authentication with AuthType == OPEN_SYSTEM.\n"));

            prJoinInfo->ucAvailableAuthTypes &=
                                            ~(UINT_8)AUTH_TYPE_OPEN_SYSTEM;

            prStaRec->ucAuthAlgNum = (UINT_8)AUTH_ALGORITHM_NUM_OPEN_SYSTEM;
        }
        else if (prJoinInfo->ucAvailableAuthTypes &
            (UINT_8)AUTH_TYPE_SHARED_KEY) {

            DBGLOG(P2P, TRACE, ("JOIN INIT: Try to do Authentication with AuthType == SHARED_KEY.\n"));

            prJoinInfo->ucAvailableAuthTypes &=
                                            ~(UINT_8)AUTH_TYPE_SHARED_KEY;

            prStaRec->ucAuthAlgNum = (UINT_8)AUTH_ALGORITHM_NUM_SHARED_KEY;
        }
        else if (prJoinInfo->ucAvailableAuthTypes &
            (UINT_8)AUTH_TYPE_FAST_BSS_TRANSITION) {

            DBGLOG(P2P, TRACE, ("JOIN INIT: Try to do Authentication with AuthType == FAST_BSS_TRANSITION.\n"));

            prJoinInfo->ucAvailableAuthTypes &=
                                            ~(UINT_8)AUTH_TYPE_FAST_BSS_TRANSITION;

            prStaRec->ucAuthAlgNum = (UINT_8)AUTH_ALGORITHM_NUM_FAST_BSS_TRANSITION;
        }
        else {
            ASSERT(0);
        }


        //4 <5> Overwrite Connection Setting for eConnectionPolicy == ANY (Used by Assoc Req)
        if (prBssDesc->ucSSIDLen) {
            COPY_SSID(prJoinInfo->rSsidStruct.aucSsid,
                      prJoinInfo->rSsidStruct.ucSsidLen,
                      prBssDesc->aucSSID,
                      prBssDesc->ucSSIDLen);
        }

        //2 <5> Backup desired channel.

        //2 <6> Send a Msg to trigger SAA to start JOIN process.
        prJoinReqMsg = (P_MSG_JOIN_REQ_T)cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_JOIN_REQ_T));

        if (!prJoinReqMsg) {
            DBGLOG(P2P, TRACE, ("Allocation Join Message Fail\n"));
            ASSERT(FALSE);
            return;
        }

        prJoinReqMsg->rMsgHdr.eMsgId = MID_P2P_SAA_FSM_START;
        prJoinReqMsg->ucSeqNum = ++prJoinInfo->ucSeqNumOfReqMsg;
        prJoinReqMsg->prStaRec = prStaRec;

        // TODO: Consider fragmentation info in station record.

        mboxSendMsg(prAdapter,
                    MBOX_ID_0,
                    (P_MSG_HDR_T)prJoinReqMsg,
                    MSG_SEND_METHOD_BUF);




    } while (FALSE);

    return;
} /* p2pStateInit_GC_JOIN */
示例#27
0
VOID
kalP2PIndicateRxMgmtFrame (
    IN P_GLUE_INFO_T prGlueInfo,
    IN P_SW_RFB_T prSwRfb,
    IN BOOLEAN fgIsDevInterface,
    IN UINT_8  ucRoleIdx
    )
{
#define DBG_P2P_MGMT_FRAME_INDICATION 1
    P_GL_P2P_INFO_T prGlueP2pInfo = (P_GL_P2P_INFO_T)NULL;
    INT_32 i4Freq = 0;
    UINT_8 ucChnlNum = 0;
#if DBG_P2P_MGMT_FRAME_INDICATION
    P_WLAN_MAC_HEADER_T prWlanHeader = (P_WLAN_MAC_HEADER_T)NULL;
#endif


    do {
        if ((prGlueInfo == NULL) || (prSwRfb == NULL)) {
            ASSERT(FALSE);
            break;
        }

        prGlueP2pInfo = prGlueInfo->prP2PInfo;

        //ToDo[6630]: Get the following by chnnel freq 
        //HAL_RX_STATUS_GET_CHAN_FREQ( prSwRfb->prRxStatus)
        //ucChnlNum = prSwRfb->prHifRxHdr->ucHwChannelNum;

        ucChnlNum = HAL_RX_STATUS_GET_CHNL_NUM(prSwRfb->prRxStatus);

#if DBG_P2P_MGMT_FRAME_INDICATION

        prWlanHeader = (P_WLAN_MAC_HEADER_T)prSwRfb->pvHeader;

        switch (prWlanHeader->u2FrameCtrl) {
        case MAC_FRAME_PROBE_REQ:
            DBGLOG(P2P, TRACE, ("RX Probe Req at channel %d ", ucChnlNum));
            break;
        case MAC_FRAME_PROBE_RSP:
            DBGLOG(P2P, TRACE, ("RX Probe Rsp at channel %d ", ucChnlNum));
            break;
        case MAC_FRAME_ACTION:
            DBGLOG(P2P, TRACE, ("RX Action frame at channel %d ", ucChnlNum));
            break;
        default:
            DBGLOG(P2P, TRACE, ("RX Packet:%d at channel %d ", prWlanHeader->u2FrameCtrl, ucChnlNum));
            break;
        }

        DBGLOG(P2P, TRACE, ("from: "MACSTR"\n", MAC2STR(prWlanHeader->aucAddr2)));
#endif
        i4Freq = nicChannelNum2Freq(ucChnlNum) / 1000;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
        cfg80211_rx_mgmt(&prGlueP2pInfo->wdev, //struct net_device * dev,
#else
        cfg80211_rx_mgmt((fgIsDevInterface)?prGlueP2pInfo->prDevHandler:prGlueP2pInfo->aprRoleHandler[ucRoleIdx], //struct net_device * dev,
#endif /* LINUX_VERSION_CODE */
                            i4Freq,
                            RCPI_TO_dBm(HAL_RX_STATUS_GET_RCPI(prSwRfb->prRxStatusGroup3)),
                            prSwRfb->pvHeader,
                            prSwRfb->u2PacketLen,
                            GFP_ATOMIC);
#else
        cfg80211_rx_mgmt((fgIsDevInterface)?prGlueP2pInfo->prDevHandler:prGlueP2pInfo->aprRoleHandler[ucRoleIdx], //struct net_device * dev,
                            i4Freq,
                            prSwRfb->pvHeader,
                            prSwRfb->u2PacketLen,
                            GFP_ATOMIC);
#endif

    } while (FALSE);

} /* kalP2PIndicateRxMgmtFrame */
示例#28
0
static int netdev_event(struct notifier_block *nb, unsigned long notification, void *ptr)
{
    UINT_8  ip[4] = { 0 };
    UINT_32 u4NumIPv4 = 0;
//#ifdef  CONFIG_IPV6
#if 0
    UINT_8  ip6[16] = { 0 };     // FIX ME: avoid to allocate large memory in stack
    UINT_32 u4NumIPv6 = 0;
#endif
    struct in_ifaddr *ifa = (struct in_ifaddr *) ptr;
    struct net_device *prDev = ifa->ifa_dev->dev;
    UINT_32 i;
    P_PARAM_NETWORK_ADDRESS_IP prParamIpAddr;
    P_GLUE_INFO_T prGlueInfo = NULL;

    if (prDev == NULL) {
        DBGLOG(REQ, INFO, ("netdev_event: device is empty.\n"));
        return NOTIFY_DONE;
    }

    if ((strncmp(prDev->name, "p2p", 3) != 0) && (strncmp(prDev->name, "wlan", 4) != 0)) {
        DBGLOG(REQ, INFO, ("netdev_event: xxx\n"));
        return NOTIFY_DONE;
    }

    prGlueInfo = *((P_GLUE_INFO_T *) netdev_priv(prDev));

    if (prGlueInfo == NULL) {
        DBGLOG(REQ, INFO, ("netdev_event: prGlueInfo is empty.\n"));
        return NOTIFY_DONE;
    }
    ASSERT(prGlueInfo);


    // <3> get the IPv4 address
    if(!prDev || !(prDev->ip_ptr)||\
            !((struct in_device *)(prDev->ip_ptr))->ifa_list||\
            !(&(((struct in_device *)(prDev->ip_ptr))->ifa_list->ifa_local))){
        DBGLOG(REQ, INFO, ("ip is not avaliable.\n"));
        return NOTIFY_DONE;
    }

    kalMemCopy(ip, &(((struct in_device *)(prDev->ip_ptr))->ifa_list->ifa_local), sizeof(ip));
    DBGLOG(REQ, INFO, ("ip is %d.%d.%d.%d\n",
            ip[0],ip[1],ip[2],ip[3]));

    // todo: traverse between list to find whole sets of IPv4 addresses
    if (!((ip[0] == 0) &&
         (ip[1] == 0) &&
         (ip[2] == 0) &&
         (ip[3] == 0))) {
        u4NumIPv4++;
    }


    if (fgIsUnderEarlierSuspend == false) {
#if defined(MTK_WLAN_ARP_OFFLOAD)
	if(NETDEV_UP == notification && PARAM_MEDIA_STATE_CONNECTED == prGlueInfo->eParamMediaStateIndicated){
		PARAM_CUSTOM_SW_CTRL_STRUC_T SwCtrlInfo;
		UINT_32 u4SetInfoLen;
		WLAN_STATUS rStatus = WLAN_STATUS_FAILURE;
		
		SwCtrlInfo.u4Id = 0x90110000;
		SwCtrlInfo.u4Data = 1;
		
		rStatus = kalIoctl(prGlueInfo,
                wlanoidSetSwCtrlWrite,
                (PVOID)&SwCtrlInfo,
                sizeof(SwCtrlInfo),
                FALSE,
                FALSE,
                TRUE,
                FALSE,
                &u4SetInfoLen);

       		if (rStatus != WLAN_STATUS_SUCCESS) {
            		DBGLOG(REQ, INFO, ("ARP OFFLOAD fail 0x%lx\n", rStatus));
       		}
       		
       		return NOTIFY_DONE;
       		
    	}else {
#endif
		DBGLOG(REQ, INFO, ("netdev_event: PARAM_MEDIA_STATE_DISCONNECTED. (%d)\n", prGlueInfo->eParamMediaStateIndicated));
		return NOTIFY_DONE;
#if defined(MTK_WLAN_ARP_OFFLOAD)
    	}
#endif
    }

//#ifdef  CONFIG_IPV6
#if 0
    if(!prDev || !(prDev->ip6_ptr)||\
        !((struct in_device *)(prDev->ip6_ptr))->ifa_list||\
        !(&(((struct in_device *)(prDev->ip6_ptr))->ifa_list->ifa_local))){
        printk(KERN_INFO "ipv6 is not avaliable.\n");
        return NOTIFY_DONE;
    }

    kalMemCopy(ip6, &(((struct in_device *)(prDev->ip6_ptr))->ifa_list->ifa_local), sizeof(ip6));
    printk(KERN_INFO"ipv6 is %d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d\n",
            ip6[0],ip6[1],ip6[2],ip6[3],
            ip6[4],ip6[5],ip6[6],ip6[7],
            ip6[8],ip6[9],ip6[10],ip6[11],
            ip6[12],ip6[13],ip6[14],ip6[15]
            );

    // todo: traverse between list to find whole sets of IPv6 addresses
    if (!((ip6[0] == 0) &&
         (ip6[1] == 0) &&
         (ip6[2] == 0) &&
         (ip6[3] == 0) &&
         (ip6[4] == 0) &&
         (ip6[5] == 0))) {
        //u4NumIPv6++;
    }
#endif

    // here we can compare the dev with other network's netdev to
    // set the proper arp filter
    //
    // IMPORTANT: please make sure if the context can sleep, if the context can't sleep
    // we should schedule a kernel thread to do this for us

    // <7> set up the ARP filter
    {
        WLAN_STATUS rStatus = WLAN_STATUS_FAILURE;
        UINT_32 u4SetInfoLen = 0;
        UINT_8 aucBuf[32] = {0};
        UINT_32 u4Len = OFFSET_OF(PARAM_NETWORK_ADDRESS_LIST, arAddress);
        P_PARAM_NETWORK_ADDRESS_LIST prParamNetAddrList = (P_PARAM_NETWORK_ADDRESS_LIST)aucBuf;
        P_PARAM_NETWORK_ADDRESS prParamNetAddr = prParamNetAddrList->arAddress;

//#ifdef  CONFIG_IPV6
#if 0
        prParamNetAddrList->u4AddressCount = u4NumIPv4 + u4NumIPv6;
#else
        prParamNetAddrList->u4AddressCount = u4NumIPv4;
#endif
        prParamNetAddrList->u2AddressType = PARAM_PROTOCOL_ID_TCP_IP;
        for (i = 0; i < u4NumIPv4; i++) {
            prParamNetAddr->u2AddressLength = sizeof(PARAM_NETWORK_ADDRESS_IP);//4;;
            prParamNetAddr->u2AddressType = PARAM_PROTOCOL_ID_TCP_IP;;
#if 0
            kalMemCopy(prParamNetAddr->aucAddress, ip, sizeof(ip));
            prParamNetAddr = (P_PARAM_NETWORK_ADDRESS)((UINT_32)prParamNetAddr + sizeof(ip));
            u4Len += OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) + sizeof(ip);
#else
            prParamIpAddr = (P_PARAM_NETWORK_ADDRESS_IP)prParamNetAddr->aucAddress;
            kalMemCopy(&prParamIpAddr->in_addr, ip, sizeof(ip));
            prParamNetAddr = (P_PARAM_NETWORK_ADDRESS)((UINT_32)prParamNetAddr + sizeof(PARAM_NETWORK_ADDRESS));
            u4Len += OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) + sizeof(PARAM_NETWORK_ADDRESS);
#endif
        }
//#ifdef  CONFIG_IPV6
#if 0
        for (i = 0; i < u4NumIPv6; i++) {
            prParamNetAddr->u2AddressLength = 6;;
            prParamNetAddr->u2AddressType = PARAM_PROTOCOL_ID_TCP_IP;;
            kalMemCopy(prParamNetAddr->aucAddress, ip6, sizeof(ip6));
            prParamNetAddr = (P_PARAM_NETWORK_ADDRESS)((UINT_32)prParamNetAddr + sizeof(ip6));
            u4Len += OFFSET_OF(PARAM_NETWORK_ADDRESS, aucAddress) + sizeof(ip6);
       }
#endif
        ASSERT(u4Len <= sizeof(aucBuf));

    DBGLOG(REQ, INFO, ("kalIoctl (0x%x, 0x%x)\n", prGlueInfo, prParamNetAddrList));

        rStatus = kalIoctl(prGlueInfo,
                wlanoidSetNetworkAddress,
                (PVOID)prParamNetAddrList,
                u4Len,
                FALSE,
                FALSE,
                TRUE,
                FALSE,
                &u4SetInfoLen);

        if (rStatus != WLAN_STATUS_SUCCESS) {
            DBGLOG(REQ, INFO, ("set HW pattern filter fail 0x%lx\n", rStatus));
        }
    }

    return NOTIFY_DONE;

}
示例#29
0
static ssize_t eemcs_ipc_write(struct file *fp, const char __user *buf, size_t in_sz, loff_t *ppos)
{
    ssize_t ret   = 0;
    eemcs_ipc_node_t *curr_node = (eemcs_ipc_node_t *)fp->private_data;
    KAL_UINT8 node_id = curr_node->ipc_node_id;/* node_id */
    KAL_UINT8 port_id = eemcs_ipc_inst.eemcs_port_id; /* port_id */
    KAL_UINT32 p_type, control_flag;    
    struct sk_buff *new_skb;
    CCCI_BUFF_T *ccci_header;
    ipc_ilm_t *ilm=NULL;
    IPC_MSGSVC_TASKMAP_T *id_map;
    size_t count = in_sz;
    
    DEBUG_LOG_FUNCTION_ENTRY;        
    DBGLOG(IPCD,TRA,"ipc_write: deivce=%s iminor=%d len=%d", curr_node->dev_name, node_id, count);

    p_type = ccci_get_port_type(port_id);
    if(p_type != EX_T_USER) 
    {
        DBGLOG(IPCD,ERR,"PORT%d refuse port(%d) access user port", port_id, p_type);
        ret=-EINVAL;
        goto _exit;                    
    }
    if(!eemcs_device_ready())
    {
        DBGLOG(IPCD,ERR,"MD device not ready!");
        ret= -EIO;
		return ret;
    }

    control_flag = ccci_get_port_cflag(port_id);

    if((control_flag & EXPORT_CCCI_H) && (count < sizeof(CCCI_BUFF_T)))
    {
        DBGLOG(IPCD,ERR,"invalid wirte_len(%d) of PORT%d", count, port_id);
        ret=-EINVAL;
        goto _exit;            
    }

    if(control_flag & EXPORT_CCCI_H){
        if(count > (MAX_TX_BYTE+sizeof(CCCI_BUFF_T))){
            DBGLOG(IPCD,WAR,"PORT%d wirte_len(%d)>MTU(%d)!", port_id, count, MAX_TX_BYTE);
            count = MAX_TX_BYTE+sizeof(CCCI_BUFF_T);
        }
    }else{
        if(count > MAX_TX_BYTE){
            DBGLOG(IPCD,WAR,"PORT%d wirte_len(%d)>MTU(%d)!", port_id, count, MAX_TX_BYTE);
            count = MAX_TX_BYTE;
        }
    }

	if (ccci_ch_write_space_alloc(eemcs_ipc_inst.ccci_ch.tx)==0){
        DBGLOG(IPCD,WAR,"PORT%d write return 0)", port_id);
        ret = -EAGAIN;
        goto _exit;
	}	
    
    new_skb = ccci_ipc_mem_alloc(count + CCCI_IPC_HEADER_ROOM);
    if(NULL == new_skb)
    {
        DBGLOG(IPCD,ERR,"PORT%d alloct tx memory fail", port_id);
        ret = -ENOMEM;
        goto _exit;            
    }
    
    /* reserve SDIO_H header room */
    skb_reserve(new_skb, sizeof(SDIO_H));

    ccci_header = (CCCI_BUFF_T *)skb_put(new_skb, sizeof(CCCI_BUFF_T)) ;

    if(copy_from_user(skb_put(new_skb, count), buf, count))
    {
        DBGLOG(IPCD,ERR,"PORT%d copy_from_user(len=%d) fail", port_id, count);
        dev_kfree_skb(new_skb);
        ret = -EFAULT;
        goto _exit;
    }

    ilm = (ipc_ilm_t*)((char*)ccci_header + sizeof(CCCI_BUFF_T));
    /* Check IPC extq_id */
	if ((id_map=local_MD_id_2_unify_id(ilm->dest_mod_id))==NULL)
	{
		DBGLOG(IPCD,ERR,"Invalid dest_mod_id=%d",ilm->dest_mod_id);
        dev_kfree_skb(new_skb);
		ret=-EINVAL;
		goto _exit;
	}
    
    /* user bring down the payload only */
    ccci_header->data[1]    = count + sizeof(CCCI_BUFF_T);
    ccci_header->reserved   = id_map->extq_id;
    ccci_header->channel    = eemcs_ipc_inst.ccci_ch.tx;

    DBGLOG(IPCD,TRA,"ipc_write: PORT%d CCCI_MSG(0x%08X, 0x%08X, %02d, 0x%08X)", 
                    port_id, 
                    ccci_header->data[0], ccci_header->data[1],
                    ccci_header->channel, ccci_header->reserved);

  
    ret = ccci_ch_write_desc_to_q(ccci_header->channel, new_skb);

	if (KAL_SUCCESS != ret) {
		DBGLOG(IPCD,ERR,"PKT of ch%d DROP!",ccci_header->channel);
		dev_kfree_skb(new_skb);
        ret = -EAGAIN;
	} else {
        atomic_inc(&curr_node->tx_pkt_cnt);
        wake_up(&curr_node->tx_waitq); /* wake up tx_waitq for notify poll_wait of state change */
	}

_exit:
    DEBUG_LOG_FUNCTION_LEAVE;
    if(!ret){
        return count;
    }
    return ret;
}
示例#30
0
void HelperDll::logLoaded()
{
    logLoad = true;
    DBGLOG("Loaded DLL %s", name.get());
}