📄 card.cpp
字号:
// BEGIN 802.11 OIDs (set)
//***************************************************************************
//-----------------------------------------------------------------------
// This object defines the Service Set Identifier. The SSID is a string,
// up to 32 characters. It identifies a set of interconnected Basic Service
// Sets. Passing in an empty string means associate with any SSID. Setting
// an SSID would result in disassociating if already associated with a
// particular SSID, turning on the radio if the radio is currently in the
// off state, setting the SSID with the value specified or setting it to
// any SSID if SSID is not specified, and attempting to associate with the
// set SSID.
//
// Data type: NDIS_802_11_SSID.
// Query: Returns the SSID.
// Set: Sets the SSID.
// Indication: Not supported.
//-----------------------------------------------------------------------
case OID_802_11_SSID: {
if (!cmdAwaken(card, TRUE)) {
StatusToReturn = -1000;
}
else {
STSSID ssid;
if (cmdSSIDGet(card, &ssid)) {
NDIS_802_11_SSID *ndis_ssid = (NDIS_802_11_SSID*)InfBuff;
ssid.Len1 = (USHORT)ndis_ssid->SsidLength;
NdisZeroMemory(ssid.ID1, 32);
NdisMoveMemory(ssid.ID1, ndis_ssid->Ssid, ndis_ssid->SsidLength);
if (cmdSSIDSet(card, &ssid, TRUE)) {
NdisZeroMemory(card->m_ESS_ID1, 32);
NdisMoveMemory(card->m_ESS_ID1, ndis_ssid->Ssid, ndis_ssid->SsidLength);
}
else {
StatusToReturn = NDIS_STATUS_INVALID_DATA;
}
}
else {
StatusToReturn = NDIS_STATUS_INVALID_DATA;
}
}
break;
}
//-----------------------------------------------------------------------
// Query or Set how an 802.11 NIC connects to the network. Will also reset
// the network association algorithm.
//
// Data type: NDIS_802_11_NETWORK_INFRASTRUCTURE.
// Query: Returns either Infrastructure or Independent Basic Service Set
// (IBSS), unknown.
// Set: Sets Infrastructure or IBSS, or automatic switch between the
// two.
// Indication: Not supported.
//-----------------------------------------------------------------------
case OID_802_11_INFRASTRUCTURE_MODE: {
if (!cmdAwaken(card, TRUE)) {
StatusToReturn = -1000;
}
else {
USHORT mode;
StatusToReturn = getShortVal(InfBuffLen, InfBuff, &mode);
if (StatusToReturn == NDIS_STATUS_SUCCESS) {
//
// Our card only supports adhoc and infrastructure modes.
//
// NOTE: The MS document, "IEEE 802.11 MIN Requirements", specifies
// an additional mode of Ndis802_11AutoUnknown. Since the card
// doesn't support it, we don't support it.
//
if ((mode == Ndis802_11IBSS) || (mode == Ndis802_11Infrastructure)) {
CFG_X500 cfg;
if (cmdConfigGet(card, &cfg)) {
//
// NOTE: preserve the high byte as it contains a bit mask.
//
cfg.OpMode = (cfg.OpMode & 0xFF00) | mode;
if (!cmdConfigSet(card, &cfg, TRUE)) {
StatusToReturn = NDIS_STATUS_INVALID_DATA;
}
}
else {
StatusToReturn = NDIS_STATUS_INVALID_DATA;
}
}
else {
StatusToReturn = NDIS_STATUS_INVALID_DATA;
}
}
}
break;
}
//-----------------------------------------------------------------------
// The WEP key should not be held in permanent storage but should be lost
// as soon as the card disassociates with all BSSIDs or if shared key
// authentication using the WEP key fails. Calling twice for the same index
// should overwrite the previous value.
//
// Data type: NDIS_802_11_WEP.
// Query: Not supported.
// Set: Sets the desired WEP key.
// Indication: Not supported.
//-----------------------------------------------------------------------
case OID_802_11_ADD_WEP: {
//spb018 added if statement
if (card->m_activeProfile->zFlags.cfg.HomeConfiguration) {
card->m_activeProfile->zFlags.cfg.HomeConfiguration=0;
cmdConfigSet(card,&card->m_activeProfile->zFlags.cfg,TRUE);
}
StatusToReturn = cmdAddWEP(card, (NDIS_802_11_WEP *)InfBuff);
break;
}
//-----------------------------------------------------------------------
// The WEP key should not be held in permanent storage but should be lost
// as soon as the card disassociates with all BSSIDs.
//
// Data type: NDIS_802_11_KEY_INDEX.
// Query: Not supported.
// Set: Removes the desired WEP key.
// Indication: Not supported.
//-----------------------------------------------------------------------
case OID_802_11_REMOVE_WEP: {
USHORT index;
StatusToReturn = getShortVal(InfBuffLen, InfBuff, &index);
StatusToReturn = cmdRemoveWEP(card, index);
break;
}
//-----------------------------------------------------------------------
// Query shall respond with the WEP status indicating whether WEP is enabled,
// WEP is disabled, WEP key is absent, or WEP is not supported. Query response
// indicating that WEP is enabled or WEP is disabled implies that WEP key is
// available for the NIC to encrypt data, that is, WEP key is available for
// MPDU transmission with encryption. Query response indicating WEP key is
// absent implies that WEP key is not available for the NIC to encrypt data
// and therefore WEP cannot be enabled or disabled. Note that this implies
// that while WEP key(s) may be available, the NIC does not have a WEP key
// for MPDU transmission with encryption. Query response indicating that WEP
// is not supported implies that the NIC does not support the desired WEP,
// that is, the NIC is not capable of encrypting data and hence WEP cannot be
// enabled or disabled. The NIC is permitted to set the WEP status to either
// enable or disable setting only. In order to be able to set the WEP status
// to either enable or disable setting, it is required that WEP key is
// available for MPDU transmission with encryption. If the set WEP status
// operation cannot be done, the driver shall return an NDIS_STATUS value of
// NDIS_STATUS_NOT_ACCEPTED.
//
// Data type: NDIS_802_11_WEP_STATUS.
// Query: Returns the current WEP status.
// Set: Permitted to enable or disable WEP only.
// Indication: Not supported.
//-----------------------------------------------------------------------
case OID_802_11_WEP_STATUS: {
if (!cmdAwaken(card, TRUE)) {
StatusToReturn = -1000;
}
else {
USHORT wepState;
StatusToReturn = getShortVal(InfBuffLen, InfBuff, &wepState);
if ((wepState == Ndis802_11WEPDisabled) || (wepState == Ndis802_11WEPEnabled)) {
STCAPS caps;
StatusToReturn = NDIS_STATUS_INVALID_DATA;
if (cmdCapsGet(card, &caps)) {
// Does card support WEP (40 bit) ?
// (NOTE: We can check the SOFT_CAPS_128_BIT_WEP_SUPPORT bit to see if
// 128 bit WEP is supported).
if (caps.u16SoftwareCapabilities & SOFT_CAPS_WEP_ENCRYPTION_SUPPORT) {
// WEP is supported. Now let's see if a WEP key is set.
RID_WEP_Key keyBuf;
// Read first WEP key RID.
if (RidGet(card, RID_WEP_SESSION_KEY, &keyBuf, sizeof(RID_WEP_Key))) {
// Check key index. 0xFFFF indicates no keys, 4 indicates home key.
// All we're interested in are the enterprise keys (index = 0-3).
#ifndef UNDER_CE
if ((keyBuf.keyindex == 0xFFFF) || (keyBuf.keyindex == 4)) {
#else
if ((wepState == Ndis802_11WEPEnabled) &&
((keyBuf.keyindex == 0xFFFF) || (keyBuf.keyindex == 4))){
#endif
// WEP key is not set.
StatusToReturn = NDIS_STATUS_NOT_ACCEPTED;
}
else {
StatusToReturn = NDIS_STATUS_SUCCESS;
CFG_X500 cfg;
if (cmdConfigGet(card, &cfg)) {
if (wepState == Ndis802_11WEPEnabled) {
cfg.AuthenType |= AUTH_TYPE_WEP;
}
else {
cfg.AuthenType &= ~AUTH_TYPE_WEP;
}
if (!cmdConfigSet(card, &cfg, TRUE)) {
StatusToReturn = NDIS_STATUS_INVALID_DATA;
}
}
else {
StatusToReturn = NDIS_STATUS_INVALID_DATA;
}
}
}
else {
StatusToReturn = NDIS_STATUS_INVALID_DATA;
}
}
else {
StatusToReturn = NDIS_STATUS_NOT_ACCEPTED;
}
}
}
else {
StatusToReturn = NDIS_STATUS_NOT_ACCEPTED;
}
}
break;
}
//-----------------------------------------------------------------------
// Disassociate with current SSID and turn the radio off.
//
// Data type: No data is associated with this Set.
// Query: Not supported.
// Set: Disassociates with current SSID and turn the radio off.
// Indication: Not supported.
//-----------------------------------------------------------------------
case OID_802_11_DISASSOCIATE: {
//
// Use OID_RADIO_OFF to disassociate.
//
if (card->IsAssociated) {
StatusToReturn = ExtendedOids(card, OID_RADIO_OFF, InfBuff, InfBuffLen, BytesRead, BytesNeeded);
}
else {
StatusToReturn = NDIS_STATUS_ADAPTER_NOT_READY;
}
break;
}
//-----------------------------------------------------------------------
// Sets the IEEE 802.11 authentication mode.
//
// Data type: NDIS_802_11_AUTHENTICATION_MODE.
// Query: Current mode.
// Set: Set to open or shared or auto-switch.
// Indication: Not supported.
//-----------------------------------------------------------------------
case OID_802_11_AUTHENTICATION_MODE: {
if (!cmdAwaken(card, TRUE)) {
StatusToReturn = -1000;
}
else {
USHORT mode;
StatusToReturn = getShortVal(InfBuffLen, InfBuff, &mode);
if (StatusToReturn == NDIS_STATUS_SUCCESS) {
//
// Our card only supports open and shared key authentication.
//
// NOTE: The MS document, "IEEE 802.11 MIN Requirements", specifies
// an additional authentication mode of Ndis802_11AuthModeAutoSwitch.
// Since the card doesn't support it, we don't support it.
//
if ((mode == Ndis802_11AuthModeOpen) || (mode == Ndis802_11AuthModeShared)) {
CFG_X500 cfg;
if (cmdConfigGet(card, &cfg)) {
//
// NOTE: preserve the high byte as it contains a bit mask.
//
cfg.AuthenType = (mode == Ndis802_11AuthModeOpen) ?
(cfg.AuthenType & 0xFF00) | AUTH_TYPE_OPEN :
(cfg.AuthenType & 0xFF00) | AUTH_TYPE_SHARED_KEY;
if (!cmdConfigSet(card, &cfg, TRUE)) {
StatusToReturn = NDIS_STATUS_INVALID_DATA;
}
}
else {
StatusToReturn = NDIS_STATUS_INVALID_DATA;
}
}
else {
StatusToReturn = NDIS_STATUS_INVALID_DATA;
}
}
}
break;
}
//-----------------------------------------------------------------------
// Data type: NDIS_802_11_NETWORK_TYPE.
// Query: Returns the current NDIS_802_11_NETWORK_TYPE used by the device.
// Set: Will set the network type that should be used for the driver.
// Indication: Not supported.
//-----------------------------------------------------------------------
case OID_802_11_NETWORK_TYPE_IN_USE: {
if (!cmdAwaken(card, TRUE)) {
StatusToReturn = -1000;
}
else {
USHORT type;
StatusToReturn = getShortVal(InfBuffLen, InfBuff, &type);
if (StatusToReturn == N
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -