Pocket PC Networking >> Add WEP feature with NDISUIO OID : Why doesn't it work?

by Sylvain » Wed, 04 May 2005 15:23:13 GMT

Dear CE networking programmers,

I'm currently facing a problem while developping an application dealing
with WiFi.
I'have already managed to set up many things, such as SSID, network
mode, power mode, etc... and everything is working well.

Now I'd like to add WEP support (only WEP) to my application. So, using
NDISUIO, and the OIDs OID_802_11_ADD_WEP to set up the key,
OID_802_11_WEP_STATUS to tell the wireless NIC that WEP must be used,
I'm trying to enable data encryption.
Unfortunately this is not working.

What I am doing is setting the following parameters in the following
order :
- Infrastructure mode as ad-hoc (I don't have access point yet)
- Authentication : I've tried Ndis802_11AuthModeOpen and
Ndis802_11AuthModeShared.
- Add the WEP key at a specified index.
- Enable WEP encryption.

The last step disconnect my Pocket PC from the network. But I don't
think the problem comes from here as the encryption status is properly
set (I've tried a request on it to check that values were similar, i.e.
equal to Ndis802_11WEPEnabled). I also that the most significant bits
in the index can play a role, but set to 1 they didn't change the
situation.
As a consequence I guess it might come from the way I am adding the
key. I've included the function I've developped to add WEP Key that can
be seen below.

So if somebody has an idea, or a working piece of code to offer, you're
welcome...!

By the way, I would have some technical questions as well :
-> what is exactly the index, and how does the NIC know which one to
use?
-> What are the "dangers" of not using the OID OID_802_11_REMOVE_WEP ?
-> What does Ndis802_11AuthModeShared change from
Ndis802_11AuthModeOpen when WEP is used?

Hope to hear from you soon, so thank you in advance for you help.


/****************************************************************/
/* Function : AddWEPKey() */
/* Parameters : UCHAR * pucWepKey : points to the key buffer */
/* int iKeyLength : length of the key in the buffer*/
/* int iKeyIndex : index of the key in the NIC */
/* Returned value : SUCCESS or FAILURE if error */
/* Purpose : setup the key for WEP data encryption */
/****************************************************************/
BOOL C802_11::AddWEPKey (UCHAR * pucWepKey, int iKeyLength, int
iKeyIndex){

BOOL bReturnValue = SUCCESS;

UCHAR SetBuffer[sizeof(NDISUIO_SET_OID)+sizeof(NDIS_802_11_WEP) +
13]; // 13 for 104-bit wep key

memset(SetBuffer, 0, sizeof(SetBuffer));

PNDISUIO_SET_OID pSetOID = (PNDISUIO_SET_OID)&SetBuffer[0];

pSetOID->ptcDeviceName = ptcWifiDeviceName;
pSetOID->Oid = OID_802_11_ADD_WEP;
// Set the wep structure
PNDIS_802_11_WEP pNdisWepStruct = (PNDIS_802_11_WEP)&pSetOID->Data[0];
pNdisWepStruct->KeyIndex = (ULONG) iKeyIndex |0x00000000;
pNdisWepStruct->KeyLength = (ULONG) iKeyLength;
memcpy(&pNdisWepStruct->KeyMaterial[0], pucWepKey, iKeyLength);
pNdisWepStruct->Length = (ULONG) (3 * sizeof(ULONG) + iKeyLength);

if (!DeviceIoControl(hNdisAccess,
IOCTL_NDISUIO_SET_OID_VALUE,
(LPVOID) &SetBuffer[0],
sizeof(SetBuffer),
(LPVOID) &SetBuffer[0],
sizeof(SetBuffer),
&dwReturnedBytes,
NULL))
{
// Failure
ReportError();
bReturnValue = FAILURE;
}

return bReturnValue;

}



Similar Threads

1. Wi-fi connection on HX4700 doesn't work under WEP, but does when WEP disabled on

2. WEP not working programattically using ndisuio - Pocketpc Developer

3. iPAQ RX3715 WEP Encryption doesn't work

I'm using Netgear router WGR614. There are following options:
Authentication Type: Automatic/ Open System/ Shared Key
Encryption Strength: Disable/ 64bit/ 128bit

Until now I was using AUTOMATIC/ 128bit and Generated WEP Key 4
to connect my notebook.

On my iPAQ I'm using Open/ WEP and enter the same key with index 4.
Since I can't set the number of bits on iPAQ. What do I have to select on my
router?
I've tried some different combinations of settings, nothing worked until I
disabled WEP. What have I done wrong?

thanks
Phuoc Can HUA


4. Reminder feature in Calendar doesn't work!!! - Pocket PC