⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmdx500.cpp

📁 WinCE5.0部分核心源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    return RidSet(card, RID_CAP, cap, sizeof(STCAPS) );
}
//========================================================================
BOOLEAN
cmdStatusGet(PCARD card,STSTATUS * status )
{
    return RidGet(card, RID_STATUS, status, sizeof(STSTATUS) );
}

BOOLEAN
cmdStatusSet(PCARD card,STSTATUS *status )
{
    return RidSet(card, RID_STATUS, status, sizeof(STSTATUS) );
}

//========================================================================
BOOLEAN         
cmdStatisticsGet(PCARD card, STSTATISTICS *stats )
{                                
    return RidGet(card, RID_STATS, stats, sizeof(STSTATISTICS) );
}
BOOLEAN         
cmdStatisticsClear(PCARD card,STSTATISTICS *stats )
{
    return RidGet(card, RID_STATS_CLEAR, stats, sizeof(STSTATISTICS) );
}
//........................................................................

BOOLEAN cmdStatistics32Get (PCARD card,STSTATISTICS32 *stats)
{                                
    return RidGet(card, RID_STATS32, stats, sizeof(STSTATISTICS32) );
}

BOOLEAN cmdStatistics32Clear (PCARD card,STSTATISTICS32 *stats)
{
    return RidGet(card, RID_STATS32_CLEAR, stats, sizeof(STSTATISTICS32) );
}

//========================================================================
BOOLEAN cmdReset(PCARD card)
{
    cmdDisable( card ); 
    card->m_cmd = CMD_X500_ResetCard;
    exec(card, 1000); 
    return TRUE;
}
//========================================================================
BOOLEAN         
cmdMagicPacket(PCARD card, BOOLEAN enable)
{
    CMD_X500 modeCmd = enable ? CMD_X500_MagicPacketON : CMD_X500_MagicPacketOFF;
    card->m_cmd = modeCmd;
    return exec(card, 1000); 
}
//========================================================================
BOOLEAN         
cmdSleep(PCARD card )
{
    NdisRawWritePortUshort(card->m_IOBase+REG_INT_ACK, EVNT_DO_SLEEP );
    card->IsAwake = FALSE;              
    return TRUE;
}

//===========================================================================
    BOOLEAN cmdAwaken (PCARD card, BOOLEAN wait)
//===========================================================================
// 
// Description: Wake the card up.
//    
//      Inputs: card - pointer to card structure
//              wait - if TRUE, wait for acknowledgement from card.
//                      otherwise, don't wait and return FALSE.
// 
//       Notes: Rewrote to fix an overflow condition that caused erroneous 
//              results to be returned. (jbeaujon - 11/15/00) 
//---------------------------------------------------------------------------
{
    if (!card->IsAwake) {
        USHORT  usWord;
        // 
        // save ints state & disable ints
        // 
        NdisRawReadPortUshort(card->m_IOBase+REG_INT_EN, &usWord );
        NdisRawWritePortUshort(card->m_IOBase+REG_INT_EN, 0 );
        //spb024
        //If m_IntActive is set, then it means we got an interrupt after
        //reading active interrupts but before we were able to disable
        //interrupts.  Therefore interupts really should be disabled
        //when we return from this routine. 
        //Trust me this happens.  (Caused lost fids at Microsoft)
        if (card->m_IntActive) {
            usWord=0;
        }
        //
        // Two writes are required to wake up the card.
        // 
        NdisRawWritePortUshort( card->m_IOBase+REG_INT_ACK, EVNT_DO_WAKEUP );
        NdisRawWritePortUshort( card->m_IOBase+REG_INT_ACK, EVNT_DO_WAKEUP );
        // 
        // restore interrupts
        // 
        NdisRawWritePortUshort(card->m_IOBase+REG_INT_EN, usWord );
        // 
        // Wait for wake up indication from the card.
        // 
        if (wait) {
            int i = 0;
            while (!card->IsAwake && (i++ <= 100)) {
                NdisRawReadPortUshort(card->m_IOBase+REG_INT_STAT, &usWord);
                if (usWord & EVNT_STAT_IsAWAKE) {
                    card->IsAwake = TRUE;
                    }
                   DelayMS(1);
                }
            }
        }
    return card->IsAwake;
}

//===========================================================================
    DBM_TABLE* cmdDBMTableGet (PCARD card)
//===========================================================================
// 
// Description: Read the dBm table from the card and return it in an allocated
//              buffer.  Note that not all cards support this feature (firmware
//              3.94 was the first).
//    
//      Inputs: card - pointer to card.
//    
//     Returns: pointer to allocated DBM_TABLE structure if successful, NULL
//              otherwise.
//    
//      (12/04/00)
//---------------------------------------------------------------------------
{
    DBM_TABLE   *table = new DBM_TABLE;
    if (table != NULL) {
        RidGet(card, RID_DBM_TABLE, table, sizeof(DBM_TABLE));
        if (table->length != sizeof(DBM_TABLE)) {
            delete table;
            table = NULL;
            }
        }
    return(table);
}

//===========================================================================
    BOOLEAN cmdGetFirstBSS (PCARD card, RID_BSS *ridBss, BOOLEAN *eol /* = NULL */)
//===========================================================================
// 
// Description: Get the first entry in the card's BSSID list.
//    
//      Inputs: card    - pointer to card structure
//              ridBss  - pointer to RID_BSS structure.
//              eol     - pointer to boolean to receive end of list status.
//                        Only meaningful if this function returns TRUE.
//                        May be NULL if don't care.
//    
//     Returns: TRUE if successful, FALSE otherwise.
//    
//      (12/05/00)
//---------------------------------------------------------------------------
{
    NdisZeroMemory(ridBss, sizeof(RID_BSS));
    BOOLEAN retval = RidGet(card, RID_GET_FIRST_BSS, ridBss, sizeof(RID_BSS));
    if (retval) {
        retval = (ridBss->length == sizeof(RID_BSS));
        if (eol) {
            *eol = (ridBss->index == 0xFFFF);
            }
/*
        retval = (ridBss->length == sizeof(RID_BSS)) && (ridBss->index != 0xFFFF); // end of list value
*/
        }
    return retval;
}

//===========================================================================
    BOOLEAN cmdGetNextBSS (PCARD card, RID_BSS *ridBss, BOOLEAN *eol /* = NULL */)
//===========================================================================
// 
// Description: Get the nexst entry in the card's BSSID list.
//    
//      Inputs: card    - pointer to card structure
//              ridBss  - pointer to RID_BSS structure.
//              eol     - pointer to boolean to receive end of list status.
//                        Only meaningful if this function returns TRUE.
//                        May be NULL if don't care.
//    
//     Returns: TRUE if successful, FALSE otherwise (end of list).
//    
//      (12/05/00)
//---------------------------------------------------------------------------
{
    NdisZeroMemory(ridBss, sizeof(RID_BSS));
    BOOLEAN retval = RidGet(card, RID_GET_NEXT_BSS, ridBss, sizeof(RID_BSS));
    if (retval) {
        retval = (ridBss->length == sizeof(RID_BSS));
        if (eol) {
            *eol = (ridBss->index == 0xFFFF);
            }
        }
    return retval;
}

//========================================================================
BOOLEAN         
EEReadConfigCmd(PCARD card)
{
    card->m_cmd = CMD_X500_EEReadConfig;
    if( ! exec(card, 1000) )
        return FALSE;
    
    int     delay = 1000 * 1000; //  1 sec
    for( int i=0; i<delay; i+=10 ){

        if( IsCmdComplete(card) )
            return TRUE;
        DelayUS(10);
    }
    return FALSE;
}

BOOLEAN         
EEWriteConfigCmd(PCARD card)
{
    card->m_cmd = CMD_X500_EEWriteConfig;
    if( ! exec(card, 1000) )
        return FALSE;
    
    int     delay = 1000 * 1000; //  1 sec
    for( int i=0; i<delay; i+=10 ){

        if( IsCmdComplete(card) )
            return TRUE;
        DelayUS(10);
    }
    return FALSE;
}
//========================================================================
BOOLEAN         
EEReadConfig(PCARD card, CFG_X500 * cfg)
{
    return EEReadConfigCmd(card) ? cmdConfigGet(card, cfg) : FALSE;
}
BOOLEAN         
EEWriteConfig(PCARD card, CFG_X500 * cfg)
{
    return  cmdConfigSet(card, cfg, FALSE) ? (EEWriteConfigCmd(card) ? cmdEnable(card) : FALSE) : FALSE;
}
//========================================================================
BOOLEAN         
EEReadSSIDS(PCARD card, STSSID * ssid)
{
    return EEReadConfigCmd(card) ? cmdSSIDGet(card, ssid) : FALSE;
}
BOOLEAN         
EEWriteSSIDS(PCARD card, STSSID * ssid)
{
    return  cmdSSIDSet(card, ssid, FALSE) ? (EEWriteConfigCmd(card) ? cmdEnable(card) : FALSE) : FALSE;
}
//========================================================================
BOOLEAN         
EEReadAPS(PCARD card, STAPLIST  * aps)
{
    return EEReadConfigCmd(card) ? cmdAPsSet(card, aps) : FALSE;
}
BOOLEAN         
EEWriteAPS(PCARD card, STAPLIST  * aps)
{
    return  cmdAPsSet(card, aps, FALSE) ? (EEWriteConfigCmd(card) ? cmdEnable(card) : FALSE) : FALSE;
}

 
//===========================================================================
    NDIS_STATUS cmdAddWEP (PCARD card, NDIS_802_11_WEP *WepKey)
//===========================================================================
// 
// Description: 
//    
//      Inputs: 
//    
//     Returns: 
//---------------------------------------------------------------------------
{
#if DBG 
    DbgPrint( "Key Index field = %0X\n", WepKey->KeyIndex );
    DbgPrint( "Key length field = %0X\n", WepKey->KeyLength );

//    DbgPrint( "Key = ");
//    for( USHORT i=0; i<WepKey->KeyLength && i<16; i++ ) 
//        DbgPrint( "%02X ", WepKey->KeyMaterial[i] );
//    DbgPrint( "\n");
#endif

    RID_WEP_Key     RKey = {sizeof(RID_WEP_Key),0,{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }};

    if( (0x7FFFFFFF & WepKey->KeyIndex) > 3 )
        return NDIS_STATUS_INVALID_DATA;
        
        
    RKey.keyindex   = (USHORT)(0xF & WepKey->KeyIndex);
    RKey.keylen     = (USHORT)WepKey->KeyLength;    

#ifdef UNDER_CE
    //
    //  Comment for Prefix:: WepKey->KeyLength should always be at most 104 bit.
    //                       i.e. 13 bytes.   RID_WEP_Key structure defines
    //                       key field as array of 13 UCHAR.
    //
#endif

    PREFAST_ASSERT(WepKey->KeyLength <= 13);
    NdisMoveMemory(RKey.key, WepKey->KeyMaterial, WepKey->KeyLength );  
    
    if( ! RidSetIgnoreMAC(card, RID_WEP_SESSION_KEY, &RKey, WepKey->Length ) )
        return NDIS_STATUS_NOT_SUPPORTED ;

    if( 0==(0x80000000  & WepKey->KeyIndex) )
        return NDIS_STATUS_SUCCESS;

    RKey.keyindex   = 0xFFFF;
    RKey.keylen     = (USHORT)WepKey->KeyLength;    
        
    NdisZeroMemory(RKey.macaddr, 6 );
    RKey.macaddr[0] = (UCHAR)(0x7F & WepKey->KeyIndex);

    return  RidSetIgnoreMAC(card, RID_WEP_SESSION_KEY, &RKey, WepKey->Length ) 
            ? NDIS_STATUS_SUCCESS : NDIS_STATUS_NOT_ACCEPTED;
}

//===========================================================================
    NDIS_STATUS cmdRemoveWEP (PCARD card, USHORT index)
//===========================================================================
// 
// Description: 
//    
//      Inputs: 
//    
//     Returns: 
//---------------------------------------------------------------------------
{
    RID_WEP_Key     RKey    = {sizeof(RID_WEP_Key),0,{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }};
    NDIS_STATUS     retval  = NDIS_STATUS_SUCCESS;

    if ((index >= 0) && (index <= MAX_ENTERPRISE_WEP_KEY_INDEX)) {
        RKey.keyindex   = index;
        RKey.keylen     = 0;    
        NdisMoveMemory(RKey.macaddr, "\1\0\0\0\0\0", 6);

        if (!RidSetIgnoreMAC(card, RID_WEP_SESSION_KEY, &RKey, RKey.ridlen)) {
            retval = NDIS_STATUS_NOT_SUPPORTED;
            }
        }
    else {
        retval = NDIS_STATUS_INVALID_DATA;
        }

    return retval;
}

//===========================================================================
    NDIS_STATUS cmdRestoreWEP (PCARD card)
//===========================================================================
// 
// Description: Restore WEP key from flash.
//    
//      Inputs: card - pointer to card structure.
//    
//     Returns: NDIS_STATUS_SUCCESS if successful, error code otherwise.
//    
//      (03/26/01)
//---------------------------------------------------------------------------
{
    RID_WEP_Key     RKey    = {sizeof(RID_WEP_Key),0,{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }};
    NDIS_STATUS     retval  = NDIS_STATUS_SUCCESS;
    // 
    // Ley length of -1 indicates reload WEP keys from flash.
    // 
    RKey.keylen = (USHORT)-1;
    if (!RidSetIgnoreMAC(card, RID_WEP_SESSION_KEY, &RKey, RKey.ridlen)) {
        retval = NDIS_STATUS_NOT_SUPPORTED;
        }
    return retval;
}

/*
NDIS_STATUS 
cmdRemoveWEP( PCARD card)
{
    RID_WEP_Key     RKey = {sizeof(RID_WEP_Key),0,{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }};
    
    for( int i = 0; i<4; i++ ){
    
        RKey.keyindex   = (USHORT)i;
        RKey.keylen     = 0;    
        NdisMoveMemory(RKey.macaddr, "\1\0\0\0\0\0", 6 );

        if( ! RidSetIgnoreMAC(card, RID_WEP_SESSION_KEY, &RKey, RKey.ridlen ) )
            return NDIS_STATUS_NOT_SUPPORTED;
    }

    return NDIS_STATUS_SUCCESS ;
}
*/


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -