Re: ndisuio question
From: Boyd D. Mills (BMills_at_VCIControls.ca)
Date: 10/28/04
- Next message: Ben: "How to incorporate an eVC++ project in PlatBuilder"
- Previous message: Chuck Zalinski: "Re: Where are "# @CESYSGEN IF" variables set?"
- In reply to: Jeff Kelley [MS]: "Re: ndisuio question"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 28 Oct 2004 17:46:59 -0400
Thanks.
I have applied the changes you suggested ( I think ). Below is the complete
source code for the Win CE 4.1 CEPC application.
It still hangs on the read.
Help would be greatly appreciated.
I hope this isn't a ce 4.1 restriction!
===============
#include "stdafx.h"
#include "Windev.h"
//#undef ARCNET
#include "Ndis.h"
#include "Nuiouser.h"
#include "Ntddndis.h"
static void VCIWideCharToMultiByte( LPTSTR wcIn, LPSTR acOut )
{
while ( *wcIn )
*acOut++ = (char)*wcIn++;
}
int main(int argc, char *argv[], char *envp[])
{
DWORD dwBytesOut;
HANDLE hLAN;
printf( " starting up \n" );
hLAN = CreateFile( NDISUIO_DEVICE_NAME,//L"UIO1:",
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
INVALID_HANDLE_VALUE );
printf("hLAN %d ", hLAN );
if ( hLAN != INVALID_HANDLE_VALUE )
{
char t[2048];
static int icount = 0;
DWORD dwIn;
char Buf[1024];
char aname[ 1024];
TCHAR tcDevName[ 1024 ];
DWORD dwReturnedBytes;
PNDISUIO_QUERY_BINDING pQueryBinding;
USHORT usNewType = 0x0800;
NDISUIO_SET_OID set_oid;
ULONG ulData = NDIS_PACKET_TYPE_DIRECTED | NDIS_PACKET_TYPE_BROADCAST;
pQueryBinding = (PNDISUIO_QUERY_BINDING)Buf;
DeviceIoControl(
hLAN, IOCTL_NDISUIO_QUERY_BINDING,
pQueryBinding, sizeof(NDISUIO_QUERY_BINDING),
NULL, 1024,
&dwReturnedBytes, NULL);
printf( "index %d\n", pQueryBinding->BindingIndex );
ZeroMemory( tcDevName, sizeof( tcDevName ) );
memcpy(tcDevName, &Buf[pQueryBinding->DeviceNameOffset ],
pQueryBinding->DeviceNameLength );
VCIWideCharToMultiByte( tcDevName , aname);
printf("name %s\n", aname );
set_oid.Oid = OID_GEN_CURRENT_PACKET_FILTER;
CopyMemory( &set_oid.Data[0], &ulData, sizeof( ulData) );
set_oid.ptcDeviceName = NULL;
if ( ! DeviceIoControl(
hLAN, IOCTL_NDISUIO_OPEN_DEVICE,
tcDevName, wcslen(tcDevName) * sizeof(TCHAR),
NULL, 0,
&dwReturnedBytes, NULL) )
{
printf( "deviceiocontrol failed OPEN_DEVICE %d\n", GetLastError());
}
else if ( ! DeviceIoControl(
hLAN, IOCTL_NDISUIO_SET_OID_VALUE,
&set_oid, sizeof( set_oid ),
NULL, 0,
&dwReturnedBytes, NULL) )
{
printf( "deviceiocontrol failed SET_OID_VALUE %d\n", GetLastError());
}
else if ( ! DeviceIoControl(
hLAN, IOCTL_NDISUIO_SET_ETHER_TYPE,
&usNewType, sizeof(usNewType),
NULL, 0,
&dwReturnedBytes, NULL) )
{
printf( "deviceiocontrol failed SET_ETHER_TYPE %d\n", GetLastError());
}
else
{
printf("we are away\n" );
while ( icount++ < 12 )
{
if ( ReadFile( hLAN, t, 2048, &dwIn, NULL ) && dwIn )
{
printf( "0x%x ", t[0] );
}
else Sleep( 5000 );
}
printf("\n" );
}
CloseHandle( hLAN );
}
Sleep( 5000 );
return( 0 );
}
============================
"Jeff Kelley [MS]" <jeffkel@online.microsoft.com> wrote in message
news:41815a3d$1@news.microsoft.com...
> You need to set the binding's current packet filter. See my reply to your
> other post for more details.
>
> --
> Jeff Kelley
> Microsoft / Windows CE Networking
>
>
- Next message: Ben: "How to incorporate an eVC++ project in PlatBuilder"
- Previous message: Chuck Zalinski: "Re: Where are "# @CESYSGEN IF" variables set?"
- In reply to: Jeff Kelley [MS]: "Re: ndisuio question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|