Networking Forums

Networking Forums > Wireless Networking > Wireless Networks > how to add WEP?

Reply
Thread Tools Display Modes

how to add WEP?

 
 
Eric Yun
Guest
Posts: n/a

 
      09-02-2004, 10:42 PM
hi everyone,

I am working on a project. One part of this project is force the wireless
network adapter to connect to an access point. I am doing the following way:

1. Set Authentication Mode (0 for Open)
2. Set Infrastructure Mode (1 for Infrastructure)
3. Set SSID
4. Set WEP Key
5. Enable WEP

I found when I remove WEP from my AP, and comment out step 4 & 5, my PC
(actually Pocket PC)will connect to the AP. When I add WEP to AP, and run
steps 1 to 5, my PPC only have IP address like 169.254.xx.xx. The following
is how I add WEP and enable WEP:


/*Add WEP*/
NDIS_802_11_WEP WepKey;

UCHAR KeyMaterial[13];

/*The WEP key is ACDB95776DD114409AB54323C6.
The following steps will convert 26 Digit
Hex key to a 13 bit string*/
KeyMaterial[0] = 0xAC;
KeyMaterial[1] = 0xDB;
KeyMaterial[2] = 0x95;
KeyMaterial[3] = 0x77;
KeyMaterial[4] = 0x6D;
KeyMaterial[5] = 0xD1;
KeyMaterial[6] = 0x14;
KeyMaterial[7] = 0x40;
KeyMaterial[8] = 0x9A;
KeyMaterial[9] = 0xB5;
KeyMaterial[10] = 0x43;
KeyMaterial[11] = 0x23;
KeyMaterial[12] = 0xC6;



WepKey.KeyLength = sizeof(KeyMaterial);
WepKey.KeyIndex = 0;

memset(WepKey.KeyMaterial,0,sizeof(WepKey.KeyMater ial));
memcpy(WepKey.KeyMaterial, KeyMaterial, WepKey.KeyLength);
WepKey.Length = sizeof(WepKey);

if(!AddWEP(&WepKey)) return FALSE;

/* Set WEP status, Mode means enable or disable WEP*/
if(!SetWEPStatus(mode)) return FALSE;







The following is function AddWEP:

BOOL AddWEP(PNDIS_802_11_WEP pWEP)
{
UCHAR SetBuffer[sizeof(NDIS_OID) +
sizeof(PTCHAR)+sizeof(NDIS_802_11_WEP)];
PNDISUIO_SET_OID pSetOid;
DWORD dwBytesReturned=0;

pSetOid = (PNDISUIO_SET_OID) &SetBuffer[0];
pSetOid->Oid = OID_802_11_ADD_WEP;
pSetOid->ptcDeviceName = ptcDeviceName; /*this is because the application
runs on PPC*/

memcpy(&pSetOid->Data[0], (LPVOID)pWEP, sizeof(NDIS_802_11_WEP));

if (!DeviceIoControl(g_hNdisUio,
IOCTL_NDISUIO_SET_OID_VALUE,
(LPVOID)&SetBuffer[0],
sizeof(SetBuffer),
(LPVOID) &SetBuffer[0],
0,
&dwBytesReturned,
NULL))
{

long m_dwError = GetLastError();

TCHAR szOut[64];
wsprintf(szOut, TEXT("Can Not add WEP: %d"),m_dwError );
MessageBox(0,szOut,TEXT("ERROR"),MB_OK);
return FALSE;
}



return TRUE;
}


Does anyone know what is wrong with my code? I haven't been stuck here for a
couple of days...

Thanks,

Eric


 
Reply With Quote
 
 
 
 
Pavel A.
Guest
Posts: n/a

 
      09-03-2004, 12:51 AM
"Eric Yun" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> hi everyone,
>
> I am working on a project. One part of this project is force the wireless
> network adapter to connect to an access point.


WinCE has the wireless config service that does this automagically.
Why to reinvent the wheel.

--PA


 
Reply With Quote
 
Eric Yun
Guest
Posts: n/a

 
      09-03-2004, 04:00 PM
I am not reinvent the wheel. I am trying to build the wheel again. And, if I
have to do it, anybody knows how to do it?

Eric

"Pavel A." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Eric Yun" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> hi everyone,
>>
>> I am working on a project. One part of this project is force the wireless
>> network adapter to connect to an access point.

>
> WinCE has the wireless config service that does this automagically.
> Why to reinvent the wheel.
>
> --PA
>
>



 
Reply With Quote
 
Niklas
Guest
Posts: n/a

 
      09-07-2004, 11:39 AM
Shouldn't KeyIndex be 0x80000000 (if the first key is used to transmit,
0x80000001 for second...)?
If think it matters in which order you set the oids and I would set the
AuthenticationMode after you have set the wepkey, but maybe it's just me who
think it matters.

you should get the checkbuild of wzcsvc and log what windows does.

/Niklas

"Eric Yun" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> hi everyone,
>
> I am working on a project. One part of this project is force the wireless
> network adapter to connect to an access point. I am doing the following
> way:
>
> 1. Set Authentication Mode (0 for Open)
> 2. Set Infrastructure Mode (1 for Infrastructure)
> 3. Set SSID
> 4. Set WEP Key
> 5. Enable WEP
>
> I found when I remove WEP from my AP, and comment out step 4 & 5, my PC
> (actually Pocket PC)will connect to the AP. When I add WEP to AP, and run
> steps 1 to 5, my PPC only have IP address like 169.254.xx.xx. The
> following is how I add WEP and enable WEP:
>
>
> /*Add WEP*/
> NDIS_802_11_WEP WepKey;
>
> UCHAR KeyMaterial[13];
>
> /*The WEP key is ACDB95776DD114409AB54323C6.
> The following steps will convert 26 Digit
> Hex key to a 13 bit string*/
> KeyMaterial[0] = 0xAC;
> KeyMaterial[1] = 0xDB;
> KeyMaterial[2] = 0x95;
> KeyMaterial[3] = 0x77;
> KeyMaterial[4] = 0x6D;
> KeyMaterial[5] = 0xD1;
> KeyMaterial[6] = 0x14;
> KeyMaterial[7] = 0x40;
> KeyMaterial[8] = 0x9A;
> KeyMaterial[9] = 0xB5;
> KeyMaterial[10] = 0x43;
> KeyMaterial[11] = 0x23;
> KeyMaterial[12] = 0xC6;
>
>
>
> WepKey.KeyLength = sizeof(KeyMaterial);
> WepKey.KeyIndex = 0;
>
> memset(WepKey.KeyMaterial,0,sizeof(WepKey.KeyMater ial));
> memcpy(WepKey.KeyMaterial, KeyMaterial, WepKey.KeyLength);
> WepKey.Length = sizeof(WepKey);
>
> if(!AddWEP(&WepKey)) return FALSE;
>
> /* Set WEP status, Mode means enable or disable WEP*/
> if(!SetWEPStatus(mode)) return FALSE;
>
>
>
>
>
>
>
> The following is function AddWEP:
>
> BOOL AddWEP(PNDIS_802_11_WEP pWEP)
> {
> UCHAR SetBuffer[sizeof(NDIS_OID) +
> sizeof(PTCHAR)+sizeof(NDIS_802_11_WEP)];
> PNDISUIO_SET_OID pSetOid;
> DWORD dwBytesReturned=0;
>
> pSetOid = (PNDISUIO_SET_OID) &SetBuffer[0];
> pSetOid->Oid = OID_802_11_ADD_WEP;
> pSetOid->ptcDeviceName = ptcDeviceName; /*this is because the application
> runs on PPC*/
>
> memcpy(&pSetOid->Data[0], (LPVOID)pWEP, sizeof(NDIS_802_11_WEP));
>
> if (!DeviceIoControl(g_hNdisUio,
> IOCTL_NDISUIO_SET_OID_VALUE,
> (LPVOID)&SetBuffer[0],
> sizeof(SetBuffer),
> (LPVOID) &SetBuffer[0],
> 0,
> &dwBytesReturned,
> NULL))
> {
>
> long m_dwError = GetLastError();
>
> TCHAR szOut[64];
> wsprintf(szOut, TEXT("Can Not add WEP: %d"),m_dwError );
> MessageBox(0,szOut,TEXT("ERROR"),MB_OK);
> return FALSE;
> }
>
>
>
> return TRUE;
> }
>
>
> Does anyone know what is wrong with my code? I haven't been stuck here for
> a couple of days...
>
> Thanks,
>
> Eric
>
>



 
Reply With Quote
 
David Gonzales [MS]
Guest
Posts: n/a

 
      09-08-2004, 12:51 AM
One reason might be that Pocket PC 2002 doesn't have native support for WEP
or Wireless Zero Config.

David
------
This posting is provided "AS IS" with no warranties, and confers no rights.

"Pavel A." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Eric Yun" <(E-Mail Removed)> wrote in message

news:(E-Mail Removed)...
> > hi everyone,
> >
> > I am working on a project. One part of this project is force the

wireless
> > network adapter to connect to an access point.

>
> WinCE has the wireless config service that does this automagically.
> Why to reinvent the wheel.



 
Reply With Quote
 
Prakshepak
Guest
Posts: n/a

 
      05-01-2006, 01:39 PM

Eric,

I am trying to do the same thing. I am also having the same problems
that you seem to have. Do you had any luck with this code?

Paul


Eric Yun wrote:
> [B]hi everyone,
>
> I am working on a project. One part of this project is force the
> wireless
> network adapter to connect to an access point. I am doing the
> following way:
>
> 1. Set Authentication Mode (0 for Open)
> 2. Set Infrastructure Mode (1 for Infrastructure)
> 3. Set SSID
> 4. Set WEP Key
> 5. Enable WEP
>
> I found when I remove WEP from my AP, and comment out step ....




--
Prakshepak
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1020495.html

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




1 2 3 4 5 6 7 8 9 10 11